當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。