]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OpenID/finishopenidlogin.php
Merge branch '0.9.x' of gitorious.org:statusnet/mainline into 0.9.x
[quix0rs-gnu-social.git] / plugins / OpenID / finishopenidlogin.php
index 8d498d05490b65dec6b746cbaf9a5b941b62557c..dfabdd79036fd9d898fef7b6459ca344270e7cb7 100644 (file)
@@ -118,11 +118,24 @@ class FinishopenidloginAction 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->elementStart('li');
         $this->element('input', array('type' => 'checkbox',
                                       'id' => 'license',
@@ -180,6 +193,39 @@ class FinishopenidloginAction extends Action
         $this->elementEnd('form');
     }
 
+    /**
+     * Get specified e-mail from the form, or the OpenID sreg info, or the
+     * invite code.
+     *
+     * @return string
+     */
+    function getEmail()
+    {
+        $email = $this->trimmed('email');
+        if (!empty($email)) {
+            return $email;
+        }
+
+        // Pull from openid thingy
+        list($display, $canonical, $sreg) = $this->getSavedValues();
+        if (!empty($sreg['email'])) {
+            return $sreg['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 tryLogin()
     {
         $consumer = oid_consumer();
@@ -347,11 +393,7 @@ class FinishopenidloginAction extends Action
             $fullname = '';
         }
 
-        if (!empty($sreg['email']) && Validate::email($sreg['email'], common_config('email', 'check_domain'))) {
-            $email = $sreg['email'];
-        } else {
-            $email = '';
-        }
+        $email = $this->getEmail();
 
         # XXX: add language
         # XXX: add timezone