mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 00:16:46 +02:00
Emailing is now working well, and more GUI cleanups
This commit is contained in:
parent
e520509acb
commit
405f01ee2d
4 changed files with 82 additions and 20 deletions
|
@ -12,6 +12,14 @@ $addcontact = optional_param('addcontact', 0, PARAM_INT); // adding a co
|
|||
$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
|
||||
$popup = optional_param('popup', false, PARAM_ALPHA); // If set then starts a new popup window
|
||||
|
||||
if ($popup) {
|
||||
print_header();
|
||||
echo '<script language="JavaScript" type="text/javascript">'."\n openpopup('/message/index.php', 'message', 'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500', 0);\n</script>";
|
||||
redirect("$CFG->wwwroot/");
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($addcontact and confirm_sesskey()) {
|
||||
add_to_log(SITEID, 'message', 'add contact', 'history.php?user1='.$addcontact.'&user2='.$USER->id, $addcontact);
|
||||
|
|
|
@ -64,7 +64,9 @@ function message_print_contacts() {
|
|||
print_user_picture($contact->id, SITEID, $contact->picture, 20, false, true, 'userwindow');
|
||||
echo '</td>';
|
||||
echo '<td class="message_contact">';
|
||||
link_to_popup_window("/message/user.php?id=$contact->id", "message_$contact->id", $fullnamelink, 400, 400, get_string('sendmessageto', 'message', $fullname));
|
||||
link_to_popup_window("/message/user.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 '</td>';
|
||||
echo '<td class="message_link">'.$strcontact.'</td>';
|
||||
echo '</tr>';
|
||||
|
@ -97,7 +99,9 @@ function message_print_contacts() {
|
|||
print_user_picture($contact->id, SITEID, $contact->picture, 20, false, true, 'userwindow');
|
||||
echo '</td>';
|
||||
echo '<td class="message_contact">';
|
||||
link_to_popup_window("/message/user.php?id=$contact->id", "message_$contact->id", $fullnamelink, 400, 400, get_string('sendmessageto', 'message', $fullname));
|
||||
link_to_popup_window("/message/user.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 '</td>';
|
||||
echo '<td class="message_link">'.$strcontact.'</td>';
|
||||
echo '</tr>';
|
||||
|
@ -154,7 +158,9 @@ function message_print_contacts() {
|
|||
print_user_picture($messageuser->useridfrom, SITEID, $messageuser->picture, 20, false, true, 'userwindow');
|
||||
echo '</td>';
|
||||
echo '<td class="message_contact">';
|
||||
link_to_popup_window("/message/user.php?id=$messageuser->useridfrom", "message_$messageuser->useridfrom", $fullnamelink, 400, 400, get_string('sendmessageto', 'message', $fullname));
|
||||
link_to_popup_window("/message/user.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 '</td>';
|
||||
echo '<td class="message_link">'.$strcontact.' '.$strblock.'</td>';
|
||||
echo '</tr>';
|
||||
|
@ -224,7 +230,7 @@ function message_print_settings() {
|
|||
|
||||
set_user_preferences($pref);
|
||||
|
||||
redirect($ME, get_string('settingssaved', 'message'), 3);
|
||||
redirect($ME, get_string('settingssaved', 'message'), 1);
|
||||
}
|
||||
|
||||
$cbshowmessagewindow = (get_user_preferences('message_showmessagewindow', 1) == '1') ? 'checked="checked"' : '';
|
||||
|
@ -337,7 +343,9 @@ function message_print_search_results($frm) {
|
|||
print_user_picture($user->id, SITEID, $user->picture, 20, false, true, 'userwindow');
|
||||
echo '</td>';
|
||||
echo '<td class="message_contact">';
|
||||
link_to_popup_window("/message/user.php?id=$user->id", "message_$user->id", fullname($user), 400, 400, get_string('sendmessageto', 'message', fullname($user)));
|
||||
link_to_popup_window("/message/user.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 '</td>';
|
||||
|
||||
echo '<td class="message_link">'.$strcontact.'</td>';
|
||||
|
@ -500,7 +508,9 @@ function message_print_user ($user=false, $iscontact=false, $isblocked=false) {
|
|||
message_contact_link($user->id, 'block');
|
||||
}
|
||||
echo '<br />';
|
||||
link_to_popup_window("/message/user.php?id=$user->id", "message_$user->id", fullname($user), 400, 400, get_string('sendmessageto', 'message', fullname($user)));
|
||||
link_to_popup_window("/message/user.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');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -819,11 +829,64 @@ function message_get_history($user1, $user2) {
|
|||
|
||||
function message_format_message(&$message, &$user, $format='') {
|
||||
if (empty($format)) {
|
||||
$format = get_string('strftimemessage', 'chat');
|
||||
$format = get_string('strftimedaytime');
|
||||
}
|
||||
$time = userdate($message->timecreated, $format);
|
||||
return '<p><font size="-1"><b>'.addslashes($user->firstname).'</b> ['.$time.']: '.format_text($message->message, $message->format).'</font></p>';
|
||||
return '<p><font size="-1"><strong>'.s($user->firstname).'</strong> ['.$time.']: '.
|
||||
format_text($message->message, $message->format).'</font></p>';
|
||||
}
|
||||
|
||||
/*
|
||||
* Inserts a message into the database, but also forwards it
|
||||
* via other means if appropriate.
|
||||
*/
|
||||
function message_post_message($userfrom, $userto, $message, $format, $messagetype) {
|
||||
|
||||
global $CFG, $SITE;
|
||||
|
||||
/// Save the new message in the database
|
||||
|
||||
$savemessage = NULL;
|
||||
$savemessage->useridfrom = $userfrom->id;
|
||||
$savemessage->useridto = $userto->id;
|
||||
$savemessage->message = $message;
|
||||
$savemessage->format = $format;
|
||||
$savemessage->timecreated = time();
|
||||
$savemessage->messagetype = 'direct';
|
||||
|
||||
if (!insert_record('message', $savemessage)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// Check to see if anything else needs to be done with it
|
||||
|
||||
$preference = (object)get_user_preferences(NULL, NULL, $userto->id);
|
||||
|
||||
if (!empty($preference->message_emailmessages)) { // Receiver wants mail forwarding
|
||||
if ((time() - $userto->lastaccess) > ((int)$preference->message_emailtimenosee * 60)) { // Long enough
|
||||
|
||||
$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).
|
||||
"\n\n--\n".$tagline."\n"."$CFG->wwwroot/message/index.php?popup=1";
|
||||
|
||||
if ($preference->message_emailformat == FORMAT_HTML) {
|
||||
$messagehtml = format_text($message, $format);
|
||||
$messagehtml .= '<hr /><p><a href="'.$CFG->wwwroot.'/message/index.php?popup=1">'.$tagline.'</a></p>';
|
||||
} else {
|
||||
$messagehtml = NULL;
|
||||
}
|
||||
|
||||
$userto->email = $preference->message_emailaddress; // Use custom messaging address
|
||||
email_to_user($userto, $userfrom, $messagesubject, $messagetext, $messagehtml);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
if ($messages = get_records_select('message', "useridto = '$USER->id' AND useridfrom = '$user->id'",
|
||||
'timecreated')) {
|
||||
foreach ($messages as $message) {
|
||||
$time = userdate($message->timecreated, get_string('strftimemessage', 'chat'));
|
||||
$time = userdate($message->timecreated, get_string('strftimedaytime'));
|
||||
|
||||
$options = NULL;
|
||||
$options->para = false;
|
||||
|
@ -131,17 +131,7 @@
|
|||
if ($message and confirm_sesskey()) { /// Current user has just sent a message
|
||||
|
||||
/// Save it to the database...
|
||||
$savemessage = NULL;
|
||||
$savemessage->useridfrom = $USER->id;
|
||||
$savemessage->useridto = $user->id;
|
||||
$savemessage->message = $message;
|
||||
$savemessage->format = $format;
|
||||
$savemessage->timecreated = time();
|
||||
$savemessage->messagetype = 'direct';
|
||||
|
||||
if (!insert_record('message', $savemessage)) {
|
||||
notify('Error: Message was not sent!!');
|
||||
}
|
||||
message_post_message($USER, $user, $message, $format, 'direct');
|
||||
|
||||
/// Format the message as HTML
|
||||
$options = NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue