OSDN Git Service

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