| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?php // $Id: history.php,v 1.14.4.2 2008/05/02 04:07:32 dongsheng Exp $ 2 // For listing message histories between any two users 3 4 require ('../config.php'); 5 require ('lib.php'); 6 7 require_login(); 8 9 if (isguest()) { 10 redirect($CFG->wwwroot); 11 } 12 13 if (empty($CFG->messaging)) { 14 error("Messaging is disabled on this site"); 15 } 16 17 /// Script parameters 18 $userid1 = required_param('user1', PARAM_INT); 19 if (! $user1 = get_record("user", "id", $userid1)) { // Check it's correct 20 error("User ID 1 was incorrect"); 21 } 22 23 if (has_capability('moodle/site:readallmessages', get_context_instance(CONTEXT_SYSTEM))) { // Able to see any discussion 24 $userid2 = optional_param('user2', $USER->id, PARAM_INT); 25 if (! $user2 = get_record("user", "id", $userid2)) { // Check 26 error("User ID 2 was incorrect"); 27 } 28 } else { 29 $userid2 = $USER->id; // Can only see messages involving yourself 30 $user2 = $USER; 31 } 32 $search = optional_param('search', '', PARAM_CLEAN); 33 34 add_to_log(SITEID, 'message', 'history', 'history.php?user1='.$userid1.'&user2='.$userid2, $userid1); 35 36 /// Our two users are defined - let's set up the page 37 38 print_header(get_string('messagehistory', 'message'), '', '', '', '<base target="_blank" />'); 39 40 /// Print out a heading including the users we are looking at 41 42 print_simple_box_start('center'); 43 echo '<table align="center" cellpadding="10"><tr>'; 44 echo '<td align="center">'; 45 echo print_user_picture($user1, SITEID, $user1->picture, 100, true, true, 'userwindow').'<br />'; 46 echo fullname($user1); 47 echo '</td>'; 48 echo '<td align="center">'; 49 echo '<img src="'.$CFG->wwwroot.'/pix/t/left.gif" alt="'.get_string('from').'" />'; 50 echo '<img src="'.$CFG->wwwroot.'/pix/t/right.gif" alt="'.get_string('to').'" />'; 51 echo '</td>'; 52 echo '<td align="center">'; 53 echo print_user_picture($user2, SITEID, $user2->picture, 100, true, true, 'userwindow').'<br />'; 54 echo fullname($user2); 55 echo '</td>'; 56 echo '</tr></table>'; 57 print_simple_box_end(); 58 59 60 /// Get all the messages and print them 61 62 if ($messages = message_get_history($user1, $user2)) { 63 $current->mday = ''; 64 $current->month = ''; 65 $current->year = ''; 66 $messagedate = get_string('strftimetime'); 67 $blockdate = get_string('strftimedaydate'); 68 foreach ($messages as $message) { 69 $date = usergetdate($message->timecreated); 70 if ($current->mday != $date['mday'] | $current->month != $date['month'] | $current->year != $date['year']) { 71 $current->mday = $date['mday']; 72 $current->month = $date['month']; 73 $current->year = $date['year']; 74 echo '<a name="'.$date['year'].$date['mon'].$date['mday'].'"></a>'; 75 print_heading(userdate($message->timecreated, $blockdate), 'center', 4); 76 } 77 if ($message->useridfrom == $user1->id) { 78 echo message_format_message($message, $user1, $messagedate, $search, 'other'); 79 } else { 80 echo message_format_message($message, $user2, $messagedate, $search, 'me'); 81 } 82 } 83 } else { 84 print_heading(get_string('nomessagesfound', 'message')); 85 } 86 87 print_footer('none'); 88 89 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |