]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/EmailSummary/siteemailsummaryhandler.php
add path separators for Plugin::path()
[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
46 class SiteEmailSummaryHandler extends QueueHandler
47 {
48
49     /**
50      * Return transport keyword which identifies items this queue handler
51      * services; must be defined for all subclasses.
52      *
53      * Must be 8 characters or less to fit in the queue_item database.
54      * ex "email", "jabber", "sms", "irc", ...
55      *
56      * @return string
57      */
58     
59     function transport()
60     {
61         return 'sitesum';
62     }
63
64     /**
65      * Handle the site
66      * 
67      * @param mixed $object
68      * @return boolean true on success, false on failure
69      */
70     
71     function handle($object)
72     {
73         $qm = QueueManager::get();
74
75         try {
76             // Enqueue a summary for all users
77             
78             $user = new User();
79             $user->find();
80             
81             while ($user->fetch()) {
82                 try {
83                     $qm->enqueue($user->id, 'usersum');
84                 } catch (Exception $e) {
85                     common_log(LOG_WARNING, $e->getMessage());
86                     continue;
87                 }
88             }
89         } catch (Exception $e) {
90             common_log(LOG_WARNING, $e->getMessage());
91         }
92         
93         return true;
94     }
95 }
96