Commit f46e341e authored by Darryl Hamilton's avatar Darryl Hamilton
Browse files

Add optional institution registration confirmation (bug #662775)



There is now a new option in the settings for an institution to
confirm registrations. When this is set, a new user admitting
themselves to an institution is required to complete an extra step
during registration, where they must provide a "reason" for their
registration.

After email verification the user must wait until an administrator
approves or denies their registration before they can properly
access the site. For the administrator, this is done via a new
admin page under Institutions, called "Pending Registrations".

Change-Id: I2bd68e39a9f4ef89f350ac573d8232f342de6fdc
Author: Stacey Walker <stacey@catalyst-eu.net>
Signed-off-by: default avatarBrett Wilkins <brett@catalyst.net.nz>
Signed-off-by: default avatarDarryl Hamilton <darrylh@catalyst.net.nz>
parent 1cb411f2
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2011 Catalyst IT Ltd and others; see:
* http://wiki.mahara.org/Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage core
* @author Stacey Walker
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2011 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
define('INSTITUTIONALADMIN', 1);
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'admin');
define('SECTION_PAGE', 'actionregistration');
require_once('pieforms/pieform.php');
require_once('institution.php');
$id = param_integer('r');
$action = param_alpha('action');
if (!is_logged_in()) {
throw new AccessDeniedException();
}
if (!$registration = get_record_select('usr_registration', '"id" = ? AND pending = 1', array($id))) {
die_info(get_string('registrationnosuchkey', 'auth.internal'));
}
if (!$inst = get_record('institution', 'name', $registration->institution)) {
die_info(get_string('nosuchinstitution', 'admin'));
}
if ($action == 'approve') {
$message = get_string('approveregistrationmessage', 'admin', $inst->displayname);
}
else {
$message = get_string('denyregistrationmessage', 'admin');
}
if ($action == 'approve') {
$submitbtn = get_string('approve', 'admin');
}
else {
$submitbtn = get_string('deny', 'admin');
}
define('TITLE', get_string($action.'registrationfor', 'admin', $registration->firstname, $registration->lastname));
if ($action !== 'approve') {
$elements['message'] = array(
'type' => 'textarea',
'title' => get_string('registrationdeniedreason', 'admin'),
'description' => get_string('registrationdeniedreasondesc', 'admin'),
'cols' => 50,
'rows' => 10,
);
}
foreach ((array)$registration as $key => $value) {
$elements[$key] = array(
'type' => 'hidden',
'value' => $value,
);
}
$elements['submit'] = array(
'type' => 'submitcancel',
'value' => array($submitbtn, get_string('cancel')),
'goto' => get_config('wwwroot') . 'admin/users/pendingregistrations.php?institution='.$inst->name,
);
$form = pieform(array(
'name' => $action.'registration',
'autofocus' => false,
'method' => 'post',
'elements' => $elements,
));
$smarty = smarty();
$smarty->assign('PAGEHEADING', TITLE);
$smarty->assign('message', $message);
$smarty->assign('form', $form);
$smarty->display('admin/users/actionregistration.tpl');
function denyregistration_submit(Pieform $form, $values) {
global $USER, $SESSION;
if (isset($values['message']) && !empty($values['message'])) {
$message = get_string('registrationdeniedmessagereason', 'auth.internal',
$values['firstname'], get_config('sitename'), $values['message'], display_name($USER), get_config('sitename'));
}
else {
$message = get_string('registrationdeniedmessage', 'auth.internal',
$values['firstname'], get_config('sitename'), display_name($USER), get_config('sitename'));
}
try {
delete_records('usr_registration', 'email', $values['email']);
$user = (object) $values;
$user->admin = 0;
$user->staff = 0;
email_user($user, $USER,
get_string('registrationdeniedemailsubject', 'auth.internal', get_config('sitename')),
$message
);
}
catch (EmailException $e) {
log_warn($e);
die_info(get_string('registrationdeniedunsuccessful', 'admin'));
}
catch (SQLException $e) {
log_warn($e);
die_info(get_string('registrationdeniedunsuccessful', 'admin'));
}
$SESSION->add_ok_msg(get_string('registrationdeniedsuccessful', 'admin'));
redirect('/admin/users/pendingregistrations.php?institution='.$values['institution']);
}
function approveregistration_submit(Pieform $form, $values) {
global $SESSION;
// update expiry time and set pending to a value that identify
// it as approved (2)
$values['pending'] = 2;
$values['expiry'] = db_format_timestamp(time() + 86400); // now + 1 day
update_record('usr_registration', $values, array('email' => $values['email']));
// send the user the official account completion email
$user = (object) $values;
$user->admin = 0;
$user->staff = 0;
email_user($user, null,
get_string('registeredemailsubject', 'auth.internal', get_config('sitename')),
get_string('registeredemailmessagetext', 'auth.internal',
$user->firstname, get_config('sitename'), get_config('wwwroot'),
$user->key, get_config('sitename')),
get_string('registeredemailmessagehtml', 'auth.internal',
$user->firstname, get_config('sitename'), get_config('wwwroot'),
$user->key, get_config('wwwroot'), $user->key, get_config('sitename'))
);
$SESSION->add_ok_msg(get_string('registrationapprovedsuccessfully', 'admin'));
redirect('/admin/users/pendingregistrations.php?institution='.$user->institution);
}
...@@ -183,6 +183,7 @@ if ($institution || $add) { ...@@ -183,6 +183,7 @@ if ($institution || $add) {
$data->expiry = null; $data->expiry = null;
if (!get_config('usersuniquebyusername')) { if (!get_config('usersuniquebyusername')) {
$data->registerallowed = 1; $data->registerallowed = 1;
$data->registerconfirm = 1;
} }
$data->theme = 'sitedefault'; $data->theme = 'sitedefault';
$data->defaultmembershipperiod = null; $data->defaultmembershipperiod = null;
...@@ -281,6 +282,12 @@ if ($institution || $add) { ...@@ -281,6 +282,12 @@ if ($institution || $add) {
'defaultvalue' => $data->registerallowed, 'defaultvalue' => $data->registerallowed,
'help' => true, 'help' => true,
); );
$elements['registerconfirm'] = array(
'type' => 'checkbox',
'title' => get_string('registrationconfirm', 'admin'),
'description' => get_string('registrationconfirmdescription', 'admin'),
'defaultvalue' => $data->registerconfirm,
);
} }
if (empty($data->name) || $data->name != 'mahara') { if (empty($data->name) || $data->name != 'mahara') {
...@@ -473,6 +480,7 @@ function institution_submit(Pieform $form, $values) { ...@@ -473,6 +480,7 @@ function institution_submit(Pieform $form, $values) {
} }
else { else {
$newinstitution->registerallowed = ($values['registerallowed']) ? 1 : 0; $newinstitution->registerallowed = ($values['registerallowed']) ? 1 : 0;
$newinstitution->registerconfirm = ($values['registerconfirm']) ? 1 : 0;
} }
$newinstitution->theme = (empty($values['theme']) || $values['theme'] == 'sitedefault') ? null : $values['theme']; $newinstitution->theme = (empty($values['theme']) || $values['theme'] == 'sitedefault') ? null : $values['theme'];
......
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2011 Catalyst IT Ltd and others; see:
* http://wiki.mahara.org/Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage admin
* @author Stacey Walker
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2011 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
define('INSTITUTIONALADMIN', 1);
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
define('TITLE', get_string('pendingregistrations', 'admin'));
define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'admin');
define('SECTION_PAGE', 'pendingregistrations');
define('MENUITEM', 'manageinstitutions/pendingregistrations');
require_once('pieforms/pieform.php');
require_once('institution.php');
if (!is_logged_in()) {
throw new AccessDeniedException();
}
$institutionelement = get_institution_selector();
if (empty($institutionelement)) {
$smarty = smarty();
$smarty->display('admin/users/noinstitutions.tpl');
exit;
}
$institution = param_alphanum('institution', null);
if (!$institution || !$USER->can_edit_institution($institution)) {
$institution = empty($institutionelement['value']) ? $institutionelement['defaultvalue'] : $institutionelement['value'];
}
else if (!empty($institution)) {
$institutionelement['defaultvalue'] = $institution;
}
$institutionselector = pieform(array(
'name' => 'usertypeselect',
'elements' => array(
'institution' => $institutionelement,
)
));
$pending = get_records_sql_array('
SELECT u.* FROM {usr_registration} u
WHERE u.institution = ? AND u.pending = 1
ORDER BY u.expiry ASC', array($institution)
);
if (!$pending) {
$pending = array();
}
function build_pending_html($data, $institution) {
$smarty = smarty_core();
$smarty->assign('data', isset($data) ? $data : null);
$smarty->assign('institution', $institution);
$tablerows = $smarty->fetch('admin/users/pendinguserslist.tpl');
return $tablerows;
}
$data = build_pending_html($pending, $institution);
$wwwroot = get_config('wwwroot');
$js = <<< EOF
function reloadUsers() {
window.location.href = '{$wwwroot}admin/users/pendingregistrations.php?institution='+$('usertypeselect_institution').value;
}
addLoadEvent(function() {
connect($('usertypeselect_institution'), 'onchange', reloadUsers);
});
EOF;
$smarty = smarty();
$smarty->assign('PAGEHEADING', TITLE);
$smarty->assign('INLINEJAVASCRIPT', $js);
$smarty->assign('data', $data);
$smarty->assign('institutionselector', $institutionselector);
$smarty->display('admin/users/pendingregistrations.tpl');
...@@ -65,3 +65,87 @@ $string['usernamealreadytaken'] = 'Sorry, this username is already taken'; ...@@ -65,3 +65,87 @@ $string['usernamealreadytaken'] = 'Sorry, this username is already taken';
$string['usernameinvalidform'] = 'Usernames may contain letters, numbers and most common symbols, and must be from 3 to 30 characters in length. Spaces are not allowed.'; $string['usernameinvalidform'] = 'Usernames may contain letters, numbers and most common symbols, and must be from 3 to 30 characters in length. Spaces are not allowed.';
$string['usernameinvalidadminform'] = 'Usernames may contain letters, numbers and most common symbols, and must be from 3 to 236 characters in length. Spaces are not allowed.'; $string['usernameinvalidadminform'] = 'Usernames may contain letters, numbers and most common symbols, and must be from 3 to 236 characters in length. Spaces are not allowed.';
$string['youmaynotregisterwithouttandc'] = 'You may not register unless you agree to abide by the <a href="terms.php">Terms and Conditions</a>'; $string['youmaynotregisterwithouttandc'] = 'You may not register unless you agree to abide by the <a href="terms.php">Terms and Conditions</a>';
// pending institution registrations
$string['confirmcancelregistration'] = 'Are you sure you want to cancel this registration? Doing so will result in your request being removed from the system.';
$string['confirmemailsubject'] = 'Confirm email for registration at %s';
$string['confirmemailmessagetext'] = 'Hi %s,
Thank you for registering an account on %s. Please select the following link to confirm your email address.
The institution adminstrator will be notified and your application will be considered for approval and you
will be notified of the outcome.
%sregister.php?key=%s
The link will expire in 24 hours.
--
Regards,
The %s Team';
$string['confirmemailmessagehtml'] = '<p>Hi %s,</p>
<p>Thank you for registering an account on %s. Please select the following link to confirm your email address.
The institution adminstrator will be notified and your application will be considered for approval and you
will be notified of the outcome.</p>
<p><a href="%sregister.php?key=%s">%sregister.php?key=%s</a></p>
<p>The link will expire in 24 hours.</p>
<pre>--
Regards,
The %s Team</pre>';
$string['emailconfirmedok'] = '<p>You have successfully confirmed your email. You will be notified with further registration details soon.</p>';
$string['registrationcancelledok'] = 'You have successfully cancelled your registration application.';
$string['registrationconfirm'] = 'Confirm registration?';
$string['registrationconfirmdescription'] = 'Registration must be approved by institutional adminstrators.';
$string['registrationdeniedemailsubject'] = 'Registration attempt at %s denied.';
$string['registrationdeniedmessage'] = 'Hi %s,
Your registration attempt at %s has been denied.
--
Regards,
%s
The %s Team';
$string['registrationdeniedmessagereason'] = 'Hi %s,
Your registration attempt at %s has been denied.
Reason:
"%s"
--
Regards,
%s
The %s Team';
$string['registeredokawaitingemail'] = 'You have successfully submitted your application for registration. An email should have been sent to you in order to confirm your email and continue the process.';
$string['registrationreason'] = 'Registration Reason';
$string['registrationreasondesc'] = 'The reason for requesting registration with your chosen institution and any other details you think might be useful for the administrator in processing your application. The registration cannot be completed without this information.';
$string['pendingregistrationadminemailsubject'] = "New user registration for institution '%s' at %s.";
$string['pendingregistrationadminemailtext'] = "Hi %s,
A new user has requested to join the institution '%s'.
Because you are listed as an admin of this institution you need to approve or deny this registration request. To do this, select the following link: %s
Details of the registration request follows:
Name: %s
Email: %s
Registration reason:
%s
--
Regards,
The %s Team";
$string['pendingregistrationadminemailhtml'] = "<p>Hi %s,</p>
<p>A new user has requested to join the institution '%s'.</p>
<p>Because you are listed as an admin of this institution you need to approve or deny this registration request. To do this, select the following link: <a href='%s'>%s</a></p>
<p>Details of the registration request follows:</p>
<p>Name: %s</p>
<p>Email: %s</p>
<p>Registration reason:</p>
<p>%s</p>
<pre>--
Regards,
The %s Team</pre>";
...@@ -614,6 +614,8 @@ $string['institutionexpirydescription'] = 'The date at which this institutions m ...@@ -614,6 +614,8 @@ $string['institutionexpirydescription'] = 'The date at which this institutions m
$string['institutionupdatedsuccessfully'] = 'Institution updated successfully.'; $string['institutionupdatedsuccessfully'] = 'Institution updated successfully.';
$string['registrationallowed'] = 'Registration allowed?'; $string['registrationallowed'] = 'Registration allowed?';
$string['registrationalloweddescription2'] = 'Whether users can register for your site for this institution using the registration form. If registration is off, non-members cannot request membership of the institution, and members cannot leave the institution or delete their user accounts voluntarily.'; $string['registrationalloweddescription2'] = 'Whether users can register for your site for this institution using the registration form. If registration is off, non-members cannot request membership of the institution, and members cannot leave the institution or delete their user accounts voluntarily.';
$string['registrationconfirm'] = 'Confirm registration?';
$string['registrationconfirmdescription'] = 'Registration must be approved by institutional adminstrators.';
$string['defaultmembershipperiod'] = 'Default membership period'; $string['defaultmembershipperiod'] = 'Default membership period';
$string['defaultmembershipperioddescription'] = 'How long new members remain associated with the institution'; $string['defaultmembershipperioddescription'] = 'How long new members remain associated with the institution';
$string['showonlineusers'] = 'Show online users'; $string['showonlineusers'] = 'Show online users';
...@@ -694,6 +696,27 @@ $string['disabledlockedfieldhelp'] = 'Note: Disabled check boxes are for profile ...@@ -694,6 +696,27 @@ $string['disabledlockedfieldhelp'] = 'Note: Disabled check boxes are for profile
$string['defaultinstitutionquotadescription'] = 'You can set the amount of disk space new users in this institution will have as their quota. Existing users quotas for this institution will not be changed.'; $string['defaultinstitutionquotadescription'] = 'You can set the amount of disk space new users in this institution will have as their quota. Existing users quotas for this institution will not be changed.';
// pending institution registrations
$string['approve'] = 'Approve';
$string['deny'] = 'Deny';
$string['approveregistrationfor'] = 'Approve registration for \'%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?';
$string['nopendingregistrations'] = 'No pending registrations were found for this institution.';
$string['pendingregistration'] = 'Pending registration';
$string['pendingregistrations'] = 'Pending registrations';
$string['pendingregistrationspagedescription'] = '<p>On this page you can see users who have self registered and requested membership of your institution and approve or deny their registration.<p>
<p>On approving their registration you are also adding them as members of the institution and they will be notified with further instructions about activating their account. On denying their registration they will be notified that their application was denied by an automated response email.</p>';
$string['nosuchinstitution'] = 'No such institution.';
$string['registrationapprovedsuccessfully'] = 'Registration approved successfully.';
$string['registrationdeniedreason'] = 'Denial reason';
$string['registrationdeniedreasondesc'] = 'Information as to why the application was denied that might help the user.';
$string['registrationdeniedsuccessful'] = 'Registration denied successfully.';
$string['registrationdeniedunsuccessful'] = 'The attempted registration denial failed.';
$string['registrationreason'] = 'Registration Reason';
// Suspend Institutions // Suspend Institutions
$string['errorwhileunsuspending'] = 'An error occured while trying to unsuspend'; $string['errorwhileunsuspending'] = 'An error occured while trying to unsuspend';
$string['institutionsuspended'] = 'Institution suspended'; $string['institutionsuspended'] = 'Institution suspended';
......
...@@ -301,6 +301,7 @@ $string['accountsuspended'] = 'Your account has been suspended as of %s. The rea ...@@ -301,6 +301,7 @@ $string['accountsuspended'] = 'Your account has been suspended as of %s. The rea
$string['youraccounthasbeensuspended'] = 'Your account has been suspended'; $string['youraccounthasbeensuspended'] = 'Your account has been suspended';
$string['youraccounthasbeenunsuspended'] = 'Your account has been unsuspended'; $string['youraccounthasbeenunsuspended'] = 'Your account has been unsuspended';
$string['changepasswordinfo'] = 'You are required to change your password before you can proceed.'; $string['changepasswordinfo'] = 'You are required to change your password before you can proceed.';
$string['chooseinstitution'] = 'Choose your institution';
$string['chooseusernamepassword'] = 'Choose your username and password'; $string['chooseusernamepassword'] = 'Choose your username and password';
$string['chooseusernamepasswordinfo'] = 'You need a username and password to log in to %s. Please choose them now.'; $string['chooseusernamepasswordinfo'] = 'You need a username and password to log in to %s. Please choose them now.';
$string['confirmpassword'] = 'Confirm password'; $string['confirmpassword'] = 'Confirm password';
......
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
<FIELD NAME="defaultquota" TYPE="int" LENGTH="10" NOTNULL="false"/> <FIELD NAME="defaultquota" TYPE="int" LENGTH="10" NOTNULL="false"/>
<FIELD NAME="showonlineusers" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="2"/> <FIELD NAME="showonlineusers" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="2"/>
<FIELD NAME="allowinstitutionpublicviews" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0"/> <FIELD NAME="allowinstitutionpublicviews" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0"/>
<FIELD NAME="registerconfirm" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1"/>
</FIELDS> </FIELDS>
<KEYS> <KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="name" /> <KEY NAME="primary" TYPE="primary" FIELDS="name" />
...@@ -551,6 +552,8 @@ ...@@ -551,6 +552,8 @@
<FIELD NAME="lang" TYPE="text" NOTNULL="false"/> <FIELD NAME="lang" TYPE="text" NOTNULL="false"/>
<FIELD NAME="key" TYPE="char" LENGTH="16" NOTNULL="true"/> <FIELD NAME="key" TYPE="char" LENGTH="16" NOTNULL="true"/>
<FIELD NAME="expiry" TYPE="datetime" NOTNULL="true"/> <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"/>
</FIELDS> </FIELDS>
<KEYS> <KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" /> <KEY NAME="primary" TYPE="primary" FIELDS="id" />
......
...@@ -2450,5 +2450,23 @@ function xmldb_core_upgrade($oldversion=0) { ...@@ -2450,5 +2450,23 @@ function xmldb_core_upgrade($oldversion=0) {
} }
} }
if ($oldversion < 2011062400) {
// self-registration per institution confrimation setting
$table = new XMLDBTable('institution');
$field = new XMLDBField('registerconfirm');
$field->setAttributes(XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 1);
add_field($table, $field);
$table = new XMLDBTable('usr_registration');
$field = new XMLDBField('pending');
$field->setAttributes(XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 0);
add_field($table, $field);
$table = new XMLDBTable('usr_registration');
$field = new XMLDBField('reason');
$field->setAttributes(XMLDB_TYPE_TEXT);
add_field($table, $field);
}
return $status; return $status;
} }
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
defined('INTERNAL') || die(); defined('INTERNAL') || die();
$config = new StdClass; $config = new StdClass;
$config->version = 2011062300; $config->version = 2011062400;
$config->release = '1.5.0dev'; $config->release = '1.5.0dev';
$config->minupgradefrom = 2008040200; $config->minupgradefrom = 2008040200;
$config->minupgraderelease = '1.0.0 (release tag 1.0.0_RELEASE)'; $config->minupgraderelease = '1.0.0 (release tag 1.0.0_RELEASE)';
......
...@@ -1837,6 +1837,12 @@ function admin_nav() { ...@@ -1837,6 +1837,12 @@ function admin_nav() {
'title' => get_string('Files', 'artefact.file'), 'title' => get_string('Files', 'artefact.file'),
'weight' => 70, 'weight' => 70,
), ),
'manageinstitutions/pendingregistrations' => array(
'path' => 'manageinstitutions/pendingregistrations',
'url' => 'admin/users/pendingregistrations.php',
'title' => get_string('pendingregistrations', 'admin'),
'weight' => 80,
),
'configextensions' => array( 'configextensions' => array(
'path' => 'configextensions', 'path' => 'configextensions',
'url' => 'admin/extensions/plugins.php', 'url' => 'admin/extensions/plugins.php',
...@@ -1952,6 +1958,12 @@ function institutional_admin_nav() { ...@@ -1952,6 +1958,12 @@ function institutional_admin_nav() {
'title' => get_string('Files', 'artefact.file'), 'title' => get_string('Files', 'artefact.file'),
'weight' => 80, 'weight' => 80,
), ),
'manageinstitutions/pendingregistrations' => array(
'path' => 'manageinstitutions/pendingregistrations',
'url' => 'admin/users/pendingregistrations.php',
'title' => get_string('pendingregistrations', 'admin'),
'weight' => 90,
),
); );
} }
......
...@@ -33,6 +33,7 @@ define('SECTION_PAGE', 'register'); ...@@ -33,6 +33,7 @@ define('SECTION_PAGE', 'register');
require('init.php'); require('init.php');
require_once('pieforms/pieform.php'); require_once('pieforms/pieform.php');
require_once('lib/antispam.php'); require_once('lib/antispam.php');
require_once('lib/institution.php');
define('TITLE', get_string('register')); define('TITLE', get_string('register'));
$key = param_alphanum('key', null); $key = param_alphanum('key', null);
...@@ -66,6 +67,53 @@ if (!empty($_SESSION['registered'])) { ...@@ -66,6 +67,53 @@ if (!empty($_SESSION['registered'])) {
die_info(get_string('registeredok', 'auth.internal')); die_info(get_string('registeredok', 'auth.internal'));
} }
if (!empty($_SESSION['registrationcancelled'])) {
unset($_SESSION['registrationcancelled']);
die_info(get_string('registrationcancelledok', 'auth.internal'));
}
// email confirmed, show them a screen telling them this.
if (!empty($_SESSION['emailconfirmed'])) {
// email institutional administrator(s) of new registration
if (isset($_SESSION['registrationkey'])) {
$key = $_SESSION['registrationkey'];
if ($registration = get_record_select('usr_registration', '"key" = ? AND "pending" = ?', array($key, 1))) {
$fullname = sprintf("%s %s", trim($registration->firstname), trim($registration->lastname));
$institution = new Institution($registration->institution);
$pendingregistrationslink = sprintf("%sadmin/users/pendingregistrations.php", get_config('wwwroot'));
// list of admins for this institution
if (count($institution->admins()) > 0) {
$admins = $institution->admins();