From 5fa51a394b2246b31f78a057a7265424036e4baa Mon Sep 17 00:00:00 2001 From: martin Date: Wed, 5 Jun 2002 14:05:59 +0000 Subject: [PATCH] Fixes to convert mail to individual mailing ... so that we can use the new preferences for mail (plain or html). --- error/index.php | 4 ++-- lib/moodlelib.php | 33 +++++++++++++++++++++------------ lib/setup.php | 2 +- login/forgot_password.php | 3 +-- login/signup.php | 3 +-- 5 files changed, 26 insertions(+), 19 deletions(-) diff --git a/error/index.php b/error/index.php index a4bef56d00..7550b0825c 100644 --- a/error/index.php +++ b/error/index.php @@ -3,11 +3,11 @@ require("../config.php"); if (isset($text)) { // form submitted - if (!$user = get_records("users", "id", 1)) { + if (!$admin = get_admin() ) { error("Could not find the admin user to mail to!"); } - email_to_users($user, $USER, "Error: $referer -> $requested", "$text"); + email_to_user($admin, $USER, "Error: $referer -> $requested", "$text"); redirect("$CFG->wwwroot/course/", "Message sent, thanks", 3); die; diff --git a/lib/moodlelib.php b/lib/moodlelib.php index b60e3571af..d6bf254e50 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -178,22 +178,31 @@ function print_editing_switch($courseid) { } -function userdate($date, $format="l, j F Y, g:i A") { +function userdate($date, $format="", $timezone=99) { global $USER; - if (abs($USER->timezone) > 12) { + if ($format == "") { + $format = "l, j F Y, g:i A"; + } + if ($timezone == 99) { + $timezone = (float)$USER->timezone; + } + if (abs($timezone) > 12) { return date("$format T", $date); } - return gmdate($format, $date + (int)($USER->timezone * 3600)); + return gmdate($format, $date + (int)($timezone * 3600)); } -function usergetdate($date) { +function usergetdate($date, $timezone=99) { global $USER; - if (abs($USER->timezone) > 12) { + if ($timezone == 99) { + $timezone = (float)$USER->timezone; + } + if (abs($timezone) > 12) { return getdate($date); } - return getdate($date + (int)($USER->timezone * 3600)); + return getdate($date + (int)($timezone * 3600)); } @@ -879,8 +888,10 @@ function print_update_module_icon($moduleid) { /// CORRESPONDENCE //////////////////////////////////////////////// -function email_to_users(&$users, $from, $subject, $messagetext, $messagehtml="", $attachment="", $attachname="") { -// users - an array of user records as returned by get_records_sql +function email_to_user($user, $from, $subject, $messagetext, $messagehtml="", $attachment="", $attachname="") { +// user - a user record as an object +// from - a user record as an object +// subject - plain text subject line of the email // messagetext - plain text version of the message // messagehtml - complete html version of the message (optional) // attachment - a file on the filesystem, relative to $CFG->dataroot @@ -890,7 +901,7 @@ function email_to_users(&$users, $from, $subject, $messagetext, $messagehtml="", include_once("$CFG->libdir/phpmailer/class.phpmailer.php"); - if (!$users) { + if (!$user) { return false; } @@ -905,9 +916,7 @@ function email_to_users(&$users, $from, $subject, $messagetext, $messagehtml="", $mail->FromName = "$from->firstname $from->lastname"; $mail->Subject = stripslashes($subject); - foreach ($users as $user) { - $mail->AddAddress("$user->email","$user->firstname $user->lastname"); - } + $mail->AddBCC("$user->email","$user->firstname $user->lastname"); $mail->WordWrap = 70; // set word wrap diff --git a/lib/setup.php b/lib/setup.php index 6a12ff0473..094ad4399e 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -22,7 +22,7 @@ // Default editing time for discussions and the like (in seconds) - $CFG->maxeditingtime = 1800; + $CFG->maxeditingtime = 10; // Location of standard files diff --git a/login/forgot_password.php b/login/forgot_password.php index fc7044cb02..7d7b343113 100644 --- a/login/forgot_password.php +++ b/login/forgot_password.php @@ -93,8 +93,7 @@ function reset_password_and_mail($user) { $subject = "$site->fullname: Changed password"; - $users[] = $user; - return email_to_users($users, $from, $subject, $message); + return email_to_user($user, $from, $subject, $message); } diff --git a/login/signup.php b/login/signup.php index 28078b0301..ada95adcc1 100644 --- a/login/signup.php +++ b/login/signup.php @@ -117,8 +117,7 @@ function send_confirmation_email($user) { $subject = "$site->fullname account confirmation"; - $users[] = $user; - return email_to_users($users, $from, $subject, $message); + return email_to_user($user, $from, $subject, $message); } -- 2.39.5