]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/invite.php
better output for registration confirmation
[quix0rs-gnu-social.git] / actions / invite.php
index e9adb3b7f93255cca5aa0234566857416a1b42c0..35606037f35a0baf13d4602951de76857646446c 100644 (file)
@@ -19,6 +19,7 @@
 
 if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
 
+// @todo XXX: Add documentation.
 class InviteAction extends CurrentUserDesignAction
 {
     var $mode = null;
@@ -27,6 +28,11 @@ class InviteAction extends CurrentUserDesignAction
     var $subbed = null;
     var $sent = null;
 
+    function showNoticeForm()
+    {
+        return;
+    }
+
     function isReadOnly($args)
     {
         return false;
@@ -53,9 +59,10 @@ class InviteAction extends CurrentUserDesignAction
 
     function sendInvitations()
     {
-        # CSRF protection
+        // CSRF protection
         $token = $this->trimmed('token');
         if (!$token || $token != common_session_token()) {
+            // TRANS: Client error displayed when the session token does not match or is not given.
             $this->showForm(_('There was a problem with your session token. Try again, please.'));
             return;
         }
@@ -71,7 +78,14 @@ class InviteAction extends CurrentUserDesignAction
 
         foreach ($addresses as $email) {
             $email = trim($email);
-            if (!Validate::email($email, common_config('email', 'check_domain'))) {
+            $valid = null;
+
+            if (Event::handle('StartValidateEmailInvite', array($user, $email, &$valid))) {
+                $valid = Validate::email($email, common_config('email', 'check_domain'));
+                Event::handle('EndValidateEmailInvite', array($user, $email, &$valid));
+            }
+
+            if (!$valid) {
                 // TRANS: Form validation message when providing an e-mail address that does not validate.
                 // TRANS: %s is an invalid e-mail address.
                 $this->showForm(sprintf(_('Invalid email address: %s.'), $email));
@@ -217,7 +231,7 @@ class InviteAction extends CurrentUserDesignAction
         $this->textarea('addresses', _('Email addresses'),
                         $this->trimmed('addresses'),
                         // TRANS: Tooltip for field label for a list of e-mail addresses.
-                        _('Addresses of friends to invite (one per line)'));
+                        _('Addresses of friends to invite (one per line).'));
         $this->elementEnd('li');
         $this->elementStart('li');
         // TRANS: Field label for a personal message to send to invitees.
@@ -253,44 +267,31 @@ class InviteAction extends CurrentUserDesignAction
             return false;
         }
 
+        $confirmUrl = common_local_url('register', array('code' => $invite->code));
+
         $recipients = array($email);
 
         $headers['From'] = mail_notify_from();
         $headers['To'] = trim($email);
+        $headers['Content-Type'] = 'text/html; charset=UTF-8';
+
         // TRANS: Subject for invitation email. Note that 'them' is correct as a gender-neutral
         // TRANS: singular 3rd-person pronoun in English. %1$s is the inviting user, $2$s is
         // TRANS: the StatusNet sitename.
+
         $headers['Subject'] = sprintf(_('%1$s has invited you to join them on %2$s'), $bestname, $sitename);
 
-        // TRANS: Body text for invitation email. Note that 'them' is correct as a gender-neutral
-        // TRANS: singular 3rd-person pronoun in English. %1$s is the inviting user, %2$s is the
-        // TRANS: StatusNet sitename, %3$s is the site URL, %4$s is the personal message from the
-        // TRANS: inviting user, %s%5 a link to the timeline for the inviting user, %s$6 is a link
-        // TRANS: to register with the StatusNet site.
-        $body = sprintf(_("%1\$s has invited you to join them on %2\$s (%3\$s).\n\n".
-                          "%2\$s is a micro-blogging service that lets you keep up-to-date with people you know and people who interest you.\n\n".
-                          "You can also share news about yourself, your thoughts, or your life online with people who know about you. ".
-                          "It's also great for meeting new people who share your interests.\n\n".
-                          "%1\$s said:\n\n%4\$s\n\n".
-                          "You can see %1\$s's profile page on %2\$s here:\n\n".
-                          "%5\$s\n\n".
-                          "If you'd like to try the service, click on the link below to accept the invitation.\n\n".
-                          "%6\$s\n\n".
-                          "If not, you can ignore this message. Thanks for your patience and your time.\n\n".
-                          "Sincerely, %2\$s\n"),
-                        $bestname,
-                        $sitename,
-                        common_root_url(),
-                        $personal,
-                        common_local_url('showstream', array('nickname' => $user->nickname)),
-                        common_local_url('register', array('code' => $invite->code)));
+        $title = (empty($personal)) ? 'invite' : 'invitepersonal';
 
-        mail_send($recipients, $headers, $body);
-    }
+        $inviteTemplate = DocFile::forTitle($title, DocFile::mailPaths());
 
-    function showLocalNav()
-    {
-        $nav = new SubGroupNav($this, common_current_user());
-        $nav->show();
+        $body = $inviteTemplate->toHTML(array('inviter' => $bestname,
+                                              'inviteurl' => $profile->profileurl,
+                                              'confirmurl' => $confirmUrl,
+                                              'personal' => $personal));
+
+        common_debug('Confirm URL is ' . common_local_url('register', array('code' => $invite->code)));
+
+        mail_send($recipients, $headers, $body);
     }
 }