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


PHP message_get_recent_notifications函数代码示例

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


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

示例1: message_print_recent_notifications

/**
 * Print the user's recent notifications
 * @param object $user1 the current user
 */
function message_print_recent_notifications($user=null) {
    global $USER;

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

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

    $notifications = message_get_recent_notifications($user);

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

示例2: test_message_get_recent_notifications

 /**
  * Test message_get_recent_notifications.
  */
 public function test_message_get_recent_notifications()
 {
     global $DB, $USER;
     // Set this user as the admin.
     $this->setAdminUser();
     // Create a user to send messages from.
     $user1 = $this->getDataGenerator()->create_user(array('firstname' => 'Test1', 'lastname' => 'user1'));
     // Add two messages - will mark them as notifications later.
     $m1 = message_post_message($user1, $USER, 'Message 1', FORMAT_PLAIN);
     $m2 = message_post_message($user1, $USER, 'Message 2', FORMAT_PLAIN);
     // Mark the second message as a notification.
     $updatemessage = new stdClass();
     $updatemessage->id = $m2;
     $updatemessage->notification = 1;
     $DB->update_record('message_read', $updatemessage);
     // Mark the first message as a notification and change the timecreated to 0.
     $updatemessage->id = $m1;
     $updatemessage->notification = 1;
     $updatemessage->timecreated = 0;
     $DB->update_record('message_read', $updatemessage);
     $notifications = message_get_recent_notifications($USER);
     // Get the messages.
     $firstmessage = array_shift($notifications);
     $secondmessage = array_shift($notifications);
     // Confirm that we have received the notifications with the maximum timecreated, rather than the max id.
     $this->assertEquals('Message 2', $firstmessage->smallmessage);
     $this->assertEquals('Message 1', $secondmessage->smallmessage);
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:31,代码来源:messagelib_test.php


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