]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/register.php
Merge branch '0.9.x' into 1.0.x
[quix0rs-gnu-social.git] / actions / register.php
index ec6534eee042ff49a02b547a26a13cbe361c79f4..7307bc689b26cda56839fbadfb4ada3992bbe14d 100644 (file)
@@ -74,6 +74,13 @@ class RegisterAction extends Action
         parent::prepare($args);
         $this->code = $this->trimmed('code');
 
+        // @todo this check should really be in index.php for all sensitive actions
+        $ssl = common_config('site', 'ssl');
+        if (empty($_SERVER['HTTPS']) && ($ssl == 'always' || $ssl == 'sometimes')) {
+            common_redirect(common_local_url('register'));
+            // exit
+        }
+
         if (empty($this->code)) {
             common_ensure_session();
             if (array_key_exists('invitecode', $_SESSION)) {
@@ -260,16 +267,6 @@ class RegisterAction extends Action
                 // Re-init language env in case it changed (not yet, but soon)
                 common_init_language();
 
-                if (common_config('site', 'ssl') == 'sometimes' && // mixed environment
-                    0 != strcasecmp(common_config('site', 'server'), common_config('site', 'sslserver'))) {
-
-                    $url = common_local_url('all',
-                                            array('nickname' =>
-                                                  $user->nickname));
-                    $this->redirectFromSSL($user, $url, $this->boolean('rememberme'));
-                    return;
-                }
-
                 $this->showSuccess();
             } else {
                 $this->showForm(_('Invalid username or password.'));
@@ -290,7 +287,7 @@ class RegisterAction extends Action
     function nicknameExists($nickname)
     {
         $user = User::staticGet('nickname', $nickname);
-        return ($user !== false);
+        return is_object($user);
     }
 
     /**
@@ -310,7 +307,7 @@ class RegisterAction extends Action
             return false;
         }
         $user = User::staticGet('email', $email);
-        return ($user !== false);
+        return is_object($user);
     }
 
     // overrrided to add entry-title class
@@ -351,7 +348,7 @@ class RegisterAction extends Action
         } else {
             $instr =
               common_markup_to_html(_('With this form you can create '.
-                                      ' a new account. ' .
+                                      'a new account. ' .
                                       'You can then post notices and '.
                                       'link up to friends and colleagues. '));
 
@@ -501,11 +498,7 @@ class RegisterAction extends Action
             $this->elementStart('li');
             $this->element('input', $attrs);
             $this->elementStart('label', array('class' => 'checkbox', 'for' => 'license'));
-            $this->text(_('My text and files are available under '));
-            $this->element('a', array('href' => common_config('license', 'url')),
-                           common_config('license', 'title'), _("Creative Commons Attribution 3.0"));
-            $this->text(_(' except this private data: password, '.
-                          'email address, IM address, and phone number.'));
+            $this->raw($this->licenseCheckbox());
             $this->elementEnd('label');
             $this->elementEnd('li');
         }
@@ -515,6 +508,48 @@ class RegisterAction extends Action
         $this->elementEnd('form');
     }
 
+    function licenseCheckbox()
+    {
+        $out = '';
+        switch (common_config('license', 'type')) {
+        case 'private':
+            // TRANS: Copyright checkbox label in registration dialog, for private sites.
+            $out .= htmlspecialchars(sprintf(
+                _('I understand that content and data of %1$s are private and confidential.'),
+                common_config('site', 'name')));
+            // fall through
+        case 'allrightsreserved':
+            if ($out != '') {
+                $out .= ' ';
+            }
+            if (common_config('license', 'owner')) {
+                // TRANS: Copyright checkbox label in registration dialog, for all rights reserved with a specified copyright owner.
+                $out .= htmlspecialchars(sprintf(
+                    _('My text and files are copyright by %1$s.'),
+                    common_config('license', 'owner')));
+            } else {
+                // TRANS: Copyright checkbox label in registration dialog, for all rights reserved with ownership left to contributors.
+                $out .= htmlspecialchars(_('My text and files remain under my own copyright.'));
+            }
+            // TRANS: Copyright checkbox label in registration dialog, for all rights reserved.
+            $out .= ' ' . _('All rights reserved.');
+            break;
+        case 'cc': // fall through
+        default:
+            // TRANS: Copyright checkbox label in registration dialog, for Creative Commons-style licenses.
+            $message = _('My text and files are available under %s ' .
+                         'except this private data: password, ' .
+                         'email address, IM address, and phone number.');
+            $link = '<a href="' .
+                    htmlspecialchars(common_config('license', 'url')) .
+                    '">' .
+                    htmlspecialchars(common_config('license', 'title')) .
+                    '</a>';
+            $out .= sprintf(htmlspecialchars($message), $link);
+        }
+        return $out;
+    }
+
     /**
      * Show some information about registering for the site
      *
@@ -545,9 +580,9 @@ class RegisterAction extends Action
                                        array('nickname' => $nickname));
 
         $this->elementStart('div', 'success');
-        $instr = sprintf(_('Congratulations, %s! And welcome to %%%%site.name%%%%. '.
+        $instr = sprintf(_('Congratulations, %1$s! And welcome to %%%%site.name%%%%. '.
                            'From here, you may want to...'. "\n\n" .
-                           '* Go to [your profile](%s) '.
+                           '* Go to [your profile](%2$s) '.
                            'and post your first message.' .  "\n" .
                            '* Add a [Jabber/GTalk address]'.
                            '(%%%%action.imsettings%%%%) '.
@@ -589,32 +624,5 @@ class RegisterAction extends Action
         $nav = new LoginGroupNav($this);
         $nav->show();
     }
-
-    function redirectFromSSL($user, $returnto, $rememberme)
-    {
-        try {
-            $login_token = Login_token::makeNew($user);
-        } catch (Exception $e) {
-            $this->serverError($e->getMessage());
-            return;
-        }
-
-        $params = array();
-
-        if (!empty($returnto)) {
-            $params['returnto'] = $returnto;
-        }
-
-        if (!empty($rememberme)) {
-            $params['rememberme'] = $rememberme;
-        }
-
-        $target = common_local_url('otp',
-                                   array('user_id' => $login_token->user_id,
-                                         'token' => $login_token->token),
-                                   $params);
-
-        common_redirect($target, 303);
-    }
 }