| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?php // $Id: send.php,v 1.22.2.4 2008/05/08 03:41:11 jerome Exp $ 2 3 require ('../config.php'); 4 require ('lib.php'); 5 6 require_login(); 7 8 if (isguest()) { 9 redirect($CFG->wwwroot); 10 } 11 12 if (empty($CFG->messaging)) { 13 error("Messaging is disabled on this site"); 14 } 15 16 if (has_capability('moodle/site:sendmessage', get_context_instance(CONTEXT_SYSTEM))) { 17 18 19 /// Don't use print_header, for more speed 20 $stylesheetshtml = ''; 21 foreach ($CFG->stylesheets as $stylesheet) { 22 $stylesheetshtml .= '<link rel="stylesheet" type="text/css" href="'.$stylesheet.'" />'; 23 } 24 25 /// Select direction 26 if ( get_string('thisdirection') == 'rtl' ) { 27 $direction = ' dir="rtl"'; 28 } else { 29 $direction = ' dir="ltr"'; 30 } 31 32 @header('Content-Type: text/html; charset=utf-8'); 33 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n"; 34 echo "<html $direction xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n"; 35 echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />'; 36 echo $stylesheetshtml; 37 include($CFG->javascript); 38 39 /// Script parameters 40 $userid = required_param('id', PARAM_INT); 41 $message = optional_param('message', '', PARAM_CLEANHTML); 42 $format = optional_param('format', FORMAT_MOODLE, PARAM_INT); 43 44 /// Check the user we are talking to is valid 45 if (! $user = get_record('user', 'id', $userid)) { 46 error("User ID was incorrect"); 47 } 48 49 /// Check that the user is not blocking us!! 50 if ($contact = get_record('message_contacts', 'userid', $user->id, 'contactid', $USER->id)) { 51 if ($contact->blocked and !has_capability('moodle/site:readallmessages', get_context_instance(CONTEXT_SYSTEM))) { 52 print_heading(get_string('userisblockingyou', 'message')); 53 exit; 54 } 55 } 56 $userpreferences = get_user_preferences(NULL, NULL, $user->id); 57 58 if (!empty($userpreferences['message_blocknoncontacts'])) { // User is blocking non-contacts 59 if (empty($contact)) { // We are not a contact! 60 print_heading(get_string('userisblockingyounoncontact', 'message')); 61 exit; 62 } 63 } 64 65 66 if ($message!='' and confirm_sesskey()) { /// Current user has just sent a message 67 68 /// Save it to the database... 69 $messageid = message_post_message($USER, $user, addslashes($message), $format, 'direct'); 70 71 /// Format the message as HTML 72 $options = NULL; 73 $options->para = false; 74 $options->newlines = true; 75 $message = format_text($message, $format, $options); 76 77 $time = userdate(time(), get_string('strftimedatetimeshort')); 78 $message = '<div class="message me"><span class="author">'.fullname($USER).'</span> '. 79 '<span class="time">['.$time.']</span>: '. 80 '<span class="content">'.$message.'</span></div>'; 81 $message = addslashes_js($message); // So Javascript can write it 82 83 /// Then write it to our own message screen immediately 84 echo "\n<script type=\"text/javascript\">\n<!--\n"; 85 echo 'parent.messages.document.write(\''.$message."\\n');\n"; 86 echo 'parent.messages.scroll(1,5000000);'; 87 echo "\n-->\n</script>\n\n"; 88 89 add_to_log(SITEID, 'message', 'write', 'history.php?user1='.$user->id.'&user2='.$USER->id.'#m'.$messageid, $user->id); 90 } 91 92 echo '<title> </title></head>'; 93 94 95 echo '<body class="message course-1" id="message-send">'; 96 echo '<center>'; 97 echo '<form id="editing" method="post" action="send.php">'; 98 echo '<div>'; 99 echo '<input type="hidden" name="id" value="'.$user->id.'" />'; 100 echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />'; 101 102 $usehtmleditor = (can_use_html_editor() && get_user_preferences('message_usehtmleditor', 0)); 103 if ($usehtmleditor) { 104 echo '<table><tr><td class="fixeditor" align="center">'; 105 print_textarea($usehtmleditor, 9, 200, 0, 0, 'message', ''); 106 echo '</td></tr></table>'; 107 echo '<input type="submit" value="'.get_string('sendmessage', 'message').'" />'; 108 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'); 109 echo '<input type="hidden" name="format" value="'.FORMAT_HTML.'" />'; 110 } else { 111 print_textarea(false, 5, 34, 0, 0, 'message', ''); 112 echo '<input type="hidden" name="format" value="'.FORMAT_MOODLE.'" />'; 113 echo '<br /><input type="submit" value="'.get_string('sendmessage', 'message').'" />'; 114 } 115 echo '</div>'; 116 echo '</form>'; 117 if (!empty($CFG->messagewasjustemailed)) { 118 notify(get_string('mailsent', 'message'), 'notifysuccess'); 119 } 120 echo '<div class="noframesjslink"><a target="_parent" href="discussion.php?id='.$userid.'&noframesjs=1">'.get_string('noframesjs', 'message').'</a></div>'; 121 echo '</center>'; 122 123 echo "\n<script type=\"text/javascript\">\n<!--\n"; /// Focus on the textarea 124 echo 'document.getElementById("edit-message").focus();'."\n"; 125 echo "\n-->\n</script>\n\n"; 126 127 echo '</body></html>'; 128 } 129 ?>
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 |