Merge branch '0.7.x' of git@gitorious.org:laconica/dev into 0.7.x

This commit is contained in:
Robin Millette 2009-04-18 19:08:48 +00:00
commit eec323b5b7
3 changed files with 129 additions and 78 deletions

View File

@ -191,11 +191,28 @@ class FinishopenidloginAction extends Action
{
# FIXME: save invite code before redirect, and check here
if (common_config('site', 'closed') || common_config('site', 'inviteonly')) {
if (common_config('site', 'closed')) {
$this->clientError(_('Registration not allowed.'));
return;
}
$invite = null;
if (common_config('site', 'inviteonly')) {
$code = $_SESSION['invitecode'];
if (empty($code)) {
$this->clientError(_('Registration not allowed.'));
return;
}
$invite = Invitation::staticGet($code);
if (empty($invite)) {
$this->clientError(_('Not a valid invitation code.'));
return;
}
}
$nickname = $this->trimmed('newname');
if (!Validate::string($nickname, array('min_length' => 1,
@ -257,10 +274,16 @@ class FinishopenidloginAction extends Action
# XXX: add language
# XXX: add timezone
$user = User::register(array('nickname' => $nickname,
$args = array('nickname' => $nickname,
'email' => $email,
'fullname' => $fullname,
'location' => $location));
'location' => $location);
if (!empty($invite)) {
$args['code'] = $invite->code;
}
$user = User::register($args);
$result = oid_link_user($user->id, $canonical, $display);

View File

@ -55,6 +55,45 @@ class RegisterAction extends Action
var $registered = false;
/**
* Prepare page to run
*
*
* @param $args
* @return string title
*/
function prepare($args)
{
parent::prepare($args);
$this->code = $this->trimmed('code');
if (empty($this->code)) {
common_ensure_session();
if (array_key_exists('invitecode', $_SESSION)) {
$this->code = $_SESSION['invitecode'];
}
}
if (common_config('site', 'inviteonly') && empty($this->code)) {
$this->clientError(_('Sorry, only invited people can register.'));
return false;
}
if (!empty($this->code)) {
$this->invite = Invitation::staticGet('code', $this->code);
if (empty($this->invite)) {
$this->clientError(_('Sorry, invalid invitation code.'));
return false;
}
// Store this in case we need it
common_ensure_session();
$_SESSION['invitecode'] = $this->code;
}
return true;
}
/**
* Title of the page
*
@ -343,17 +382,6 @@ class RegisterAction extends Action
function showFormContent()
{
$code = $this->trimmed('code');
if ($code) {
$invite = Invitation::staticGet($code);
}
if (common_config('site', 'inviteonly') && !($code && $invite)) {
$this->clientError(_('Sorry, only invited people can register.'));
return;
}
$this->elementStart('form', array('method' => 'post',
'id' => 'form_register',
'class' => 'form_settings',
@ -362,8 +390,8 @@ class RegisterAction extends Action
$this->element('legend', null, 'Account settings');
$this->hidden('token', common_session_token());
if ($code) {
$this->hidden('code', $code);
if ($this->code) {
$this->hidden('code', $this->code);
}
$this->elementStart('ul', 'form_data');
@ -382,8 +410,8 @@ class RegisterAction extends Action
_('Same as password above. Required.'));
$this->elementEnd('li');
$this->elementStart('li');
if ($invite && $invite->address_type == 'email') {
$this->input('email', _('Email'), $invite->address,
if ($this->invite && $this->invite->address_type == 'email') {
$this->input('email', _('Email'), $this->invite->address,
_('Used only for updates, announcements, '.
'and password recovery'));
} else {

View File

@ -179,13 +179,13 @@ $(document).ready(function(){
}
else {
$("#notices_primary .notices").prepend(document._importNode($("li", xml).get(0), true));
counter();
$("#notices_primary .notice:first").css({display:"none"});
$("#notices_primary .notice:first").fadeIn(2500);
NoticeHover();
NoticeReply();
}
$("#notice_data-text").val("");
counter();
}
$("#form_notice").removeClass("processing");
$("#notice_action-submit").removeAttr("disabled");