]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/TwitterBridge/twitterauthorization.php
Remove inline reply forms on click-away if they have initial text as well as if empty...
[quix0rs-gnu-social.git] / plugins / TwitterBridge / twitterauthorization.php
index cc3af588789f5d780497a79d5729db19608e3afe..972fa527d41340fac906c14482bb2064237002d3 100644 (file)
@@ -382,11 +382,24 @@ class TwitterauthorizationAction extends Action
         $this->element('p', null,
                        _m('Create a new user with this nickname.'));
         $this->elementStart('ul', 'form_data');
+
+        // Hook point for captcha etc
+        Event::handle('StartRegistrationFormData', array($this));
+
         $this->elementStart('li');
         $this->input('newname', _m('New nickname'),
                      ($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));
+
         $this->elementEnd('ul');
         $this->submit('create', _m('Create'));
         $this->elementEnd('fieldset');
@@ -411,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;
@@ -470,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)) {