本文整理汇总了PHP中message_get_course_contexts函数的典型用法代码示例。如果您正苦于以下问题:PHP message_get_course_contexts函数的具体用法?PHP message_get_course_contexts怎么用?PHP message_get_course_contexts使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了message_get_course_contexts函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: message_print_contact_selector
function message_print_contact_selector($countunreadtotal, $usergroup, $user1, $user2, $blockedusers, $onlinecontacts, $offlinecontacts, $strangers, $showcontactactionlinks, $page = 0)
{
global $PAGE;
echo html_writer::start_tag('div', array('class' => 'contactselector mdl-align'));
//if 0 unread messages and they've requested unread messages then show contacts
if ($countunreadtotal == 0 && $usergroup == VIEW_UNREAD_MESSAGES) {
$usergroup = VIEW_CONTACTS;
}
//if they have no blocked users and they've requested blocked users switch them over to contacts
if (count($blockedusers) == 0 && $usergroup == VIEW_BLOCKED) {
$usergroup = VIEW_CONTACTS;
}
$onlyactivecourses = true;
$courses = enrol_get_users_courses($user1->id, $onlyactivecourses);
$coursecontexts = message_get_course_contexts($courses);
//we need one of these again so holding on to them
$strunreadmessages = null;
if ($countunreadtotal > 0) {
//if there are unread messages
$strunreadmessages = get_string('unreadmessages', 'message', $countunreadtotal);
}
message_print_usergroup_selector($usergroup, $courses, $coursecontexts, $countunreadtotal, count($blockedusers), $strunreadmessages);
$refreshpage = false;
if ($usergroup == VIEW_UNREAD_MESSAGES) {
message_print_contacts($onlinecontacts, $offlinecontacts, $strangers, $refreshpage, $PAGE->url, 1, $showcontactactionlinks, $strunreadmessages, $user2);
} else {
if ($usergroup == VIEW_CONTACTS || $usergroup == VIEW_SEARCH) {
message_print_contacts($onlinecontacts, $offlinecontacts, $strangers, $refreshpage, $PAGE->url, 0, $showcontactactionlinks, $strunreadmessages, $user2);
} else {
if ($usergroup == VIEW_BLOCKED) {
message_print_blocked_users($blockedusers, $PAGE->url, $showcontactactionlinks, null, $user2);
} else {
if (substr($usergroup, 0, 7) == VIEW_COURSE) {
$courseidtoshow = intval(substr($usergroup, 7));
if (!empty($courseidtoshow) && array_key_exists($courseidtoshow, $coursecontexts) && has_capability('moodle/course:viewparticipants', $coursecontexts[$courseidtoshow])) {
message_print_participants($coursecontexts[$courseidtoshow], $courseidtoshow, $PAGE->url, $showcontactactionlinks, null, $page, $user2);
} else {
//shouldn't get here. User trying to access a course they're not in perhaps.
add_to_log(SITEID, 'message', 'view', 'index.php', $usergroup);
}
}
}
}
}
echo html_writer::start_tag('form', array('action' => 'index.php', 'method' => 'GET'));
echo html_writer::start_tag('fieldset');
$managebuttonclass = 'visible';
if ($usergroup == VIEW_SEARCH) {
$managebuttonclass = 'hiddenelement';
}
$strmanagecontacts = get_string('search', 'message');
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'usergroup', 'value' => VIEW_SEARCH));
echo html_writer::empty_tag('input', array('type' => 'submit', 'value' => $strmanagecontacts, 'class' => $managebuttonclass));
echo html_writer::end_tag('fieldset');
echo html_writer::end_tag('form');
echo html_writer::end_tag('div');
}
示例2: message_print_contact_selector
/**
* Print the selector that allows the user to view their contacts, course participants, their recent
* conversations etc
*
* @param int $countunreadtotal how many unread messages does the user have?
* @param int $viewing What is the user viewing? ie MESSAGE_VIEW_UNREAD_MESSAGES, MESSAGE_VIEW_SEARCH etc
* @param object $user1 the user whose messages are being viewed
* @param object $user2 the user $user1 is talking to
* @param array $blockedusers an array of users blocked by $user1
* @param array $onlinecontacts an array of $user1's online contacts
* @param array $offlinecontacts an array of $user1's offline contacts
* @param array $strangers an array of users who have messaged $user1 who aren't contacts
* @param bool $showactionlinks show action links (add/remove contact etc)
* @param int $page if there are so many users listed that they have to be split into pages what page are we viewing
* @return void
*/
function message_print_contact_selector($countunreadtotal, $viewing, $user1, $user2, $blockedusers, $onlinecontacts, $offlinecontacts, $strangers, $showactionlinks, $page=0) {
global $PAGE;
echo html_writer::start_tag('div', array('class' => 'contactselector mdl-align'));
//if 0 unread messages and they've requested unread messages then show contacts
if ($countunreadtotal == 0 && $viewing == MESSAGE_VIEW_UNREAD_MESSAGES) {
$viewing = MESSAGE_VIEW_CONTACTS;
}
//if they have no blocked users and they've requested blocked users switch them over to contacts
if (count($blockedusers) == 0 && $viewing == MESSAGE_VIEW_BLOCKED) {
$viewing = MESSAGE_VIEW_CONTACTS;
}
$onlyactivecourses = true;
$courses = enrol_get_users_courses($user1->id, $onlyactivecourses);
$coursecontexts = message_get_course_contexts($courses);//we need one of these again so holding on to them
$strunreadmessages = null;
if ($countunreadtotal>0) { //if there are unread messages
$strunreadmessages = get_string('unreadmessages','message', $countunreadtotal);
}
message_print_usergroup_selector($viewing, $courses, $coursecontexts, $countunreadtotal, count($blockedusers), $strunreadmessages, $user1);
if ($viewing == MESSAGE_VIEW_UNREAD_MESSAGES) {
message_print_contacts($onlinecontacts, $offlinecontacts, $strangers, $PAGE->url, 1, $showactionlinks,$strunreadmessages, $user2);
} else if ($viewing == MESSAGE_VIEW_CONTACTS || $viewing == MESSAGE_VIEW_SEARCH || $viewing == MESSAGE_VIEW_RECENT_CONVERSATIONS || $viewing == MESSAGE_VIEW_RECENT_NOTIFICATIONS) {
message_print_contacts($onlinecontacts, $offlinecontacts, $strangers, $PAGE->url, 0, $showactionlinks, $strunreadmessages, $user2);
} else if ($viewing == MESSAGE_VIEW_BLOCKED) {
message_print_blocked_users($blockedusers, $PAGE->url, $showactionlinks, null, $user2);
} else if (substr($viewing, 0, 7) == MESSAGE_VIEW_COURSE) {
$courseidtoshow = intval(substr($viewing, 7));
if (!empty($courseidtoshow)
&& array_key_exists($courseidtoshow, $coursecontexts)
&& has_capability('moodle/course:viewparticipants', $coursecontexts[$courseidtoshow])) {
message_print_participants($coursecontexts[$courseidtoshow], $courseidtoshow, $PAGE->url, $showactionlinks, null, $page, $user2);
}
}
// Only show the search button if we're viewing our own contacts.
if ($viewing == MESSAGE_VIEW_CONTACTS && $user2 == null) {
echo html_writer::start_tag('form', array('action' => 'index.php','method' => 'GET'));
echo html_writer::start_tag('fieldset');
$managebuttonclass = 'visible';
$strmanagecontacts = get_string('search','message');
echo html_writer::empty_tag('input', array('type' => 'hidden','name' => 'viewing','value' => MESSAGE_VIEW_SEARCH));
echo html_writer::empty_tag('input', array('type' => 'submit','value' => $strmanagecontacts,'class' => $managebuttonclass));
echo html_writer::end_tag('fieldset');
echo html_writer::end_tag('form');
}
echo html_writer::end_tag('div');
}