X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fregister.php;h=e6b1931cef6de26752c7d9bbd1ed7abfaba02146;hb=92645bbc578fafeb6816a44b8cf9cd594ffb5bd7;hp=d97e3a18af2c2807286251a2f18100877441b0ec;hpb=e97c06e8e27b4dce977a493a47c216d6c5796c2e;p=quix0rs-gnu-social.git diff --git a/actions/register.php b/actions/register.php index d97e3a18af..e6b1931cef 100644 --- a/actions/register.php +++ b/actions/register.php @@ -82,7 +82,9 @@ class RegisterAction extends Action { return; } else if ($password != $confirm) { $this->show_form(_('Passwords don\'t match.')); - } else if ($user = $this->register_user($nickname, $password, $email, $fullname, $homepage, $bio, $location)) { + } else if ($user = User::register(array('nickname' => $nickname, 'password' => $password, 'email' => $email, + 'fullname' => $fullname, 'homepage' => $homepage, 'bio' => $bio, + 'location' => $location))) { if (!$user) { $this->show_form(_('Invalid username or password.')); return; @@ -98,6 +100,8 @@ class RegisterAction extends Action { common_debug('Adding rememberme cookie for ' . $nickname); common_rememberme($user); } + # Re-init language env in case it changed (not yet, but soon) + common_init_language(); $this->show_success(); } else { $this->show_form(_('Invalid username or password.')); @@ -119,88 +123,6 @@ class RegisterAction extends Action { return ($user !== false); } - function register_user($nickname, $password, $email, $fullname, $homepage, $bio, $location) { - - $profile = new Profile(); - - $profile->query('BEGIN'); - - $profile->nickname = $nickname; - $profile->profileurl = common_profile_url($nickname); - if ($fullname) { - $profile->fullname = $fullname; - } - if ($homepage) { - $profile->homepage = $homepage; - } - if ($bio) { - $profile->bio = $bio; - } - if ($location) { - $profile->location = $location; - } - $profile->created = DB_DataObject_Cast::dateTime(); # current time - - $id = $profile->insert(); - - if (!$id) { - common_log_db_error($profile, 'INSERT', __FILE__); - return FALSE; - } - $user = new User(); - $user->id = $id; - $user->nickname = $nickname; - $user->password = common_munge_password($password, $id); - $user->created = DB_DataObject_Cast::dateTime(); # current time - $user->uri = common_user_uri($user); - - $result = $user->insert(); - - if (!$result) { - common_log_db_error($user, 'INSERT', __FILE__); - return FALSE; - } - - # Everyone is subscribed to themself - - $subscription = new Subscription(); - $subscription->subscriber = $user->id; - $subscription->subscribed = $user->id; - $subscription->created = $user->created; - - $result = $subscription->insert(); - - if (!$result) { - common_log_db_error($subscription, 'INSERT', __FILE__); - return FALSE; - } - - if ($email) { - - $confirm = new Confirm_address(); - $confirm->code = common_confirmation_code(128); - $confirm->user_id = $user->id; - $confirm->address = $email; - $confirm->address_type = 'email'; - - $result = $confirm->insert(); - if (!$result) { - common_log_db_error($confirm, 'INSERT', __FILE__); - return FALSE; - } - } - - $profile->query('COMMIT'); - - if ($email) { - mail_confirm_address($confirm->code, - $profile->nickname, - $email); - } - - return $user; - } - function show_top($error=NULL) { if ($error) { common_element('p', 'error', $error);