* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
-
class RegisterAction extends Action
{
/**
* Has there been an error?
*/
-
var $error = null;
/**
* Have we registered?
*/
-
var $registered = false;
/**
* Are we processing an invite?
*/
-
var $invite = null;
/**
* @param $args
* @return string title
*/
-
function prepare($args)
{
parent::prepare($args);
*
* @return string title
*/
-
function title()
{
if ($this->registered) {
*
* @return void
*/
-
function handle($args)
{
parent::handle($args);
*
* @return void
*/
-
function tryRegister()
{
if (Event::handle('StartRegistrationTry', array($this))) {
}
// Input scrubbing
- $nickname = common_canonical_nickname($nickname);
+ try {
+ $nickname = Nickname::normalize($nickname);
+ } catch (NicknameException $e) {
+ $this->showForm($e->getMessage());
+ }
$email = common_canonical_email($email);
if (!$this->boolean('license')) {
- $this->showForm(_('You can\'t register if you don\'t '.
+ $this->showForm(_('You cannot register if you don\'t '.
'agree to the license.'));
} 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,
- 'format' => NICKNAME_FMT))) {
- $this->showForm(_('Nickname must have only lowercase letters '.
- 'and numbers and no spaces.'));
} else if ($this->nicknameExists($nickname)) {
$this->showForm(_('Nickname already in use. Try another one.'));
} else if (!User::allowed_nickname($nickname)) {
$this->showForm(_('Homepage is not a valid URL.'));
return;
} else if (!is_null($fullname) && mb_strlen($fullname) > 255) {
- $this->showForm(_('Full name is too long (max 255 chars).'));
+ $this->showForm(_('Full name is too long (maximum 255 characters).'));
return;
} else if (Profile::bioTooLong($bio)) {
- $this->showForm(sprintf(_('Bio is too long (max %d chars).'),
+ $this->showForm(sprintf(_m('Bio is too long (maximum %d character).',
+ 'Bio is too long (maximum %d characters).',
+ Profile::maxBio()),
Profile::maxBio()));
return;
} else if (!is_null($location) && mb_strlen($location) > 255) {
- $this->showForm(_('Location is too long (max 255 chars).'));
+ $this->showForm(_('Location is too long (maximum 255 characters).'));
return;
} else if (strlen($password) < 6) {
$this->showForm(_('Password must be 6 or more characters.'));
*
* @return boolean true if the nickname already exists
*/
-
function nicknameExists($nickname)
{
$user = User::staticGet('nickname', $nickname);
- return ($user !== false);
+ return is_object($user);
}
/**
*
* @return boolean true if the address already exists
*/
-
function emailExists($email)
{
$email = common_canonical_email($email);
return false;
}
$user = User::staticGet('email', $email);
- return ($user !== false);
+ return is_object($user);
}
// overrrided to add entry-title class
*
* @return void
*/
-
function showPageNotice()
{
if ($this->registered) {
} 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. '));
+ 'link up to friends and colleagues.'));
$this->elementStart('div', 'instructions');
$this->raw($instr);
*
* @return void
*/
-
function showForm($error=null)
{
$this->error = $error;
*
* @return void
*/
-
function showContent()
{
if ($this->registered) {
*
* @return void
*/
-
function showFormContent()
{
$code = $this->trimmed('code');
if (Event::handle('StartRegistrationFormData', array($this))) {
$this->elementStart('li');
$this->input('nickname', _('Nickname'), $this->trimmed('nickname'),
- _('1-64 lowercase letters or numbers, '.
- 'no punctuation or spaces. Required.'));
+ _('1-64 lowercase letters or numbers, no punctuation or spaces.'));
$this->elementEnd('li');
$this->elementStart('li');
$this->password('password', _('Password'),
- _('6 or more characters. Required.'));
+ _('6 or more characters.'));
$this->elementEnd('li');
$this->elementStart('li');
$this->password('confirm', _('Confirm'),
- _('Same as password above. Required.'));
+ _('Same as password above.'));
$this->elementEnd('li');
$this->elementStart('li');
if ($this->invite && $this->invite->address_type == 'email') {
$this->input('email', _('Email'), $this->invite->address,
_('Used only for updates, announcements, '.
- 'and password recovery'));
+ 'and password recovery.'));
} else {
$this->input('email', _('Email'), $this->trimmed('email'),
_('Used only for updates, announcements, '.
- 'and password recovery'));
+ 'and password recovery.'));
}
$this->elementEnd('li');
$this->elementStart('li');
$this->input('fullname', _('Full name'),
$this->trimmed('fullname'),
- _('Longer name, preferably your "real" name'));
+ _('Longer name, preferably your "real" name.'));
$this->elementEnd('li');
$this->elementStart('li');
$this->input('homepage', _('Homepage'),
$this->trimmed('homepage'),
_('URL of your homepage, blog, '.
- 'or profile on another site'));
+ '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'),
+ // TRANS: Tooltip for field label in form for profile settings. Plural
+ // TRANS: is decided by the number of characters available for the
+ // TRANS: biography (%d).
+ $bioInstr = sprintf(_m('Describe yourself and your interests in %d character',
+ 'Describe yourself and your interests in %d characters',
+ $maxBio),
$maxBio);
} else {
$bioInstr = _('Describe yourself and your interests');
$this->input('location', _('Location'),
$this->trimmed('location'),
_('Where you are, like "City, '.
- 'State (or Region), Country"'));
+ 'State (or Region), Country".'));
$this->elementEnd('li');
Event::handle('EndRegistrationFormData', array($this));
$this->elementStart('li', array('id' => 'settings_rememberme'));
$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');
}
$this->elementEnd('form');
}
+ function licenseCheckbox()
+ {
+ $out = '';
+ switch (common_config('license', 'type')) {
+ case 'private':
+ // TRANS: Copyright checkbox label in registration dialog, for private sites.
+ // TRANS: %1$s is the StatusNet sitename.
+ $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
*
*
* @return void
*/
-
function showSuccess()
{
$this->registered = true;
*
* @return void
*/
-
function showSuccessContent()
{
$nickname = $this->arg('nickname');
*
* @return void
*/
-
function showLocalNav()
{
$nav = new LoginGroupNav($this);
$nav->show();
}
}
-