]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/mail.php
get the correct context for apitimelinementions
[quix0rs-gnu-social.git] / lib / mail.php
index d90fe6e8f2a27fbd352a9a229fa5e98ec8b8eeae..eaef2285b59d6bdb5fd52e2c7b63d9bbbd825eb1 100644 (file)
@@ -259,6 +259,49 @@ function mail_subscribe_notify_profile($listenee, $other)
     }
 }
 
+function mail_subscribe_pending_notify_profile($listenee, $other)
+{
+    if ($other->hasRight(Right::EMAILONSUBSCRIBE) &&
+        $listenee->email && $listenee->emailnotifysub) {
+
+        $profile = $listenee->getProfile();
+
+        $name = $profile->getBestName();
+
+        $long_name = ($other->fullname) ?
+          ($other->fullname . ' (' . $other->nickname . ')') : $other->nickname;
+
+        $recipients = $listenee->email;
+
+        // use the recipient's localization
+        common_switch_locale($listenee->language);
+
+        $headers = _mail_prepare_headers('subscribe', $listenee->nickname, $other->nickname);
+        $headers['From']    = mail_notify_from();
+        $headers['To']      = $name . ' <' . $listenee->email . '>';
+        // TRANS: Subject of pending new-subscriber notification e-mail.
+        // TRANS: %1$s is the subscribing user's nickname, %2$s is the StatusNet sitename.
+        $headers['Subject'] = sprintf(_('%1$s would like to listen to '.
+                                        'your notices on %2$s.'),
+                                      $other->getBestName(),
+                                      common_config('site', 'name'));
+
+        // TRANS: Main body of pending new-subscriber notification e-mail.
+        // TRANS: %1$s is the subscriber's long name, %2$s is the StatusNet sitename.
+        $body = sprintf(_('%1$s would like to listen to your notices on %2$s. ' .
+                          'You may approve or reject their subscription at %3$s'),
+                        $long_name,
+                        common_config('site', 'name'),
+                        common_local_url('subqueue', array('nickname' => $listenee->nickname))) .
+                mail_profile_block($other) .
+                mail_footer_block();
+
+        // reset localization
+        common_switch_locale();
+        mail_send($recipients, $headers, $body);
+    }
+}
+
 function mail_footer_block()
 {
     // TRANS: Common footer block for StatusNet notification emails.
@@ -277,7 +320,7 @@ function mail_footer_block()
  * Format a block of profile info for a plaintext notification email.
  *
  * @param Profile $profile
- * @return string 
+ * @return string
  */
 function mail_profile_block($profile)
 {
@@ -313,9 +356,9 @@ function mail_profile_block($profile)
 
     // TRANS: This is a paragraph in a new-subscriber e-mail.
     // TRANS: %s is a URL where the subscriber can be reported as abusive.
-    $out[] = sprintf(_("If you believe this account is being used abusively, " .
-                       "you can block them from your subscribers list and " .
-                       "report as spam to site administrators at %s"),
+    $out[] = sprintf(_('If you believe this account is being used abusively, ' .
+                       'you can block them from your subscribers list and ' .
+                       'report as spam to site administrators at %s.'),
                      $blocklink);
     $out[] = "";
 
@@ -498,7 +541,7 @@ function mail_confirm_sms($code, $nickname, $address)
 
     // TRANS: Main body heading for SMS-by-email address confirmation message.
     // TRANS: %s is the addressed user's nickname.
-    $body  = sprintf(_("%s: confirm you own this phone number with this code:"), $nickname);
+    $body  = sprintf(_('%s: confirm you own this phone number with this code:'), $nickname);
     $body .= "\n\n";
     $body .= $code;
     $body .= "\n\n";
@@ -598,7 +641,7 @@ function mail_notify_message($message, $from=null, $to=null)
 }
 
 /**
- * notify a user that one of their notices has been chosen as a 'fave'
+ * Notify a user that one of their notices has been chosen as a 'fave'
  *
  * Doesn't check that the user has an email address nor if they
  * want to receive notification of faves. Maybe this happens higher
@@ -661,7 +704,7 @@ function mail_notify_fave($other, $user, $notice)
 }
 
 /**
- * notify a user that they have received an "attn:" message AKA "@-reply"
+ * 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
@@ -832,7 +875,7 @@ function mail_notify_group_join_pending($group, $joiner)
 
             // 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: %3$s is the URL to the moderation queue page.
+            // 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(),