]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Subscription pending notification mail
authorBrion Vibber <brion@pobox.com>
Tue, 29 Mar 2011 00:15:48 +0000 (17:15 -0700)
committerBrion Vibber <brion@pobox.com>
Tue, 29 Mar 2011 00:15:48 +0000 (17:15 -0700)
classes/Subscription_queue.php
lib/mail.php

index 41c0a54fa8f7be1cf1b914a64343a94653ac56da..3c677902716e1a10b39063c504ee65fd557f4b65 100644 (file)
@@ -98,8 +98,8 @@ class Subscription_queue extends Managed_DataObject
      */
     public function notify()
     {
-        $subscriber = Profile::staticGet('id', $this->subscriber);
-        $subscribed = Profile::staticGet('id', $this->subscribed);
-        //mail_notify_subscription_pending($subscribed, $subscriber);
+        $listenee = User::staticGet('id', $this->subscriber);
+        $other = Profile::staticGet('id', $this->subscribed);
+        mail_subscribe_pending_notify_profile($listenee, $other);
     }
 }
index 708e5349b16ae2bd9b544987566ba91d1d041434..e8c5d3c4e7374446ab56639dfc7faa03ea18482f 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.