OSDN Git Service

Subversion由来のタグを削除
[nucleus-jp/nucleus-jp-ancient.git] / nucleus / libs / NOTIFICATION.php
1 <?php
2 /*
3  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4  * Copyright (C) 2002-2012 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  * Class used to represent a collection of e-mail addresses, to which a
13  * message can be sent (e.g. comment or karma vote notification).
14  */
15 class NOTIFICATION {
16
17         // array of addresses that need to get a notification
18         var $addresses = array();
19
20         /**
21           * takes one string as argument, containing multiple e-mail addresses
22           * separated by semicolons
23           * eg: site@demuynck.org;nucleus@demuynck.org;foo@bar.com
24           */
25         function NOTIFICATION($addresses) {
26                 $this->addresses = explode(';' , $addresses);
27         }
28
29         /**
30           * returns true if all addresses are valid
31           */
32         function validAddresses() {
33                 foreach ( $this->addresses as $address ) {
34                         if (!isValidMailAddress(trim($address)))
35                                 return 0;
36                 }
37                 return 1;
38         }
39
40         /**
41           * Sends email messages to all the email addresses
42           */
43         function notify($title, $message, $from) {
44                 global $member;
45
46                 foreach ( $this->addresses as $address ) {
47                         $address = trim($address);
48
49                         if (!$address)
50                                 continue;
51
52                         // don't send messages to yourself
53                         if ($member->isLoggedIn() && ($member->getEmail() == $address))
54                                 continue;
55
56                         @mb_language('ja');
57                         @mb_internal_encoding(_CHARSET);
58                         @mb_send_mail($address, $title, $message, "From: ". $from);
59                 }
60         }
61 }
62
63 ?>