function notifyBackupFile($user, $fileName)
 {
     $fileUrl = File::url($fileName);
     $body = sprintf(_m("The backup file you requested is ready for download.\n\n" . "%s\n" . "Thanks for your time,\n", "%s\n"), $fileUrl, common_config('site', 'name'));
     $headers = _mail_prepare_headers('offlinebackup', $user->nickname, $user->nickname);
     mail_to_user($user, _('Backup file ready for download'), $body, $headers);
 }
 /**
  * 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);
         }
     }
 }
Exemple #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);
}
Exemple #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);
}
Exemple #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);
}
Exemple #6
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);
}
function create_and_ask($username, $password, $name, $mail, $device_id, $question_body, $musername, $to, $from, $extradata)
{
    if ($username != '') {
        $question_detail = login_and_ask($device_id, $username, $password, $question_body, $musername);
        #print_r ($question_detail);
        $data['link'] = $question_detail['question']['web_link'];
        $val = mail_to_user($musername, $to, $question_detail, $mail, $name, $from, $extradata);
        if ($val == true) {
            $data['message'] = 'sent';
            $data['success'] = $question_detail['success'];
        } else {
            $data['message'] = 'Email not sent. Frankly will send a notification to the user. You can view the question here ' . $question_detail['question']['web_link'];
            $data['success'] = false;
        }
        print json_encode($data);
    } else {
        $response_reg = register_user($device_id, $mail);
        if (isset($response_reg['message'])) {
            $data["message"] = $response_reg['message'];
            $data["success"] = false;
            print json_encode($data);
        } else {
            $token = $response_reg['access_token'];
            $username_asker = $response_reg['username'];
            $question_detail = ask_question($question_body, false, $musername, $device_id, $token);
            #print_r ($question_detail);
            $data['link'] = $question_detail['question']['web_link'];
            $val = mail_to_user($musername, $to, $question_detail, $mail, $name, $from, $extradata);
            if ($val == true) {
                $data['message'] = 'sent';
                $data['success'] = $question_detail['success'];
            } else {
                $data['message'] = 'Email not sent. Frankly will send a notification to the user. You can view the question here ' . $question_detail['question']['web_link'];
                $data['success'] = false;
            }
            print json_encode($data);
        }
    }
}
Exemple #8
0
        } else {
            print "Faltan parámetros\n";
            exit(1);
        }
    }
}
// Si hemos llegado aquí es que hay usuario o grupo válido.
foreach ($members as $member) {
    $user = $member->getUser();
    if (empty($user->email)) {
        print "El usuario '{$user->nickname}' no tiene email registrado.\n";
    } else {
        $subject = "Esto es un asunto de ejemplo";
        $body = crearEmail($user, $confirm);
        print "Enviando correo a {$user->nickname}...";
        if (mail_to_user($user, $subject, $body)) {
            print " Enviado.\n";
            sleep(5);
        } else {
            print " Fallo.\n";
        }
    }
}
function body($user)
{
    // Creamos el correo personalizado
    $body = "Hola, {$user->nickname}.";
    $body .= "\n\n";
    $body .= "Bienvenido a " . common_config('site', 'name') . ".";
    $body .= "\n\n";
    $body .= "Escribe por aquí el contenido del mensaje. " . ($body .= "\n\n\n\n");
Exemple #9
0
 static function recoverPassword($nore)
 {
     $user = User::staticGet('email', common_canonical_email($nore));
     if (!$user) {
         try {
             $user = User::staticGet('nickname', common_canonical_nickname($nore));
         } catch (NicknameException $e) {
             // invalid
         }
     }
     // See if it's an unconfirmed email address
     if (!$user) {
         // Warning: it may actually be legit to have multiple folks
         // who have claimed, but not yet confirmed, the same address.
         // We'll only send to the first one that comes up.
         $confirm_email = new Confirm_address();
         $confirm_email->address = common_canonical_email($nore);
         $confirm_email->address_type = 'email';
         $confirm_email->find();
         if ($confirm_email->fetch()) {
             $user = User::staticGet($confirm_email->user_id);
         } else {
             $confirm_email = null;
         }
     } else {
         $confirm_email = null;
     }
     if (!$user) {
         // TRANS: Information on password recovery form if no known username or e-mail address was specified.
         throw new ClientException(_('No user with that email address or username.'));
         return;
     }
     // Try to get an unconfirmed email address if they used a user name
     if (!$user->email && !$confirm_email) {
         $confirm_email = new Confirm_address();
         $confirm_email->user_id = $user->id;
         $confirm_email->address_type = 'email';
         $confirm_email->find();
         if (!$confirm_email->fetch()) {
             $confirm_email = null;
         }
     }
     if (!$user->email && !$confirm_email) {
         // TRANS: Client error displayed on password recovery form if a user does not have a registered e-mail address.
         throw new ClientException(_('No registered email address for that user.'));
         return;
     }
     // Success! We have a valid user and a confirmed or unconfirmed email address
     $confirm = new Confirm_address();
     $confirm->code = common_confirmation_code(128);
     $confirm->address_type = 'recover';
     $confirm->user_id = $user->id;
     $confirm->address = !empty($user->email) ? $user->email : $confirm_email->address;
     if (!$confirm->insert()) {
         common_log_db_error($confirm, 'INSERT', __FILE__);
         // TRANS: Server error displayed if e-mail address confirmation fails in the database on the password recovery form.
         throw new ServerException(_('Error saving address confirmation.'));
         return;
     }
     // @todo FIXME: needs i18n.
     $body = "Hola, {$user->nickname}.";
     $body .= "\n\n";
     $body .= 'Alguien ha solicitado una nueva contraseña ' . 'para esta cuenta en ' . common_config('site', 'name') . '.';
     $body .= "\n\n";
     $body .= 'Si has sido tú, y quieres modificarla, pulsa en el enlace de abajo:';
     $body .= "\n\n";
     $body .= "\t" . common_local_url('recoverpassword', array('code' => $confirm->code));
     $body .= "\n\n";
     $body .= 'Si no, puedes ignorar y eliminar este mensaje.';
     $body .= "\n\n";
     $body .= 'Gracias por tu tiempo, ';
     $body .= "\n";
     $body .= common_config('site', 'name');
     $body .= "\n";
     $headers = _mail_prepare_headers('recoverpassword', $user->nickname, $user->nickname);
     // TRANS: Subject for password recovery e-mail.
     mail_to_user($user, _('Solicitud de recuperación de contraseña'), $body, $headers, $confirm->address);
 }
 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__);
     }
 }
Exemple #11
0
 function recoverPassword()
 {
     $nore = $this->trimmed('nicknameoremail');
     if (!$nore) {
         $this->showForm(_('Enter a nickname or email address.'));
         return;
     }
     $user = User::staticGet('email', common_canonical_email($nore));
     if (!$user) {
         $user = User::staticGet('nickname', common_canonical_nickname($nore));
     }
     # See if it's an unconfirmed email address
     if (!$user) {
         $confirm_email = Confirm_address::staticGet('address', common_canonical_email($nore));
         if ($confirm_email && $confirm_email->address_type == 'email') {
             $user = User::staticGet($confirm_email->user_id);
         }
     }
     if (!$user) {
         $this->showForm(_('No user with that email address or username.'));
         return;
     }
     # Try to get an unconfirmed email address if they used a user name
     if (!$user->email && !$confirm_email) {
         $confirm_email = Confirm_address::staticGet('user_id', $user->id);
         if ($confirm_email && $confirm_email->address_type != 'email') {
             # Skip non-email confirmations
             $confirm_email = null;
         }
     }
     if (!$user->email && !$confirm_email) {
         $this->clientError(_('No registered email address for that user.'));
         return;
     }
     # Success! We have a valid user and a confirmed or unconfirmed email address
     $confirm = new Confirm_address();
     $confirm->code = common_confirmation_code(128);
     $confirm->address_type = 'recover';
     $confirm->user_id = $user->id;
     $confirm->address = isset($user->email) ? $user->email : $confirm_email->address;
     if (!$confirm->insert()) {
         common_log_db_error($confirm, 'INSERT', __FILE__);
         $this->serverError(_('Error saving address confirmation.'));
         return;
     }
     $body = "Hey, {$user->nickname}.";
     $body .= "\n\n";
     $body .= 'Someone just asked for a new password ' . 'for this account on ' . common_config('site', 'name') . '.';
     $body .= "\n\n";
     $body .= 'If it was you, and you want to confirm, use the URL below:';
     $body .= "\n\n";
     $body .= "\t" . common_local_url('recoverpassword', array('code' => $confirm->code));
     $body .= "\n\n";
     $body .= 'If not, just ignore this message.';
     $body .= "\n\n";
     $body .= 'Thanks for your time, ';
     $body .= "\n";
     $body .= common_config('site', 'name');
     $body .= "\n";
     mail_to_user($user, _('Password recovery requested'), $body, $confirm->address);
     $this->mode = 'sent';
     $this->msg = _('Instructions for recovering your password ' . 'have been sent to the email address registered to your ' . 'account.');
     $this->success = true;
     $this->showPage();
 }
 /**
  * Send a summary email to the user
  *
  * @param mixed $object
  * @return boolean true on success, false on failure
  */
 function handle($user_id)
 {
     // Skip if they've asked not to get summaries
     $ess = Email_summary_status::staticGet('user_id', $user_id);
     if (!empty($ess) && !$ess->send_summary) {
         common_log(LOG_INFO, sprintf('Not sending email summary for user %s by request.', $user_id));
         return true;
     }
     $since_id = null;
     if (!empty($ess)) {
         $since_id = $ess->last_summary_id;
     }
     $user = User::staticGet('id', $user_id);
     if (empty($user)) {
         common_log(LOG_INFO, sprintf('Not sending email summary for user %s; no such user.', $user_id));
         return true;
     }
     if (empty($user->email)) {
         common_log(LOG_INFO, sprintf('Not sending email summary for user %s; no email address.', $user_id));
         return true;
     }
     $profile = $user->getProfile();
     if (empty($profile)) {
         common_log(LOG_WARNING, sprintf('Not sending email summary for user %s; no profile.', $user_id));
         return true;
     }
     $stream = new InboxNoticeStream($user, $user->getProfile());
     $notice = $stream->getNotices(0, self::MAX_NOTICES, $since_id);
     if (empty($notice) || $notice->N == 0) {
         common_log(LOG_WARNING, sprintf('Not sending email summary for user %s; no notices.', $user_id));
         return true;
     }
     // XXX: This is risky fingerpoken in der objektvars, but I didn't feel like
     // figuring out a better way. -ESP
     $new_top = null;
     if ($notice instanceof ArrayWrapper) {
         $new_top = $notice->_items[0]->id;
     }
     // TRANS: Subject for e-mail.
     $subject = sprintf(_m('Your latest updates from %s'), common_config('site', 'name'));
     $out = new XMLStringer(true);
     $out->elementStart('html');
     $out->elementStart('head');
     $out->element('title', null, $subject);
     $out->elementEnd('head');
     $out->elementStart('body');
     $out->elementStart('div', array('width' => '100%', 'style' => 'background-color: #ffffff; border: 4px solid #4c609a; padding: 10px;'));
     $out->elementStart('div', array('style' => 'color: #ffffff; background-color: #4c609a; font-weight: bold; margin-bottom: 10px; padding: 4px;'));
     // TRANS: Text in e-mail summary.
     // TRANS: %1$s is the StatusNet sitename, %2$s is the recipient's profile name.
     $out->raw(sprintf(_m('Recent updates from %1$s for %2$s:'), common_config('site', 'name'), $profile->getBestName()));
     $out->elementEnd('div');
     $out->elementStart('table', array('width' => '550px', 'style' => 'border: none; border-collapse: collapse;', 'cellpadding' => '6'));
     while ($notice->fetch()) {
         $profile = Profile::staticGet('id', $notice->profile_id);
         if (empty($profile)) {
             continue;
         }
         $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
         $out->elementStart('tr');
         $out->elementStart('td', array('width' => AVATAR_STREAM_SIZE, 'height' => AVATAR_STREAM_SIZE, 'align' => 'left', 'valign' => 'top', 'style' => 'border-bottom: 1px dotted #C5CEE3; padding: 10px 6px 10px 6px;'));
         $out->element('img', array('src' => $avatar ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_STREAM_SIZE), 'width' => AVATAR_STREAM_SIZE, 'height' => AVATAR_STREAM_SIZE, 'alt' => $profile->getBestName()));
         $out->elementEnd('td');
         $out->elementStart('td', array('align' => 'left', 'valign' => 'top', 'style' => 'border-bottom: 1px dotted #C5CEE3; padding: 10px 6px 10px 6px;'));
         $out->element('a', array('href' => $profile->profileurl), $profile->nickname);
         $out->text(' ');
         $out->raw($notice->rendered);
         $out->elementStart('div', array('style' => 'font-size: 0.8em; padding-top: 4px;'));
         $noticeurl = $notice->bestUrl();
         // above should always return an URL
         assert(!empty($noticeurl));
         $out->elementStart('a', array('rel' => 'bookmark', 'href' => $noticeurl));
         $dt = common_date_iso8601($notice->created);
         $out->element('abbr', array('style' => 'border-bottom: none;', 'title' => $dt), common_date_string($notice->created));
         $out->elementEnd('a');
         if ($notice->hasConversation()) {
             $conv = Conversation::staticGet('id', $notice->conversation);
             $convurl = $conv->uri;
             if (!empty($convurl)) {
                 $out->text(' ');
                 $out->element('a', array('href' => $convurl . '#notice-' . $notice->id), _m('in context'));
             }
         }
         $out->elementEnd('div');
         $out->elementEnd('td');
         $out->elementEnd('tr');
     }
     $out->elementEnd('table');
     // TRANS: Link text for link to e-mail settings.
     // TRANS: %1$s is a link to the e-mail settings, %2$s is the StatusNet sitename.
     $out->raw("<p>" . sprintf(_m('<a href="%1$s">change your email settings for %2$s</a>'), common_local_url('emailsettings'), common_config('site', 'name')) . "</p>");
     $out->elementEnd('div');
     $out->elementEnd('body');
     $out->elementEnd('html');
     $body = $out->getString();
     // FIXME: do something for people who don't like HTML email
     mail_to_user($user, $subject, $body, array('Content-Type' => 'text/html; charset=utf-8', 'Mime-Version' => '1.0'));
     if (empty($ess)) {
         $ess = new Email_summary_status();
         $ess->user_id = $user_id;
         $ess->created = common_sql_now();
         $ess->last_summary_id = $new_top;
         $ess->modified = common_sql_now();
         $ess->insert();
     } else {
         $orig = clone $ess;
         $ess->last_summary_id = $new_top;
         $ess->modified = common_sql_now();
         $ess->update($orig);
     }
     return true;
 }
Exemple #13
0
 function notify_mail($other, $user, $notice)
 {
     $profile = $user->getProfile();
     $bestname = $profile->getBestName();
     $subject = sprintf(_('%s added your notice as a favorite'), $bestname);
     $body = sprintf(_("%1\$s just added your notice from %2\$s as one of their favorites.\n\n" . "In case you forgot, you can see the text of your notice here:\n\n" . "%3\$s\n\n" . "You can see the list of %1\$s's favorites here:\n\n" . "%4\$s\n\n" . "Faithfully yours,\n" . "%5\$s\n"), $bestname, common_exact_date($notice->created), common_local_url('shownotice', array('notice' => $notice->id)), common_local_url('showfavorites', array('nickname' => $user->nickname)), common_config('site', 'name'));
     mail_to_user($other, $subject, $body);
 }
 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);
 }
Exemple #15
0
 static function recoverPassword($nore)
 {
     // $confirm_email will be used as a fallback if our user doesn't have a confirmed email
     $confirm_email = null;
     if (common_is_email($nore)) {
         $user = User::getKV('email', common_canonical_email($nore));
         // See if it's an unconfirmed email address
         if (!$user instanceof User) {
             // Warning: it may actually be legit to have multiple folks
             // who have claimed, but not yet confirmed, the same address.
             // We'll only send to the first one that comes up.
             $confirm_email = new Confirm_address();
             $confirm_email->address = common_canonical_email($nore);
             $confirm_email->address_type = 'email';
             if ($confirm_email->find(true)) {
                 $user = User::getKV('id', $confirm_email->user_id);
             }
         }
         // No luck finding anyone by that email address.
         if (!$user instanceof User) {
             if (common_config('site', 'fakeaddressrecovery')) {
                 // Return without actually doing anything! We fake address recovery
                 // to avoid revealing which email addresses are registered with the site.
                 return;
             }
             // TRANS: Information on password recovery form if no known e-mail address was specified.
             throw new ClientException(_('No user with that email address exists here.'));
         }
     } else {
         // This might throw a NicknameException on bad nicknames
         $user = User::getKV('nickname', common_canonical_nickname($nore));
         if (!$user instanceof User) {
             // TRANS: Information on password recovery form if no known username was specified.
             throw new ClientException(_('No user with that nickname exists here.'));
         }
     }
     // Try to get an unconfirmed email address if they used a user name
     if (empty($user->email) && $confirm_email === null) {
         $confirm_email = new Confirm_address();
         $confirm_email->user_id = $user->id;
         $confirm_email->address_type = 'email';
         $confirm_email->find();
         if (!$confirm_email->fetch()) {
             // Nothing found, so let's reset it to null
             $confirm_email = null;
         }
     }
     if (empty($user->email) && !$confirm_email instanceof Confirm_address) {
         // TRANS: Client error displayed on password recovery form if a user does not have a registered e-mail address.
         throw new ClientException(_('No registered email address for that user.'));
     }
     // Success! We have a valid user and a confirmed or unconfirmed email address
     $confirm = new Confirm_address();
     $confirm->code = common_confirmation_code(128);
     $confirm->address_type = 'recover';
     $confirm->user_id = $user->id;
     $confirm->address = $user->email ?: $confirm_email->address;
     if (!$confirm->insert()) {
         common_log_db_error($confirm, 'INSERT', __FILE__);
         // TRANS: Server error displayed if e-mail address confirmation fails in the database on the password recovery form.
         throw new ServerException(_('Error saving address confirmation.'));
     }
     // @todo FIXME: needs i18n.
     $body = "Hey, {$user->nickname}.";
     $body .= "\n\n";
     $body .= 'Someone just asked for a new password ' . 'for this account on ' . common_config('site', 'name') . '.';
     $body .= "\n\n";
     $body .= 'If it was you, and you want to confirm, use the URL below:';
     $body .= "\n\n";
     $body .= "\t" . common_local_url('recoverpassword', array('code' => $confirm->code));
     $body .= "\n\n";
     $body .= 'If not, just ignore this message.';
     $body .= "\n\n";
     $body .= 'Thanks for your time, ';
     $body .= "\n";
     $body .= common_config('site', 'name');
     $body .= "\n";
     $headers = _mail_prepare_headers('recoverpassword', $user->nickname, $user->nickname);
     // TRANS: Subject for password recovery e-mail.
     mail_to_user($user, _('Password recovery requested'), $body, $headers, $confirm->address);
 }
/**
 * 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);
}
Exemple #17
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();
    $bestname = $sender->getBestName();
    common_init_locale($user->language);
    $subject = sprintf(_('%s sent a notice to your attention'), $bestname);
    $body = sprintf(_("%1\$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" . "You can reply back here:\n\n" . "\t%5\$s\n\n" . "The list of all @-replies for you here:\n\n" . "%6\$s\n\n" . "Faithfully yours,\n" . "%2\$s\n\n" . "P.S. You can turn off these email notifications here: %7\$s\n"), $bestname, common_config('site', 'name'), common_local_url('shownotice', array('notice' => $notice->id)), $notice->content, common_local_url('newnotice', array('replyto' => $sender->nickname)), common_local_url('replies', array('nickname' => $user->nickname)), common_local_url('emailsettings'));
    common_init_locale();
    mail_to_user($user, $subject, $body);
}
Exemple #18
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->receivesEmailNotifications()) {
        return;
    }
    $sender = $notice->getProfile();
    if ($sender->id == $user->id) {
        return;
    }
    // See if the notice's author who mentions this user is sandboxed
    if (!$sender->hasRight(Right::EMAILONREPLY)) {
        return;
    }
    // If the author has blocked the author, don't spam them with a notification.
    if ($user->hasBlocked($sender)) {
        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 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 the text "The full conversation can be read here:" and 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 @-replies for the addressed user,
    $body = sprintf(_("%1\$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"), $sender->getFancyName(), 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))) . mail_footer_block();
    $headers = _mail_prepare_headers('mention', $user->nickname, $sender->nickname);
    common_switch_locale();
    mail_to_user($user, $subject, $body, $headers);
}
 function recoverPassword()
 {
     $nore = $this->trimmed('nicknameoremail');
     if (!$nore) {
         // TRANS: Form instructions for password recovery form.
         $this->showForm(_('Enter a nickname or email address.'));
         return;
     }
     $user = User::staticGet('email', common_canonical_email($nore));
     if (!$user) {
         try {
             $user = User::staticGet('nickname', common_canonical_nickname($nore));
         } catch (NicknameException $e) {
             // invalid
         }
     }
     # See if it's an unconfirmed email address
     if (!$user) {
         // Warning: it may actually be legit to have multiple folks
         // who have claimed, but not yet confirmed, the same address.
         // We'll only send to the first one that comes up.
         $confirm_email = new Confirm_address();
         $confirm_email->address = common_canonical_email($nore);
         $confirm_email->address_type = 'email';
         $confirm_email->find();
         if ($confirm_email->fetch()) {
             $user = User::staticGet($confirm_email->user_id);
         } else {
             $confirm_email = null;
         }
     } else {
         $confirm_email = null;
     }
     if (!$user) {
         // TRANS: Information on password recovery form if no known username or e-mail address was specified.
         $this->showForm(_('No user with that email address or username.'));
         return;
     }
     # Try to get an unconfirmed email address if they used a user name
     if (!$user->email && !$confirm_email) {
         $confirm_email = new Confirm_address();
         $confirm_email->user_id = $user->id;
         $confirm_email->address_type = 'email';
         $confirm_email->find();
         if (!$confirm_email->fetch()) {
             $confirm_email = null;
         }
     }
     if (!$user->email && !$confirm_email) {
         // TRANS: Client error displayed on password recovery form if a user does not have a registered e-mail address.
         $this->clientError(_('No registered email address for that user.'));
         return;
     }
     # Success! We have a valid user and a confirmed or unconfirmed email address
     $confirm = new Confirm_address();
     $confirm->code = common_confirmation_code(128);
     $confirm->address_type = 'recover';
     $confirm->user_id = $user->id;
     $confirm->address = !empty($user->email) ? $user->email : $confirm_email->address;
     if (!$confirm->insert()) {
         common_log_db_error($confirm, 'INSERT', __FILE__);
         // TRANS: Server error displayed if e-mail address confirmation fails in the database on the password recovery form.
         $this->serverError(_('Error saving address confirmation.'));
         return;
     }
     // @todo FIXME: needs i18n.
     $body = "Hey, {$user->nickname}.";
     $body .= "\n\n";
     $body .= 'Someone just asked for a new password ' . 'for this account on ' . common_config('site', 'name') . '.';
     $body .= "\n\n";
     $body .= 'If it was you, and you want to confirm, use the URL below:';
     $body .= "\n\n";
     $body .= "\t" . common_local_url('recoverpassword', array('code' => $confirm->code));
     $body .= "\n\n";
     $body .= 'If not, just ignore this message.';
     $body .= "\n\n";
     $body .= 'Thanks for your time, ';
     $body .= "\n";
     $body .= common_config('site', 'name');
     $body .= "\n";
     $headers = _mail_prepare_headers('recoverpassword', $user->nickname, $user->nickname);
     // TRANS: Subject for password recovery e-mail.
     mail_to_user($user, _('Password recovery requested'), $body, $headers, $confirm->address);
     $this->mode = 'sent';
     // TRANS: User notification after an e-mail with instructions was sent from the password recovery form.
     $this->msg = _('Instructions for recovering your password ' . 'have been sent to the email address registered to your ' . 'account.');
     $this->success = true;
     $this->showPage();
 }
    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__);
        }
    }