messaging MDL-22320 first commit for new messaging UI

This commit is contained in:
Andrew Davis 2010-06-25 08:16:10 +00:00
parent ed11e19b4a
commit c8621a0280
13 changed files with 1265 additions and 265 deletions

131
message/contacts.php Normal file
View File

@ -0,0 +1,131 @@
<?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('../config.php');
require('lib.php');
require_login(0, false);
if (isguestuser()) {
redirect($CFG->wwwroot);
}
if (empty($CFG->messaging)) {
print_error('disabled', 'message');
}
/// Optional variables that may be passed in
$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
$advancedsearch = optional_param('advanced', 0, PARAM_INT);
$usergroup = optional_param('usergroup', VIEW_UNREAD_MESSAGES, PARAM_ALPHANUMEXT);
$url = new moodle_url('/message/contacts.php');
/*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);
}*/
if ($usergroup !== 0) {
$url->param('usergroup', $usergroup);
}
if ($advancedsearch !== 0) {
$url->param('advanced', $advancedsearch);
}
$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.'&amp;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.'&amp;user2='.$USER->id, $removecontact);
message_remove_contact($removecontact);
}
if ($blockcontact and confirm_sesskey()) {
add_to_log(SITEID, 'message', 'block contact', 'history.php?user1='.$blockcontact.'&amp;user2='.$USER->id, $blockcontact);
message_block_contact($blockcontact);
}
if ($unblockcontact and confirm_sesskey()) {
add_to_log(SITEID, 'message', 'unblock contact', 'history.php?user1='.$unblockcontact.'&amp;user2='.$USER->id, $unblockcontact);
message_unblock_contact($unblockcontact);
}
//$PAGE->blocks->add_region('content');
$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);
$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($strcontacts);
$PAGE->set_title(fullname($USER).': '.$strcontacts);
$PAGE->set_heading("$SITE->shortname: $strcontacts");
//now the page contents
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;
$countunreadtotal = message_count_unread_messages($user1);
$blockedusers = message_get_blocked_users($user1, $user2);
list($onlinecontacts, $offlinecontacts, $strangers) = message_get_contacts($user1, $user2);
$showcontactactionlinks = true;
message_print_contact_selector($countunreadtotal, $usergroup, $user1, $user2, $blockedusers, $onlinecontacts, $offlinecontacts, $strangers, $showcontactactionlinks);
echo html_writer::start_tag('div', array('class'=>'messagearea mdl-align'));
message_print_search($advancedsearch, $user1);
echo html_writer::end_tag('div');
echo $OUTPUT->box_end();
echo $OUTPUT->footer();

View File

@ -0,0 +1,262 @@
<?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.'&amp;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.'&amp;user2='.$USER->id, $removecontact);
message_remove_contact($removecontact);
}
if ($blockcontact and confirm_sesskey()) {
add_to_log(SITEID, 'message', 'block contact', 'history.php?user1='.$blockcontact.'&amp;user2='.$USER->id, $blockcontact);
message_block_contact($blockcontact);
}
if ($unblockcontact and confirm_sesskey()) {
add_to_log(SITEID, 'message', 'unblock contact', 'history.php?user1='.$unblockcontact.'&amp;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)) { /// 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');
$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','style'=>'clear:both;padding-bottom:20px;'));
$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();

View File

@ -65,6 +65,8 @@ $systemcontext = get_context_instance(CONTEXT_SYSTEM);
$personalcontext = get_context_instance(CONTEXT_USER, $user->id);
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
$PAGE->set_context(get_context_instance(CONTEXT_USER, $USER->id));
$PAGE->set_pagelayout('course');
// check access control
if ($user->id == $USER->id) {
@ -95,11 +97,14 @@ if (($form = data_submitted()) && confirm_sesskey()) {
foreach ( $providers as $providerid => $provider){
foreach (array('loggedin', 'loggedoff') as $state){
$linepref = '';
foreach ($form->{$provider->component.'_'.$provider->name.'_'.$state} as $process=>$one){
if ($linepref == ''){
$linepref = $process;
} else {
$linepref .= ','.$process;
$componentproviderstate = $provider->component.'_'.$provider->name.'_'.$state;
if (array_key_exists($componentproviderstate, $form)) {
foreach ($form->{$componentproviderstate} as $process=>$one){
if ($linepref == ''){
$linepref = $process;
} else {
$linepref .= ','.$process;
}
}
}
$preferences['message_provider_'.$provider->component.'_'.$provider->name.'_'.$state] = $linepref;
@ -171,12 +176,17 @@ $streditmymessage = get_string('editmymessage', 'message');
$strparticipants = get_string('participants');
$userfullname = fullname($user, true);
if (has_capability('moodle/course:viewparticipants', $coursecontext) ||
has_capability('moodle/site:viewparticipants', $systemcontext)) {
$PAGE->navbar->add($strparticipants, new moodle_url('/message/index.php', array('id'=>$course->id)));
if ($user->id==$USER->id) {
$PAGE->navigation->extend_for_user($USER);
} else {
if (has_capability('moodle/course:viewparticipants', $coursecontext) ||
has_capability('moodle/site:viewparticipants', $systemcontext)) {
$PAGE->navbar->add($strparticipants, new moodle_url('/message/index.php', array('id'=>$course->id)));
}
$PAGE->navbar->add($userfullname, new moodle_url('/user/view.php', array('id'=>$user->id, 'course'=>$course->id)));
$PAGE->navbar->add($streditmymessage);
}
$PAGE->navbar->add($userfullname, new moodle_url('/user/view.php', array('id'=>$user->id, 'course'=>$course->id)));
$PAGE->navbar->add($streditmymessage);
$PAGE->set_title("$course->shortname: $streditmymessage");
if ($course->id != SITEID) {
$PAGE->set_heading("$course->fullname: $streditmymessage");

View File

@ -36,38 +36,73 @@ if (empty($CFG->messaging)) {
print_error('disabled', 'message');
}
$PAGE->set_title(get_string('messagehistory', 'message'));
/// Script parameters
$userid1 = required_param('user1', PARAM_INT);
$PAGE->set_url('/message/history.php', array('user1'=>$userid1));
if (! $user1 = $DB->get_record("user", array("id"=>$userid1))) { // Check it's correct
print_error('invaliduserid');
}
$userid1 = optional_param('user1', $USER->id, PARAM_INT);
$userid2 = required_param('user2', PARAM_INT);
$popup = optional_param('popup', 0, PARAM_INT);
if ($user1->deleted) {
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('userdeleted').': '.$userid1, 1);
echo $OUTPUT->footer();
die;
$url = new moodle_url('/message/history.php');
$url->param('user1', $userid1);
if (!empty($userid2)) {
$url->param('user2', $userid2);
}
$PAGE->set_url($url);
if (has_capability('moodle/site:readallmessages', get_context_instance(CONTEXT_SYSTEM))) { // Able to see any discussion
$userid2 = optional_param('user2', $USER->id, PARAM_INT);
$PAGE->url->param('user2', $userid2);
if (! $user2 = $DB->get_record("user", array("id"=>$userid2))) { // Check
$PAGE->set_context(get_context_instance(CONTEXT_USER, $USER->id));
$iscurrentuser = $USER->id == $userid1;
if ($iscurrentuser) {
$PAGE->navigation->extend_for_user($USER);
} else {
$PAGE->navigation->extend_for_user($DB->get_record('user',array('id'=>$userid1)));
}
$PAGE->navigation->extend_for_user($DB->get_record('user',array('id'=>$userid2)));
$strmessagehistory = get_string('messagehistory', 'message');
if (!$popup) {
if ($iscurrentuser) {
$PAGE->navigation->get('myprofile')->get('messages')->make_active();
} else {
$PAGE->navigation->find($userid1,navigation_node::TYPE_USER)->make_active();
}
$PAGE->navbar->add($strmessagehistory);
$PAGE->set_pagelayout('course');
$PAGE->set_heading($strmessagehistory);
}
$PAGE->set_title($strmessagehistory);
// Are we able to see other user's discussions?
if (has_capability('moodle/site:readallmessages', get_context_instance(CONTEXT_SYSTEM))) {
if (! $user1 = $DB->get_record("user", array("id"=>$userid1))) {
print_error('invaliduserid');
}
if ($user2->deleted) {
if ($user1->deleted) {
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('userdeleted').': '.$userid2, 1);
echo $OUTPUT->heading(get_string('userdeleted').': '.$userid1, 1);
echo $OUTPUT->footer();
die;
}
} else {
$userid2 = $USER->id; // Can only see messages involving yourself
$user2 = $USER;
//User can only see their own discussions
$userid1 = $USER->id;
$user1 = $USER;
}
if (! $user2 = $DB->get_record("user", array("id"=>$userid2))) { // Check
print_error('invaliduserid');
}
if ($user2->deleted) {
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('userdeleted').': '.$userid2, 1);
echo $OUTPUT->footer();
die;
}
$search = optional_param('search', '', PARAM_CLEAN);
add_to_log(SITEID, 'message', 'history', 'history.php?user1='.$userid1.'&amp;user2='.$userid2, $userid1);
@ -77,51 +112,7 @@ add_to_log(SITEID, 'message', 'history', 'history.php?user1='.$userid1.'&amp;use
echo $OUTPUT->header();
/// Print out a heading including the users we are looking at
echo $OUTPUT->box_start('center');
echo '<table align="center" cellpadding="10"><tr>';
echo '<td align="center">';
echo $OUTPUT->user_picture($user1, array('size'=>100, 'courseid'=>SITEID)).'<br />';
echo fullname($user1);
echo '</td>';
echo '<td align="center">';
echo '<img src="'.$CFG->wwwroot.'/pix/t/left.gif" alt="'.get_string('from').'" />';
echo '<img src="'.$CFG->wwwroot.'/pix/t/right.gif" alt="'.get_string('to').'" />';
echo '</td>';
echo '<td align="center">';
echo $OUTPUT->user_picture($user2, array('size'=>100, 'courseid'=>SITEID)).'<br />';
echo fullname($user2);
echo '</td>';
echo '</tr></table>';
echo $OUTPUT->box_end();
/// Get all the messages and print them
if ($messages = message_get_history($user1, $user2)) {
$current->mday = '';
$current->month = '';
$current->year = '';
$messagedate = get_string('strftimetime');
$blockdate = get_string('strftimedaydate');
foreach ($messages as $message) {
$date = usergetdate($message->timecreated);
if ($current->mday != $date['mday'] | $current->month != $date['month'] | $current->year != $date['year']) {
$current->mday = $date['mday'];
$current->month = $date['month'];
$current->year = $date['year'];
echo '<a name="'.$date['year'].$date['mon'].$date['mday'].'"></a>';
echo $OUTPUT->heading(userdate($message->timecreated, $blockdate), 4, 'center');
}
if ($message->useridfrom == $user1->id) {
echo message_format_message($message, $user1, $messagedate, $search, 'other');
} else {
echo message_format_message($message, $user2, $messagedate, $search, 'me');
}
}
} else {
echo $OUTPUT->heading(get_string('nomessagesfound', 'message'), 1);
}
message_print_message_history($user1, $user2, $search);
echo $OUTPUT->footer();

View File

@ -112,8 +112,6 @@ $tabrow[] = new tabobject('contacts', $CFG->wwwroot.'/message/index.php?tab=cont
get_string('contacts', 'message'));
$tabrow[] = new tabobject('search', $CFG->wwwroot.'/message/index.php?tab=search',
get_string('search', 'message'));
$tabrow[] = new tabobject('settings', $CFG->wwwroot.'/message/index.php?tab=settings',
get_string('settings', 'message'));
$tabrows = array($tabrow);
print_tabs($tabrows, $tab);
@ -129,7 +127,7 @@ echo '<td>';
/// a print function is associated with each tab
$tabprintfunction = 'message_print_'.$tab;
if (function_exists($tabprintfunction)) {
$tabprintfunction();
$tabprintfunction('index.php');
}
echo '</td> </tr> </table>';

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,6 @@ M.core_message.init_focus = function(Y, eid) {
}
M.core_message.init_refresh_parent_frame = function(Y, msgcount, msg) {
var add_message = function (messagestr) {
var messageblock = parent.messages.document.getElementById('messages');
var message = document.createElement('div');
@ -28,3 +27,18 @@ M.core_message.init_refresh_page = function(Y, delay, url) {
}
setTimeout(delay_callback, delay);
}
M.core_message.init_search_page = function(Y, defaultsearchterm) {
this.Y = Y;
this.defaultsearchterm = defaultsearchterm;
var combinedsearchbox = this.Y.one('#combinedsearch');
combinedsearchbox.on('focus', this.combinedsearchgotfocus, this);
}
M.core_message.combinedsearchgotfocus = function(e) {
if (e.target.get('value')==this.defaultsearchterm) {
e.target.select();
}
}

View File

@ -56,22 +56,42 @@ class message_output_popup extends message_output{
'<tr><td align="right">'.get_string('showmessagewindow', 'message').':</td><td><input type="checkbox" name="showmessagewindow" '.($preferences->showmessagewindow==1?" checked=\"checked\"":"").' /></td></tr>'.
'<tr><td align="right">'.get_string('blocknoncontacts', 'message').':</td><td><input type="checkbox" name="blocknoncontacts" '.($preferences->blocknoncontacts==1?" checked=\"checked\"":"").' /></td></tr>'.
'<tr><td align="right">'.get_string('beepnewmessage', 'message').':</td><td><input type="checkbox" name="beepnewmessage" '.($preferences->beepnewmessage==1?" checked=\"checked\"":"").' /></td></tr>'.
'<tr><td align="right">'.get_string('htmleditor').':</td><td><input type="checkbox" name="usehtmleditor" '.($preferences->usehtmleditor==1?" checked=\"checked\"":"").' /></td></tr>'.
'<tr><td align="right">'.get_string('noframesjs', 'message').':</td><td><input type="checkbox" name="noframesjs" '.($preferences->noframesjs==1?" checked=\"checked\"":"").' /></td></tr>'.
'<tr><td align="right">'.get_string('emailmessages', 'message').':</td><td><input type="checkbox" name="emailmessages" '.($preferences->emailmessages==1?" checked=\"checked\"":"").' /></td></tr>'.
'<tr><td align="right">'.get_string('formorethan', 'message').':</td><td><input type="text" name="emailtimenosee" id="emailtimenosee" size="2" value="'.$preferences->emailtimenosee.'" /> '.get_string('mins').'</td></tr>'.
'<tr><td align="right">'.get_string('email').':</td><td><input type="text" name="emailaddress" id="emailaddress" size="20" value="'.$preferences->emailaddress.'" /></td></tr>'.
'<tr><td align="right">'.get_string('format').':</td><td>'.$preferences->formatselect.'</td></tr>'.
'</table>';
}
public function process_form($form, &$preferences) {
$preferences['message_showmessagewindow'] = $form->showmessagewindow?1:0;
$preferences['message_blocknoncontacts'] = $form->blocknoncontacts?1:0;
$preferences['message_beepnewmessage'] = $form->beepnewmessage?1:0;
$preferences['message_noframesjs'] = $form->noframesjs?1:0;
$preferences['message_showmessagewindow'] = !empty($form->showmessagewindow)?1:0;
$preferences['message_blocknoncontacts'] = !empty($form->blocknoncontacts)?1:0;
$preferences['message_beepnewmessage'] = !empty($form->beepnewmessage)?1:0;
$preferences['message_usehtmleditor'] = !empty($form->usehtmleditor)?1:0;
$preferences['message_noframesjs'] = !empty($form->noframesjs)?1:0;
$preferences['message_emailmessages'] = !empty($form->emailmessages)?1:0;
$preferences['message_emailtimenosee'] = $form->emailtimenosee;
$preferences['message_emailaddress'] = $form->emailaddress;
$preferences['message_emailformat'] = $form->emailformat;
return true;
}
public function load_data(&$preferences, $userid) {
global $USER;
$preferences->showmessagewindow = get_user_preferences( 'message_showmessagewindow', 1, $userid);
$preferences->blocknoncontacts = get_user_preferences( 'message_blocknoncontacts', '', $userid);
$preferences->beepnewmessage = get_user_preferences( 'message_beepnewmessage', '', $userid);
$preferences->usehtmleditor = get_user_preferences( 'message_usehtmleditor', '', $userid);
$preferences->noframesjs = get_user_preferences( 'message_noframesjs', '', $userid);
$preferences->emailmessages = get_user_preferences( 'message_emailmessages', 1, $userid);
$preferences->emailtimenosee = get_user_preferences( 'message_emailtimenosee', 10, $userid);
$preferences->emailaddress = get_user_preferences( 'message_emailaddress', $USER->email, $userid);
$preferences->formatselect = html_writer::select(array(FORMAT_PLAIN => get_string('formatplain'),
FORMAT_HTML => get_string('formathtml')),
'emailformat', get_user_preferences('message_emailformat', FORMAT_PLAIN));
return true;
}
}

View File

@ -76,7 +76,7 @@ if ($messages ) {
}
}
$PAGE->requires->js_init_call('M.core_message.init_refresh_parent_frame', array($jsmessages, $jsmessages));
$PAGE->requires->js_init_call('M.core_message.init_refresh_parent_frame', array(count($jsmessages), $jsmessages));
echo $OUTPUT->header();
if (!empty($playbeep)) {

View File

@ -1,58 +1,16 @@
<form id="personsearch" action="index.php" method="post">
<form id="personsearch" method="post">
<div><input type="hidden" name="tab" value="search" /></div>
<table cellpadding="5" class="message_form boxaligncenter">
<div id="combinedcontactssearchspan" class="mdl-left">
<table cellpadding="5" class="message_form">
<tr>
<td colspan="3" class="message_heading"><?php echo $OUTPUT->heading(get_string('searchforperson', 'message')) ?></td>
<td colspan="3" class="message_heading mdl-left">
<input type="text" name="combinedsearch" size="50" id="combinedsearch" value="<?php echo $combinedsearchstring; ?>" />
<input type="submit" name="combinedsubmit" value="<?php print_string('search') ?>" />
<a href="contacts.php?advanced=1" id="advancedcontactsearchlink"><?php print_string('advanced') ?></a>
</td>
</tr>
<tr>
<td align="right"><label for="name"><?php print_string('name') ?></label></td>
<td><input type="text" name="name" size="16" id="name" /></td>
<td><input type="submit" name="personsubmit" value="<?php print_string('search') ?>" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2">
<input type="checkbox" name="mycourses" id="mycourses" /><label for="mycourses"><?php print_string('onlymycourses', 'message') ?></label></td>
</tr>
<tr><td colspan="3"></td></tr>
<tr>
<td colspan="3" class="message_heading"><?php echo $OUTPUT->heading(get_string('searchmessages', 'message')) ?></td>
</tr>
<tr>
<td align="right"><label for="keywords"><?php print_string('keywords', 'message') ?></label></td>
<td><input type="text" name="keywords" id="keywords" size="16" /></td>
<td><input type="submit" name="keywordssubmit" value="<?php print_string('search') ?>" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2">
<input type="checkbox" name="includeblocked" id="includeblocked" /><label for="includeblocked"><?php print_string('includeblockedusers', 'message') ?></label></td>
</tr>
<tr><td>&nbsp;</td><td colspan="2"><input type="radio" name="keywordsoption" id="keywordsoption1" value="tome" /><label for="keywordsoption1"><?php print_string('onlytome', 'message') ?></label></td></tr>
<tr><td>&nbsp;</td><td colspan="2"><input type="radio" name="keywordsoption" id="keywordsoption2" value="fromme" /><label for="keywordsoption2"><?php print_string('onlyfromme', 'message') ?></label></td></tr>
<tr><td>&nbsp;</td><td colspan="2"><input type="radio" checked="checked" name="keywordsoption" id="keywordsoption3" value="allmine" /><label for="keywordsoption3"><?php print_string('allmine', 'message') ?></label></td></tr>
<?php if (has_capability('moodle/site:readallmessages', get_context_instance(CONTEXT_SYSTEM))) { ?>
<tr><td>&nbsp;</td><td colspan="2"><input type="radio" name="keywordsoption" id="keywordsoption4" value="allusers" /><label for="keywordsoption4"><?php print_string('allusers', 'message') ?></label></td></tr>
<?php } ?>
<?php
/* Potential abuse problems - temporarily disabled
echo '<tr><td colspan="3"><input type="radio" name="keywordsoption" alt="'.get_string('allstudents', 'message').'" value="courseusers" />'.get_string('allstudents', 'message').'<br />&nbsp;&nbsp;&nbsp;'.$cs.'; </td></tr>';
*/
?>
</table>
</div>
</form>

View File

@ -0,0 +1,61 @@
<form id="personsearch" method="post">
<div><input type="hidden" name="tab" value="search" /></div>
<div id="advancedcontactssearchspan">
<table cellpadding="5" class="message_form mdl-left">
<tr>
<td colspan="3" class="message_heading mdl-left"><div id="hideadvancedsearch" class="mdl-align"><a href="contacts.php" id="combinedcontactsearchlink"><?php print_string('hideadvanced','form') ?></a></div></td>
</tr>
<tr>
<td colspan="3" class="message_heading mdl-left"><p class="heading"><?php echo get_string('searchforperson', 'message') ?></p></td>
</tr>
<tr>
<td><label for="name"><?php print_string('name') ?></label></td>
<td><input type="text" name="name" size="50" id="name" value="<? echo $personsearch ?>" /></td>
<td><input type="submit" name="personsubmit" value="<?php print_string('search') ?>" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2">
<input type="checkbox" name="mycourses" id="mycourses" /><label for="mycourses"><?php print_string('onlymycourses', 'message') ?></label></td>
</tr>
<tr><td colspan="3"></td></tr>
<tr>
<td colspan="3" class="message_heading"><p class="heading"><?php echo get_string('searchmessages', 'message') ?></p></td>
</tr>
<tr>
<td><label for="keywords"><?php print_string('keywords', 'message') ?></label></td>
<td><input type="text" name="keywords" id="keywords" size="50" value="<? echo $messagesearch ?>" /></td>
<td><input type="submit" name="keywordssubmit" value="<?php print_string('search') ?>" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2">
<input type="checkbox" name="includeblocked" id="includeblocked" /><label for="includeblocked"><?php print_string('includeblockedusers', 'message') ?></label></td>
</tr>
<tr><td>&nbsp;</td><td colspan="2"><input type="radio" name="keywordsoption" id="keywordsoption1" value="tome" /><label for="keywordsoption1"><?php print_string('onlytome', 'message') ?></label></td></tr>
<tr><td>&nbsp;</td><td colspan="2"><input type="radio" name="keywordsoption" id="keywordsoption2" value="fromme" /><label for="keywordsoption2"><?php print_string('onlyfromme', 'message') ?></label></td></tr>
<tr><td>&nbsp;</td><td colspan="2"><input type="radio" checked="checked" name="keywordsoption" id="keywordsoption3" value="allmine" /><label for="keywordsoption3"><?php print_string('allmine', 'message') ?></label></td></tr>
<?php if (has_capability('moodle/site:readallmessages', get_context_instance(CONTEXT_SYSTEM))) { ?>
<tr><td>&nbsp;</td><td colspan="2"><input type="radio" name="keywordsoption" id="keywordsoption4" value="allusers" /><label for="keywordsoption4"><?php print_string('allusers', 'message') ?></label></td></tr>
<?php } ?>
<?php
/* Potential abuse problems - temporarily disabled
echo '<tr><td colspan="3"><input type="radio" name="keywordsoption" alt="'.get_string('allstudents', 'message').'" value="courseusers" />'.get_string('allstudents', 'message').'<br />&nbsp;&nbsp;&nbsp;'.$cs.'; </td></tr>';
*/
?>
</table>
</div>
</form>

View File

@ -102,7 +102,7 @@ if (has_capability('moodle/site:sendmessage', get_context_instance(CONTEXT_SYSTE
'<span class="time">['.$time.']</span>: '.
'<span class="content">'.$message.'</span></div>';
//$PAGE->requires->js_function_call('parent.messages.document.write', Array($message));
$PAGE->requires->js_function_call('add_message', Array($message));
$PAGE->requires->js_function_call('parent.refresh.add_message', Array($message));
$PAGE->requires->js_function_call('parent.messages.scroll', Array(1,5000000));
add_to_log(SITEID, 'message', 'write', 'history.php?user1='.$user->id.'&amp;user2='.$USER->id.'#m'.$messageid, $user->id);

View File

@ -12,19 +12,21 @@ class send_form extends moodleform {
$mform =& $this->_form;
$editoroptions = array('maxfiles'=>0, 'maxbytes'=>0, 'trusttext'=>false);
//$editoroptions = array('maxfiles'=>0, 'maxbytes'=>0, 'trusttext'=>false);
$editoroptions = array();
//width handled by css so cols is empty. Still present so the page validates.
$displayoptions = array('rows'=>'4', 'cols'=>'', 'class'=>'messagesendbox');
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
$mform->addElement('html', '<div class="message-send-box">');
$mform->addElement('editor', 'message_editor', get_string('message', 'message'), null, $editoroptions);
$mform->addElement('html', '</div>');
//$mform->addElement('html', '<div class="message-send-box">');
$mform->addElement('textarea', 'message', get_string('message', 'message'), $displayoptions, $editoroptions);
//$mform->addElement('editor', 'message_editor', get_string('message', 'message'), null, $editoroptions);
//$mform->addElement('html', '</div>');
$this->add_action_buttons(false, get_string('sendmessage', 'message'));
}
/**
@ -34,7 +36,7 @@ class send_form extends moodleform {
*/
function set_data($data) {
$data->message = array('text'=>$data->message, 'format'=>$data->messageformat);
//$data->message = array('text'=>$data->message, 'format'=>$data->messageformat);
parent::set_data($data);
}
@ -47,10 +49,10 @@ class send_form extends moodleform {
function get_data() {
$data = parent::get_data();
if ($data !== null) {
$data->messageformat = $data->message_editor['format'];
$data->message = clean_text($data->message_editor['text'], $data->messageformat);
}
/*if ($data !== null) {
//$data->messageformat = $data->message_editor['format'];
//$data->message = clean_text($data->message_editor['text'], $data->messageformat);
}*/
return $data;
}
@ -62,9 +64,9 @@ class send_form extends moodleform {
* re-display the form but with an empty message so the user can type the next
* thing into it
*/
function reset_message() {
$this->_form->_elements[$this->_form->_elementIndex['message_editor']]->setValue(array('text'=>''));
}
//function reset_message() {
//$this->_form->_elements[$this->_form->_elementIndex['message']]->setValue(array('text'=>''));
//}
}