OSDN Git Service

Update project date from '2002 - 2009' to '2002 - 2010'.
[nucleus-jp/nucleus-jp-ancient.git] / utf8 / nucleus / libs / NOTIFICATION.php
1 <?php
2 /*
3  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4  * Copyright (C) 2002-2010 The Nucleus Group
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  * (see nucleus/documentation/index.html#license for more info)
11  */
12 /**
13  * Class used to represent a collection of e-mail addresses, to which a
14  * message can be sent (e.g. comment or karma vote notification).
15  *
16  * @license http://nucleuscms.org/license.txt GNU General Public License
17  * @copyright Copyright (C) 2002-2010 The Nucleus Group
18  * @version $Id$
19  * $NucleusJP: NOTIFICATION.php,v 1.6 2006/07/17 20:03:44 kimitake Exp $
20  */
21 class NOTIFICATION {
22
23         // array of addresses that need to get a notification
24         var $addresses = array();
25
26         /**
27           * takes one string as argument, containing multiple e-mail addresses
28           * separated by semicolons
29           * eg: site@demuynck.org;nucleus@demuynck.org;foo@bar.com
30           */
31         function NOTIFICATION($addresses) {
32                 $this->addresses = explode(';' , $addresses);
33         }
34
35         /**
36           * returns true if all addresses are valid
37           */
38         function validAddresses() {
39                 foreach ( $this->addresses as $address ) {
40                         if (!isValidMailAddress(trim($address)))
41                                 return 0;
42                 }
43                 return 1;
44         }
45
46         /**
47           * Sends email messages to all the email addresses
48           */
49         function notify($title, $message, $from) {
50                 global $member;
51
52                 foreach ( $this->addresses as $address ) {
53                         $address = trim($address);
54
55                         if (!$address)
56                                 continue;
57
58                         // don't send messages to yourself
59                         if ($member->isLoggedIn() && ($member->getEmail() == $address))
60                                 continue;
61
62                         @mb_language('ja');
63                         @mb_internal_encoding(_CHARSET);
64                         @mb_send_mail($address, $title, $message, "From: ". $from);
65                 }
66         }
67 }
68
69 ?>