]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Add email field to Twitter registration form; needed when RequireValidatedEmail plugi...
authorBrion Vibber <brion@pobox.com>
Fri, 21 Jan 2011 01:02:34 +0000 (17:02 -0800)
committerBrion Vibber <brion@pobox.com>
Fri, 21 Jan 2011 01:02:34 +0000 (17:02 -0800)
Since Twitter doesn't provide email address back to us here, we only prefill the field if we have an invite.

plugins/TwitterBridge/twitterauthorization.php

index e78ba6a674e1c392db9fe20b73fb002d9cf32aab..972fa527d41340fac906c14482bb2064237002d3 100644 (file)
@@ -391,6 +391,11 @@ class TwitterauthorizationAction extends Action
                      ($this->username) ? $this->username : '',
                      _m('1-64 lowercase letters or numbers, no punctuation or spaces'));
         $this->elementEnd('li');
+        $this->elementStart('li');
+        $this->input('email', _('Email'), $this->getEmail(),
+                     _('Used only for updates, announcements, '.
+                       'and password recovery'));
+        $this->elementEnd('li');
 
         // Hook point for captcha etc
         Event::handle('EndRegistrationFormData', array($this));
@@ -419,6 +424,32 @@ class TwitterauthorizationAction extends Action
         $this->elementEnd('form');
     }
 
+    /**
+     * Get specified e-mail from the form, or the invite code.
+     *
+     * @return string
+     */
+    function getEmail()
+    {
+        $email = $this->trimmed('email');
+        if (!empty($email)) {
+            return $email;
+        }
+
+        // Terrible hack for invites...
+        if (common_config('site', 'inviteonly')) {
+            $code = $_SESSION['invitecode'];
+            if ($code) {
+                $invite = Invitation::staticGet($code);
+
+                if ($invite && $invite->address_type == 'email') {
+                    return $invite->address;
+                }
+            }
+        }
+        return '';
+    }
+
     function message($msg)
     {
         $this->message_text = $msg;
@@ -478,6 +509,11 @@ class TwitterauthorizationAction extends Action
             $args['code'] = $invite->code;
         }
 
+        $email = $this->getEmail();
+        if (!empty($email)) {
+            $args['email'] = $email;
+        }
+
         $user = User::register($args);
 
         if (empty($user)) {