/**
  * Do the actual notification
  *
  * @param class $from reminderer
  * @param class $to reminderee
  *
  * @return nothing
  */
 function notify($from, $to)
 {
     if ($to->id != $from->id) {
         if ($to->email) {
             // TODO
             common_switch_locale($to->language);
             // TRANS: Subject for 'reminder' notification email.
             // TRANS: %s is the sender.
             $subject = sprintf(_('%s would like to see you post on GNU social'), $from->nickname);
             $from_profile = $from->getProfile();
             // TRANS: Body for 'reminder' notification email.
             // TRANS: %1$s is the sender's long name, $2$s is the receiver's nickname,
             // TRANS: %3$s is a URL to post notices at.
             $body = sprintf(_("%1\$s (%2\$s) is wondering what you are up to " . "these days and is inviting you to post some news.\n\n" . "So let's hear from you :)\n\n" . "%3\$s\n\n" . "Don't reply to this email; it won't get to them."), $from_profile->getBestName(), $from->nickname, common_local_url('all', array('nickname' => $to->nickname))) . mail_footer_block();
             common_switch_locale();
             $headers = $this->mail_prepare_headers('nudge', $to->nickname, $from->nickname);
             return mail_to_user($to, $subject, $body, $headers);
         }
     }
 }
/**
 * Notify a user that one of their notices has been chosen as a 'fave'
 *
 * @param User    $rcpt   The user whose notice was faved
 * @param Profile $sender The user who faved the notice
 * @param Notice  $notice The notice that was faved
 *
 * @return void
 */
function mail_notify_fave(User $rcpt, Profile $sender, Notice $notice)
{
    if (!$rcpt->receivesEmailNotifications() || !$rcpt->getConfigPref('email', 'notify_fave')) {
        return;
    }
    // This test is actually "if the sender is sandboxed"
    if (!$sender->hasRight(Right::EMAILONFAVE)) {
        return;
    }
    if ($rcpt->hasBlocked($sender)) {
        // If the author has blocked us, don't spam them with a notification.
        return;
    }
    // We need the global mail.php for various mail related functions below.
    require_once INSTALLDIR . '/lib/mail.php';
    $bestname = $sender->getBestName();
    common_switch_locale($rcpt->language);
    // TRANS: Subject for favorite notification e-mail.
    // TRANS: %1$s is the adding user's long name, %2$s is the adding user's nickname.
    $subject = sprintf(_('%1$s (@%2$s) added your notice as a favorite'), $bestname, $sender->getNickname());
    // TRANS: Body for favorite notification e-mail.
    // TRANS: %1$s is the adding user's long name, $2$s is the date the notice was created,
    // TRANS: %3$s is a URL to the faved notice, %4$s is the faved notice text,
    // TRANS: %5$s is a URL to all faves of the adding user, %6$s is the StatusNet sitename,
    // TRANS: %7$s is the adding user's nickname.
    $body = sprintf(_("%1\$s (@%7\$s) just added your notice from %2\$s" . " as one of their favorites.\n\n" . "The URL of your notice is:\n\n" . "%3\$s\n\n" . "The text of your notice is:\n\n" . "%4\$s\n\n" . "You can see the list of %1\$s's favorites here:\n\n" . "%5\$s"), $bestname, common_exact_date($notice->created), common_local_url('shownotice', array('notice' => $notice->id)), $notice->content, common_local_url('showfavorites', array('nickname' => $sender->getNickname())), common_config('site', 'name'), $sender->getNickname()) . mail_footer_block();
    $headers = _mail_prepare_headers('fave', $rcpt->getNickname(), $sender->getNickname());
    common_switch_locale();
    mail_to_user($rcpt, $subject, $body, $headers);
}
Beispiel #3
0
/**
 * notify a user that they have received an "attn:" message AKA "@-reply"
 *
 * @param User   $user   The user who recevied the notice
 * @param Notice $notice The notice that was sent
 *
 * @return void
 */
function mail_notify_attn($user, $notice)
{
    if (!$user->email || !$user->emailnotifyattn) {
        return;
    }
    $sender = $notice->getProfile();
    if ($sender->id == $user->id) {
        return;
    }
    if (!$sender->hasRight(Right::EMAILONREPLY)) {
        return;
    }
    $bestname = $sender->getBestName();
    common_switch_locale($user->language);
    if ($notice->hasConversation()) {
        $conversationUrl = common_local_url('conversation', array('id' => $notice->conversation)) . '#notice-' . $notice->id;
        // TRANS: Line in @-reply notification e-mail. %s is conversation URL.
        $conversationEmailText = sprintf(_("The full conversation can be read here:\n\n" . "\t%s"), $conversationUrl) . "\n\n";
    } else {
        $conversationEmailText = '';
    }
    // TRANS: E-mail subject for notice notification.
    // TRANS: %1$s is the sending user's long name, %2$s is the adding user's nickname.
    $subject = sprintf(_('%1$s (@%2$s) sent a notice to your attention'), $bestname, $sender->nickname);
    // TRANS: Body of @-reply notification e-mail.
    // TRANS: %1$s is the sending user's long name, $2$s is the StatusNet sitename,
    // TRANS: %3$s is a URL to the notice, %4$s is the notice text,
    // TRANS: %5$s is a URL to the full conversion if it exists (otherwise empty),
    // TRANS: %6$s is a URL to reply to the notice, %7$s is a URL to all @-replied for the addressed user,
    // TRANS: %8$s is a URL to the addressed user's e-mail settings, %9$s is the sender's nickname.
    $body = sprintf(_("%1\$s (@%9\$s) just sent a notice to your attention (an '@-reply') on %2\$s.\n\n" . "The notice is here:\n\n" . "\t%3\$s\n\n" . "It reads:\n\n" . "\t%4\$s\n\n" . "%5\$s" . "You can reply back here:\n\n" . "\t%6\$s\n\n" . "The list of all @-replies for you here:\n\n" . "%7\$s\n\n" . "Faithfully yours,\n" . "%2\$s\n\n" . "P.S. You can turn off these email notifications here: %8\$s\n"), $bestname, common_config('site', 'name'), common_local_url('shownotice', array('notice' => $notice->id)), $notice->content, $conversationEmailText, common_local_url('newnotice', array('replyto' => $sender->nickname, 'inreplyto' => $notice->id)), common_local_url('replies', array('nickname' => $user->nickname)), common_local_url('emailsettings'), $sender->nickname);
    //%9
    $headers = _mail_prepare_headers('mention', $user->nickname, $sender->nickname);
    common_switch_locale();
    mail_to_user($user, $subject, $body, $headers);
}
Beispiel #4
0
/**
 * Send a mail message to notify a user that her Twitter bridge link
 * has stopped working, and therefore has been removed.  This can
 * happen when the user changes her Twitter password, or otherwise
 * revokes access.
 *
 * @param User $user   user whose Twitter bridge link has been removed
 *
 * @return boolean success flag
 */
function mail_twitter_bridge_removed($user)
{
    $profile = $user->getProfile();
    common_switch_locale($user->language);
    $subject = sprintf(_m('Your Twitter bridge has been disabled.'));
    $site_name = common_config('site', 'name');
    $body = sprintf(_m('Hi, %1$s. We\'re sorry to inform you that your ' . 'link to Twitter has been disabled. We no longer seem to have ' . 'permission to update your Twitter status. (Did you revoke ' . '%3$s\'s access?)' . "\n\n" . 'You can re-enable your Twitter bridge by visiting your ' . "Twitter settings page:\n\n\t%2\$s\n\n" . "Regards,\n%3\$s\n"), $profile->getBestName(), common_local_url('twittersettings'), common_config('site', 'name'));
    common_switch_locale();
    return mail_to_user($user, $subject, $body);
}
Beispiel #5
0
/**
 * Send a mail message to notify a user that her Facebook Application
 * access has been removed.
 *
 * @param User $user   user whose Facebook app link has been removed
 *
 * @return boolean success flag
 */
function mail_facebook_app_removed($user)
{
    $profile = $user->getProfile();
    $site_name = common_config('site', 'name');
    common_switch_locale($user->language);
    $subject = sprintf(_m('Your %1$s Facebook application access has been disabled.', $site_name));
    $body = sprintf(_m("Hi, %1\$s. We're sorry to inform you that we are " . 'unable to update your Facebook status from %2$s, and have disabled ' . 'the Facebook application for your account. This may be because ' . 'you have removed the Facebook application\'s authorization, or ' . 'have deleted your Facebook account.  You can re-enable the ' . 'Facebook application and automatic status updating by ' . "re-installing the %2\$s Facebook application.\n\nRegards,\n\n%2\$s"), $user->nickname, $site_name);
    common_switch_locale();
    return mail_to_user($user, $subject, $body);
}
Beispiel #6
0
/**
 * Send notification emails to group administrator.
 *
 * @param User_group $group
 * @param Profile $joiner
 */
function mail_notify_group_join_pending($group, $joiner)
{
    $admin = $group->getAdmins();
    while ($admin->fetch()) {
        // We need a local user for email notifications...
        $adminUser = User::staticGet('id', $admin->id);
        // @fixme check for email preference?
        if ($adminUser && $adminUser->email) {
            // use the recipient's localization
            common_switch_locale($adminUser->language);
            $headers = _mail_prepare_headers('join', $admin->nickname, $joiner->nickname);
            $headers['From'] = mail_notify_from();
            $headers['To'] = $admin->getBestName() . ' <' . $adminUser->email . '>';
            // TRANS: Subject of pending group join request notification e-mail.
            // TRANS: %1$s is the joining user's nickname, %2$s is the group name, and %3$s is the StatusNet sitename.
            $headers['Subject'] = sprintf(_('%1$s wants to join your group %2$s on %3$s.'), $joiner->getBestName(), $group->getBestName(), common_config('site', 'name'));
            // TRANS: Main body of pending group join request notification e-mail.
            // TRANS: %1$s is the subscriber's long name, %2$s is the group name, and %3$s is the StatusNet sitename,
            // TRANS: %4$s is the URL to the moderation queue page.
            $body = sprintf(_('%1$s would like to join your group %2$s on %3$s. ' . 'You may approve or reject their group membership at %4$s'), $joiner->getFancyName(), $group->getFancyName(), common_config('site', 'name'), common_local_url('groupqueue', array('nickname' => $group->nickname))) . mail_profile_block($joiner) . mail_footer_block();
            // reset localization
            common_switch_locale();
            mail_send($adminUser->email, $headers, $body);
        }
    }
}
Beispiel #7
0
/**
 * Send a mail message to notify a user that her Twitter bridge link
 * has stopped working, and therefore has been removed.  This can
 * happen when the user changes her Twitter password, or otherwise
 * revokes access.
 *
 * @param User $user   user whose Twitter bridge link has been removed
 *
 * @return boolean success flag
 */
function mail_twitter_bridge_removed($user)
{
    $profile = $user->getProfile();
    common_switch_locale($user->language);
    // TRANS: Mail subject after forwarding notices to Twitter has stopped working.
    $subject = sprintf(_m('Your Twitter bridge has been disabled'));
    $site_name = common_config('site', 'name');
    // TRANS: Mail body after forwarding notices to Twitter has stopped working.
    // TRANS: %1$ is the name of the user the mail is sent to, %2$s is a URL to the
    // TRANS: Twitter settings, %3$s is the StatusNet sitename.
    $body = sprintf(_m('Hi, %1$s. We\'re sorry to inform you that your ' . 'link to Twitter has been disabled. We no longer seem to have ' . 'permission to update your Twitter status. Did you maybe revoke ' . '%3$s\'s access?' . "\n\n" . 'You can re-enable your Twitter bridge by visiting your ' . "Twitter settings page:\n\n\t%2\$s\n\n" . "Regards,\n%3\$s"), $profile->getBestName(), common_local_url('twittersettings'), common_config('site', 'name'));
    common_switch_locale();
    return mail_to_user($user, $subject, $body);
}
 static function emailWarn($user)
 {
     $profile = $user->getProfile();
     $siteName = common_config('site', 'name');
     $siteEmail = common_config('site', 'email');
     if (empty($siteEmail)) {
         common_log(LOG_WARNING, "No site email address configured. Please set one.");
     }
     common_switch_locale($user->language);
     // TRANS: E-mail subject. %s is the StatusNet sitename.
     $subject = _m('Contact the %s administrator to retrieve your account');
     // TRANS: E-mail body. %1$s is a username,
     // TRANS: %2$s is the StatusNet sitename, %3$s is the site contact e-mail address.
     $msg = _m("Hi %1\$s,\n\n" . "We have noticed you have deauthorized the Facebook connection for your\n" . "%2\$s account.  You have not set a password for your %2\$s account yet, so\n" . "you will not be able to login. If you wish to continue using your %2\$s\n" . "account, please contact the site administrator (%3\$s) to set a password.\n\n" . "Sincerely,\n\n" . "%2\$s\n");
     $body = sprintf($msg, $user->nickname, $siteName, $siteEmail);
     common_switch_locale();
     if (mail_to_user($user, $subject, $body)) {
         common_log(LOG_INFO, sprintf('Sent account lockout warning to %s (%d)', $user->nickname, $user->id), __FILE__);
     } else {
         common_log(LOG_WARNING, sprintf('Unable to send account lockout warning to %s (%d)', $user->nickname, $user->id), __FILE__);
     }
 }
 function notifyByMail()
 {
     $to = User::staticGet('id', $this->to_profile);
     if (empty($to) || is_null($to->email) || !$to->emailnotifymsg) {
         return true;
     }
     $gm = Group_message::staticGet('id', $this->group_message_id);
     $from_profile = Profile::staticGet('id', $gm->from_profile);
     $group = $gm->getGroup();
     common_switch_locale($to->language);
     // TRANS: Subject for direct-message notification email.
     // TRANS: %s is the sending user's nickname.
     $subject = sprintf(_('New private message from %s to group %s'), $from_profile->nickname, $group->nickname);
     // TRANS: Body for direct-message notification email.
     // TRANS: %1$s is the sending user's long name, %2$s is the sending user's nickname,
     // TRANS: %3$s is the message content, %4$s a URL to the message,
     // TRANS: %5$s is the StatusNet sitename.
     $body = sprintf(_("%1\$s (%2\$s) sent a private message to group %3\$s:\n\n" . "------------------------------------------------------\n" . "%4\$s\n" . "------------------------------------------------------\n\n" . "You can reply to their message here:\n\n" . "%5\$s\n\n" . "Don't reply to this email; it won't get to them.\n\n" . "With kind regards,\n" . "%6\$s\n"), $from_profile->getBestName(), $from_profile->nickname, $group->nickname, $gm->content, common_local_url('newmessage', array('to' => $from_profile->id)), common_config('site', 'name'));
     $headers = _mail_prepare_headers('message', $to->nickname, $from_profile->nickname);
     common_switch_locale();
     return mail_to_user($to, $subject, $body, $headers);
 }
    static function emailWarn($user)
    {
        $profile = $user->getProfile();
        $siteName = common_config('site', 'name');
        $siteEmail = common_config('site', 'email');
        if (empty($siteEmail)) {
            common_log(LOG_WARNING, "No site email address configured. Please set one.");
        }
        common_switch_locale($user->language);
        $subject = _m('Contact the %s administrator to retrieve your account');
        $msg = <<<BODY
Hi %1{$s},

We've noticed you have deauthorized the Facebook connection for your
%2{$s} account.  You have not set a password for your %2{$s} account yet, so
you will not be able to login. If you wish to continue using your %2{$s}
account, please contact the site administrator (%3{$s}) to set a password.

Sincerely,

%2{$s}
BODY;
        $body = sprintf(_m($msg), $user->nickname, $siteName, $siteEmail);
        common_switch_locale();
        if (mail_to_user($user, $subject, $body)) {
            common_log(LOG_INFO, sprintf('Sent account lockout warning to %s (%d)', $user->nickname, $user->id), __FILE__);
        } else {
            common_log(LOG_WARNING, sprintf('Unable to send account lockout warning to %s (%d)', $user->nickname, $user->id), __FILE__);
        }
    }