当前位置: 首页>>代码示例>>PHP>>正文


PHP message_get_contacts函数代码示例

本文整理汇总了PHP中message_get_contacts函数的典型用法代码示例。如果您正苦于以下问题:PHP message_get_contacts函数的具体用法?PHP message_get_contacts怎么用?PHP message_get_contacts使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了message_get_contacts函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: message_mark_messages_read

        message_mark_messages_read($user1->id, $user2->id);
        if ($viewing == MESSAGE_VIEW_UNREAD_MESSAGES) {
            $viewingnewmessages = true;
        }
    }
}
$countunreadtotal = message_count_unread_messages($user1);
if ($currentuser && $countunreadtotal == 0 && $viewing == MESSAGE_VIEW_UNREAD_MESSAGES && empty($user2)) {
    // If the user has no unread messages, show the search box.
    // We don't do this when a user is viewing another user's messages as search doesn't
    // handle user A searching user B's messages properly.
    $viewing = MESSAGE_VIEW_SEARCH;
}
$blockedusers = message_get_blocked_users($user1, $user2);
$countblocked = count($blockedusers);
list($onlinecontacts, $offlinecontacts, $strangers) = message_get_contacts($user1, $user2);
message_print_contact_selector($countunreadtotal, $viewing, $user1, $user2, $blockedusers, $onlinecontacts, $offlinecontacts, $strangers, $showactionlinks, $page);
echo html_writer::start_tag('div', array('class' => 'messagearea mdl-align'));
if (!empty($user2)) {
    echo html_writer::start_tag('div', array('class' => 'mdl-left messagehistory'));
    $visible = 'visible';
    $hidden = 'hiddenelement';
    //cant just use hidden as mform adds that class to its fieldset for something else
    $recentlinkclass = $recentlabelclass = $historylinkclass = $historylabelclass = $visible;
    if ($history == MESSAGE_HISTORY_ALL) {
        $displaycount = 0;
        $recentlabelclass = $historylinkclass = $hidden;
    } else {
        if ($viewingnewmessages) {
            //if user is viewing new messages only show them the new messages
            $displaycount = $countunread;
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:31,代码来源:index.php

示例2: get_contacts

 /**
  * Get contacts.
  *
  * @param array $userids array of user IDs.
  * @return external_description
  * @since Moodle 2.5
  */
 public static function get_contacts()
 {
     global $CFG, $PAGE;
     // Check if messaging is enabled.
     if (!$CFG->messaging) {
         throw new moodle_exception('disabled', 'message');
     }
     require_once $CFG->dirroot . '/user/lib.php';
     list($online, $offline, $strangers) = message_get_contacts();
     $allcontacts = array('online' => $online, 'offline' => $offline, 'strangers' => $strangers);
     foreach ($allcontacts as $mode => $contacts) {
         foreach ($contacts as $key => $contact) {
             $newcontact = array('id' => $contact->id, 'fullname' => fullname($contact), 'unread' => $contact->messagecount);
             $userpicture = new user_picture($contact);
             $userpicture->size = 1;
             // Size f1.
             $newcontact['profileimageurl'] = $userpicture->get_url($PAGE)->out(false);
             $userpicture->size = 0;
             // Size f2.
             $newcontact['profileimageurlsmall'] = $userpicture->get_url($PAGE)->out(false);
             $allcontacts[$mode][$key] = $newcontact;
         }
     }
     return $allcontacts;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:32,代码来源:externallib.php

示例3: get_contacts

    /**
     * Get contacts.
     *
     * @param array $userids array of user IDs.
     * @return external_description
     * @since 2.5
     */
    public static function get_contacts() {
        global $CFG;
        require_once($CFG->dirroot . '/user/lib.php');

        list($online, $offline, $strangers) = message_get_contacts();
        $allcontacts = array('online' => $online, 'offline' => $offline, 'strangers' => $strangers);
        foreach ($allcontacts as $mode => $contacts) {
            foreach ($contacts as $key => $contact) {
                $newcontact = array(
                    'id' => $contact->id,
                    'fullname' => fullname($contact),
                    'unread' => $contact->messagecount
                );

                // Try to get the user picture, but sometimes this method can return null.
                $userdetails = user_get_user_details($contact, null, array('profileimageurl', 'profileimageurlsmall'));
                if (!empty($userdetails)) {
                    $newcontact['profileimageurl'] = $userdetails['profileimageurl'];
                    $newcontact['profileimageurlsmall'] = $userdetails['profileimageurlsmall'];
                }

                $allcontacts[$mode][$key] = $newcontact;
            }
        }
        return $allcontacts;
    }
开发者ID:Burick,项目名称:moodle,代码行数:33,代码来源:externallib.php

示例4: test_message_get_contacts

 /**
  * Test message_get_contacts.
  */
 public function test_message_get_contacts()
 {
     global $USER, $CFG;
     // Set this user as the admin.
     $this->setAdminUser();
     $noreplyuser = core_user::get_noreply_user();
     $supportuser = core_user::get_support_user();
     // Create a user to add to the admin's contact list.
     $user1 = $this->getDataGenerator()->create_user();
     $user2 = $this->getDataGenerator()->create_user();
     $user3 = $this->getDataGenerator()->create_user();
     // Stranger.
     // Add users to the admin's contact list.
     message_add_contact($user1->id);
     message_add_contact($user2->id);
     // Send some messages.
     $this->send_fake_message($user1, $USER);
     $this->send_fake_message($user2, $USER);
     $this->send_fake_message($user3, $USER);
     list($onlinecontacts, $offlinecontacts, $strangers) = message_get_contacts();
     $this->assertCount(0, $onlinecontacts);
     $this->assertCount(2, $offlinecontacts);
     $this->assertCount(1, $strangers);
     // Send message from noreply and support users.
     $this->send_fake_message($noreplyuser, $USER);
     $this->send_fake_message($supportuser, $USER);
     list($onlinecontacts, $offlinecontacts, $strangers) = message_get_contacts();
     $this->assertCount(0, $onlinecontacts);
     $this->assertCount(2, $offlinecontacts);
     $this->assertCount(3, $strangers);
     // Block 1 user.
     message_block_contact($user2->id);
     list($onlinecontacts, $offlinecontacts, $strangers) = message_get_contacts();
     $this->assertCount(0, $onlinecontacts);
     $this->assertCount(1, $offlinecontacts);
     $this->assertCount(3, $strangers);
     // Noreply user being valid user.
     core_user::reset_internal_users();
     $CFG->noreplyuserid = $user3->id;
     $noreplyuser = core_user::get_noreply_user();
     list($onlinecontacts, $offlinecontacts, $strangers) = message_get_contacts();
     $this->assertCount(0, $onlinecontacts);
     $this->assertCount(1, $offlinecontacts);
     $this->assertCount(2, $strangers);
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:48,代码来源:messagelib_test.php

示例5: get_contacts

 /**
  * Get contacts.
  *
  * @param array $userids array of user IDs.
  * @return external_description
  * @since Moodle 2.5
  */
 public static function get_contacts()
 {
     global $CFG;
     // Check if messaging is enabled.
     if (!$CFG->messaging) {
         throw new moodle_exception('disabled', 'message');
     }
     require_once $CFG->dirroot . '/user/lib.php';
     list($online, $offline, $strangers) = message_get_contacts();
     $allcontacts = array('online' => $online, 'offline' => $offline, 'strangers' => $strangers);
     foreach ($allcontacts as $mode => $contacts) {
         foreach ($contacts as $key => $contact) {
             $newcontact = array('id' => $contact->id, 'fullname' => fullname($contact), 'unread' => $contact->messagecount);
             $usercontextid = context_user::instance($contact->id)->id;
             $newcontact['profileimageurl'] = moodle_url::make_webservice_pluginfile_url($usercontextid, 'user', 'icon', null, '/', 'f1')->out(false);
             $newcontact['profileimageurlsmall'] = moodle_url::make_webservice_pluginfile_url($usercontextid, 'user', 'icon', null, '/', 'f2')->out(false);
             $allcontacts[$mode][$key] = $newcontact;
         }
     }
     return $allcontacts;
 }
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:28,代码来源:externallib.php


注:本文中的message_get_contacts函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。