mirror of
https://github.com/moodle/moodle.git
synced 2025-04-19 07:25:30 +02:00
Fixes to convert mail to individual mailing ...
so that we can use the new preferences for mail (plain or html).
This commit is contained in:
parent
f3ecd2c8da
commit
5fa51a394b
@ -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;
|
||||
|
@ -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
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
// Default editing time for discussions and the like (in seconds)
|
||||
|
||||
$CFG->maxeditingtime = 1800;
|
||||
$CFG->maxeditingtime = 10;
|
||||
|
||||
// Location of standard files
|
||||
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user