X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FTwitterBridge%2Ftwitterauthorization.php;h=972fa527d41340fac906c14482bb2064237002d3;hb=4e1ce4e5bbc43869dc7c85463f9a733da9f5fda4;hp=bbe41bd438f181303c033bc59181958300d5f182;hpb=dc350b5463e7d64a46d7f90143c2d001be99e280;p=quix0rs-gnu-social.git diff --git a/plugins/TwitterBridge/twitterauthorization.php b/plugins/TwitterBridge/twitterauthorization.php index bbe41bd438..972fa527d4 100644 --- a/plugins/TwitterBridge/twitterauthorization.php +++ b/plugins/TwitterBridge/twitterauthorization.php @@ -241,7 +241,7 @@ class TwitterauthorizationAction extends Action $this->twuid = $twitter_user->id; $this->tw_fields = array("screen_name" => $twitter_user->screen_name, - "name" => $twitter_user->name); + "fullname" => $twitter_user->name); $this->access_token = $atok; $this->tryLogin(); } @@ -373,7 +373,7 @@ class TwitterauthorizationAction extends Action $this->hidden('access_token_secret', $this->access_token->secret); $this->hidden('twuid', $this->twuid); $this->hidden('tw_fields_screen_name', $this->tw_fields['screen_name']); - $this->hidden('tw_fields_name', $this->tw_fields['name']); + $this->hidden('tw_fields_name', $this->tw_fields['fullname']); $this->elementStart('fieldset'); $this->hidden('token', common_session_token()); @@ -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; @@ -419,6 +458,10 @@ class TwitterauthorizationAction extends Action function createNewUser() { + if (!Event::handle('StartRegistrationTry', array($this))) { + return; + } + if (common_config('site', 'closed')) { $this->clientError(_m('Registration not allowed.')); return; @@ -458,7 +501,7 @@ class TwitterauthorizationAction extends Action return; } - $fullname = trim($this->tw_fields['name']); + $fullname = trim($this->tw_fields['fullname']); $args = array('nickname' => $nickname, 'fullname' => $fullname); @@ -466,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)) { @@ -490,6 +538,8 @@ class TwitterauthorizationAction extends Action common_debug('TwitterBridge Plugin - ' . "Registered new user $user->id from Twitter user $this->twuid"); + Event::handle('EndRegistrationTry', array($this)); + common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)), 303); } @@ -596,8 +646,8 @@ class TwitterauthorizationAction extends Action function bestNewNickname() { - if (!empty($this->tw_fields['name'])) { - $nickname = $this->nicknamize($this->tw_fields['name']); + if (!empty($this->tw_fields['fullname'])) { + $nickname = $this->nicknamize($this->tw_fields['fullname']); if ($this->isNewNickname($nickname)) { return $nickname; }