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/
29 if (!defined('STATUSNET')) {
34 * Handler for queue items of type 'uinvrem' (user invite reminder)
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 UserInviteReminderHandler extends UserReminderHandler {
45 const INVITE_REMINDER = 'invite';
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 invitation reminder. We'll send one after one day, and then
62 * one after three days.
64 * @todo Abstract this stuff further
66 * @param array $invitem Invitation obj and any special options
67 * @return boolean success value
69 function sendNextReminder($invitem)
71 list($invitation, $opts) = $invitem;
73 $invDate = strtotime($invitation->created);
74 $now = strtotime('now');
76 // Days since first invitation was sent
77 $days = ($now - $invDate) / 86499; // 60*60*24 = 86499
78 // $days = ($now - $regDate) / 120; // Two mins, good for testing
80 $siteName = common_config('site', 'name');
82 if ($days > 7 && isset($opts['onetime'])) {
83 // Don't send the reminder if we're past the normal reminder window and
84 // we've already pestered her at all before
85 if (Email_reminder::needsReminder(self::INVITE_REMINDER, $invitation)) {
86 common_log(LOG_INFO, "Sending one-time invitation reminder to {$invitation->address}", __FILE__);
87 $subject = _m("Reminder - you have been invited to join {$siteName}!");
88 return EmailReminderPlugin::sendReminder(
89 self::INVITE_REMINDER,
92 -1 // special one-time indicator
98 case ($days > 1 && $days < 2):
99 if (Email_reminder::needsReminder(self::INVITE_REMINDER, $invitation, 1)) {
100 common_log(LOG_INFO, "Sending one day invitation reminder to {$invitation->address}", __FILE__);
101 // TRANS: Subject for reminder e-mail. %s is the StatusNet sitename.
102 $subject = sprintf(_m('Reminder - You have been invited to join %s!'),$siteName);
103 return EmailReminderPlugin::sendReminder(
104 self::INVITE_REMINDER,
112 case ($days > 3 && $days < 4):
113 if (Email_reminder::needsReminder(self::INVITE_REMINDER, $invitation, 3)) {
114 common_log(LOG_INFO, "Sending three day invitation reminder to {$invitation->address}", __FILE__);
115 // TRANS: Subject for reminder e-mail. %s is the StatusNet sitename.
116 $subject = sprintf(_m('Final reminder - you have been invited to join %s!'),$siteName);
117 return EmailReminderPlugin::sendReminder(
118 self::INVITE_REMINDER,
128 common_log(LOG_INFO, "No need to send invitation reminder to {$invitation->address}.", __FILE__);