3 * StatusNet - the distributed open-source microblogging tool
5 * Handler for queue items of type 'uinvrem' - sends an email reminder to
6 * an email address of someone who has been invited to the site
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/
28 if (!defined('STATUSNET')) {
33 * Handler for queue items of type 'uinvrem' (user invite reminder)
37 * @author Zach Copley <zach@status.net>
38 * @copyright 2011 StatusNet, Inc.
39 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
40 * @link http://status.net/
42 class UserInviteReminderHandler extends UserReminderHandler {
44 const INVITE_REMINDER = 'invite';
47 * Return transport keyword which identifies items this queue handler
48 * services; must be defined for all subclasses.
50 * Must be 8 characters or less to fit in the queue_item database.
51 * ex "email", "jabber", "sms", "irc", ...
55 function transport() {
60 * Send an invitation reminder. We'll send one after one day, and then
61 * one after three days.
63 * @todo Abstract this stuff further
65 * @param Invitation $invitation
66 * @return boolean success value
68 function sendNextReminder($invitation)
70 $invDate = strtotime($invitation->created);
71 $now = strtotime('now');
73 // Days since first invitation was sent
74 $days = ($now - $invDate) / 86499; // 60*60*24 = 86499
76 $siteName = common_config('site', 'name');
79 case ($days > 1 && $days < 2):
80 if (Email_reminder::needsReminder(self::INVITE_REMINDER, $invitation, 1)) {
81 common_log(LOG_INFO, "Sending one day invitation reminder to {$invitation->address}", __FILE__);
82 $subject = _m("Reminder - You have been invited to join {$siteName}!");
83 return EmailReminderPlugin::sendReminder(
84 self::INVITE_REMINDER,
92 case ($days > 3 && $days < 4):
93 if (Email_reminder::needsReminder(self::INVITE_REMINDER, $invitation, 3)) {
94 common_log(LOG_INFO, "Sending three day invitation reminder to {$invitation->address}", __FILE__);
95 $subject = _m("Final reminder - you have been invited to join {$siteName}!");
96 return EmailReminderPlugin::sendReminder(
97 self::INVITE_REMINDER,