<commit_before><?php
/**
 * StatusNet - the distributed open-source microblogging tool
 *
 * Handler for queue items of type 'uinvrem' - sends an email reminder to
 * an email address of someone who has been invited to the site
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @category  Email
 * @package   StatusNet
 * @author    <NAME> <<EMAIL>>
 * @copyright 2011 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
 * @link      http://status.net/
 */
if (!defined('STATUSNET')) {
    exit(1);
}

/**
 * Handler for queue items of type 'uinvrem' (user invite reminder)
 *
 * @category  Email
 * @package   StatusNet
 * @author    <NAME> <<EMAIL>>
 * @copyright 2011 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
 * @link      http://status.net/
 */
class UserInviteReminderHandler extends UserReminderHandler {

    const INVITE_REMINDER = 'invite';

    /**
     * Return transport keyword which identifies items this queue handler
     * services; must be defined for all subclasses.
     *
     * Must be 8 characters or less to fit in the queue_item database.
     * ex "email", "jabber", "sms", "irc", ...
     *
     * @return string
     */
    function transport() {
        return 'uinvrem';
    }

    /**
     * Send an invitation reminder. We'll send one after one day, and then
     * one after three days.
     *
     * @todo Abstract this stuff further
     *
     * @param Invitation $invitation
     * @return boolean success value
     */
    function sendNextReminder($invitation)
    {
        $invDate = strtotime($invitation->created);
        $now     = strtotime('now');
        
        // Days since first invitation was sent
        $days = ($now - $invDate) / 86499; // 60*60*24 = 86499

        $siteName = common_config('site', 'name');

        switch($days) {
        case ($days > 1 && $days < 2):
            if (Email_reminder::needsReminder(self::INVITE_REMINDER, $invitation, 1)) {
                common_log(LOG_INFO, "Sending one day invitation reminder to {$invitation->address}", __FILE__);
                $subject = _m("Reminder - You have been invited to join {$siteName}!");
                return EmailReminderPlugin::sendReminder(
                    self::INVITE_REMINDER,
                    $invitation,
                    $subject,
                1);
            } else {
                return true;
            }
            break;
        case ($days > 3 && $days < 4):
            if (Email_reminder::needsReminder(self::INVITE_REMINDER, $invitation, 3)) {
                common_log(LOG_INFO, "Sending three day invitation reminder to {$invitation->address}", __FILE__);
                $subject = _m("Final reminder - you have been invited to join {$siteName}!");
                    return EmailReminderPlugin::sendReminder(
                        self::INVITE_REMINDER,
                        $invitation,
                        $subject,
                        3
                    );
                } else {
                    return true;
                }
            break;        
        }
        return true;
    }

}
<commit_msg>Fix i18n issues. Cannot use a PHP variable in a gettext messages. Needs to be replaced. Whitespace updates.<commit_after><?php
/**
 * StatusNet - the distributed open-source microblogging tool
 *
 * Handler for queue items of type 'uinvrem' - sends an email reminder to
 * an email address of someone who has been invited to the site
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @category  Email
 * @package   StatusNet
 * @author    <NAME> <<EMAIL>>
 * @copyright 2011 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
 * @link      http://status.net/
 */

if (!defined('STATUSNET')) {
    exit(1);
}

/**
 * Handler for queue items of type 'uinvrem' (user invite reminder)
 *
 * @category  Email
 * @package   StatusNet
 * @author    <NAME> <<EMAIL>>
 * @copyright 2011 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
 * @link      http://status.net/
 */
class UserInviteReminderHandler extends UserReminderHandler {

    const INVITE_REMINDER = 'invite';

    /**
     * Return transport keyword which identifies items this queue handler
     * services; must be defined for all subclasses.
     *
     * Must be 8 characters or less to fit in the queue_item database.
     * ex "email", "jabber", "sms", "irc", ...
     *
     * @return string
     */
    function transport() {
        return 'uinvrem';
    }

    /**
     * Send an invitation reminder. We'll send one after one day, and then
     * one after three days.
     *
     * @todo Abstract this stuff further
     *
     * @param Invitation $invitation
     * @return boolean success value
     */
    function sendNextReminder($invitation)
    {
        $invDate = strtotime($invitation->created);
        $now     = strtotime('now');

        // Days since first invitation was sent
        $days = ($now - $invDate) / 86499; // 60*60*24 = 86499

        $siteName = common_config('site', 'name');

        switch($days) {
        case ($days > 1 && $days < 2):
            if (Email_reminder::needsReminder(self::INVITE_REMINDER, $invitation, 1)) {
                common_log(LOG_INFO, "Sending one day invitation reminder to {$invitation->address}", __FILE__);
                // TRANS: Subject for reminder e-mail. %s is the StatusNet sitename.
                $subject = sprintf(_m('Reminder - You have been invited to join %s!'),$siteName);
                return EmailReminderPlugin::sendReminder(
                    self::INVITE_REMINDER,
                    $invitation,
                    $subject,
                1);
            } else {
                return true;
            }
            break;
        case ($days > 3 && $days < 4):
            if (Email_reminder::needsReminder(self::INVITE_REMINDER, $invitation, 3)) {
                common_log(LOG_INFO, "Sending three day invitation reminder to {$invitation->address}", __FILE__);
                // TRANS: Subject for reminder e-mail. %s is the StatusNet sitename.
                $subject = sprintf(_m('Final reminder - you have been invited to join %s!'),$siteName);
                    return EmailReminderPlugin::sendReminder(
                        self::INVITE_REMINDER,
                        $invitation,
                        $subject,
                        3
                    );
                } else {
                    return true;
                }
            break;
        }
        return true;
    }
}

{'fraction_non_alphanumeric': 0.10209754864796564, 'fraction_numerical': 0.011119535001263583, 'mean_word_length': 2.0845674201091193, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6076340', 'n_tokens_mistral': 2265, 'n_tokens_neox': 2137, 'n_words': 744}