From 6c43967e8c2bad93e00e1ac98aa2cf4f2ef978b5 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Sat, 17 Sep 2011 14:47:35 -0700 Subject: [PATCH 1/4] Don't allow Twitter registration if site is invite only --- .../TwitterBridge/twitterauthorization.php | 65 ++++++++++--------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/plugins/TwitterBridge/twitterauthorization.php b/plugins/TwitterBridge/twitterauthorization.php index 22d7a7fbdc..410f10ff90 100644 --- a/plugins/TwitterBridge/twitterauthorization.php +++ b/plugins/TwitterBridge/twitterauthorization.php @@ -385,41 +385,44 @@ class TwitterauthorizationAction extends Action $this->hidden('tw_fields_screen_name', $this->tw_fields['screen_name']); $this->hidden('tw_fields_name', $this->tw_fields['fullname']); - $this->elementStart('fieldset'); - $this->hidden('token', common_session_token()); - $this->element('legend', null, - // TRANS: Fieldset legend. - _m('Create new account')); - $this->element('p', null, - // TRANS: Sub form introduction text. - _m('Create a new user with this nickname.')); - $this->elementStart('ul', 'form_data'); + // Don't allow new account creation if site is flagged as invite only + if (common_config('site', 'inviteonly') == false) { + $this->elementStart('fieldset'); + $this->hidden('token', common_session_token()); + $this->element('legend', null, + // TRANS: Fieldset legend. + _m('Create new account')); + $this->element('p', null, + // TRANS: Sub form introduction text. + _m('Create a new user with this nickname.')); + $this->elementStart('ul', 'form_data'); - // Hook point for captcha etc - Event::handle('StartRegistrationFormData', array($this)); + // Hook point for captcha etc + Event::handle('StartRegistrationFormData', array($this)); - $this->elementStart('li'); - // TRANS: Field label. - $this->input('newname', _m('New nickname'), - ($this->username) ? $this->username : '', - // TRANS: Field title for nickname field. - _m('1-64 lowercase letters or numbers, no punctuation or spaces.')); - $this->elementEnd('li'); - $this->elementStart('li'); - // TRANS: Field label. - $this->input('email', _m('LABEL','Email'), $this->getEmail(), - // TRANS: Field title for e-mail address field. - _m('Used only for updates, announcements, '. - 'and password recovery')); - $this->elementEnd('li'); + $this->elementStart('li'); + // TRANS: Field label. + $this->input('newname', _m('New nickname'), + ($this->username) ? $this->username : '', + // TRANS: Field title for nickname field. + _m('1-64 lowercase letters or numbers, no punctuation or spaces.')); + $this->elementEnd('li'); + $this->elementStart('li'); + // TRANS: Field label. + $this->input('email', _m('LABEL','Email'), $this->getEmail(), + // TRANS: Field title for e-mail address field. + _m('Used only for updates, announcements, '. + 'and password recovery')); + $this->elementEnd('li'); - // Hook point for captcha etc - Event::handle('EndRegistrationFormData', array($this)); + // Hook point for captcha etc + Event::handle('EndRegistrationFormData', array($this)); - $this->elementEnd('ul'); - // TRANS: Button text for creating a new StatusNet account in the Twitter connect page. - $this->submit('create', _m('BUTTON','Create')); - $this->elementEnd('fieldset'); + $this->elementEnd('ul'); + // TRANS: Button text for creating a new StatusNet account in the Twitter connect page. + $this->submit('create', _m('BUTTON','Create')); + $this->elementEnd('fieldset'); + } $this->elementStart('fieldset'); $this->element('legend', null, From be95dcf008c40d27f8bf34d18b56a8e25bc93d9d Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Sat, 17 Sep 2011 15:43:21 -0700 Subject: [PATCH 2/4] Move license checkbox to the end of the form --- .../TwitterBridge/twitterauthorization.php | 51 +++++++++++-------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/plugins/TwitterBridge/twitterauthorization.php b/plugins/TwitterBridge/twitterauthorization.php index 410f10ff90..7a07e4690b 100644 --- a/plugins/TwitterBridge/twitterauthorization.php +++ b/plugins/TwitterBridge/twitterauthorization.php @@ -357,28 +357,7 @@ class TwitterauthorizationAction extends Action $this->elementStart('fieldset', array('id' => 'settings_twitter_connect_options')); // TRANS: Fieldset legend. $this->element('legend', null, _m('Connection options')); - $this->elementStart('ul', 'form_data'); - $this->elementStart('li'); - $this->element('input', array('type' => 'checkbox', - 'id' => 'license', - 'class' => 'checkbox', - 'name' => 'license', - 'value' => 'true')); - $this->elementStart('label', array('class' => 'checkbox', 'for' => 'license')); - // TRANS: Text for license agreement checkbox. - // TRANS: %s is the license as configured for the StatusNet site. - $message = _m('My text and files are available under %s ' . - 'except this private data: password, ' . - 'email address, IM address, and phone number.'); - $link = '' . - htmlspecialchars(common_config('license', 'title')) . - ''; - $this->raw(sprintf(htmlspecialchars($message), $link)); - $this->elementEnd('label'); - $this->elementEnd('li'); - $this->elementEnd('ul'); + $this->hidden('access_token_key', $this->access_token->key); $this->hidden('access_token_secret', $this->access_token->secret); $this->hidden('twuid', $this->twuid); @@ -445,6 +424,34 @@ class TwitterauthorizationAction extends Action $this->submit('connect', _m('BUTTON','Connect')); $this->elementEnd('fieldset'); + $this->elementStart('fieldset'); + $this->element('legend', null, + // TRANS: Fieldset legend. + _m('License')); + $this->elementStart('ul', 'form_data'); + $this->elementStart('li'); + $this->element('input', array('type' => 'checkbox', + 'id' => 'license', + 'class' => 'checkbox', + 'name' => 'license', + 'value' => 'true')); + $this->elementStart('label', array('class' => 'checkbox', 'for' => 'license')); + // TRANS: Text for license agreement checkbox. + // TRANS: %s is the license as configured for the StatusNet site. + $message = _m('My text and files are available under %s ' . + 'except this private data: password, ' . + 'email address, IM address, and phone number.'); + $link = '' . + htmlspecialchars(common_config('license', 'title')) . + ''; + $this->raw(sprintf(htmlspecialchars($message), $link)); + $this->elementEnd('label'); + $this->elementEnd('li'); + $this->elementEnd('ul'); + $this->elementEnd('fieldset'); + $this->elementEnd('fieldset'); $this->elementEnd('form'); } From 2df2d4fd1d3dd32d6040e254e041316e986fefe6 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Sat, 17 Sep 2011 15:45:55 -0700 Subject: [PATCH 3/4] Move submit (connect) button to the very bottom --- plugins/TwitterBridge/twitterauthorization.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/TwitterBridge/twitterauthorization.php b/plugins/TwitterBridge/twitterauthorization.php index 7a07e4690b..baaf4a1af7 100644 --- a/plugins/TwitterBridge/twitterauthorization.php +++ b/plugins/TwitterBridge/twitterauthorization.php @@ -420,8 +420,6 @@ class TwitterauthorizationAction extends Action $this->password('password', _m('Password')); $this->elementEnd('li'); $this->elementEnd('ul'); - // TRANS: Button text for connecting an existing StatusNet account in the Twitter connect page.. - $this->submit('connect', _m('BUTTON','Connect')); $this->elementEnd('fieldset'); $this->elementStart('fieldset'); @@ -451,7 +449,8 @@ class TwitterauthorizationAction extends Action $this->elementEnd('li'); $this->elementEnd('ul'); $this->elementEnd('fieldset'); - + // TRANS: Button text for connecting an existing StatusNet account in the Twitter connect page.. + $this->submit('connect', _m('BUTTON','Connect')); $this->elementEnd('fieldset'); $this->elementEnd('form'); } From d4ed6db1d87a8109529554bca1f39417907ffe0f Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Sat, 17 Sep 2011 15:50:13 -0700 Subject: [PATCH 4/4] Make sure the session token gets output no matter what (whoops) --- plugins/TwitterBridge/twitterauthorization.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/TwitterBridge/twitterauthorization.php b/plugins/TwitterBridge/twitterauthorization.php index baaf4a1af7..1a7234214e 100644 --- a/plugins/TwitterBridge/twitterauthorization.php +++ b/plugins/TwitterBridge/twitterauthorization.php @@ -363,11 +363,11 @@ class TwitterauthorizationAction extends Action $this->hidden('twuid', $this->twuid); $this->hidden('tw_fields_screen_name', $this->tw_fields['screen_name']); $this->hidden('tw_fields_name', $this->tw_fields['fullname']); + $this->hidden('token', common_session_token()); // Don't allow new account creation if site is flagged as invite only if (common_config('site', 'inviteonly') == false) { $this->elementStart('fieldset'); - $this->hidden('token', common_session_token()); $this->element('legend', null, // TRANS: Fieldset legend. _m('Create new account'));