From: moodler Date: Sat, 1 Jan 2005 11:47:18 +0000 (+0000) Subject: Tidying up icons and layout X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=e520509acbc2022c2a678700c43db0d442dd082e;p=moodle.git Tidying up icons and layout --- diff --git a/message/history.php b/message/history.php index 55050fd30b..3586a967b9 100644 --- a/message/history.php +++ b/message/history.php @@ -62,6 +62,7 @@ $current->mday = $date['mday']; $current->month = $date['month']; $current->year = $date['year']; + echo ''; print_heading(userdate($message->timecreated, $blockdate), 'center', 4); } if ($message->useridfrom == $user1->id) { diff --git a/message/index.php b/message/index.php index 20330da6c3..fd3983f369 100644 --- a/message/index.php +++ b/message/index.php @@ -14,15 +14,19 @@ $blockcontact = optional_param('blockcontact', 0, PARAM_INT); // blocking a $unblockcontact = optional_param('unblockcontact', 0, PARAM_INT); // unblocking a contact if ($addcontact and confirm_sesskey()) { + add_to_log(SITEID, 'message', 'add contact', 'history.php?user1='.$addcontact.'&user2='.$USER->id, $addcontact); message_add_contact($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); } diff --git a/message/lib.php b/message/lib.php index 0e6338f517..46006a2f4e 100644 --- a/message/lib.php +++ b/message/lib.php @@ -37,17 +37,13 @@ function message_print_contacts() { $blockedcontacts = get_records_select('message_contacts', "userid='$USER->id' AND blocked='1'", '', 'contactid, id'); - echo ''; - echo ''; + echo '
'.get_string('mycontacts', 'message').'
'; /// print out list of online contacts - echo ''; - echo ''; /// print out list of offline contacts - echo ''; - echo ''; /// Cycle through messages and extract those that are from unknown contacts @@ -146,32 +135,30 @@ function message_print_contacts() { /// print out list of incoming contacts if (!empty($unknownmessages)) { - echo ''; - echo ''; - echo ''; } echo '
 '; $countcontacts = (is_array($onlinecontacts)) ? count($onlinecontacts) : 0; - echo ''; echo ''; @@ -55,37 +51,32 @@ function message_print_contacts() { if (!empty($onlinecontacts)) { foreach ($onlinecontacts as $contact) { if ($contact->blocked == 1) continue; - $strcontact = ''; + $fullname = fullname($contact); + $fullnamelink = $fullname; /// are there any unread messages for this contact? if (($unread = message_count_messages($unreadmessages, 'useridfrom', $contact->id)) > 0) { - $strcontact .= '( '.get_string('unreadmessages', 'message', $unread).')'; + $fullnamelink = ''.$fullnamelink.' ('.$unread.')'; } /// link to remove from contact list $strcontact .= message_contact_link($contact->id, 'remove', true); echo ''; echo ''; echo ''; echo ''; } } echo ''; - echo '
'; echo ''.get_string('onlinecontacts', 'message', $countcontacts).''; echo '
'; - print_user_picture($contact->id, SITEID, $contact->picture, 20, false, false); + print_user_picture($contact->id, SITEID, $contact->picture, 20, false, true, 'userwindow'); echo ''; - link_to_popup_window("/message/user.php?id=$contact->id", "message_$contact->id", fullname($contact), 400, 400, get_string('sendmessageto', 'message', fullname($contact))); + link_to_popup_window("/message/user.php?id=$contact->id", "message_$contact->id", $fullnamelink, 400, 400, get_string('sendmessageto', 'message', $fullname)); echo '
 
'; - - echo '
 '; $countcontacts = (is_array($offlinecontacts)) ? count($offlinecontacts) : 0; - echo ''; echo ''; @@ -93,28 +84,26 @@ function message_print_contacts() { if (!empty($offlinecontacts)) { foreach ($offlinecontacts as $contact) { if ($contact->blocked == 1) continue; - $strcontact = ''; + $fullname = fullname($contact); + $fullnamelink = $fullname; /// are there any unread messages for this contact? if (($unread = message_count_messages($unreadmessages, 'useridfrom', $contact->id)) > 0) { - $strcontact .= '( '.get_string('unreadmessages', 'message', $unread).')'; + $fullnamelink = ''.$fullnamelink.' ('.$unread.')'; } /// link to remove from contact list - $strcontact .= message_contact_link($contact->id, 'remove', true); + $strcontact = message_contact_link($contact->id, 'remove', true); echo ''; echo ''; echo ''; echo ''; } } echo ''; - echo '
'; echo ''.get_string('offlinecontacts', 'message', $countcontacts).''; echo '
'; - print_user_picture($contact->id, SITEID, $contact->picture, 20, false, false); + print_user_picture($contact->id, SITEID, $contact->picture, 20, false, true, 'userwindow'); echo ''; - link_to_popup_window("/message/user.php?id=$contact->id", "message_$contact->id", fullname($contact), 400, 400, get_string('sendmessageto', 'message', fullname($contact))); + link_to_popup_window("/message/user.php?id=$contact->id", "message_$contact->id", $fullnamelink, 400, 400, get_string('sendmessageto', 'message', $fullname)); echo '
 
'; - - echo '
'; + echo '
'; echo ''.get_string('incomingcontacts', 'message', count($unknownmessages)).''; echo '
 '; - echo ''; foreach ($unknownmessages as $messageuser) { - $strcontact = '( '.get_string('unreadmessages', 'message', $messageuser->count).')'; + $fullname = fullname($messageuser); + $fullnamelink = $fullname; + if ($messageuser->count) { + $fullnamelink = ''.$fullnamelink.' ('.$messageuser->count.')'; + } /// link to add to contact list - $strcontact .= message_contact_link($messageuser->useridfrom, 'add', true); + $strcontact = message_contact_link($messageuser->useridfrom, 'add', true); $strblock = message_contact_link($messageuser->useridfrom, 'block', true); echo ''; echo ''; - echo ''; - echo ''; + echo ''; echo ''; } - echo '
'; - print_user_picture($messageuser->useridfrom, SITEID, $messageuser->picture, 20, false, false); + print_user_picture($messageuser->useridfrom, SITEID, $messageuser->picture, 20, false, true, 'userwindow'); echo ''; - link_to_popup_window("/message/user.php?id=$messageuser->useridfrom", "message_$messageuser->useridfrom", fullname($messageuser), 400, 400, get_string('sendmessageto', 'message', fullname($messageuser))); + link_to_popup_window("/message/user.php?id=$messageuser->useridfrom", "message_$messageuser->useridfrom", $fullnamelink, 400, 400, get_string('sendmessageto', 'message', $fullname)); echo '
'; - echo '
'; @@ -289,7 +276,6 @@ function message_add_contact($contactid, $blocked=0) { function message_remove_contact($contactid) { global $USER; - return delete_records('message_contacts', 'userid', $USER->id, 'contactid', $contactid); } @@ -348,7 +334,7 @@ function message_print_search_results($frm) { } echo ''; - print_user_picture($user->id, SITEID, $user->picture, 20, false, false); + print_user_picture($user->id, SITEID, $user->picture, 20, false, true, 'userwindow'); echo ''; echo ''; link_to_popup_window("/message/user.php?id=$user->id", "message_$user->id", fullname($user), 400, 400, get_string('sendmessageto', 'message', fullname($user))); @@ -405,7 +391,7 @@ function message_print_search_results($frm) { echo ''.get_string('keywordssearchresults', 'message', count($messages)).''; /// print table headings - echo ''; + echo '
'; echo ''; echo ''; echo ''; @@ -414,6 +400,7 @@ function message_print_search_results($frm) { echo "\n"; $blockedcount = 0; + $dateformat = get_string('strftimedatetime'); foreach ($messages as $message) { /// ignore messages to and from blocked users unless $frm->includeblocked is set @@ -452,6 +439,10 @@ function message_print_search_results($frm) { $fromblocked = false; } + /// find date string for this message + $date = usergetdate($message->timecreated); + $datestring = $date['year'].$date['mon'].$date['mday']; + /// print out message row echo ''; echo ''; - echo ''; - echo ''; + echo ''; + echo ''; echo "\n"; } - if ($blockedcount > 0) echo ''; + if ($blockedcount > 0) { + echo ''; + } echo '
'.get_string('from').''.get_string('to').'
'; @@ -460,13 +451,17 @@ function message_print_search_results($frm) { echo ''; message_print_user($userto, $tocontact, $toblocked); echo ''.message_shorten_message($message->message, 20).''.userdate($message->timecreated, get_string('strftimedatetime')).''.message_shorten_message($message->message, 20); + echo ' '.message_history_link($message->useridto, $message->useridfrom, true, $datestring); + echo ''.userdate($message->timecreated, $dateformat).'
'.get_string('blockedmessages', 'message', $blockedcount).'
'.get_string('blockedmessages', 'message', $blockedcount).'
'; } else { @@ -489,11 +484,10 @@ function message_print_search_results($frm) { function message_print_user ($user=false, $iscontact=false, $isblocked=false) { global $USER; if ($user === false) { - print_user_picture($USER->id, SITEID, $USER->picture, 20, false, false); + print_user_picture($USER->id, SITEID, $USER->picture, 20, false, true, 'userwindow'); } else { - print_user_picture($user->id, SITEID, $user->picture, 20, false, false); - link_to_popup_window("/message/user.php?id=$user->id", "message_$user->id", fullname($user), 400, 400, get_string('sendmessageto', 'message', fullname($user))); - echo '
'; + print_user_picture($user->id, SITEID, $user->picture, 20, false, true, 'userwindow'); + echo ' '; if ($iscontact) { message_contact_link($user->id, 'remove'); } else { @@ -505,57 +499,68 @@ function message_print_user ($user=false, $iscontact=false, $isblocked=false) { } else { message_contact_link($user->id, 'block'); } + echo '
'; + link_to_popup_window("/message/user.php?id=$user->id", "message_$user->id", fullname($user), 400, 400, get_string('sendmessageto', 'message', fullname($user))); } } /// linktype can be: add, remove, block, unblock -function message_contact_link ($userid, $linktype='add', $returnstr=false) { - global $USER; +function message_contact_link($userid, $linktype='add', $return=false) { + global $USER, $CFG; + + static $str; + + if (empty($str->blockcontact)) { + $str->blockcontact = get_string('blockcontact', 'message'); + $str->unblockcontact = get_string('unblockcontact', 'message'); + $str->removecontact = get_string('removecontact', 'message'); + $str->addcontact = get_string('addcontact', 'message'); + } + switch ($linktype) { case 'block': - $str = '['. - get_string('blockcontact', 'message').']'; + $output = ''. + ''; break; case 'unblock': - $str = '['. - get_string('unblockcontact', 'message').']'; + $output = ''. + ''; break; case 'remove': - $str = '['. - get_string('removecontact', 'message').']'; + $output = ''. + ''; break; case 'add': default: - $str = '['. - get_string('addcontact', 'message').']'; + $output = ''. + ''; } - if ($returnstr) { - return $str; + if ($return) { + return $output; } else { - echo $str; + echo $output; return true; } } -function message_history_link ($userid1, $userid2=0, $returnstr=false) { +function message_history_link ($userid1, $userid2=0, $returnstr=false, $position='') { global $USER; if (!$userid2) { $userid2 = $USER->id; } + if ($position) { + $position = "#$position"; + } - $str = link_to_popup_window("/message/history.php?user1=$userid1&user2=$userid2", "message_history_$user->id", - get_string('messagehistory', 'message'), 500, 500, '', + $str = link_to_popup_window("/message/history.php?user1=$userid1&user2=$userid2$position", + "message_history_$user->id", get_string('messagehistory', 'message'), 500, 500, '', 'menubar=0,location=0,status,scrollbars,resizable,width=500,height=500', true); if ($returnstr) { @@ -817,7 +822,7 @@ function message_format_message(&$message, &$user, $format='') { $format = get_string('strftimemessage', 'chat'); } $time = userdate($message->timecreated, $format); - return '

'.addslashes($user->firstname).' ['.$time.']: '.$message->message.'

'; + return '

'.addslashes($user->firstname).' ['.$time.']: '.format_text($message->message, $message->format).'

'; } diff --git a/message/user.php b/message/user.php index 0085571948..37db3d8f25 100644 --- a/message/user.php +++ b/message/user.php @@ -160,7 +160,10 @@ $script .= "parent.messages.scroll(1,5000000);\n"; $script .= "\n\n"; - add_to_log(SITEID, 'message', 'write', 'history.php?user='.$user->id.'&time='.time(), $user->id); + $date = usergetdate($message->timecreated); + $datestring = $date['year'].$date['mon'].$date['mday']; + + add_to_log(SITEID, 'message', 'write', 'history.php?user1='.$user->id.'&user2='.$USER->id.'#'.$datestring, $user->id); } else { $script = ''; }