本文整理汇总了PHP中message_count_unread_messages函数的典型用法代码示例。如果您正苦于以下问题:PHP message_count_unread_messages函数的具体用法?PHP message_count_unread_messages怎么用?PHP message_count_unread_messages使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了message_count_unread_messages函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_mark_all_read_for_user_touser_with_type
public function test_mark_all_read_for_user_touser_with_type()
{
$sender = $this->getDataGenerator()->create_user(array('firstname' => 'Test1', 'lastname' => 'User1'));
$recipient = $this->getDataGenerator()->create_user(array('firstname' => 'Test2', 'lastname' => 'User2'));
$this->send_fake_message($sender, $recipient, 'Notification', 1);
$this->send_fake_message($sender, $recipient, 'Notification', 1);
$this->send_fake_message($sender, $recipient, 'Notification', 1);
$this->send_fake_message($sender, $recipient);
$this->send_fake_message($sender, $recipient);
$this->send_fake_message($sender, $recipient);
\core_message\api::mark_all_read_for_user($recipient->id, 0, MESSAGE_TYPE_NOTIFICATION);
$this->assertEquals(message_count_unread_messages($recipient), 3);
\core_message\api::mark_all_read_for_user($recipient->id, 0, MESSAGE_TYPE_MESSAGE);
$this->assertEquals(message_count_unread_messages($recipient), 0);
}
示例2: get_content
/**
* Return contents of course_overview block
*
* @return stdClass contents of block
*/
public function get_content()
{
global $USER, $CFG, $DB;
require_once $CFG->dirroot . '/user/profile/lib.php';
if ($this->content !== NULL) {
return $this->content;
}
$config = get_config('block_course_overview');
$this->content = new stdClass();
$this->content->text = '';
$this->content->footer = '';
$content = array();
$updatemynumber = optional_param('mynumber', -1, PARAM_INT);
if ($updatemynumber >= 0) {
block_course_overview_update_mynumber($updatemynumber);
}
profile_load_custom_fields($USER);
list($sortedcourses, $sitecourses, $totalcourses) = block_course_overview_get_sorted_courses();
$overviews = block_course_overview_get_overviews($sitecourses);
$renderer = $this->page->get_renderer('block_course_overview');
if (!empty($config->showwelcomearea)) {
require_once $CFG->dirroot . '/message/lib.php';
$msgcount = message_count_unread_messages();
$this->content->text = $renderer->welcome_area($msgcount);
}
// Number of sites to display.
if ($this->page->user_is_editing() && empty($config->forcedefaultmaxcourses)) {
$this->content->text .= $renderer->editing_bar_head($totalcourses);
}
if (empty($sortedcourses)) {
$this->content->text .= get_string('nocourses', 'my');
} else {
// For each course, build category cache.
$this->content->text .= $renderer->course_overview($sortedcourses, $overviews);
$this->content->text .= $renderer->hidden_courses($totalcourses - count($sortedcourses));
if ($this->page->user_is_editing() && ajaxenabled()) {
$this->page->requires->js_init_call('M.block_course_overview.add_handles');
}
}
return $this->content;
}
示例3: message_count_unread_messages
$countunreadtotal = 0;
//count of unread messages from all users
//we're dealing with unread messages early so the contact list will accurately reflect what is read/unread
$viewingnewmessages = false;
if (!empty($user2)) {
//are there any unread messages from $user2
$countunread = message_count_unread_messages($user1, $user2);
if ($countunread > 0) {
//mark the messages we're going to display as 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';
示例4: message_get_contacts
/**
* Retrieve $user1's contacts (online, offline and strangers)
*
* @param object $user1 the user whose messages are being viewed
* @param object $user2 the user $user1 is talking to. If they are a contact
* they will have a variable called 'iscontact' added to their user object
* @return array containing 3 arrays. array($onlinecontacts, $offlinecontacts, $strangers)
*/
function message_get_contacts($user1=null, $user2=null) {
global $DB, $CFG, $USER;
if (empty($user1)) {
$user1 = $USER;
}
if (!empty($user2)) {
$user2->iscontact = false;
}
$timetoshowusers = 300; //Seconds default
if (isset($CFG->block_online_users_timetosee)) {
$timetoshowusers = $CFG->block_online_users_timetosee * 60;
}
// time which a user is counting as being active since
$timefrom = time()-$timetoshowusers;
// people in our contactlist who are online
$onlinecontacts = array();
// people in our contactlist who are offline
$offlinecontacts = array();
// people who are not in our contactlist but have sent us a message
$strangers = array();
$userfields = user_picture::fields('u', array('lastaccess'));
// get all in our contactlist who are not blocked in our contact list
// and count messages we have waiting from each of them
$contactsql = "SELECT $userfields, COUNT(m.id) AS messagecount
FROM {message_contacts} mc
JOIN {user} u ON u.id = mc.contactid
LEFT OUTER JOIN {message} m ON m.useridfrom = mc.contactid AND m.useridto = ?
WHERE u.deleted = 0 AND mc.userid = ? AND mc.blocked = 0
GROUP BY $userfields
ORDER BY u.firstname ASC";
$rs = $DB->get_recordset_sql($contactsql, array($user1->id, $user1->id));
foreach ($rs as $rd) {
if ($rd->lastaccess >= $timefrom) {
// they have been active recently, so are counted online
$onlinecontacts[] = $rd;
} else {
$offlinecontacts[] = $rd;
}
if (!empty($user2) && $user2->id == $rd->id) {
$user2->iscontact = true;
}
}
$rs->close();
// get messages from anyone who isn't in our contact list and count the number
// of messages we have from each of them
$strangersql = "SELECT $userfields, count(m.id) as messagecount
FROM {message} m
JOIN {user} u ON u.id = m.useridfrom
LEFT OUTER JOIN {message_contacts} mc ON mc.contactid = m.useridfrom AND mc.userid = m.useridto
WHERE u.deleted = 0 AND mc.id IS NULL AND m.useridto = ?
GROUP BY $userfields
ORDER BY u.firstname ASC";
$rs = $DB->get_recordset_sql($strangersql, array($USER->id));
// Add user id as array index, so supportuser and noreply user don't get duplicated (if they are real users).
foreach ($rs as $rd) {
$strangers[$rd->id] = $rd;
}
$rs->close();
// Add noreply user and support user to the list, if they don't exist.
$supportuser = core_user::get_support_user();
if (!isset($strangers[$supportuser->id])) {
$supportuser->messagecount = message_count_unread_messages($USER, $supportuser);
if ($supportuser->messagecount > 0) {
$strangers[$supportuser->id] = $supportuser;
}
}
$noreplyuser = core_user::get_noreply_user();
if (!isset($strangers[$noreplyuser->id])) {
$noreplyuser->messagecount = message_count_unread_messages($USER, $noreplyuser);
if ($noreplyuser->messagecount > 0) {
$strangers[$noreplyuser->id] = $noreplyuser;
}
}
return array($onlinecontacts, $offlinecontacts, $strangers);
}
示例5: render_cocustommenu
//.........这里部分代码省略.........
$content .="<li><a href=$CFG->wwwroot/local/scheduleexam>Scheduled Assesments</a></li>";
$content .="<li><a href=$CFG->wwwroot/local/myacademics/transcript.php>Transcript</a></li>";
$content .="<li><a href=$CFG->wwwroot/local/academiccalendar>Events Calender</a></li>";
$content .="</ul></li>";
//--------------------------------end of my academics--------------------------------------------------------------------------------
//--------------------------------course registration--------------------------------------------------------------------------------
$content .="<li class='dropdown'>
<a href='#' class='dropdown-toggle' data-toggle='dropdown'>Course Registration<b class='caret'></b></a>
<ul class='dropdown-menu'>";
$content .="<li><a href=$CFG->wwwroot/local/courseregistration/index.php>Register to Course/Class</a></li>";
$content .="</ul></li>";
//--------------------end of course registration----------------------------------------------------------------------------------------------
//--------------------Requests links----------------------------------------------------------------------------------------------------------
$content .="<li class='dropdown'>
<a href='#' class='dropdown-toggle' data-toggle='dropdown'>My Requests<b class='caret'></b></a>
<ul class='dropdown-menu'>";
$content .="<li><a href=$CFG->wwwroot/local/request/request_id.php>ID Card</a></li>";
$content .="<li><a href=$CFG->wwwroot/local/request/request_profile.php>Profile Change</a></li>";
$content .="<li><a href=$CFG->wwwroot/local/request/request_transcript.php>Transcript</a></li>";
$content .="<li><a href=$CFG->wwwroot/local/request/course_exem.php>Course Exemption</a></li>";
$content .="</ul></li>";
//-----------------------------end of requests links-------------------------------------------------------------------------------------------
$content .="<li><a href=$CFG->wwwroot/local/helpmanuals/student/index.html target='_blank'>Help Manual</a></li>";
}
}
// for mentor starts-------------------------------------------
if (has_capability('local/classes:approvemystudentclasses', $systemcontext) && !is_siteadmin()) {
$content .="<li><a href=$CFG->wwwroot/local/mentor>My Students</a></li>";
$content .="<li><a href=$CFG->wwwroot/local/helpmanuals/mentor/index.html target='_blank'>Help Manual</a></li>";
}
// mentor ends
if (isloggedin() & !isguestuser()) {
$msgnotification = message_count_unread_messages($USER);
$heirarchy = new hierarchy();
$request = new requests();
$applicationnotice = $heirarchy->count_admissions_from_applicants($USER->id);
$requestnotice = $request->all_student_requests_count($USER->id);
$courserequestnotice = $heirarchy->count_course_requests_from_students($USER->id);
$transcriptnotice = $heirarchy->count_transcript_req_from_student($USER->id);
$courseexemptionnotice = $heirarchy->count_coureexe_req_from_student($USER->id);
$profilechangenotice = $heirarchy->count_profilechange_req_from_student($USER->id);
$idcardnotice = $heirarchy->count_idcard_req_from_student($USER->id);
$newappnotice = $heirarchy->count_new_admission_req_from_student($USER->id);
$transferappnotice = $heirarchy->count_transfer_admission_req_from_student($USER->id);
$totalrequest = $courserequestnotice + $requestnotice;
$content .="<li><a href=$CFG->wwwroot/message/ title='Messages' id='messages'>
<sup id='msgnotice'>$msgnotification</sup></a></li>";
$context = context_user::instance($USER->id);
if (has_capability('local/classes:enrollclass', $context) && !is_siteadmin()) {
$allapprovals = $request->all_approved_requests($USER->id);
$transcriptapprovals = $heirarchy->count_trasncripts_approve_from_registrar($USER->id);
$courseexemptionapproval = $heirarchy->count_courseexe_approve_from_registrar($USER->id);
$idcardapproval = $heirarchy->count_idcard_approve_from_registrar($USER->id);
$profilechangeapproval = $heirarchy->count_profilechange_approve_from_registrar($USER->id);
$content .="<li class='dropdown'>
<a href='#' class='dropdown-toggle open' data-toggle='dropdown' id='allrequests' title='Request Approvals'>
<sup id='arequests'>$allapprovals</sup></a>
<ul class='dropdown-menu'>";
$content .="<li><a href=$CFG->wwwroot/local/request/request_transcript.php>Transcripts($transcriptapprovals)</a></li>";
$content .="<li><a href=$CFG->wwwroot/local/request/course_exem.php>Coures Exemptions($courseexemptionapproval)</a></li>";
$content .="<li><a href=$CFG->wwwroot/local/request/request_id.php>ID Card($idcardapproval)</a></li>";
$content .="<li><a href=$CFG->wwwroot/local/request/request_profile.php>Profile Change($profilechangeapproval)</a></li>";
$content .="</ul></li>";
}
示例6: test_message_count_unread_messages
/**
* Test message_count_unread_messages.
*/
public function test_message_count_unread_messages()
{
// Create users to send and receive message.
$userfrom1 = $this->getDataGenerator()->create_user();
$userfrom2 = $this->getDataGenerator()->create_user();
$userto = $this->getDataGenerator()->create_user();
$this->assertEquals(0, message_count_unread_messages($userto));
// Send fake messages.
$this->send_fake_message($userfrom1, $userto);
$this->send_fake_message($userfrom2, $userto);
$this->assertEquals(2, message_count_unread_messages($userto));
$this->assertEquals(1, message_count_unread_messages($userto, $userfrom1));
}
示例7: welcome_area
public function welcome_area()
{
global $OUTPUT, $USER;
$output = $OUTPUT->box_start('welcome_area');
$picture = $OUTPUT->user_picture($USER, array('size' => 75, 'class' => 'welcome_userpicture'));
$output .= html_writer::tag('div', $picture, array('class' => 'profilepicture'));
$output .= $OUTPUT->box_start('welcome_message');
$output .= $OUTPUT->heading(get_string('welcome', 'block_my_course_overview', $USER->firstname));
//messages
$count = message_count_unread_messages($USER);
$plural = 's';
if ($count > 0) {
$output .= get_string('you_have_messages', 'block_my_course_overview', $count);
} else {
$output .= get_string('you_have_no_messages', 'block_my_course_overview');
if ($count == 1) {
$plural = '';
}
}
$output .= html_writer::link(new moodle_url('/message/index.php'), get_string('message' . $plural, 'block_my_course_overview'));
$output .= $OUTPUT->box_end();
$output .= $OUTPUT->box('', 'flush');
$output .= $OUTPUT->box_end();
return $output;
}