Commit d24ca315 authored by Son Nguyen's avatar Son Nguyen

Update the title of user's default blog if registering via Persona

(Bug 1064780)

also set default values for the user's account.

Change-Id: I347cb39e3ae663b23a37f81af5a48325eaedfcea
Signed-off-by: default avatarSon Nguyen <son.nguyen@catalyst.net.nz>
parent 2bc741c0
......@@ -54,6 +54,7 @@ class AuthBrowserid extends Auth {
}
// Personal details are currently not provided by the Persona API.
$user = new stdClass();
$user->username = $email;
$user->firstname = '';
$user->lastname = '';
......@@ -64,6 +65,11 @@ class AuthBrowserid extends Auth {
$user->passwordchange = 0;
$user->authinstance = $this->instanceid;
// Set default values to activate this user
$user->deleted = 0;
$user->expiry = null;
$user->suspendedcusr = null;
$user->id = create_user($user, array(), $this->institution);
return $user;
......
......@@ -1051,6 +1051,18 @@ function requiredfields_submit(Pieform $form, $values) {
$SESSION->add_ok_msg(get_string('requiredfieldsset', 'auth'));
}
// Update the title of user's first blog if first and/or last name have been changed
$updatedfields = array_keys($values);
if (in_array('firstname', $updatedfields) || in_array('lastname', $updatedfields)) {
safe_require('artefact', 'blog');
$userblogs = get_records_select_array('artefact', 'artefacttype = \'blog\' AND owner = ?', array($USER->get('id')));
if ($userblogs && count($userblogs) == 1) {
$defaultblog = new ArtefactTypeBlog($userblogs[0]->id);
$defaultblog->set('title', get_string('defaultblogtitle', 'artefact.blog', display_name($USER, null, true)));
$defaultblog->commit();
}
}
redirect();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment