-function mail_subscribe_notify_profile($listenee, $other) {
- if ($listenee->email && $listenee->emailnotifysub) {
- $profile = $listenee->getProfile();
- $name = $profile->getBestName();
- $long_name = ($other->fullname) ? ($other->fullname . ' (' . $other->nickname . ')') : $other->nickname;
- $recipients = $listenee->email;
- $headers['From'] = mail_notify_from();
- $headers['To'] = $name . ' <' . $listenee->email . '>';
- $headers['Subject'] = sprintf(_('%1$s is now listening to your notices on %2$s.'), $other->getBestName(),
- common_config('site', 'name'));
- $body = sprintf(_('%1$s is now listening to your notices on %2$s.'."\n\n".
- "\t".'%3$s'."\n\n".
- 'Faithfully yours,'."\n".'%4$s.'."\n"),
- $long_name,
- common_config('site', 'name'),
- $other->profileurl,
- common_config('site', 'name'));
- mail_send($recipients, $headers, $body);
- }
+/**
+ * notify a user of subscription by a profile (remote or local)
+ *
+ * This function checks to see if the listenee has an email
+ * address and wants subscription notices.
+ *
+ * @param User $listenee user who's being subscribed to
+ * @param Profile $other profile of person who's listening
+ *
+ * @return void
+ */
+
+function mail_subscribe_notify_profile($listenee, $other)
+{
+ if ($listenee->email && $listenee->emailnotifysub) {
+
+ // use the recipient's localization
+ common_init_locale($listenee->language);
+
+ $profile = $listenee->getProfile();
+
+ $name = $profile->getBestName();
+
+ $long_name = ($other->fullname) ?
+ ($other->fullname . ' (' . $other->nickname . ')') : $other->nickname;
+
+ $recipients = $listenee->email;
+
+ $headers['From'] = mail_notify_from();
+ $headers['To'] = $name . ' <' . $listenee->email . '>';
+ $headers['Subject'] = sprintf(_('%1$s is now listening to '.
+ 'your notices on %2$s.'),
+ $other->getBestName(),
+ common_config('site', 'name'));
+
+ $body = sprintf(_('%1$s is now listening to your notices on %2$s.'."\n\n".
+ "\t".'%3$s'."\n\n".
+ '%4$s'.
+ '%5$s'.
+ '%6$s'.
+ "\n".'Faithfully yours,'."\n".'%7$s.'."\n\n".
+ "----\n".
+ "Change your email address or ".
+ "notification options at ".'%8$s' ."\n"),
+ $long_name,
+ common_config('site', 'name'),
+ $other->profileurl,
+ ($other->location) ?
+ sprintf(_("Location: %s\n"), $other->location) : '',
+ ($other->homepage) ?
+ sprintf(_("Homepage: %s\n"), $other->homepage) : '',
+ ($other->bio) ?
+ sprintf(_("Bio: %s\n\n"), $other->bio) : '',
+ common_config('site', 'name'),
+ common_local_url('emailsettings'));
+
+ // reset localization
+ common_init_locale();
+ mail_send($recipients, $headers, $body);
+ }