messaging MDL-22320 replaced the old popup index.php with the new non-popup index.php
This commit is contained in:
+2
-2
@@ -8929,7 +8929,7 @@ WHERE m.useridto = :userid AND m.timecreated > :ts AND p.name='popup'";
|
||||
$count = $DB->count_records_sql($sql, array('userid'=>$USER->id, 'ts'=>$USER->message_lastpopup));
|
||||
if ($count) {
|
||||
|
||||
$strmessages = get_string('unreadmessages', 'message', $count);
|
||||
$strmessages = get_string('unreadnewmessages', 'message', $count);
|
||||
$strgomessage = get_string('gotomessages', 'message');
|
||||
$strstaymessage = get_string('ignore','admin');
|
||||
|
||||
@@ -8941,7 +8941,7 @@ WHERE m.useridto = :userid AND m.timecreated > :ts AND p.name='popup'";
|
||||
html_writer::tag('button', $strstaymessage, array('id'=>'buttondontreadmessage')).
|
||||
html_writer::end_tag('div');
|
||||
|
||||
$url = $CFG->wwwroot.'/message/contacts_messages.php';
|
||||
$url = $CFG->wwwroot.'/message/index.php';
|
||||
$PAGE->requires->js_init_call('M.core_message.init_notification', array('', $content, $url));
|
||||
|
||||
$USER->message_lastpopup = time();
|
||||
|
||||
@@ -1525,7 +1525,7 @@ class global_navigation extends navigation_node {
|
||||
if ($USER->id!=$user->id) {
|
||||
$messageargs = array('id'=>$user->id);
|
||||
}
|
||||
$url = new moodle_url('/message/contacts_messages.php',$messageargs);
|
||||
$url = new moodle_url('/message/index.php',$messageargs);
|
||||
$usernode->add(get_string('messages', 'message'), $url, self::TYPE_SETTING, null, 'messages');
|
||||
|
||||
// Add a node to view the users notes if permitted
|
||||
|
||||
@@ -69,7 +69,7 @@ $PAGE->set_url($url);
|
||||
if ($addcontact and confirm_sesskey()) {
|
||||
add_to_log(SITEID, 'message', 'add contact', 'history.php?user1='.$addcontact.'&user2='.$USER->id, $addcontact);
|
||||
message_add_contact($addcontact);
|
||||
redirect($CFG->wwwroot . '/message/contacts_messages.php?usergroup=contacts&id='.$addcontact);
|
||||
redirect($CFG->wwwroot . '/message/index.php?usergroup=contacts&id='.$addcontact);
|
||||
}
|
||||
if ($removecontact and confirm_sesskey()) {
|
||||
add_to_log(SITEID, 'message', 'remove contact', 'history.php?user1='.$removecontact.'&user2='.$USER->id, $removecontact);
|
||||
@@ -95,7 +95,7 @@ $strmycontacts = get_string('mycontacts', 'message');
|
||||
$strcontacts = get_string('contacts', 'message');
|
||||
|
||||
$PAGE->navbar->add(get_string('myprofile'));
|
||||
$PAGE->navbar->add(get_string('messages','message'), 'contacts_messages.php');
|
||||
$PAGE->navbar->add(get_string('messages','message'), 'index.php');
|
||||
$PAGE->navbar->add($strcontacts);
|
||||
|
||||
$PAGE->set_title(fullname($USER).': '.$strcontacts);
|
||||
@@ -106,12 +106,6 @@ echo $OUTPUT->header();
|
||||
|
||||
echo $OUTPUT->box_start('message');
|
||||
|
||||
/*echo html_writer::start_tag('div', array('class'=>'contactselector mdl-align'));
|
||||
$refreshpage = false;
|
||||
$showcontactactionlinks = true;
|
||||
message_print_contacts($onlinecontacts, $offlinecontacts, $strangers, $refreshpage, 'contacts_messages.php?usergroup=contacts', 0, $showactionlinks);
|
||||
echo html_writer::end_tag('div');*/
|
||||
|
||||
$user1 = $USER;//we'll need a way to specify this if we want to view this page as a different user
|
||||
$user2 = null;
|
||||
|
||||
|
||||
@@ -1,269 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* A page displaying the user's contacts. Similar to index.php but not a popup.
|
||||
*
|
||||
* @package moodlecore
|
||||
* @copyright 2010 Andrew Davis
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once('../config.php');
|
||||
require_once('lib.php');
|
||||
require_once('send_form.php');
|
||||
|
||||
require_login(0, false);
|
||||
|
||||
if (isguestuser()) {
|
||||
redirect($CFG->wwwroot);
|
||||
}
|
||||
|
||||
if (empty($CFG->messaging)) {
|
||||
print_error('disabled', 'message');
|
||||
}
|
||||
|
||||
$usergroup = optional_param('usergroup', VIEW_UNREAD_MESSAGES, PARAM_ALPHANUMEXT);
|
||||
$history = optional_param('history', MESSAGE_HISTORY_SHORT, PARAM_INT);
|
||||
$search = optional_param('search', '', PARAM_CLEAN);
|
||||
|
||||
$user1id = optional_param('user', $USER->id, PARAM_INT);
|
||||
$user2id = optional_param('id', 0, PARAM_INT);
|
||||
|
||||
$addcontact = optional_param('addcontact', 0, PARAM_INT); // adding a contact
|
||||
$removecontact = optional_param('removecontact', 0, PARAM_INT); // removing a contact
|
||||
$blockcontact = optional_param('blockcontact', 0, PARAM_INT); // blocking a contact
|
||||
$unblockcontact = optional_param('unblockcontact', 0, PARAM_INT); // unblocking a contact
|
||||
|
||||
$url = new moodle_url('/message/contacts_messages.php');
|
||||
|
||||
if ($usergroup !== 0) {
|
||||
$url->param('usergroup', $usergroup);
|
||||
}
|
||||
if ($user2id !== 0) {
|
||||
$url->param('id', $user2id);
|
||||
}
|
||||
|
||||
/*if ($addcontact !== 0) {
|
||||
$url->param('addcontact', $addcontact);
|
||||
}
|
||||
if ($removecontact !== 0) {
|
||||
$url->param('removecontact', $removecontact);
|
||||
}
|
||||
if ($blockcontact !== 0) {
|
||||
$url->param('blockcontact', $blockcontact);
|
||||
}
|
||||
if ($unblockcontact !== 0) {
|
||||
$url->param('unblockcontact', $unblockcontact);
|
||||
}*/
|
||||
|
||||
$PAGE->set_url($url);
|
||||
|
||||
/// Process any contact maintenance requests there may be
|
||||
if ($addcontact and confirm_sesskey()) {
|
||||
add_to_log(SITEID, 'message', 'add contact', 'history.php?user1='.$addcontact.'&user2='.$USER->id, $addcontact);
|
||||
message_add_contact($addcontact);
|
||||
redirect($CFG->wwwroot . '/message/contacts_messages.php?usergroup=contacts&id='.$addcontact);
|
||||
}
|
||||
if ($removecontact and confirm_sesskey()) {
|
||||
add_to_log(SITEID, 'message', 'remove contact', 'history.php?user1='.$removecontact.'&user2='.$USER->id, $removecontact);
|
||||
message_remove_contact($removecontact);
|
||||
}
|
||||
if ($blockcontact and confirm_sesskey()) {
|
||||
add_to_log(SITEID, 'message', 'block contact', 'history.php?user1='.$blockcontact.'&user2='.$USER->id, $blockcontact);
|
||||
message_block_contact($blockcontact);
|
||||
}
|
||||
if ($unblockcontact and confirm_sesskey()) {
|
||||
add_to_log(SITEID, 'message', 'unblock contact', 'history.php?user1='.$unblockcontact.'&user2='.$USER->id, $unblockcontact);
|
||||
message_unblock_contact($unblockcontact);
|
||||
}
|
||||
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_USER, $USER->id));
|
||||
$PAGE->navigation->extend_for_user($USER);
|
||||
$PAGE->set_pagelayout('course');
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
$user1 = null;
|
||||
$currentuser = true;
|
||||
$showcontactactionlinks = SHOW_ACTION_LINKS_IN_CONTACT_LIST;
|
||||
if ($user1id!=$USER->id) {
|
||||
$user1 = $DB->get_record('user', array('id'=>$user1id));
|
||||
if (!$user1) {
|
||||
print_error('invaliduserid');
|
||||
}
|
||||
$currentuser = false;//if we're looking at someone else's messages we need to lock/remove some UI elements
|
||||
$showcontactactionlinks = false;
|
||||
} else {
|
||||
$user1 = $USER;
|
||||
}
|
||||
unset($user1id);
|
||||
|
||||
$user2 = null;
|
||||
if (!empty($user2id)) {
|
||||
$user2 = $DB->get_record("user", array("id"=>$user2id));
|
||||
if (!$user2) {
|
||||
print_error('invaliduserid');
|
||||
}
|
||||
}
|
||||
unset($user2id);
|
||||
|
||||
//was a message sent? Do NOT allow someone looking at somone elses messages to send them.
|
||||
$messageerror = null;
|
||||
if ($currentuser && !empty($user2) && has_capability('moodle/site:sendmessage', $context)) {
|
||||
|
||||
// Check that the user is not blocking us!!
|
||||
if ($contact = $DB->get_record('message_contacts', array('userid'=>$user2->id, 'contactid'=>$user1->id))) {
|
||||
if ($contact->blocked and !has_capability('moodle/site:readallmessages', $context)) {
|
||||
$messageerror = get_string('userisblockingyou', 'message');
|
||||
}
|
||||
}
|
||||
$userpreferences = get_user_preferences(NULL, NULL, $user2->id);
|
||||
|
||||
if (!empty($userpreferences['message_blocknoncontacts'])) { // User is blocking non-contacts
|
||||
if (empty($contact)) { // We are not a contact!
|
||||
$messageerror = get_string('userisblockingyounoncontact', 'message');
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($messageerror)) {
|
||||
$mform = new send_form();
|
||||
$defaultmessage = new stdClass;
|
||||
$defaultmessage->id = $user2->id;
|
||||
$defaultmessage->message = '';
|
||||
|
||||
$data = $mform->get_data();
|
||||
if (!empty($data) && !empty($data->message)) { /// Current user has just sent a message
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('invalidsesskey');
|
||||
}
|
||||
|
||||
/// Save it to the database...
|
||||
$messageid = message_post_message($user1, $user2, $data->message, FORMAT_PLAIN, 'direct');
|
||||
if (!empty($messageid)) {
|
||||
redirect($CFG->wwwroot . '/message/contacts_messages.php?usergroup='.$usergroup.'&id='.$user2->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($messageerror)) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($messageerror, 1);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
$strmessages = get_string('messages', 'message');
|
||||
if (!empty($user2)) {
|
||||
$user2fullname = fullname($user2);
|
||||
|
||||
$PAGE->set_title("$strmessages: $user2fullname");
|
||||
$PAGE->set_heading("$strmessages: $user2fullname");
|
||||
} else {
|
||||
$PAGE->set_title("{$SITE->shortname}: $strmessages");
|
||||
$PAGE->set_heading("{$SITE->shortname}: $strmessages");
|
||||
}
|
||||
|
||||
//now the page contents
|
||||
echo $OUTPUT->header();
|
||||
|
||||
echo $OUTPUT->box_start('message');
|
||||
|
||||
$countunread = 0; //count of unread messages from $user2
|
||||
$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
|
||||
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);
|
||||
}
|
||||
}
|
||||
$countunreadtotal = message_count_unread_messages($user1);
|
||||
|
||||
$blockedusers = message_get_blocked_users($user1, $user2);
|
||||
$countblocked = count($blockedusers);
|
||||
|
||||
list($onlinecontacts, $offlinecontacts, $strangers) = message_get_contacts($user1, $user2);
|
||||
|
||||
message_print_contact_selector($countunreadtotal, $usergroup, $user1, $user2, $blockedusers, $onlinecontacts, $offlinecontacts, $strangers, $showcontactactionlinks);
|
||||
|
||||
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'));
|
||||
|
||||
$historyclass = 'visible';
|
||||
$recentclass = 'hiddenelement';//cant just use hidden as mform adds that class to its fieldset
|
||||
if ($history==MESSAGE_HISTORY_ALL) {
|
||||
$displaycount = 0;
|
||||
|
||||
$historyclass = 'hiddenelement';
|
||||
$recentclass = 'visible';
|
||||
} else {
|
||||
//default to only showing a few messages unless explicitly told not to
|
||||
$displaycount = MESSAGE_SHORTVIEW_LIMIT;
|
||||
|
||||
if ($countunread>MESSAGE_SHORTVIEW_LIMIT) {
|
||||
$displaycount = $countunread;
|
||||
}
|
||||
}
|
||||
|
||||
$messagehistorylink = html_writer::start_tag('div', array('class'=>'mdl-align messagehistorytype'));
|
||||
$messagehistorylink .= html_writer::link($PAGE->url->out(false).'&history='.MESSAGE_HISTORY_ALL,
|
||||
get_string('messagehistoryfull','message'),
|
||||
array('class'=>$historyclass));
|
||||
|
||||
$messagehistorylink .= html_writer::start_tag('span', array('class'=>$recentclass));
|
||||
$messagehistorylink .= get_string('messagehistoryfull','message');
|
||||
$messagehistorylink .= html_writer::end_tag('span');
|
||||
|
||||
$messagehistorylink .= ' | '.html_writer::link($PAGE->url->out(false).'&history='.MESSAGE_HISTORY_SHORT,
|
||||
get_string('mostrecent','message'),
|
||||
array('class'=>$recentclass));
|
||||
|
||||
$messagehistorylink .= html_writer::start_tag('span', array('class'=>$historyclass));
|
||||
$messagehistorylink .= get_string('mostrecent','message');
|
||||
$messagehistorylink .= html_writer::end_tag('span');
|
||||
|
||||
$messagehistorylink .= html_writer::end_tag('div');
|
||||
|
||||
message_print_message_history($user1, $user2, $search, $displaycount, $messagehistorylink);
|
||||
echo html_writer::end_tag('div');
|
||||
|
||||
//send message form
|
||||
if ($currentuser && has_capability('moodle/site:sendmessage', $context)) {
|
||||
echo html_writer::start_tag('div', array('class'=>'mdl-align messagesend'));
|
||||
$mform = new send_form();
|
||||
$defaultmessage = new stdClass;
|
||||
$defaultmessage->id = $user2->id;
|
||||
$defaultmessage->message = '';
|
||||
//$defaultmessage->messageformat = FORMAT_MOODLE;
|
||||
$mform->set_data($defaultmessage);
|
||||
$mform->display();
|
||||
echo html_writer::end_tag('div');
|
||||
}
|
||||
}
|
||||
echo html_writer::end_tag('div');
|
||||
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
|
||||
+189
-55
@@ -16,15 +16,16 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Main interface window for messaging
|
||||
* A page displaying the user's contacts. Similar to index.php but not a popup.
|
||||
*
|
||||
* @author Luis Rodrigues and Martin Dougiamas
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @package message
|
||||
* @package moodlecore
|
||||
* @copyright 2010 Andrew Davis
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require('../config.php');
|
||||
require('lib.php');
|
||||
require_once('../config.php');
|
||||
require_once('lib.php');
|
||||
require_once('send_form.php');
|
||||
|
||||
require_login(0, false);
|
||||
|
||||
@@ -36,19 +37,28 @@ if (empty($CFG->messaging)) {
|
||||
print_error('disabled', 'message');
|
||||
}
|
||||
|
||||
/// Optional variables that may be passed in
|
||||
$tab = optional_param('tab', 'contacts', PARAM_ALPHA); // current tab - default to contacts
|
||||
$usergroup = optional_param('usergroup', VIEW_UNREAD_MESSAGES, PARAM_ALPHANUMEXT);
|
||||
$history = optional_param('history', MESSAGE_HISTORY_SHORT, PARAM_INT);
|
||||
$search = optional_param('search', '', PARAM_CLEAN);
|
||||
|
||||
$user1id = optional_param('user', $USER->id, PARAM_INT);
|
||||
$user2id = optional_param('id', 0, PARAM_INT);
|
||||
|
||||
$addcontact = optional_param('addcontact', 0, PARAM_INT); // adding a contact
|
||||
$removecontact = optional_param('removecontact', 0, PARAM_INT); // removing a contact
|
||||
$blockcontact = optional_param('blockcontact', 0, PARAM_INT); // blocking a contact
|
||||
$unblockcontact = optional_param('unblockcontact', 0, PARAM_INT); // unblocking a contact
|
||||
$popup = optional_param('popup', false, PARAM_ALPHANUM); // If set then starts a new popup window
|
||||
|
||||
$url = new moodle_url('/message/index.php');
|
||||
if ($tab !== 'contacts') {
|
||||
$url->param('tab', $tab);
|
||||
|
||||
if ($usergroup !== 0) {
|
||||
$url->param('usergroup', $usergroup);
|
||||
}
|
||||
if ($addcontact !== 0) {
|
||||
if ($user2id !== 0) {
|
||||
$url->param('id', $user2id);
|
||||
}
|
||||
|
||||
/*if ($addcontact !== 0) {
|
||||
$url->param('addcontact', $addcontact);
|
||||
}
|
||||
if ($removecontact !== 0) {
|
||||
@@ -59,26 +69,15 @@ if ($blockcontact !== 0) {
|
||||
}
|
||||
if ($unblockcontact !== 0) {
|
||||
$url->param('unblockcontact', $unblockcontact);
|
||||
}
|
||||
if ($popup !== false) {
|
||||
$url->param('popup', $popup);
|
||||
}
|
||||
}*/
|
||||
|
||||
$PAGE->set_url($url);
|
||||
|
||||
|
||||
/// Popup a window if required and quit (usually from external links).
|
||||
if ($popup) {
|
||||
$PAGE->set_pagelayout('popup');
|
||||
echo $OUTPUT->header();
|
||||
echo html_writer::script(js_writer::function_call('openpopup', Array('/message/index.php', 'message', 'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500', 0)));
|
||||
redirect("$CFG->wwwroot/", '', 0);
|
||||
exit;
|
||||
}
|
||||
|
||||
/// Process any contact maintenance requests there may be
|
||||
if ($addcontact and confirm_sesskey()) {
|
||||
add_to_log(SITEID, 'message', 'add contact', 'history.php?user1='.$addcontact.'&user2='.$USER->id, $addcontact);
|
||||
message_add_contact($addcontact);
|
||||
redirect($CFG->wwwroot . '/message/index.php?usergroup=contacts&id='.$addcontact);
|
||||
}
|
||||
if ($removecontact and confirm_sesskey()) {
|
||||
add_to_log(SITEID, 'message', 'remove contact', 'history.php?user1='.$removecontact.'&user2='.$USER->id, $removecontact);
|
||||
@@ -93,43 +92,178 @@ if ($unblockcontact and confirm_sesskey()) {
|
||||
message_unblock_contact($unblockcontact);
|
||||
}
|
||||
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_USER, $USER->id));
|
||||
$PAGE->navigation->extend_for_user($USER);
|
||||
$PAGE->set_pagelayout('course');
|
||||
|
||||
/// Header on this page
|
||||
if ($tab == 'contacts') {
|
||||
$PAGE->set_periodic_refresh_delay($CFG->message_contacts_refresh);
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
$user1 = null;
|
||||
$currentuser = true;
|
||||
$showcontactactionlinks = SHOW_ACTION_LINKS_IN_CONTACT_LIST;
|
||||
if ($user1id!=$USER->id) {
|
||||
$user1 = $DB->get_record('user', array('id'=>$user1id));
|
||||
if (!$user1) {
|
||||
print_error('invaliduserid');
|
||||
}
|
||||
$currentuser = false;//if we're looking at someone else's messages we need to lock/remove some UI elements
|
||||
$showcontactactionlinks = false;
|
||||
} else {
|
||||
$user1 = $USER;
|
||||
}
|
||||
unset($user1id);
|
||||
|
||||
$user2 = null;
|
||||
if (!empty($user2id)) {
|
||||
$user2 = $DB->get_record("user", array("id"=>$user2id));
|
||||
if (!$user2) {
|
||||
print_error('invaliduserid');
|
||||
}
|
||||
}
|
||||
unset($user2id);
|
||||
|
||||
//was a message sent? Do NOT allow someone looking at somone elses messages to send them.
|
||||
$messageerror = null;
|
||||
if ($currentuser && !empty($user2) && has_capability('moodle/site:sendmessage', $context)) {
|
||||
|
||||
// Check that the user is not blocking us!!
|
||||
if ($contact = $DB->get_record('message_contacts', array('userid'=>$user2->id, 'contactid'=>$user1->id))) {
|
||||
if ($contact->blocked and !has_capability('moodle/site:readallmessages', $context)) {
|
||||
$messageerror = get_string('userisblockingyou', 'message');
|
||||
}
|
||||
}
|
||||
$userpreferences = get_user_preferences(NULL, NULL, $user2->id);
|
||||
|
||||
if (!empty($userpreferences['message_blocknoncontacts'])) { // User is blocking non-contacts
|
||||
if (empty($contact)) { // We are not a contact!
|
||||
$messageerror = get_string('userisblockingyounoncontact', 'message');
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($messageerror)) {
|
||||
$mform = new send_form();
|
||||
$defaultmessage = new stdClass;
|
||||
$defaultmessage->id = $user2->id;
|
||||
$defaultmessage->message = '';
|
||||
|
||||
$data = $mform->get_data();
|
||||
if (!empty($data) && !empty($data->message)) { /// Current user has just sent a message
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('invalidsesskey');
|
||||
}
|
||||
|
||||
/// Save it to the database...
|
||||
$messageid = message_post_message($user1, $user2, $data->message, FORMAT_PLAIN, 'direct');
|
||||
if (!empty($messageid)) {
|
||||
redirect($CFG->wwwroot . '/message/index.php?usergroup='.$usergroup.'&id='.$user2->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($messageerror)) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($messageerror, 1);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
$PAGE->set_pagelayout('popup');
|
||||
$PAGE->set_title(get_string('messages', 'message').' - '.format_string($SITE->fullname));
|
||||
$strmessages = get_string('messages', 'message');
|
||||
if (!empty($user2)) {
|
||||
$user2fullname = fullname($user2);
|
||||
|
||||
$PAGE->set_title("$strmessages: $user2fullname");
|
||||
$PAGE->set_heading("$strmessages: $user2fullname");
|
||||
} else {
|
||||
$PAGE->set_title("{$SITE->shortname}: $strmessages");
|
||||
$PAGE->set_heading("{$SITE->shortname}: $strmessages");
|
||||
}
|
||||
|
||||
//now the page contents
|
||||
echo $OUTPUT->header();
|
||||
echo '<table cellspacing="2" cellpadding="2" border="0" width="95%" class="boxaligncenter">';
|
||||
echo '<tr>';
|
||||
|
||||
/// Print out the tabs
|
||||
echo '<td>';
|
||||
$tabrow = array();
|
||||
$tabrow[] = new tabobject('contacts', $CFG->wwwroot.'/message/index.php?tab=contacts',
|
||||
get_string('contacts', 'message'));
|
||||
$tabrow[] = new tabobject('search', $CFG->wwwroot.'/message/index.php?tab=search',
|
||||
get_string('search', 'message'));
|
||||
$tabrows = array($tabrow);
|
||||
echo $OUTPUT->box_start('message');
|
||||
|
||||
print_tabs($tabrows, $tab);
|
||||
$countunread = 0; //count of unread messages from $user2
|
||||
$countunreadtotal = 0; //count of unread messages from all users
|
||||
|
||||
echo '</td>';
|
||||
|
||||
|
||||
echo '</tr><tr>';
|
||||
|
||||
/// Print out contents of the tab
|
||||
echo '<td>';
|
||||
|
||||
/// a print function is associated with each tab
|
||||
$tabprintfunction = 'message_print_'.$tab;
|
||||
if (function_exists($tabprintfunction)) {
|
||||
$tabprintfunction('index.php');
|
||||
//we're dealing with unread messages early so the contact list will accurately reflect what is read/unread
|
||||
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);
|
||||
}
|
||||
}
|
||||
$countunreadtotal = message_count_unread_messages($user1);
|
||||
|
||||
$blockedusers = message_get_blocked_users($user1, $user2);
|
||||
$countblocked = count($blockedusers);
|
||||
|
||||
list($onlinecontacts, $offlinecontacts, $strangers) = message_get_contacts($user1, $user2);
|
||||
|
||||
message_print_contact_selector($countunreadtotal, $usergroup, $user1, $user2, $blockedusers, $onlinecontacts, $offlinecontacts, $strangers, $showcontactactionlinks);
|
||||
|
||||
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'));
|
||||
|
||||
$historyclass = 'visible';
|
||||
$recentclass = 'hiddenelement';//cant just use hidden as mform adds that class to its fieldset
|
||||
if ($history==MESSAGE_HISTORY_ALL) {
|
||||
$displaycount = 0;
|
||||
|
||||
$historyclass = 'hiddenelement';
|
||||
$recentclass = 'visible';
|
||||
} else {
|
||||
//default to only showing a few messages unless explicitly told not to
|
||||
$displaycount = MESSAGE_SHORTVIEW_LIMIT;
|
||||
|
||||
if ($countunread>MESSAGE_SHORTVIEW_LIMIT) {
|
||||
$displaycount = $countunread;
|
||||
}
|
||||
}
|
||||
|
||||
$messagehistorylink = html_writer::start_tag('div', array('class'=>'mdl-align messagehistorytype'));
|
||||
$messagehistorylink .= html_writer::link($PAGE->url->out(false).'&history='.MESSAGE_HISTORY_ALL,
|
||||
get_string('messagehistoryfull','message'),
|
||||
array('class'=>$historyclass));
|
||||
|
||||
$messagehistorylink .= html_writer::start_tag('span', array('class'=>$recentclass));
|
||||
$messagehistorylink .= get_string('messagehistoryfull','message');
|
||||
$messagehistorylink .= html_writer::end_tag('span');
|
||||
|
||||
$messagehistorylink .= ' | '.html_writer::link($PAGE->url->out(false).'&history='.MESSAGE_HISTORY_SHORT,
|
||||
get_string('mostrecent','message'),
|
||||
array('class'=>$recentclass));
|
||||
|
||||
$messagehistorylink .= html_writer::start_tag('span', array('class'=>$historyclass));
|
||||
$messagehistorylink .= get_string('mostrecent','message');
|
||||
$messagehistorylink .= html_writer::end_tag('span');
|
||||
|
||||
$messagehistorylink .= html_writer::end_tag('div');
|
||||
|
||||
message_print_message_history($user1, $user2, $search, $displaycount, $messagehistorylink);
|
||||
echo html_writer::end_tag('div');
|
||||
|
||||
//send message form
|
||||
if ($currentuser && has_capability('moodle/site:sendmessage', $context)) {
|
||||
echo html_writer::start_tag('div', array('class'=>'mdl-align messagesend'));
|
||||
$mform = new send_form();
|
||||
$defaultmessage = new stdClass;
|
||||
$defaultmessage->id = $user2->id;
|
||||
$defaultmessage->message = '';
|
||||
//$defaultmessage->messageformat = FORMAT_MOODLE;
|
||||
$mform->set_data($defaultmessage);
|
||||
$mform->display();
|
||||
echo html_writer::end_tag('div');
|
||||
}
|
||||
}
|
||||
echo html_writer::end_tag('div');
|
||||
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
echo '</td> </tr> </table>';
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
|
||||
|
||||
+4
-4
@@ -107,7 +107,7 @@ function message_print_contact_selector($countunreadtotal, $usergroup, $user1, $
|
||||
message_print_participants($coursecontexts[$courseidtoshow], $courseidtoshow, $PAGE->url, $showcontactactionlinks);
|
||||
} else {
|
||||
//shouldnt get here. User trying to access a course theyre not in perhaps.
|
||||
add_to_log(SITEID, 'message', 'view', 'contacts_messages.php', $usergroup);
|
||||
add_to_log(SITEID, 'message', 'view', 'index.php', $usergroup);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -714,7 +714,7 @@ function message_print_search_results($frm, $showicontext=false, $user1=null) {
|
||||
'resizable' => true);
|
||||
|
||||
//$link = new moodle_url("/message/discussion.php?id=$user->id");
|
||||
$link = new moodle_url("/message/contacts_messages.php?id=$user->id");
|
||||
$link = new moodle_url("/message/index.php?id=$user->id");
|
||||
//$action = new popup_action('click', $link, "message_$user->id", $popupoptions);
|
||||
$action = null;
|
||||
echo $OUTPUT->action_link($link, fullname($user), $action, array('title'=>get_string('sendmessageto', 'message', fullname($user))));
|
||||
@@ -927,7 +927,7 @@ function message_print_user ($user=false, $iscontact=false, $isblocked=false, $i
|
||||
'resizable' => true);
|
||||
|
||||
//$link = new moodle_url("/message/discussion.php?id=$user->id");
|
||||
$link = new moodle_url("/message/contacts_messages.php?id=$user->id");
|
||||
$link = new moodle_url("/message/index.php?id=$user->id");
|
||||
//$action = new popup_action('click', $link, "message_$user->id", $popupoptions);
|
||||
$action = null;
|
||||
echo $OUTPUT->action_link($link, fullname($user), $action, array('title'=>get_string('sendmessageto', 'message', fullname($user))));
|
||||
@@ -1040,7 +1040,7 @@ function message_history_link($userid1, $userid2, $returnstr=false, $keywords=''
|
||||
'scrollbars' => true,
|
||||
'resizable' => true);
|
||||
|
||||
$link = new moodle_url('/message/contacts_messages.php?history='.MESSAGE_HISTORY_ALL."&user=$userid1&id=$userid2$keywords$position");
|
||||
$link = new moodle_url('/message/index.php?history='.MESSAGE_HISTORY_ALL."&user=$userid1&id=$userid2$keywords$position");
|
||||
//$action = new popup_action('click', $link, "message_history_$userid1", $popupoptions);
|
||||
$action = null;
|
||||
$str = $OUTPUT->action_link($link, $fulllink, $action, array('title'=>$strmessagehistory));
|
||||
|
||||
Reference in New Issue
Block a user