3 * StatusNet - the distributed open-source microblogging tool
5 * Handler for queue items of type 'uregem' - sends email registration
6 * confirmation reminders to a particular user.
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.
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.
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/>.
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/
29 if (!defined('STATUSNET')) {
34 * Handler for queue items of type 'uregrem'
38 * @author Zach Copley <zach@status.net>
39 * @copyright 2011 StatusNet, Inc.
40 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
41 * @link http://status.net/
43 class UserConfirmRegReminderHandler extends UserReminderHandler {
45 const REGISTER_REMINDER = 'register';
48 * Return transport keyword which identifies items this queue handler
49 * services; must be defined for all subclasses.
51 * Must be 8 characters or less to fit in the queue_item database.
52 * ex "email", "jabber", "sms", "irc", ...
56 function transport() {
61 * Send an email registration confirmation reminder until the user
62 * confirms her registration. We'll send a reminder after one day,
63 * three days, and a full week.
65 * @todo abstract this bit further
67 * @param Confirm_address $confirm
68 * @return boolean success value
70 function sendNextReminder($confirm)
72 $regDate = strtotime($confirm->modified); // Seems like my best bet
73 $now = strtotime('now');
75 // Days since registration
76 $days = ($now - $regDate) / 86499; // 60*60*24 = 86499
78 // Welcome to one of the ugliest switch statement I've ever written
81 case ($days > 1 && $days < 2):
82 if (Email_reminder::needsReminder(self::REGISTER_REMINDER, $confirm, 1)) {
83 common_log(LOG_INFO, "Sending one day registration confirmation reminder to {$confirm->address}", __FILE__);
84 // TRANS: Subject for reminder e-mail.
85 $subject = _m('Reminder - please confirm your registration!');
86 return EmailReminderPlugin::sendReminder(
87 self::REGISTER_REMINDER,
95 case ($days > 3 && $days < 4):
96 if (Email_reminder::needsReminder(self::REGISTER_REMINDER, $confirm, 3)) {
97 common_log(LOG_INFO, "Sending three day registration confirmation reminder to {$confirm->address}", __FILE__);
98 // TRANS: Subject for reminder e-mail.
99 $subject = _m('Second reminder - please confirm your registration!');
100 return EmailReminderPlugin::sendReminder(
101 self::REGISTER_REMINDER,
110 case ($days > 7 && $days < 8):
111 if (Email_reminder::needsReminder(self::REGISTER_REMINDER, $confirm, 7)) {
112 common_log(LOG_INFO, "Sending one week registration confirmation reminder to {$confirm->address}", __FILE__);
113 // TRANS: Subject for reminder e-mail.
114 $subject = _m('Final reminder - please confirm your registration!');
115 return EmailReminderPlugin::sendReminder(
116 self::REGISTER_REMINDER,