From 1f4b63d533beee7018f93a9050969909631d4442 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 20 Jan 2011 17:02:34 -0800 Subject: [PATCH] Add email field to Twitter registration form; needed when RequireValidatedEmail plugin is present. Since Twitter doesn't provide email address back to us here, we only prefill the field if we have an invite. --- .../TwitterBridge/twitterauthorization.php | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/plugins/TwitterBridge/twitterauthorization.php b/plugins/TwitterBridge/twitterauthorization.php index e78ba6a674..972fa527d4 100644 --- a/plugins/TwitterBridge/twitterauthorization.php +++ b/plugins/TwitterBridge/twitterauthorization.php @@ -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)) { -- 2.39.5