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
58
59
60
61
62
63
64
65
66
|
<?php /* * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/) * Copyright (C) 2002-2005 The Nucleus Group * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * (see nucleus/documentation/index.html#license for more info) */ /** * Class used to represent a collection of e-mail addresses, to which a * message can be sent (e.g. comment or karma vote notification). * * @license http://nucleuscms.org/license.txt GNU General Public License * @copyright Copyright (C) 2002-2005 The Nucleus Group * @version $Id: NOTIFICATION.php,v 1.9.2.1 2005/08/15 10:50:12 dekarma Exp $ */ class NOTIFICATION {
// array of addresses that need to get a notification var $addresses = array();
/** * takes one string as argument, containing multiple e-mail addresses * separated by semicolons * eg: site@demuynck.org;nucleus@demuynck.org;foo@bar.com */ function NOTIFICATION($addresses) { $this->addresses = explode(';' , $addresses); }
/** * returns true if all addresses are valid */ function validAddresses() { foreach ( $this->addresses as $address ) { if (!isValidMailAddress(trim($address))) return 0; } return 1; } /** * Sends email messages to all the email addresses */ function notify($title, $message, $from) { global $member; foreach ( $this->addresses as $address ) { $address = trim($address); if (!$address) continue; // don't send messages to yourself if ($member->isLoggedIn() && ($member->getEmail() == $address)) continue; @mail($address, $title, $message , "From: ". $from . "\nContent-Type: text/plain; charset=utf-8"); } } }
?>
|