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


PHP message_get_recent_conversations函数代码示例

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


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

示例1: message_print_recent_conversations

/**
 * Print the user's recent conversations
 * @param object $user1 the current user
 * @param bool $showicontext flag indicating whether or not to show text next to the action icons
 */
function message_print_recent_conversations($user=null, $showicontext=false) {
    global $USER;

    echo html_writer::start_tag('p', array('class' => 'heading'));
    echo get_string('mostrecentconversations', 'message');
    echo html_writer::end_tag('p');

    if (empty($user)) {
        $user = $USER;
    }

    $conversations = message_get_recent_conversations($user);

    $showotheruser = true;
    message_print_recent_messages_table($conversations, $user, $showotheruser, $showicontext);
}
开发者ID:nfreear,项目名称:moodle,代码行数:21,代码来源:lib.php

示例2: message_print_recent_conversations

/**
 * Print the user's recent conversations
 *
 * @param stdClass $user the current user
 * @param bool $showicontext flag indicating whether or not to show text next to the action icons
 */
function message_print_recent_conversations($user1 = null, $showicontext = false, $showactionlinks = true) {
    global $USER;

    echo html_writer::start_tag('p', array('class' => 'heading'));
    echo get_string('mostrecentconversations', 'message');
    echo html_writer::end_tag('p');

    if (empty($user1)) {
        $user1 = $USER;
    }

    $conversations = message_get_recent_conversations($user1);

    // Attach context url information to create the "View this conversation" type links
    foreach($conversations as $conversation) {
        $conversation->contexturl = new moodle_url("/message/index.php?user1={$user1->id}&user2={$conversation->id}");
        $conversation->contexturlname = get_string('thisconversation', 'message');
    }

    $showotheruser = true;
    message_print_recent_messages_table($conversations, $user1, $showotheruser, $showicontext, false, $showactionlinks);
}
开发者ID:nickbert77,项目名称:moodle,代码行数:28,代码来源:lib.php

示例3: test_message_get_recent_conversations

 /**
  * Test message_get_recent_conversations with a mixture of messages.
  *
  * @dataProvider message_get_recent_conversations_provider
  * @param array $usersdata The list of users to create for this test.
  * @param array $messagesdata The list of messages to create.
  * @param array $expectations The list of expected outcomes.
  */
 public function test_message_get_recent_conversations($usersdata, $messagesdata, $expectations)
 {
     global $DB;
     // Create all of the users.
     $users = array();
     foreach ($usersdata as $username) {
         $users[$username] = $this->getDataGenerator()->create_user(array('username' => $username));
     }
     $defaulttimecreated = time();
     foreach ($messagesdata as $messagedata) {
         $from = $users[$messagedata['from']];
         $to = $users[$messagedata['to']];
         $subject = $messagedata['subject'];
         if (isset($messagedata['state']) && $messagedata['state'] == 'unread') {
             $table = 'message';
             $messageid = $this->send_fake_message($from, $to, $subject, FORMAT_PLAIN);
         } else {
             // If there is no state, or the state is not 'unread', assume the message is read.
             $table = 'message_read';
             $messageid = message_post_message($from, $to, $subject, FORMAT_PLAIN);
         }
         $updatemessage = new stdClass();
         $updatemessage->id = $messageid;
         if (isset($messagedata['timecreated'])) {
             $updatemessage->timecreated = $messagedata['timecreated'];
         } else {
             if (isset($messagedata['timemodifier'])) {
                 $updatemessage->timecreated = $defaulttimecreated + $messagedata['timemodifier'];
             } else {
                 $updatemessage->timecreated = $defaulttimecreated;
             }
         }
         $DB->update_record($table, $updatemessage);
     }
     foreach ($expectations as $username => $data) {
         // Get the recent conversations for the specified user.
         $user = $users[$username];
         $conversations = message_get_recent_conversations($user);
         foreach ($data as $expectation) {
             $otheruser = $users[$expectation['with']];
             $conversation = $conversations[$expectation['messageposition']];
             $this->assertEquals($otheruser->id, $conversation->id);
             $this->assertEquals($expectation['subject'], $conversation->smallmessage);
         }
     }
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:54,代码来源:messagelib_test.php

示例4: test_message_get_recent_conversations

 /**
  * Test message_get_recent_conversations.
  */
 public function test_message_get_recent_conversations()
 {
     global $DB, $USER;
     // Set this user as the admin.
     $this->setAdminUser();
     // Create user's to send messages to/from.
     $user1 = $this->getDataGenerator()->create_user(array('firstname' => 'Test1', 'lastname' => 'user1'));
     $user2 = $this->getDataGenerator()->create_user(array('firstname' => 'Test2', 'lastname' => 'user2'));
     // Add a few messages that have been read and some that are unread.
     $m1 = $this->send_fake_message($USER, $user1, 'Message 1');
     // An unread message.
     $m2 = $this->send_fake_message($user1, $USER, 'Message 2');
     // An unread message.
     $m3 = $this->send_fake_message($USER, $user1, 'Message 3');
     // An unread message.
     $m4 = message_post_message($USER, $user2, 'Message 4', FORMAT_PLAIN);
     $m5 = message_post_message($user2, $USER, 'Message 5', FORMAT_PLAIN);
     $m6 = message_post_message($USER, $user2, 'Message 6', FORMAT_PLAIN);
     // We want to alter the timecreated values so we can ensure message_get_recent_conversations orders
     // by timecreated, not the max id, to begin with. However, we also want more than one message to have
     // the same timecreated value to ensure that when this happens we retrieve the one with the maximum id.
     // Store the current time.
     $time = time();
     // Set the first and second unread messages to have the same timecreated value.
     $updatemessage = new stdClass();
     $updatemessage->id = $m1;
     $updatemessage->timecreated = $time;
     $DB->update_record('message', $updatemessage);
     $updatemessage->id = $m2;
     $updatemessage->timecreated = $time;
     $DB->update_record('message', $updatemessage);
     // Set the third unread message to have a timecreated value of 0.
     $updatemessage->id = $m3;
     $updatemessage->timecreated = 0;
     $DB->update_record('message', $updatemessage);
     // Set the first and second read messages to have the same timecreated value.
     $updatemessage->id = $m4;
     $updatemessage->timecreated = $time + 1;
     $DB->update_record('message', $updatemessage);
     $updatemessage->id = $m5;
     $updatemessage->timecreated = $time + 1;
     $DB->update_record('message', $updatemessage);
     // Set the third read message to have a timecreated value of 0.
     $updatemessage->id = $m6;
     $updatemessage->timecreated = 0;
     $DB->update_record('message_read', $updatemessage);
     // Get the recent conversations for the current user.
     $conversations = message_get_recent_conversations($USER);
     // Confirm that we have received the messages with the maximum timecreated, rather than the max id.
     $this->assertEquals('Message 2', $conversations[0]->fullmessage);
     $this->assertEquals('Message 5', $conversations[1]->smallmessage);
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:55,代码来源:messagelib_test.php

示例5: get_conversations

 /**
  * Returns the contacts and their conversation to display in the contacts area.
  *
  * @param int $userid The user id
  * @param int $limitfrom
  * @param int $limitnum
  * @return array
  */
 public static function get_conversations($userid, $limitfrom = 0, $limitnum = 0)
 {
     $arrconversations = array();
     if ($conversations = message_get_recent_conversations($userid, $limitfrom, $limitnum)) {
         foreach ($conversations as $conversation) {
             $arrconversations[$conversation->id] = helper::create_contact($conversation);
         }
     }
     return $arrconversations;
 }
开发者ID:dg711,项目名称:moodle,代码行数:18,代码来源:api.php


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