OSDN Git Service

This commit was generated by cvs2svn to compensate for changes in r4,
[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-2004 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   * $Id: NOTIFICATION.php,v 1.1.1.1 2005-02-28 07:14:51 kimitake Exp $
16   */
17 class NOTIFICATION {
18
19         // array of addresses that need to get a notification
20         var $addresses = array();
21
22         /**
23           * takes one string as argument, containing multiple e-mail addresses
24           * separated by semicolons
25           * eg: site@demuynck.org;nucleus@demuynck.org;foo@bar.com
26           */
27         function NOTIFICATION($addresses) {
28                 $this->addresses = explode(';' , $addresses);
29         }
30
31         /**
32           * returns true if all addresses are valid
33           */
34         function validAddresses() {
35                 foreach ( $this->addresses as $address ) {
36                         if (!isValidMailAddress(trim($address))) 
37                                 return 0;
38                 }
39                 return 1;
40         }
41         
42         /**
43           * Sends email messages to all the email addresses
44           */
45         function notify($title, $message, $from) {
46                 global $member;
47                         
48                 foreach ( $this->addresses as $address ) {
49                         $address = trim($address);
50                         
51                         if (!$address)
52                                 continue;
53                         
54                         // don't send messages to yourself
55                         if ($member->isLoggedIn() && ($member->getEmail() == $address))
56                                 continue;
57                 
58                         @mb_language('ja');
59                         @mb_internal_encoding(_CHARSET);
60                         @mb_send_mail($address, $title, $message, "From: ". $from);
61                 }
62         }
63 }
64
65 ?>