Commit 0f1879c3 authored by Hugh Davenport's avatar Hugh Davenport Committed by Gerrit Code Review
Browse files

Merge "Assign staff permissions during registration approval (bug #982670)"

parents 2f6d0984 74cda0f6
......@@ -50,21 +50,21 @@ if (!$inst = get_record('institution', 'name', $registration->institution)) {
if ($action == 'approve') {
$message = get_string('approveregistrationmessage', 'admin', $inst->displayname);
}
else {
$message = get_string('denyregistrationmessage', 'admin');
}
if ($action == 'approve') {
$submitbtn = get_string('approve', 'admin');
define('TITLE', get_string('approveregistrationfor2', 'admin', $registration->firstname, $registration->lastname, $registration->email));
if ($registration->institution != 'mahara') {
$elements['institutionstaff'] = array(
'type' => 'checkbox',
'title' => get_string('institutionstaff', 'admin'),
'description' => get_string('makeuserinstitutionstaff', 'admin'),
'defaultvalue' => 0,
);
}
}
else {
$message = get_string('denyregistrationmessage', 'admin');
$submitbtn = get_string('deny', 'admin');
}
define('TITLE', get_string($action.'registrationfor', 'admin', $registration->firstname, $registration->lastname));
if ($action !== 'approve') {
define('TITLE', get_string('denyregistrationfor', 'admin', $registration->firstname, $registration->lastname));
$elements['message'] = array(
'type' => 'textarea',
'title' => get_string('registrationdeniedreason', 'admin'),
......@@ -136,6 +136,13 @@ function denyregistration_submit(Pieform $form, $values) {
function approveregistration_submit(Pieform $form, $values) {
global $SESSION;
// Get additional values to pass through to user creation
$extra = new StdClass;
if (!empty($values['institutionstaff'])) {
$extra->institutionstaff = 1;
}
$values['extra'] = serialize($extra);
// update expiry time and set pending to a value that identify
// it as approved (2)
$values['pending'] = 2;
......
......@@ -832,7 +832,7 @@ $string['updateinstitutionuserquotasdesc'] = 'If checked, the default quota you
// pending institution registrations
$string['approve'] = 'Approve';
$string['deny'] = 'Deny';
$string['approveregistrationfor'] = 'Approve registration for \'%s %s\'';
$string['approveregistrationfor2'] = 'Approve registration for %s %s <%s>';
$string['approveregistrationmessage'] = 'This will approve the registration and add the user to the institution \'%s\'. Are you sure you want to approve this registration?';
$string['denyregistrationfor'] = 'Deny registration for \'%s %s\'';
$string['denyregistrationmessage'] = 'This will deny the registration for the user. Are you sure you want to deny this registration?';
......@@ -849,6 +849,7 @@ $string['registrationdeniedreasondesc'] = 'Information as to why the application
$string['registrationdeniedsuccessful'] = 'Registration denied successfully.';
$string['registrationdeniedunsuccessful'] = 'The attempted registration denial failed.';
$string['registrationreason'] = 'Registration reason';
$string['makeuserinstitutionstaff'] = 'Automatically assign institution staff permissions to the owner of this email the first time they log in';
// Suspend Institutions
$string['errorwhileunsuspending'] = 'An error occured while trying to unsuspend';
......
......@@ -595,6 +595,7 @@
<FIELD NAME="expiry" TYPE="datetime" NOTNULL="true"/>
<FIELD NAME="pending" TYPE="int" LENGTH="1" DEFAULT="0" NOTNULL="true"/>
<FIELD NAME="reason" TYPE="text" NOTNULL="false"/>
<FIELD NAME="extra" TYPE="text" NOTNULL="false"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" />
......
......@@ -2876,5 +2876,12 @@ function xmldb_core_upgrade($oldversion=0) {
set_config('iframeregexp', $iframeregexp);
}
if ($oldversion < 2012042800) {
$table = new XMLDBTable('usr_registration');
$field = new XMLDBField('extra');
$field->setAttributes(XMLDB_TYPE_TEXT);
add_field($table, $field);
}
return $status;
}
......@@ -28,7 +28,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2012042600;
$config->version = 2012042800;
$config->release = '1.6.0dev';
$config->minupgradefrom = 2008040200;
$config->minupgraderelease = '1.0.0 (release tag 1.0.0_RELEASE)';
......
......@@ -113,6 +113,11 @@ if (isset($key)) {
throw new ConfigException('No internal auth instance for institution');
}
if (!empty($registration->extra)) {
// Additional user settings were added during confirmation
$extrafields = unserialize($registration->extra);
}
$user = new User();
$user->active = 1;
$user->authinstance = $authinstance->id;
......@@ -162,6 +167,12 @@ if (isset($key)) {
}
}
}
if (!empty($extrafields->institutionstaff)) {
// If the user isn't a member yet, this does nothing, but that's okay, it'll
// only be set after successful confirmation.
set_field('usr_institution', 'staff', 1, 'usr', $user->id, 'institution', $registration->institution);
}
}
......
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