blob: 8ddbbd04b0ae2113860ff80f352f2a037fda5d6c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
<?php
include_once($UTIL_DIR . "/error.php");
include_once($UTIL_DIR . "/log.php");
function send($email, $subject, $message)
{
global $subject_prefix;
global $sender;
global $replyto;
global $footer;
$message .= $footer;
// $message .= "";
$headers = "From: " . $sender . "\r\n";
$headers .= "Reply-To: " . $replyto . "\r\n";
$headers .= "Content-Type: text/plain; charset=iso-8859-1\r\n";
$headers .= "X-Mailer: PHP/" . phpversion();
$subject = "[".$subject_prefix."] " . utf8_decode($subject);
$ret = mail($email, $subject, utf8_decode($message), $headers);
if(!$ret) echo error("The mail to " . $email . "could not be sent.");
}
function notify($module = "", $event = "")
{
global $users;
global $current_user;
global $NOTIFY_RESEND;
$users_changed = false;
foreach($users->users as $user) {
if($user->uid == 0) continue; // Don't notify the admin
if($user->enabled == false) continue; // Do not mail disabled accounts.
if($module == "calendar" || // Always mail calendar updates.
(
$module == "forum" &&
$user != $current_user && // Don't notify current user.
$user->notified < (time() - $NOTIFY_RESEND) // Don't notify if already notified.
)
) {
send($user->email, $module . " changed",
"There has been a change in the " . $module . " module by " .
$current_user->name . ":\n" . $event);
_log($user->username, "notified (" . $module . ")");
if($module != "calendar") {
$user->notified = time();
$users_changed = true;
}
}
}
if($users_changed == true) $users->write();
}
?>
|