X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FOpenID%2Ffinishopenidlogin.php;h=438a728d83fb65c0934887353713cb6e747f05d3;hb=894b221e8aec57768d6804ee3bf53c85196e09bf;hp=50a9c15c87a8730e2b9fb7ce11f415e97cb93d32;hpb=7f3c1ac2beca8f0e21c002930a5df6dc2d9415ad;p=quix0rs-gnu-social.git diff --git a/plugins/OpenID/finishopenidlogin.php b/plugins/OpenID/finishopenidlogin.php index 50a9c15c87..438a728d83 100644 --- a/plugins/OpenID/finishopenidlogin.php +++ b/plugins/OpenID/finishopenidlogin.php @@ -31,16 +31,16 @@ class FinishopenidloginAction extends Action { parent::handle($args); if (common_is_real_login()) { - $this->clientError(_('Already logged in.')); + $this->clientError(_m('Already logged in.')); } else if ($_SERVER['REQUEST_METHOD'] == 'POST') { $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { - $this->showForm(_('There was a problem with your session token. Try again, please.')); + $this->showForm(_m('There was a problem with your session token. Try again, please.')); return; } if ($this->arg('create')) { if (!$this->boolean('license')) { - $this->showForm(_('You can\'t register if you don\'t agree to the license.'), + $this->showForm(_m('You can\'t register if you don\'t agree to the license.'), $this->trimmed('newname')); return; } @@ -49,7 +49,7 @@ class FinishopenidloginAction extends Action $this->connectUser(); } else { common_debug(print_r($this->args, true), __FILE__); - $this->showForm(_('Something weird happened.'), + $this->showForm(_m('Something weird happened.'), $this->trimmed('newname')); } } else { @@ -63,13 +63,13 @@ class FinishopenidloginAction extends Action $this->element('div', array('class' => 'error'), $this->error); } else { $this->element('div', 'instructions', - sprintf(_('This is the first time you\'ve logged into %s so we must connect your OpenID to a local account. You can either create a new account, or connect with your existing account, if you have one.'), common_config('site', 'name'))); + sprintf(_m('This is the first time you\'ve logged into %s so we must connect your OpenID to a local account. You can either create a new account, or connect with your existing account, if you have one.'), common_config('site', 'name'))); } } function title() { - return _('OpenID Account Setup'); + return _m('OpenID Account Setup'); } function showForm($error=null, $username=null) @@ -89,33 +89,53 @@ class FinishopenidloginAction extends Action $this->elementStart('form', array('method' => 'post', 'id' => 'account_connect', + 'class' => 'form_settings', 'action' => common_local_url('finishopenidlogin'))); $this->hidden('token', common_session_token()); - $this->element('h2', null, - _('Create new account')); + $this->elementStart('fieldset', array('id' => 'form_openid_createaccount')); + $this->element('legend', null, + _m('Create new account')); $this->element('p', null, - _('Create a new user with this nickname.')); - $this->input('newname', _('New nickname'), + _m('Create a new user with this nickname.')); + $this->elementStart('ul', 'form_data'); + $this->elementStart('li'); + $this->input('newname', _m('New nickname'), ($this->username) ? $this->username : '', - _('1-64 lowercase letters or numbers, no punctuation or spaces')); - $this->elementStart('p'); + _m('1-64 lowercase letters or numbers, no punctuation or spaces')); + $this->elementEnd('li'); + $this->elementStart('li'); $this->element('input', array('type' => 'checkbox', 'id' => 'license', + 'class' => 'checkbox', 'name' => 'license', 'value' => 'true')); - $this->text(_('My text and files are available under ')); + $this->elementStart('label', array('for' => 'license', + 'class' => 'checkbox')); + $this->text(_m('My text and files are available under ')); $this->element('a', array('href' => common_config('license', 'url')), common_config('license', 'title')); - $this->text(_(' except this private data: password, email address, IM address, phone number.')); - $this->elementEnd('p'); - $this->submit('create', _('Create')); - $this->element('h2', null, - _('Connect existing account')); + $this->text(_m(' except this private data: password, email address, IM address, phone number.')); + $this->elementEnd('label'); + $this->elementEnd('li'); + $this->elementEnd('ul'); + $this->submit('create', _m('Create')); + $this->elementEnd('fieldset'); + + $this->elementStart('fieldset', array('id' => 'form_openid_createaccount')); + $this->element('legend', null, + _m('Connect existing account')); $this->element('p', null, - _('If you already have an account, login with your username and password to connect it to your OpenID.')); - $this->input('nickname', _('Existing nickname')); - $this->password('password', _('Password')); - $this->submit('connect', _('Connect')); + _m('If you already have an account, login with your username and password to connect it to your OpenID.')); + $this->elementStart('ul', 'form_data'); + $this->elementStart('li'); + $this->input('nickname', _m('Existing nickname')); + $this->elementEnd('li'); + $this->elementStart('li'); + $this->password('password', _m('Password')); + $this->elementEnd('li'); + $this->elementEnd('ul'); + $this->submit('connect', _m('Connect')); + $this->elementEnd('fieldset'); $this->elementEnd('form'); } @@ -126,11 +146,11 @@ class FinishopenidloginAction extends Action $response = $consumer->complete(common_local_url('finishopenidlogin')); if ($response->status == Auth_OpenID_CANCEL) { - $this->message(_('OpenID authentication cancelled.')); + $this->message(_m('OpenID authentication cancelled.')); return; } else if ($response->status == Auth_OpenID_FAILURE) { // Authentication failed; display the error message. - $this->message(sprintf(_('OpenID authentication failed: %s'), $response->message)); + $this->message(sprintf(_m('OpenID authentication failed: %s'), $response->message)); } else if ($response->status == Auth_OpenID_SUCCESS) { // This means the authentication succeeded; extract the // identity URL and Simple Registration data (if it was @@ -192,7 +212,7 @@ class FinishopenidloginAction extends Action # FIXME: save invite code before redirect, and check here if (common_config('site', 'closed')) { - $this->clientError(_('Registration not allowed.')); + $this->clientError(_m('Registration not allowed.')); return; } @@ -201,14 +221,14 @@ class FinishopenidloginAction extends Action if (common_config('site', 'inviteonly')) { $code = $_SESSION['invitecode']; if (empty($code)) { - $this->clientError(_('Registration not allowed.')); + $this->clientError(_m('Registration not allowed.')); return; } $invite = Invitation::staticGet($code); if (empty($invite)) { - $this->clientError(_('Not a valid invitation code.')); + $this->clientError(_m('Not a valid invitation code.')); return; } } @@ -218,24 +238,24 @@ class FinishopenidloginAction extends Action if (!Validate::string($nickname, array('min_length' => 1, 'max_length' => 64, 'format' => NICKNAME_FMT))) { - $this->showForm(_('Nickname must have only lowercase letters and numbers and no spaces.')); + $this->showForm(_m('Nickname must have only lowercase letters and numbers and no spaces.')); return; } if (!User::allowed_nickname($nickname)) { - $this->showForm(_('Nickname not allowed.')); + $this->showForm(_m('Nickname not allowed.')); return; } if (User::staticGet('nickname', $nickname)) { - $this->showForm(_('Nickname already in use. Try another one.')); + $this->showForm(_m('Nickname already in use. Try another one.')); return; } list($display, $canonical, $sreg) = $this->getSavedValues(); if (!$display || !$canonical) { - $this->serverError(_('Stored OpenID not found.')); + $this->serverError(_m('Stored OpenID not found.')); return; } @@ -244,7 +264,7 @@ class FinishopenidloginAction extends Action $other = oid_get_user($canonical); if ($other) { - $this->serverError(_('Creating new account for OpenID that already has a user.')); + $this->serverError(_m('Creating new account for OpenID that already has a user.')); return; } @@ -265,7 +285,7 @@ class FinishopenidloginAction extends Action $fullname = ''; } - if (!empty($sreg['email']) && Validate::email($sreg['email'], true)) { + if (!empty($sreg['email']) && Validate::email($sreg['email'], common_config('email', 'check_domain'))) { $email = $sreg['email']; } else { $email = ''; @@ -304,7 +324,7 @@ class FinishopenidloginAction extends Action $password = $this->trimmed('password'); if (!common_check_user($nickname, $password)) { - $this->showForm(_('Invalid username or password.')); + $this->showForm(_m('Invalid username or password.')); return; } @@ -315,14 +335,14 @@ class FinishopenidloginAction extends Action list($display, $canonical, $sreg) = $this->getSavedValues(); if (!$display || !$canonical) { - $this->serverError(_('Stored OpenID not found.')); + $this->serverError(_m('Stored OpenID not found.')); return; } $result = oid_link_user($user->id, $canonical, $display); if (!$result) { - $this->serverError(_('Error connecting user to OpenID.')); + $this->serverError(_m('Error connecting user to OpenID.')); return; } @@ -343,6 +363,7 @@ class FinishopenidloginAction extends Action if ($url) { # We don't have to return to it again common_set_returnto(null); + $url = common_inject_session($url); } else { $url = common_local_url('all', array('nickname' => @@ -417,49 +438,7 @@ class FinishopenidloginAction extends Action function urlToNickname($openid) { - static $bad = array('query', 'user', 'password', 'port', 'fragment'); - - $parts = parse_url($openid); - - # If any of these parts exist, this won't work - - foreach ($bad as $badpart) { - if (array_key_exists($badpart, $parts)) { - return null; - } - } - - # We just have host and/or path - - # If it's just a host... - if (array_key_exists('host', $parts) && - (!array_key_exists('path', $parts) || strcmp($parts['path'], '/') == 0)) - { - $hostparts = explode('.', $parts['host']); - - # Try to catch common idiom of nickname.service.tld - - if ((count($hostparts) > 2) && - (strlen($hostparts[count($hostparts) - 2]) > 3) && # try to skip .co.uk, .com.au - (strcmp($hostparts[0], 'www') != 0)) - { - return $this->nicknamize($hostparts[0]); - } else { - # Do the whole hostname - return $this->nicknamize($parts['host']); - } - } else { - if (array_key_exists('path', $parts)) { - # Strip starting, ending slashes - $path = preg_replace('@/$@', '', $parts['path']); - $path = preg_replace('@^/@', '', $path); - if (strpos($path, '/') === false) { - return $this->nicknamize($path); - } - } - } - - return null; + return common_url_to_nickname($openid); } function xriToNickname($xri) @@ -489,7 +468,6 @@ class FinishopenidloginAction extends Action function nicknamize($str) { - $str = preg_replace('/\W/', '', $str); - return strtolower($str); + return common_nicknamize($str); } }