]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/finishopenidlogin.php
Merge branch 'master' of /var/www/trunk
[quix0rs-gnu-social.git] / actions / finishopenidlogin.php
index ae5b136a25cc40ab4515bd7961cf451e8e53b784..bc33ac330b705e3bcd1ee75b32601042972abdf6 100644 (file)
@@ -21,12 +21,14 @@ if (!defined('LACONICA')) { exit(1); }
 
 require_once(INSTALLDIR.'/lib/openid.php');
 
-class FinishopenidloginAction extends Action {
+class FinishopenidloginAction extends Action
+{
 
-    function handle($args) {
+    function handle($args)
+    {
         parent::handle($args);
         if (common_logged_in()) {
-            common_user_error(_('Already logged in.'));
+            $this->clientError(_('Already logged in.'));
         } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             $token = $this->trimmed('token');
             if (!$token || $token != common_session_token()) {
@@ -52,54 +54,57 @@ class FinishopenidloginAction extends Action {
         }
     }
 
-    function show_top($error=null) {
+    function show_top($error=null)
+    {
         if ($error) {
-            common_element('div', array('class' => 'error'), $error);
+            $this->element('div', array('class' => 'error'), $error);
         } else {
             global $config;
-            common_element('div', 'instructions',
+            $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.'), $config['site']['name']));
         }
     }
 
-    function show_form($error=null, $username=null) {
+    function show_form($error=null, $username=null)
+    {
         common_show_header(_('OpenID Account Setup'), null, $error,
                            array($this, 'show_top'));
 
-        common_element_start('form', array('method' => 'post',
+        $this->elementStart('form', array('method' => 'post',
                                            'id' => 'account_connect',
                                            'action' => common_local_url('finishopenidlogin')));
-        common_hidden('token', common_session_token());
-        common_element('h2', null,
+        $this->hidden('token', common_session_token());
+        $this->element('h2', null,
                        _('Create new account'));
-        common_element('p', null,
+        $this->element('p', null,
                        _('Create a new user with this nickname.'));
-        common_input('newname', _('New nickname'),
+        $this->input('newname', _('New nickname'),
                      ($username) ? $username : '',
                      _('1-64 lowercase letters or numbers, no punctuation or spaces'));
-        common_element_start('p');
-        common_element('input', array('type' => 'checkbox',
+        $this->elementStart('p');
+        $this->element('input', array('type' => 'checkbox',
                                       'id' => 'license',
                                       'name' => 'license',
                                       'value' => 'true'));
-        common_text(_('My text and files are available under '));
-        common_element('a', array(href => common_config('license', 'url')),
+        $this->text(_('My text and files are available under '));
+        $this->element('a', array(href => common_config('license', 'url')),
                        common_config('license', 'title'));
-        common_text(_(' except this private data: password, email address, IM address, phone number.'));
-        common_element_end('p');
-        common_submit('create', _('Create'));
-        common_element('h2', null,
+        $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'));
-        common_element('p', null,
+        $this->element('p', null,
                        _('If you already have an account, login with your username and password to connect it to your OpenID.'));
-        common_input('nickname', _('Existing nickname'));
-        common_password('password', _('Password'));
-        common_submit('connect', _('Connect'));
-        common_element_end('form');
+        $this->input('nickname', _('Existing nickname'));
+        $this->password('password', _('Password'));
+        $this->submit('connect', _('Connect'));
+        $this->elementEnd('form');
         common_show_footer();
     }
 
-    function try_login() {
+    function try_login()
+    {
 
         $consumer = oid_consumer();
 
@@ -146,31 +151,35 @@ class FinishopenidloginAction extends Action {
         }
     }
 
-    function message($msg) {
+    function message($msg)
+    {
         common_show_header(_('OpenID Login'));
-        common_element('p', null, $msg);
+        $this->element('p', null, $msg);
         common_show_footer();
     }
 
-    function save_values($display, $canonical, $sreg) {
+    function save_values($display, $canonical, $sreg)
+    {
         common_ensure_session();
         $_SESSION['openid_display'] = $display;
         $_SESSION['openid_canonical'] = $canonical;
         $_SESSION['openid_sreg'] = $sreg;
     }
 
-    function get_saved_values() {
+    function get_saved_values()
+    {
         return array($_SESSION['openid_display'],
                      $_SESSION['openid_canonical'],
                      $_SESSION['openid_sreg']);
     }
 
-    function create_new_user() {
+    function create_new_user()
+    {
 
         # FIXME: save invite code before redirect, and check here
 
         if (common_config('site', 'closed') || common_config('site', 'inviteonly')) {
-            common_user_error(_('Registration not allowed.'));
+            $this->clientError(_('Registration not allowed.'));
             return;
         }
 
@@ -196,7 +205,7 @@ class FinishopenidloginAction extends Action {
         list($display, $canonical, $sreg) = $this->get_saved_values();
 
         if (!$display || !$canonical) {
-            common_server_error(_('Stored OpenID not found.'));
+            $this->serverError(_('Stored OpenID not found.'));
             return;
         }
 
@@ -205,7 +214,7 @@ class FinishopenidloginAction extends Action {
         $other = oid_get_user($canonical);
 
         if ($other) {
-            common_server_error(_('Creating new account for OpenID that already has a user.'));
+            $this->serverError(_('Creating new account for OpenID that already has a user.'));
             return;
         }
 
@@ -247,7 +256,8 @@ class FinishopenidloginAction extends Action {
         common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)));
     }
 
-    function connect_user() {
+    function connect_user()
+    {
 
         $nickname = $this->trimmed('nickname');
         $password = $this->trimmed('password');
@@ -264,14 +274,14 @@ class FinishopenidloginAction extends Action {
         list($display, $canonical, $sreg) = $this->get_saved_values();
 
         if (!$display || !$canonical) {
-            common_server_error(_('Stored OpenID not found.'));
+            $this->serverError(_('Stored OpenID not found.'));
             return;
         }
 
         $result = oid_link_user($user->id, $canonical, $display);
 
         if (!$result) {
-            common_server_error(_('Error connecting user to OpenID.'));
+            $this->serverError(_('Error connecting user to OpenID.'));
             return;
         }
 
@@ -286,7 +296,8 @@ class FinishopenidloginAction extends Action {
         $this->go_home($user->nickname);
     }
 
-    function go_home($nickname) {
+    function go_home($nickname)
+    {
         $url = common_get_returnto();
         if ($url) {
             # We don't have to return to it again
@@ -299,7 +310,8 @@ class FinishopenidloginAction extends Action {
         common_redirect($url);
     }
 
-    function best_new_nickname($display, $sreg) {
+    function best_new_nickname($display, $sreg)
+    {
 
         # Try the passed-in nickname
 
@@ -332,7 +344,8 @@ class FinishopenidloginAction extends Action {
         return null;
     }
 
-    function is_new_nickname($str) {
+    function is_new_nickname($str)
+    {
         if (!Validate::string($str, array('min_length' => 1,
                                           'max_length' => 64,
                                           'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
@@ -347,7 +360,8 @@ class FinishopenidloginAction extends Action {
         return true;
     }
 
-    function openid_to_nickname($openid) {
+    function openid_to_nickname($openid)
+    {
         if (Auth_Yadis_identifierScheme($openid) == 'XRI') {
             return $this->xri_to_nickname($openid);
         } else {
@@ -360,7 +374,8 @@ class FinishopenidloginAction extends Action {
     # 2. One element in path, like http://profile.typekey.com/EvanProdromou/
     #    or http://getopenid.com/evanprodromou
 
-    function url_to_nickname($openid) {
+    function url_to_nickname($openid)
+    {
         static $bad = array('query', 'user', 'password', 'port', 'fragment');
 
         $parts = parse_url($openid);
@@ -406,7 +421,8 @@ class FinishopenidloginAction extends Action {
         return null;
     }
 
-    function xri_to_nickname($xri) {
+    function xri_to_nickname($xri)
+    {
         $base = $this->xri_base($xri);
 
         if (!$base) {
@@ -419,7 +435,8 @@ class FinishopenidloginAction extends Action {
         }
     }
 
-    function xri_base($xri) {
+    function xri_base($xri)
+    {
         if (substr($xri, 0, 6) == 'xri://') {
             return substr($xri, 6);
         } else {
@@ -429,7 +446,8 @@ class FinishopenidloginAction extends Action {
 
     # Given a string, try to make it work as a nickname
 
-    function nicknamize($str) {
+    function nicknamize($str)
+    {
         $str = preg_replace('/\W/', '', $str);
         return strtolower($str);
     }