From 531e58f1b232da76739aa658b9298ebb75a8855b Mon Sep 17 00:00:00 2001 From: skodak Date: Mon, 25 Dec 2006 22:34:05 +0000 Subject: [PATCH] MDL-7956 Add frameless and JSless message composition option --- lang/en_utf8/message.php | 2 + message/discussion.php | 237 +++++++++++++++++++++++++++++-- message/lib.php | 170 ++++++++++++---------- message/refresh.php | 8 +- message/send.php | 7 +- message/settings.html | 6 +- theme/standard/styles_fonts.css | 21 +++ theme/standard/styles_layout.css | 50 +++++++ 8 files changed, 406 insertions(+), 95 deletions(-) diff --git a/lang/en_utf8/message.php b/lang/en_utf8/message.php index 634dd966ae..6e93ba40fa 100644 --- a/lang/en_utf8/message.php +++ b/lang/en_utf8/message.php @@ -34,6 +34,7 @@ $string['messages'] = 'Messages'; $string['messaging'] = 'Messaging'; $string['mycontacts'] = 'My Contacts'; $string['newsearch'] = 'New search'; +$string['noframesjs'] = 'Version without frames and JavaScript'; $string['nomessages'] = 'No messages waiting'; $string['nomessagesfound'] = 'No messages were found'; $string['nosearchresults'] = 'There were no results from your search'; @@ -46,6 +47,7 @@ $string['onlymycourses'] = 'Only in my courses'; $string['onlytome'] = 'Only messages to me'; $string['pagerefreshes'] = 'This page refreshes automatically every $a seconds'; $string['readmessages'] = '$a read messages'; +$string['refresh'] = 'Refresh'; $string['removecontact'] = 'Remove contact'; $string['savemysettings'] = 'Save my settings'; $string['search'] = 'Search'; diff --git a/message/discussion.php b/message/discussion.php index d0211aaaf6..42ec9c7713 100644 --- a/message/discussion.php +++ b/message/discussion.php @@ -1,5 +1,5 @@ @@ -31,15 +36,229 @@ <?php echo get_string('discussion', 'message').': '.fullname($user) ?> - <body>Sorry, but support for Frames is required to use Messaging</body> + <body><?php + echo '<a href="discussion.php?id='.$userid.'&amp;noframesjs=1">'.get_string('noframesjs', 'message').'<a/>'; + ?></body> - - - - + +id, $addcontact); + message_add_contact($addcontact); + } + if ($removecontact and confirm_sesskey()) { + add_to_log(SITEID, 'message', 'remove contact', + 'discussion.php?user1='.$removecontact.'&user2='.$USER->id, $removecontact); + message_remove_contact($removecontact); + } + if ($blockcontact and confirm_sesskey()) { + add_to_log(SITEID, 'message', 'block contact', + 'discussion.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); + } + +/// Check that the user is not blocking us!! + if ($contact = get_record('message_contacts', 'userid', $user->id, 'contactid', $USER->id)) { + if ($contact->blocked and !has_capability('moodle/site:readallmessages', get_context_instance(CONTEXT_SYSTEM, SITEID))) { + print_heading(get_string('userisblockingyou', 'message')); + exit; + } + } + if (get_user_preferences('message_blocknoncontacts', 0, $user->id)) { // User is blocking non-contacts + if (empty($contact)) { // We are not a contact! + print_heading(get_string('userisblockingyounoncontact', 'message')); + exit; + } + } + + $refreshedmessage = ''; + + if (!empty($refresh) and data_submitted()) { + $refreshedmessage = $message; + + } else if (empty($refresh) and data_submitted() and confirm_sesskey()) { + if ($message!='') { + message_post_message($USER, $user, $message, $format, 'direct'); + } + redirect('discussion.php?id='.$userid.'&start='.$start.'&noframesjs='.$noframesjs); + } + + + $userfullname = fullname($user); + $mefullname = fullname($USER); + + print_header(get_string('discussion', 'message').': '.fullname($user)); + echo '
'; + echo '
'; + echo print_user_picture($user->id, SITEID, $user->picture, 48, true, true, 'userwindow'); + echo '

'.get_string('discussion', 'message').': '.$userfullname.'

'; + echo '
    '; + if ($contact = get_record('message_contacts', 'userid', $USER->id, 'contactid', $user->id)) { + if ($contact->blocked) { + echo '
  • '; + message_contact_link($user->id, 'add', false, 'discussion.php?id='.$user->id.'&noframesjs='.$noframesjs, true); + echo '
  • '; + message_contact_link($user->id, 'unblock', false, 'discussion.php?id='.$user->id.'&noframesjs='.$noframesjs, true); + echo '
  • '; + } else { + echo '
  • '; + message_contact_link($user->id, 'remove', false, 'discussion.php?id='.$user->id.'&noframesjs='.$noframesjs, true); + echo '
  • '; + message_contact_link($user->id, 'block', false, 'discussion.php?id='.$user->id.'&noframesjs='.$noframesjs, true); + echo '
  • '; + } + } else { + echo '
  • '; + message_contact_link($user->id, 'add', false, 'discussion.php?id='.$user->id.'&noframesjs='.$noframesjs, true); + echo '
  • '; + message_contact_link($user->id, 'block', false, 'discussion.php?id='.$user->id.'&noframesjs='.$noframesjs, true); + echo '
  • '; + } + echo '
  • '; + message_history_link($user->id, 0, false, '', '', 'both'); + echo '
  • '; + echo '
'; + echo '
'; + echo '
'; // class="userinfo" + + echo '
'; + echo '
'; + echo ''; + echo ''; + echo ''; + echo ''; + + $usehtmleditor = (can_use_html_editor() && get_user_preferences('message_usehtmleditor', 0)); + echo '

'; + if ($usehtmleditor) { + print_textarea(true, 8, 34, 100, 100, 'message', $refreshedmessage); + use_html_editor('message', 'formatblock subscript superscript copy cut paste clean undo redo justifyleft justifycenter justifyright justifyfull lefttoright righttoleft insertorderedlist insertunorderedlist outdent indent inserthorizontalrule createanchor nolink inserttable'); + echo ''; + } else { + print_textarea(false, 8, 60, 0, 0, 'message', $refreshedmessage); + echo ''; + } + echo '
 '; + echo ''; + echo '
'; + echo '
'; + + echo '
'; + echo '

'.get_string('messages', 'message').'

'; + + $allmessages = array(); + $playbeep = false; + $options = new object(); + $options->para = false; + $options->newlines = true; + + if ($messages = get_records_select('message_read', "(useridto = '$USER->id' AND useridfrom = '$userid' AND timeread > '$start') OR (useridto = '$userid' AND useridfrom = '$USER->id' AND timeread > '$start')")) { + foreach ($messages as $message) { + $time = userdate($message->timecreated, get_string('strftimedaytime')); + + if ($message->useridfrom == $USER->id) { + $fullname = $mefullname; + } else { + $fullname = $userfullname; + } + + $printmessage = format_text($message->message, $message->format, $options, 0); + $printmessage = str_replace("\r", ' ', $printmessage); + $printmessage = str_replace("\n", ' ', $printmessage); + $printmessage = '
'.$fullname.' '. + '['.$time.']: '. + ''.$printmessage.'
'; + $allmessages[$message->timecreated] = $printmessage; + } + } + + if ($messages = get_records_select('message', "useridto = '$userid' AND useridfrom = '$USER->id'")) { + foreach ($messages as $message) { + $time = userdate($message->timecreated, get_string('strftimedaytime')); + + $printmessage = format_text($message->message, $message->format, $options, 0); + $printmessage = str_replace("\r", ' ', $printmessage); + $printmessage = str_replace("\n", ' ', $printmessage); + $printmessage = '
'.$mefullname.' '. + '['.$time.']: '. + ''.$printmessage.'
'; + $allmessages[$message->timecreated] = $printmessage; // hack alert - let's hope users will not post exactly at the same time + } + } + + if ($messages = get_records_select('message', "useridto = '$USER->id' AND useridfrom = '$userid'")) { + foreach ($messages as $message) { + $time = userdate($message->timecreated, get_string('strftimedaytime')); + + $printmessage = format_text($message->message, $message->format, $options, 0); + $printmessage = str_replace("\r", ' ', $printmessage); + $printmessage = str_replace("\n", ' ', $printmessage); + $printmessage = '
'.$userfullname.' '. + '['.$time.']: '. + ''.$printmessage.'
'; + $allmessages[$message->timecreated] = $printmessage; + + /// Move the entry to the other table + + $messageid = $message->id; + unset($message->id); + $message->timeread = time(); + $message = addslashes_object($message); + if (insert_record('message_read', $message)) { + delete_records('message', 'id', $messageid); + } + if ($message->timecreated < $start) { + $start = $message->timecreated; // move start back so that we see all current history + } + } + $playbeep = true; + } + + krsort($allmessages); + + if (empty($allmessages)) { + echo get_string('nomessagesfound', 'message'); + } else { + foreach ($allmessages as $message) { + echo $message; + } + if ($playbeep and get_user_preferences('message_beepnewmessage', 0)) { + echo ''; + } + } + + echo '
'; + + print_footer('none'); +?> \ No newline at end of file diff --git a/message/lib.php b/message/lib.php index c6cfa2041c..ef4a3f67a3 100644 --- a/message/lib.php +++ b/message/lib.php @@ -25,22 +25,22 @@ function message_print_contacts() { } $timefrom = time()-$timetoshowusers; - + /// get lists of contacts and unread messages $onlinecontacts = get_records_sql("SELECT u.id, u.firstname, u.lastname, u.picture, mc.blocked FROM {$CFG->prefix}user u, {$CFG->prefix}message_contacts mc - WHERE mc.userid='$USER->id' AND u.id=mc.contactid AND u.lastaccess>=$timefrom - AND mc.blocked='0' + WHERE mc.userid='$USER->id' AND u.id=mc.contactid AND u.lastaccess>=$timefrom + AND mc.blocked='0' ORDER BY u.firstname ASC"); $offlinecontacts = get_records_sql("SELECT u.id, u.firstname, u.lastname, u.picture, mc.blocked FROM {$CFG->prefix}user u, {$CFG->prefix}message_contacts mc WHERE mc.userid='$USER->id' AND u.id=mc.contactid AND u.lastaccess<$timefrom - AND mc.blocked='0' + AND mc.blocked='0' ORDER BY u.firstname ASC"); - $unreadmessages = get_records_sql("SELECT m.id, m.useridfrom, u.firstname, u.lastname, u.picture - FROM {$CFG->prefix}user u, {$CFG->prefix}message m + $unreadmessages = get_records_sql("SELECT m.id, m.useridfrom, u.firstname, u.lastname, u.picture + FROM {$CFG->prefix}user u, {$CFG->prefix}message m WHERE m.useridto='$USER->id' AND u.id=m.useridfrom"); $blockedcontacts = get_records_select('message_contacts', "userid='$USER->id' AND blocked='1'", '', 'contactid, id'); @@ -61,7 +61,7 @@ function message_print_contacts() { if (empty($offlinecontacts)) $offlinecontacts = array(); if (empty($blockedcontacts)) $blockedcontacts = array(); foreach ($unreadmessages as $unreadmessage) { - if (array_key_exists($unreadmessage->useridfrom, $onlinecontacts) or + if (array_key_exists($unreadmessage->useridfrom, $onlinecontacts) or array_key_exists($unreadmessage->useridfrom, $offlinecontacts) or array_key_exists($unreadmessage->useridfrom, $blockedcontacts) ) { continue; @@ -86,16 +86,16 @@ function message_print_contacts() { } if(!empty($onlinecontacts) || !empty($offlinecontacts) || !empty($unknownmessages)) { - + echo ''; - + if(!empty($onlinecontacts)) { /// print out list of online contacts - + echo ''; - + if (!empty($onlinecontacts)) { foreach ($onlinecontacts as $contact) { if ($contact->blocked == 1) continue; @@ -108,12 +108,12 @@ function message_print_contacts() { /// link to remove from contact list $strcontact = message_contact_link($contact->id, 'remove', true); $strhistory = message_history_link($contact->id, 0, true, '', '', 'icon'); - + echo ''; echo ''; @@ -123,7 +123,7 @@ function message_print_contacts() { } echo ''; } - + if (!empty($offlinecontacts)) { /// print out list of offline contacts @@ -147,7 +147,7 @@ function message_print_contacts() { print_user_picture($contact->id, SITEID, $contact->picture, 20, false, true, 'userwindow'); echo ''; echo ''; @@ -157,7 +157,7 @@ function message_print_contacts() { echo ''; } - + /// print out list of incoming contacts if (!empty($unknownmessages)) { echo ''; echo ''; @@ -190,18 +190,30 @@ function message_print_contacts() { } echo '
'; echo get_string('onlinecontacts', 'message', $countonlinecontacts); echo '
'; print_user_picture($contact->id, SITEID, $contact->picture, 20, false, true, 'userwindow'); echo ''; - link_to_popup_window("/message/discussion.php?id=$contact->id", "message_$contact->id", + link_to_popup_window("/message/discussion.php?id=$contact->id", "message_$contact->id", $fullnamelink, 500, 500, get_string('sendmessageto', 'message', $fullname), 'menubar=0,location=0,status,scrollbars,resizable,width=500,height=500'); echo '
 
'; - link_to_popup_window("/message/discussion.php?id=$contact->id", "message_$contact->id", + link_to_popup_window("/message/discussion.php?id=$contact->id", "message_$contact->id", $fullnamelink, 500, 500, get_string('sendmessageto', 'message', $fullname), 'menubar=0,location=0,status,scrollbars,resizable,width=500,height=500'); echo '
 
'; @@ -171,16 +171,16 @@ function message_print_contacts() { $fullnamelink = ''.$fullnamelink.' ('.$messageuser->count.')'; } /// link to add to contact list - + $strcontact = message_contact_link($messageuser->useridfrom, 'add', true); $strblock = message_contact_link($messageuser->useridfrom, 'block', true); $strhistory = message_history_link($messageuser->useridfrom, 0, true, '', '', 'icon'); - + echo '
'; print_user_picture($messageuser->useridfrom, SITEID, $messageuser->picture, 20, false, true, 'userwindow'); echo ''; - link_to_popup_window("/message/discussion.php?id=$messageuser->useridfrom", "message_$messageuser->useridfrom", + link_to_popup_window("/message/discussion.php?id=$messageuser->useridfrom", "message_$messageuser->useridfrom", $fullnamelink, 500, 500, get_string('sendmessageto', 'message', $fullname), 'menubar=0,location=0,status,scrollbars,resizable,width=500,height=500'); echo '
'; - + if (!empty($unknownmessages) && ($countonlinecontacts + $countofflinecontacts == 0)) { // Extra help echo '
('; print_string('addsomecontactsincoming', 'message'); echo ')
'; } - + } - echo '

'.get_string('pagerefreshes', 'message', $CFG->message_contacts_refresh).'

'; + echo '
'; + $autorefresh = '

'.get_string('pagerefreshes', 'message', $CFG->message_contacts_refresh).'

'; + $autorefresh = addslashes($autorefresh); // js escaping + + // gracefully degrade JS autorefresh + echo ''; + echo ''; } @@ -215,7 +227,7 @@ function message_print_contacts() { function message_count_messages($messagearray, $field='', $value='') { if (!is_array($messagearray)) return 0; if ($field == '' or empty($messagearray)) return count($messagearray); - + $count = 0; foreach ($messagearray as $message) { $count += ($message->$field == $value) ? 1 : 0; @@ -226,14 +238,14 @@ function message_count_messages($messagearray, $field='', $value='') { function message_print_search() { global $USER; - + if ($frm = data_submitted()) { - + message_print_search_results($frm); - + } else { /* -/// unfinished buggy code disabled in search.html anyway +/// unfinished buggy code disabled in search.html anyway // find all courses this use has readallmessages capabilities in if ($teachers = get_user_capability_course('moodle/site:readallmessages')) { $courses = get_courses('all', 'c.sortorder ASC', 'c.id, c.shortname'); @@ -250,7 +262,7 @@ function message_print_search() { function message_print_settings() { global $USER; - + if ($frm = data_submitted()) { $pref = array(); @@ -258,13 +270,14 @@ function message_print_settings() { $pref['message_beepnewmessage'] = (isset($frm->beepnewmessage)) ? '1' : '0'; $pref['message_blocknoncontacts'] = (isset($frm->blocknoncontacts)) ? '1' : '0'; $pref['message_usehtmleditor'] = (isset($frm->usehtmleditor)) ? '1' : '0'; + $pref['message_noframesjs'] = (isset($frm->noframesjs)) ? '1' : '0'; $pref['message_emailmessages'] = (isset($frm->emailmessages)) ? '1' : '0'; $pref['message_emailtimenosee'] = ((int)$frm->emailtimenosee > 0) ? (int)$frm->emailtimenosee : '10'; $pref['message_emailaddress'] = (!empty($frm->emailaddress)) ? $frm->emailaddress : $USER->email; $pref['message_emailformat'] = (isset($frm->emailformat)) ? $frm->emailformat : FORMAT_PLAIN; set_user_preferences($pref); - + redirect('index.php', get_string('settingssaved', 'message'), 1); } @@ -272,6 +285,7 @@ function message_print_settings() { $cbbeepnewmessage = (get_user_preferences('message_beepnewmessage', 0) == '1') ? 'checked="checked"' : ''; $cbblocknoncontacts = (get_user_preferences('message_blocknoncontacts', 0) == '1') ? 'checked="checked"' : ''; $cbusehtmleditor = (get_user_preferences('message_usehtmleditor', 0) == '1') ? 'checked="checked"' : ''; + $cbnoframesjs = (get_user_preferences('message_noframesjs', 0) == '1') ? 'checked="checked"' : ''; $cbemailmessages = (get_user_preferences('message_emailmessages', 1) == '1') ? 'checked="checked"' : ''; $txemailaddress = get_user_preferences('message_emailaddress', $USER->email); $txemailtimenosee = get_user_preferences('message_emailtimenosee', 10); @@ -280,7 +294,7 @@ function message_print_settings() { 'emailformat', get_user_preferences('message_emailformat', FORMAT_PLAIN), false, '', '0', true ); - + include('settings.html'); } @@ -288,14 +302,14 @@ function message_print_settings() { function message_add_contact($contactid, $blocked=0) { global $USER; - + if (!record_exists('user', 'id', $contactid)) { // invalid userid return false; } - + if (($contact = get_record('message_contacts', 'userid', $USER->id, 'contactid', $contactid)) !== false) { /// record already exists - we may be changing blocking status - + if ($contact->blocked !== $blocked) { /// change to blocking status $contact->blocked = $blocked; @@ -304,7 +318,7 @@ function message_add_contact($contactid, $blocked=0) { /// no changes to blocking status return true; } - + } else { /// new contact record unset($contact); @@ -333,7 +347,7 @@ function message_get_contact($contactid) { global $USER; return get_record('message_contacts', 'userid', $USER->id, 'contactid', $contactid); } - + function message_print_search_results($frm) { @@ -343,7 +357,7 @@ function message_print_search_results($frm) { /// search for person if (!empty($frm->personsubmit) and !empty($frm->name)) { - + if (optional_param('mycourses', 0, PARAM_BOOL)) { $users = array(); $mycourses = get_my_courses($USER->id); @@ -360,7 +374,7 @@ function message_print_search_results($frm) { echo ''.get_string('userssearchresults', 'message', count($users)).''; echo ''; foreach ($users as $user) { - + if (($contact = message_get_contact($user->id)) !== false) { if ($contact->blocked == 0) { /// not blocked $strcontact = message_contact_link($user->id, 'remove', true); @@ -374,28 +388,28 @@ function message_print_search_results($frm) { $strblock = message_contact_link($user->id, 'block', true); } $strhistory = message_history_link($user->id, 0, true, '', '', 'icon'); - + echo ''; echo ''; - + echo ''; echo ''; echo ''; echo ''; } echo '
'; print_user_picture($user->id, SITEID, $user->picture, 20, false, true, 'userwindow'); echo ''; - link_to_popup_window("/message/discussion.php?id=$user->id", "message_$user->id", fullname($user), + link_to_popup_window("/message/discussion.php?id=$user->id", "message_$user->id", fullname($user), 500, 500, get_string('sendmessageto', 'message', fullname($user)), 'menubar=0,location=0,status,scrollbars,resizable,width=500,height=500'); echo '
'; - + } else { notify(get_string('nosearchresults', 'message')); } - - + + /// search messages for keywords } else if (!empty($frm->keywordssubmit) and !empty($frm->keywords)) { $keywordstring = clean_text(trim($frm->keywords)); @@ -427,7 +441,7 @@ function message_print_search_results($frm) { } if (($messages = message_search($keywords, $fromme, $tome, $courseid)) !== false) { - + /// get a list of contacts if (($contacts = get_records('message_contacts', 'userid', $USER->id, '', 'contactid, blocked') ) === false) { $contacts = array(); @@ -459,26 +473,26 @@ function message_print_search_results($frm) { $blockedcount ++; continue; } - + /// load up user to record if ($message->useridto !== $USER->id) { $userto = get_record('user', 'id', $message->useridto); - $tocontact = (array_key_exists($message->useridto, $contacts) and + $tocontact = (array_key_exists($message->useridto, $contacts) and ($contacts[$message->useridto]->blocked == 0) ); - $toblocked = (array_key_exists($message->useridto, $contacts) and + $toblocked = (array_key_exists($message->useridto, $contacts) and ($contacts[$message->useridto]->blocked == 1) ); } else { $userto = false; $tocontact = false; $toblocked = false; } - + /// load up user from record if ($message->useridfrom !== $USER->id) { $userfrom = get_record('user', 'id', $message->useridfrom); - $fromcontact = (array_key_exists($message->useridfrom, $contacts) and + $fromcontact = (array_key_exists($message->useridfrom, $contacts) and ($contacts[$message->useridfrom]->blocked == 0) ); - $fromblocked = (array_key_exists($message->useridfrom, $contacts) and + $fromblocked = (array_key_exists($message->useridfrom, $contacts) and ($contacts[$message->useridfrom]->blocked == 1) ); } else { $userfrom = false; @@ -500,20 +514,20 @@ function message_print_search_results($frm) { echo ''; echo ''.message_get_fragment($message->message, $keywords); echo '
'; echo ''; echo ''.userdate($message->timecreated, $dateformat).''; echo "\n"; } - + if ($blockedcount > 0) { echo ''.get_string('blockedmessages', 'message', $blockedcount).''; } echo ''; - + } else { notify(get_string('nosearchresults', 'message')); } @@ -550,7 +564,7 @@ function message_print_user ($user=false, $iscontact=false, $isblocked=false) { message_contact_link($user->id, 'block'); } echo '
'; - link_to_popup_window("/message/discussion.php?id=$user->id", "message_$user->id", + link_to_popup_window("/message/discussion.php?id=$user->id", "message_$user->id", fullname($user), 400, 400, get_string('sendmessageto', 'message', fullname($user)), 'menubar=0,location=0,status,scrollbars,resizable,width=500,height=500'); } @@ -633,8 +647,8 @@ function message_history_link($userid1, $userid2=0, $returnstr=false, $keywords= $fulllink = $strmessagehistory; } - $str = link_to_popup_window("/message/history.php?user1=$userid1&user2=$userid2$keywords$position", - "message_history_$userid1", $fulllink, 500, 500, $strmessagehistory, + $str = link_to_popup_window("/message/history.php?user1=$userid1&user2=$userid2$keywords$position", + "message_history_$userid1", $fulllink, 500, 500, $strmessagehistory, 'menubar=0,location=0,status,scrollbars,resizable,width=500,height=500', true); $str = ''.$str.''; @@ -651,7 +665,7 @@ function message_history_link($userid1, $userid2=0, $returnstr=false, $keywords= /** * Search through course users * - * If $coursid specifies the site course then this function searches + * If $coursid specifies the site course then this function searches * through all undeleted and confirmed users * * @uses $CFG @@ -659,7 +673,7 @@ function message_history_link($userid1, $userid2=0, $returnstr=false, $keywords= * @param int $courseid The course in question. * @param string $searchtext ? * @param string $sort ? - * @param string $exceptions ? + * @param string $exceptions ? * @return array An array of {@link $USER} records. * @todo Finish documenting this function */ @@ -694,12 +708,12 @@ function message_search_users($courseid, $searchtext, $sort='', $exceptions='') $context = get_context_instance(CONTEXT_COURSE, $courseid); $contextlists = get_related_contexts_string($context); - + // everyone who has a role assignement in this course or higher $users = get_records_sql("SELECT $fields FROM {$CFG->prefix}user u, {$CFG->prefix}role_assignments ra - WHERE $select + WHERE $select AND ra.contextid $contextlists AND u.id = ra.userid AND ($fullname $LIKE '%$searchtext%') @@ -720,7 +734,7 @@ function message_search($searchterms, $fromme=true, $tome=true, $courseid='none' global $CFG, $USER; /// If no userid sent then assume current user - if ($userid == 0) $userid = $USER->id; + if ($userid == 0) $userid = $USER->id; /// Some differences in SQL syntax $LIKE = sql_ilike(); @@ -778,34 +792,34 @@ function message_search($searchterms, $fromme=true, $tome=true, $courseid='none' if ($courseid == SITEID) { /// admin is searching all messages $m_read = get_records_sql("SELECT m.id, m.useridto, m.useridfrom, m.message, m.timecreated - FROM {$CFG->prefix}message_read m + FROM {$CFG->prefix}message_read m WHERE $messagesearch"); $m_unread = get_records_sql("SELECT m.id, m.useridto, m.useridfrom, m.message, m.timecreated - FROM {$CFG->prefix}message m + FROM {$CFG->prefix}message m WHERE $messagesearch"); - + if ($m_read === false) $m_read = array(); if ($m_unread === false) $m_unread = array(); - + } elseif ($courseid !== 'none') { /// This has not been implemented due to security concerns } else { - + if ($fromme and $tome) $messagesearch .= "AND (m.useridfrom='$userid' OR m.useridto='$userid') "; elseif ($fromme) $messagesearch .= "AND m.useridfrom='$userid' "; elseif ($tome) $messagesearch .= "AND m.useridto='$userid' "; - + $m_read = get_records_sql("SELECT m.id, m.useridto, m.useridfrom, m.message, m.timecreated - FROM {$CFG->prefix}message_read m + FROM {$CFG->prefix}message_read m WHERE $messagesearch"); $m_unread = get_records_sql("SELECT m.id, m.useridto, m.useridfrom, m.message, m.timecreated - FROM {$CFG->prefix}message m + FROM {$CFG->prefix}message m WHERE $messagesearch"); - + if ($m_read === false) $m_read = array(); if ($m_unread === false) $m_unread = array(); - + } /// The keys may be duplicated in $m_read and $m_unread so we can't @@ -833,7 +847,7 @@ function message_shorten_message($message, $minlength=0) { $stopzone = false; $truncate = 0; if ($minlength == 0) $minlength = MESSAGE_SHORTLENGTH; - + for ($i=0; $i<$length; $i++) { $char = $message[$i]; @@ -921,11 +935,11 @@ function message_get_fragment($message, $keywords) { function message_get_history($user1, $user2) { - $messages = get_records_select('message_read', "(useridto = '$user1->id' AND useridfrom = '$user2->id') OR - (useridto = '$user2->id' AND useridfrom = '$user1->id')", + $messages = get_records_select('message_read', "(useridto = '$user1->id' AND useridfrom = '$user2->id') OR + (useridto = '$user2->id' AND useridfrom = '$user1->id')", 'timecreated'); - if ($messages_new = get_records_select('message', "(useridto = '$user1->id' AND useridfrom = '$user2->id') OR - (useridto = '$user2->id' AND useridfrom = '$user1->id')", + if ($messages_new = get_records_select('message', "(useridto = '$user1->id' AND useridfrom = '$user2->id') OR + (useridto = '$user2->id' AND useridfrom = '$user1->id')", 'timecreated')) { foreach ($messages_new as $message) { $messages[] = $message; @@ -992,7 +1006,7 @@ function message_post_message($userfrom, $userto, $message, $format, $messagetyp $message = stripslashes_safe($message); $tagline = get_string('emailtagline', 'message', $SITE->shortname); - + $messagesubject = message_shorten_message(strip_tags($message), 30).'...'; $messagetext = format_text_email($message, $format). @@ -1016,7 +1030,7 @@ function message_post_message($userfrom, $userto, $message, $format, $messagetyp } -/* +/* * Returns a list of all user ids who have used messaging in the site * This was the simple way to code the SQL ... is it going to blow up * on large datasets? diff --git a/message/refresh.php b/message/refresh.php index 4cc0f35d10..1c20c82818 100644 --- a/message/refresh.php +++ b/message/refresh.php @@ -1,5 +1,5 @@ id' AND useridfrom = '$userid'", + if ($messages = get_records_select('message', "useridto = '$USER->id' AND useridfrom = '$userid'", 'timecreated')) { foreach ($messages as $message) { $time = userdate($message->timecreated, get_string('strftimedaytime')); - $options = NULL; + $options = new object(); $options->para = false; $options->newlines = true; $printmessage = format_text($message->message, $message->format, $options, 0); @@ -67,7 +67,7 @@ /// Move the entry to the other table $message->timeread = time(); - $message->message = addslashes($message->message); + $message = addslashes_object($message); $messageid = $message->id; unset($message->id); if (insert_record('message_read', $message)) { diff --git a/message/send.php b/message/send.php index aea5d2fdd1..b7cb47b319 100644 --- a/message/send.php +++ b/message/send.php @@ -1,5 +1,5 @@ '; echo ''; + echo ''; echo ''; - + echo "\n\n\n"; diff --git a/message/settings.html b/message/settings.html index fa92084363..c2aad9fc6d 100644 --- a/message/settings.html +++ b/message/settings.html @@ -20,8 +20,12 @@ /> + + /> + + + - /> diff --git a/theme/standard/styles_fonts.css b/theme/standard/styles_fonts.css index 66e247ed81..5a35189b10 100644 --- a/theme/standard/styles_fonts.css +++ b/theme/standard/styles_fonts.css @@ -491,6 +491,27 @@ body#grade-index .grades .header { *** Message ***/ +.message-discussion-noframes #userinfo .name h1 { + font-weight: bold; + font-size:1em; +} + +.message-discussion-noframes #userinfo .commands { + font-size:0.8em; +} + +.message-discussion-noframes #send h1 { + font-size:1em; +} + +.message .noframesjslink { + font-size:0.8em; +} + +.message-discussion-noframes #messages h1 { + font-size:1em; +} + .message .link { font-size:0.8em; } diff --git a/theme/standard/styles_layout.css b/theme/standard/styles_layout.css index 0ead3c3b16..d6cb1eef9f 100644 --- a/theme/standard/styles_layout.css +++ b/theme/standard/styles_layout.css @@ -1360,6 +1360,56 @@ body#grade-index .grades .weighted { *** Message ***/ +.message-discussion-noframes #userinfo .userpicture { + float:left; +} + +.message-discussion-noframes #userinfo .name h1 { + margin:0px; +} + +.message-discussion-noframes #userinfo .name { + text-align:left; + margin-left:60px; +} + +.message-discussion-noframes #userinfo .commands { + text-align:left; + margin-left:60px; +} + +.message-discussion-noframes #userinfo .commands ul { + margin:0px; + padding:0px; + list-style-type:none; + display:inline; +} + +.message-discussion-noframes #userinfo .commands ul li { + display:inline; + padding-right:16px; +} + +.message-discussion-noframes #send { + padding-top:10px; + clear:both; +} + +.message-discussion-noframes #send h1 { + margin:0px; +} +.message-discussion-noframes #messages { + padding-top:10px; +} + +.message-discussion-noframes #send h1 { + margin:0px; +} + +.message .noframesjslink { + margin-top:20px; +} + .message .link { vertical-align:middle; } -- 2.39.5