Commit 40d6505f authored by Evan Goldenberg's avatar Evan Goldenberg
Browse files

still show that the institution is suspended, even if the user is not


admin (thanks, Ruslan) (bug #525778)
Signed-off-by: default avatarEvan Goldenberg <evang@catalyst.net.nz>
parent e33d4d1c
......@@ -525,83 +525,85 @@ function institution_cancel_submit() {
redirect('/admin/users/institutions.php');
}
if ($USER->get('admin') && $institution && $institution != 'mahara') {
function institution_suspend_submit(Pieform $form, $values) {
global $SESSION, $USER;
if (!$USER->get('admin')) {
$SESSION->add_error_msg(get_string('errorwhilesuspending', 'admin'));
if ($institution && $institution != 'mahara') {
$_institution = get_record('institution', 'name', $institution);
$suspended = $_institution->suspended;
if ($USER->get('admin')) {
function institution_suspend_submit(Pieform $form, $values) {
global $SESSION, $USER;
if (!$USER->get('admin')) {
$SESSION->add_error_msg(get_string('errorwhilesuspending', 'admin'));
}
else {
set_field('institution', 'suspended', 1, 'name', $values['i']);
$SESSION->add_ok_msg(get_string('institutionsuspended', 'admin'));
}
redirect('/admin/users/institutions.php?i=' . $values['i']);
}
else {
set_field('institution', 'suspended', 1, 'name', $values['i']);
$SESSION->add_ok_msg(get_string('institutionsuspended', 'admin'));
function institution_unsuspend_submit(Pieform $form, $values) {
global $SESSION, $USER;
if (!$USER->get('admin')) {
$SESSION->add_error_msg(get_string('errorwhileunsuspending', 'admin'));
}
else {
set_field('institution', 'suspended', 0, 'name', $values['i']);
$SESSION->add_ok_msg(get_string('institutionunsuspended', 'admin'));
}
redirect('/admin/users/institutions.php?i=' . $values['i']);
}
redirect('/admin/users/institutions.php?i=' . $values['i']);
}
function institution_unsuspend_submit(Pieform $form, $values) {
global $SESSION, $USER;
if (!$USER->get('admin')) {
$SESSION->add_error_msg(get_string('errorwhileunsuspending', 'admin'));
// Suspension controls
if (empty($suspended)) {
$suspendformdef = array(
'name' => 'institution_suspend',
'plugintype' => 'core',
'pluginname' => 'admin',
'elements' => array(
'i' => array(
'type' => 'hidden',
'value' => $institution,
),
'submit' => array(
'type' => 'submit',
'value' => get_string('suspendinstitution','admin'),
'description' => get_string('suspendinstitutiondescription','admin'),
),
)
);
$suspendform = pieform($suspendformdef);
}
else {
set_field('institution', 'suspended', 0, 'name', $values['i']);
$SESSION->add_ok_msg(get_string('institutionunsuspended', 'admin'));
$suspendformdef = array(
'name' => 'institution_unsuspend',
'plugintype' => 'core',
'pluginname' => 'admin',
'elements' => array(
'i' => array(
'type' => 'hidden',
'value' => $institution,
),
'submit' => array(
'type' => 'submit',
'value' => get_string('unsuspendinstitution','admin'),
'description' => get_string('unsuspendinstitutiondescription','admin'),
),
)
);
$suspendform = pieform($suspendformdef);
// Create a second forms for unsuspension to go in the suspend message.
// This keeps the HTML IDs unique
$suspendformdef['name'] = 'institution_unsuspend_top';
$suspendformdef['renderer'] = 'oneline';
$suspendformdef['successcallback'] = 'institution_unsuspend_submit';
$suspendform_top = pieform($suspendformdef);
}
$smarty->assign('suspendform', $suspendform);
if (isset($suspendform_top)) {
$smarty->assign('suspendform_top', $suspendform_top);
}
redirect('/admin/users/institutions.php?i=' . $values['i']);
}
$_institution = get_record('institution', 'name', $institution);
// Suspension controls
$suspended = $_institution->suspended;
if (empty($suspended)) {
$suspendformdef = array(
'name' => 'institution_suspend',
'plugintype' => 'core',
'pluginname' => 'admin',
'elements' => array(
'i' => array(
'type' => 'hidden',
'value' => $institution,
),
'submit' => array(
'type' => 'submit',
'value' => get_string('suspendinstitution','admin'),
'description' => get_string('suspendinstitutiondescription','admin'),
),
)
);
$suspendform = pieform($suspendformdef);
}
else {
$suspendformdef = array(
'name' => 'institution_unsuspend',
'plugintype' => 'core',
'pluginname' => 'admin',
'elements' => array(
'i' => array(
'type' => 'hidden',
'value' => $institution,
),
'submit' => array(
'type' => 'submit',
'value' => get_string('unsuspendinstitution','admin'),
'description' => get_string('unsuspendinstitutiondescription','admin'),
),
)
);
$suspendform = pieform($suspendformdef);
// Create a second forms for unsuspension to go in the suspend message.
// This keeps the HTML IDs unique
$suspendformdef['name'] = 'institution_unsuspend_top';
$suspendformdef['renderer'] = 'oneline';
$suspendformdef['successcallback'] = 'institution_unsuspend_submit';
$suspendform_top = pieform($suspendformdef);
}
$smarty->assign('suspendform', $suspendform);
if (isset($suspendform_top)) {
$smarty->assign('suspendform_top', $suspendform_top);
}
if ($suspended) {
$smarty->assign('suspended', get_string('suspendedinstitutionmessage', 'admin'));
......
......@@ -556,7 +556,7 @@ $string['suspendedinstitutionmessage'] = 'This institution has been suspended';
$string['unsuspendinstitution'] = 'Unsuspend Institution';
$string['unsuspendinstitutiondescription'] = 'Here you may unsuspend an institution. Users of suspended institutions will be unable to log in until the institution is unsuspended.<br /><strong>Beware:</strong> Unsuspending an institution without resetting or turning off its expiry date may result in a daily re-suspension.';
$string['unsuspendinstitutiondescription_top'] = '<em>Beware:</em> Unsuspending an institution without resetting or turning off its expiry date may result in a daily re-suspension.';
$string['unsuspendinstitutiondescription_top_instadmin'] = 'Users of suspended institutions are unable to log in. Contact site administrator to unsuspend the institution.';
// Admin User Search
$string['Query'] = 'Query';
......
......@@ -11,7 +11,11 @@
<div class="message">
<h4>{$suspended|escape}</h4>
<div id="suspendedhelp">
{if $USER->get('admin')}
<p class="description">{str tag="unsuspendinstitutiondescription_top" section="admin"}</p>
{else}
<p class="description">{str tag="unsuspendinstitutiondescription_top_instadmin" section="admin"}</p>
{/if}
</div>
<div class="center">{$suspendform_top}</div>
</div>
......
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