if ($USER->id != $user->id && has_capability('moodle/site:sendmessage', $context)) {
$userbuttons = array(
'messages' => array(
+ 'buttontype' => 'message',
'title' => get_string('message', 'message'),
'url' => new moodle_url('/message/index.php', array('id' => $user->id)),
'image' => 'message',
$html .= html_writer::start_div('btn-group header-button-group');
foreach ($contextheader->additionalbuttons as $button) {
if (!isset($button->page)) {
+ // Include js for messaging.
+ if ($button['buttontype'] === 'message') {
+ message_messenger_requirejs();
+ }
$image = $this->pix_icon($button['formattedimage'], $button['title'], 'moodle', array(
'class' => 'iconsmall',
'role' => 'presentation'
$PAGE->set_pagelayout('mypublic');
$PAGE->set_pagetype('user-profile');
-// Load the JS to send a message.
-$cansendmessage = isloggedin() && has_capability('moodle/site:sendmessage', $context)
- && !empty($CFG->messaging) && !isguestuser() && !isguestuser($user) && ($USER->id != $user->id);
-if ($cansendmessage) {
- message_messenger_requirejs();
-}
-
// Set up block editing capabilities.
if (isguestuser()) { // Guests can never edit their profile.
$USER->editing = $edit = 0; // Just in case.
echo $OUTPUT->custom_block_region('content');
-// Print messaging link if allowed.
-if ($cansendmessage) {
- $sendurl = new moodle_url('/message/index.php', array('id' => $user->id));
- echo '<div class="messagebox">';
- echo html_writer::link($sendurl, get_string('messageselectadd'), message_messenger_sendmessage_link_params($user));
- echo '</div>';
-}
-
echo '</div>'; // Userprofile class.
echo $OUTPUT->footer();
// of inhereting the pagetype will lead to an incorrect docs location.
$PAGE->set_docs_path('user/profile');
-$cansendmessage = isloggedin() && has_capability('moodle/site:sendmessage', $usercontext)
- && !empty($CFG->messaging) && !isguestuser() && !isguestuser($user) && ($USER->id != $user->id);
-if ($cansendmessage) {
- message_messenger_requirejs();
-}
-
$isparent = false;
if (!$currentuser and !$user->deleted
}
echo html_writer::end_tag('dl');
echo "</div></div>"; // Closing desriptionbox and userprofilebox.
-// Print messaging link if allowed.
-if ($cansendmessage) {
- echo '<div class="messagebox">';
- $sendmessageurl = new moodle_url('/message/index.php', array('id' => $user->id));
- if ($courseid) {
- $sendmessageurl->param('viewing', MESSAGE_VIEW_COURSE. $courseid);
- }
- echo html_writer::link($sendmessageurl, get_string('messageselectadd'), message_messenger_sendmessage_link_params($user));
- echo '</div>';
-}
if (empty($CFG->forceloginforprofiles) || $currentuser || has_capability('moodle/user:viewdetails', $usercontext)
|| has_coursecontact_role($id)) {