+
+/**
+ * Send notification emails to group administrator.
+ *
+ * @param User_group $group
+ * @param Profile $joiner
+ */
+function mail_notify_group_join($group, $joiner)
+{
+ // This returns a Profile query...
+ $admin = $group->getAdmins();
+ while ($admin->fetch()) {
+ // We need a local user for email notifications...
+ $adminUser = User::getKV('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 group join 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 has joined '.
+ 'your group %2$s on %3$s'),
+ $joiner->getBestName(),
+ $group->getBestName(),
+ common_config('site', 'name'));
+
+ // TRANS: Main body of group join 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 a block of profile info about the subscriber.
+ // TRANS: %5$s is a link to the addressed user's e-mail settings.
+ $body = sprintf(_('%1$s has joined your group %2$s on %3$s.'),
+ $joiner->getFancyName(),
+ $group->getFancyName(),
+ common_config('site', 'name')) .
+ mail_profile_block($joiner) .
+ mail_footer_block();
+
+ // reset localization
+ common_switch_locale();
+ mail_send($adminUser->email, $headers, $body);
+ }
+ }
+}
+
+
+/**
+ * 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::getKV('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);
+ }
+ }
+}