]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/EmailReminder/lib/siteconfirmreminderhandler.php
e5b561827b0de4d1b3f084accd013a9292f47165
[quix0rs-gnu-social.git] / plugins / EmailReminder / lib / siteconfirmreminderhandler.php
1 <?php
2 /*
3  * StatusNet - the distributed open-source microblogging tool
4  *
5  * Handler for reminder queue items which send reminder emails to all users
6  * we would like to complete a given process (e.g.: registration).
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  Email
22  * @package   StatusNet
23  * @author    Zach Copley <zach@status.net>
24  * @copyright 2011 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  * Handler for reminder queue items which send reminder emails to all users
35  * we would like to complete a given process (e.g.: registration)
36  *
37  * @category  Email
38  * @package   StatusNet
39  * @author    Zach Copley <zach@status.net>
40  * @copyright 2011 StatusNet, Inc.
41  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
42  * @link      http://status.net/
43  */
44 class SiteConfirmReminderHandler extends QueueHandler
45 {
46     /**
47      * Return transport keyword which identifies items this queue handler
48      * services; must be defined for all subclasses.
49      *
50      * Must be 8 characters or less to fit in the queue_item database.
51      * ex "email", "jabber", "sms", "irc", ...
52      *
53      * @return string
54      */
55     function transport()
56     {
57         return 'siterem';
58     }
59
60     /**
61      * Handle the site
62      *
63      * @param string $reminderType type of reminder to send
64      * @return boolean true on success, false on failure
65      */
66     function handle($reminderType)
67     {
68         $qm = QueueManager::get();
69
70         try {
71             switch($reminderType) {
72             case UserConfirmRegReminderHandler::REGISTER_REMINDER:
73                 $confirm               = new Confirm_address();
74                 $confirm->address_type = $object;
75                 $confirm->find();
76                 while ($confirm->fetch()) {
77                     try {
78                         $qm->enqueue($confirm, 'uregrem');
79                     } catch (Exception $e) {
80                         common_log(LOG_WARNING, $e->getMessage());
81                         continue;
82                     }
83                 }
84                 break;
85             case UserInviteReminderHandler::INVITE_REMINDER:
86                 $invitation = new Invitation();
87                 $invitation->find();
88                 while ($invitation->fetch()) {
89                     try {
90                         $qm->enqueue($invitation, 'uinvrem');
91                     } catch (Exception $e) {
92                         common_log(LOG_WARNING, $e->getMessage());
93                         continue;
94                     }
95                 }
96                 break;
97             default:
98                 // WTF?
99                 common_log(
100                     LOG_ERR,
101                     "Received unknown confirmation address type",
102                     __FILE__
103                 );
104             }
105         } catch (Exception $e) {
106             common_log(LOG_ERR, $e->getMessage());
107             return false;
108         }
109
110         return true;
111     }
112 }