Commit 403899f8 authored by Richard Mansfield's avatar Richard Mansfield Committed by Gerrit Code Review
Browse files

Merge changes Icfa57f44,Ieab78c5f,Ifcb19737

* changes:
  Preserve registration 'extra' values during approval (bug #1001064)
  Don't write logged out user preferences to the db (bug #1001064)
  Add local hooks for registration and user initialisation (bug #1001064)
parents 1a483307 17f71278
......@@ -136,8 +136,14 @@ function denyregistration_submit(Pieform $form, $values) {
function approveregistration_submit(Pieform $form, $values) {
global $SESSION;
if (!empty($values['extra'])) {
// The local_register_submit hook may have been used to put other values in
// this column; if so, leave them in the db.
$extra = unserialize($values['extra']);
}
$extra = (!empty($extra) && $extra instanceof Stdclass) ? $extra : new StdClass;
// Get additional values to pass through to user creation
$extra = new StdClass;
if (!empty($values['institutionstaff'])) {
$extra->institutionstaff = 1;
}
......
......@@ -2194,6 +2194,10 @@ function auth_register_submit(Pieform $form, $values) {
$values['expiry'] = db_format_timestamp(time() + 86400);
}
if (function_exists('local_register_submit')) {
local_register_submit($values);
}
try {
if (!record_exists('usr_registration', 'email', $values['email'])) {
insert_record('usr_registration', $values);
......
......@@ -460,7 +460,9 @@ class User {
/** @todo document this method */
public function set_account_preference($field, $value) {
set_account_preference($this->get('id'), $field, $value);
if ($id = $this->get('id')) {
set_account_preference($id, $field, $value);
}
$accountprefs = $this->get('accountprefs');
$accountprefs[$field] = $value;
$this->set('accountprefs', $accountprefs);
......
......@@ -276,6 +276,10 @@ require_once('auth/lib.php');
$SESSION = Session::singleton();
$USER = new LiveUser();
if (function_exists('local_init_user')) {
local_init_user();
}
// try to set the theme, or catch the thrown exception (eg if the name is invalid)
try {
$THEME = new Theme($USER);
......
......@@ -189,6 +189,10 @@ if (isset($key)) {
$USER = new LiveUser();
$USER->reanimate($user->id, $authinstance->id);
if (function_exists('local_post_register')) {
local_post_register($registration);
}
$SESSION->add_ok_msg(get_string('registrationcomplete', 'mahara', get_config('sitename')));
$SESSION->set('resetusername', true);
redirect();
......
Supports Markdown
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