]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/EmailSummary/siteemailsummaryhandler.php
better output for registration confirmation
[quix0rs-gnu-social.git] / plugins / EmailSummary / siteemailsummaryhandler.php
1 <?php
2 /*
3  * StatusNet - the distributed open-source microblogging tool
4  *
5  * Handler for queue items of type 'sitesum', sends email summaries
6  * to all users on the site.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU Affero General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU Affero General Public License for more details.
17  *
18  * You should have received a copy of the GNU Affero General Public License
19  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20  *
21  * @category  Sample
22  * @package   StatusNet
23  * @author    Evan Prodromou <evan@status.net>
24  * @copyright 2010 StatusNet, Inc.
25  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
26  * @link      http://status.net/
27  */
28
29 if (!defined('STATUSNET')) {
30     exit(1);
31 }
32
33 /**
34  *
35  * Handler for queue items of type 'sitesum', sends email summaries
36  * to all users on the site.
37  *
38  * @category  Email
39  * @package   StatusNet
40  * @author    Evan Prodromou <evan@status.net>
41  * @copyright 2010 StatusNet, Inc.
42  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
43  * @link      http://status.net/
44  */
45 class SiteEmailSummaryHandler extends QueueHandler
46 {
47
48     /**
49      * Return transport keyword which identifies items this queue handler
50      * services; must be defined for all subclasses.
51      *
52      * Must be 8 characters or less to fit in the queue_item database.
53      * ex "email", "jabber", "sms", "irc", ...
54      *
55      * @return string
56      */
57     function transport()
58     {
59         return 'sitesum';
60     }
61
62     /**
63      * Handle the site
64      *
65      * @param mixed $object
66      * @return boolean true on success, false on failure
67      */
68     function handle($object)
69     {
70         $qm = QueueManager::get();
71
72         try {
73             // Enqueue a summary for all users
74
75             $user = new User();
76             $user->find();
77
78             while ($user->fetch()) {
79                 try {
80                     $qm->enqueue($user->id, 'usersum');
81                 } catch (Exception $e) {
82                     common_log(LOG_WARNING, $e->getMessage());
83                     continue;
84                 }
85             }
86         } catch (Exception $e) {
87             common_log(LOG_WARNING, $e->getMessage());
88         }
89
90         return true;
91     }
92 }