From e248066b74aa697a1dfd99153b1e8c2e18f32831 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 26 Aug 2008 20:19:27 -0400 Subject: updates for invitations Add the code to registration to handle invitation codes. Some edge cases on invitations: is the user already subbed to this person? Tell them. Is the person already on the system? Sub the user to them, then, and tell the user. Add some code to User to auto-sub invitees whenever the email address changes. Call it from a new registration with an invite code, and also from confirmaddress. Some whitespace cleanup in the files touched. darcs-hash:20080827001927-84dde-b50e5d921ca3f2fb894821730ff93cac09d2ba66.gz --- actions/register.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'actions/register.php') diff --git a/actions/register.php b/actions/register.php index f366bd3e0..9a871dd53 100644 --- a/actions/register.php +++ b/actions/register.php @@ -55,6 +55,10 @@ class RegisterAction extends Action { $password = $this->arg('password'); $confirm = $this->arg('confirm'); + # invitation code, if any + + $code = $this->trimmed('code'); + # Input scrubbing $nickname = common_canonical_nickname($nickname); @@ -93,8 +97,8 @@ class RegisterAction extends Action { } else if ($password != $confirm) { $this->show_form(_('Passwords don\'t match.')); } else if ($user = User::register(array('nickname' => $nickname, 'password' => $password, 'email' => $email, - 'fullname' => $fullname, 'homepage' => $homepage, 'bio' => $bio, - 'location' => $location))) { + 'fullname' => $fullname, 'homepage' => $homepage, 'bio' => $bio, + 'location' => $location, 'code' => $code))) { if (!$user) { $this->show_form(_('Invalid username or password.')); return; @@ -149,15 +153,19 @@ class RegisterAction extends Action { common_element_start('form', array('method' => 'post', 'id' => 'login', 'action' => common_local_url('register'))); - common_hidden('token', common_session_token()); common_input('nickname', _('Nickname'), $this->trimmed('nickname'), _('1-64 lowercase letters or numbers, no punctuation or spaces. Required.')); common_password('password', _('Password'), _('6 or more characters. Required.')); common_password('confirm', _('Confirm'), _('Same as password above. Required.')); - common_input('email', _('Email'), $this->trimmed('email'), + if ($invite && $invite->address_type == 'email') { + common_input('email', _('Email'), $invite->address, _('Used only for updates, announcements, and password recovery')); + } else { + common_input('email', _('Email'), $this->trimmed('email'), + _('Used only for updates, announcements, and password recovery')); + } common_input('fullname', _('Full name'), $this->trimmed('fullname'), _('Longer name, preferably your "real" name')); @@ -170,7 +178,7 @@ class RegisterAction extends Action { common_input('location', _('Location'), $this->trimmed('location'), _('Where you are, like "City, State (or Region), Country"')); - common_checkbox('rememberme', _('Remember me'), + common_checkbox('rememberme', _('Remember me'), $this->boolean('rememberme'), _('Automatically login in the future; not for shared computers!')); common_element_start('p'); @@ -191,7 +199,7 @@ class RegisterAction extends Action { common_element_end('form'); common_show_footer(); } - + function show_success() { $nickname = $this->arg('nickname'); common_show_header(_('Registration successful')); @@ -214,5 +222,5 @@ class RegisterAction extends Action { common_element_end('div'); common_show_footer(); } - + } -- cgit v1.2.3-54-g00ecf