X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fregister.php;h=7307bc689b26cda56839fbadfb4ada3992bbe14d;hb=f8808b076108bbc80e2e23e795c34bcdf817a183;hp=dcbbbdb6a6de9afb238715b7ff1cac3d78f40b7d;hpb=b58edbcc4eddbc9d2802708aae5155e1f70e08d2;p=quix0rs-gnu-social.git diff --git a/actions/register.php b/actions/register.php index dcbbbdb6a6..7307bc689b 100644 --- a/actions/register.php +++ b/actions/register.php @@ -1,6 +1,6 @@ . * * @category Login - * @package Laconica - * @author Evan Prodromou - * @copyright 2008-2009 Control Yourself, Inc. + * @package StatusNet + * @author Evan Prodromou + * @copyright 2008-2009 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ + * @link http://status.net/ */ -if (!defined('LACONICA')) { +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } @@ -35,10 +35,10 @@ if (!defined('LACONICA')) { * An action for registering a new user account * * @category Login - * @package Laconica - * @author Evan Prodromou + * @package StatusNet + * @author Evan Prodromou * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ + * @link http://status.net/ */ class RegisterAction extends Action @@ -55,6 +55,12 @@ class RegisterAction extends Action var $registered = false; + /** + * Are we processing an invite? + */ + + var $invite = null; + /** * Prepare page to run * @@ -68,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)) { @@ -136,6 +149,12 @@ class RegisterAction extends Action } } + function showScripts() + { + parent::showScripts(); + $this->autofocus('nickname'); + } + /** * Try to register a user * @@ -185,7 +204,7 @@ class RegisterAction extends Action if (!$this->boolean('license')) { $this->showForm(_('You can\'t register if you don\'t '. 'agree to the license.')); - } else if ($email && !Validate::email($email, true)) { + } else if ($email && !Validate::email($email, common_config('email', 'check_domain'))) { $this->showForm(_('Not a valid email address.')); } else if (!Validate::string($nickname, array('min_length' => 1, 'max_length' => 64, @@ -207,8 +226,9 @@ class RegisterAction extends Action } else if (!is_null($fullname) && mb_strlen($fullname) > 255) { $this->showForm(_('Full name is too long (max 255 chars).')); return; - } else if (!is_null($bio) && mb_strlen($bio) > 140) { - $this->showForm(_('Bio is too long (max 140 chars).')); + } else if (Profile::bioTooLong($bio)) { + $this->showForm(sprintf(_('Bio is too long (max %d chars).'), + Profile::maxBio())); return; } else if (!is_null($location) && mb_strlen($location) > 255) { $this->showForm(_('Location is too long (max 255 chars).')); @@ -246,6 +266,7 @@ class RegisterAction extends Action // Re-init language env in case it changed (not yet, but soon) common_init_language(); + $this->showSuccess(); } else { $this->showForm(_('Invalid username or password.')); @@ -266,7 +287,7 @@ class RegisterAction extends Action function nicknameExists($nickname) { $user = User::staticGet('nickname', $nickname); - return ($user !== false); + return is_object($user); } /** @@ -286,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 @@ -327,12 +348,9 @@ 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. '. - '(Have an [OpenID](http://openid.net/)? ' . - 'Try our [OpenID registration]'. - '(%%action.openidlogin%%)!)')); + 'link up to friends and colleagues. ')); $this->elementStart('div', 'instructions'); $this->raw($instr); @@ -445,10 +463,16 @@ class RegisterAction extends Action 'or profile on another site')); $this->elementEnd('li'); $this->elementStart('li'); + $maxBio = Profile::maxBio(); + if ($maxBio > 0) { + $bioInstr = sprintf(_('Describe yourself and your interests in %d chars'), + $maxBio); + } else { + $bioInstr = _('Describe yourself and your interests'); + } $this->textarea('bio', _('Bio'), $this->trimmed('bio'), - _('Describe yourself and your '. - 'interests in 140 chars')); + $bioInstr); $this->elementEnd('li'); $this->elementStart('li'); $this->input('location', _('Location'), @@ -474,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'); } @@ -488,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 = '' . + htmlspecialchars(common_config('license', 'title')) . + ''; + $out .= sprintf(htmlspecialchars($message), $link); + } + return $out; + } + /** * Show some information about registering for the site * @@ -518,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%%%%) '.