Commit 244db734 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

suspend users uses sendjsonrequest

parent c1af764d
......@@ -29,9 +29,6 @@ define('JSON', 1);
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
json_headers();
json_check_sesskey();
$action = param_variable('action');
$dbprefix = get_config('dbprefix');
......@@ -43,11 +40,10 @@ if ($action == 'suspend') {
suspend_user($id, $reason);
}
catch (MaharaException $e) {
json_reply('suspendfailed', $e->getMessage());
json_reply('local', get_string('suspendfailed', 'admin') . ': ' . $e->getMessage());
}
echo json_encode(array('error' => null));
exit;
json_reply(false, get_string('usersuspended', 'admin'));
}
if ($action == 'search') {
......
......@@ -126,25 +126,12 @@ function suspendSave(reason) {
var data = reason.parentNode.parentNode.previousSibling.data;
removeElement(reason.parentNode.parentNode);
var d = loadJSONDoc('search.json.php', {'action': 'suspend', 'reason': susReason, 'id': data.id, 'sesskey': {$str_sesskey}});
d.addCallbacks(
function(response) {
if(response.error) {
var message = {$str_errorwhilesuspending} + ' "' + data.name + '"';
if (response.message) {
message += ': ' + response.message;
}
displayMessage(message, 'error');
}
else {
displayMessage('User "' + data.name + '" Suspended');
}
},
function(err) {
displayMessage({$str_errorwhilesuspending} + ' "' + data.name + '"', 'error');
}
);
sendjsonrequest('search.json.php', {'action': 'suspend', 'reason': susReason, 'id': data.id}, 'GET',
function(response) {
if(!response.error) {
displayMessage('User "' + data.name + '" Suspended');
}
});
}
function suspendCancel(reason) {
......
......@@ -195,6 +195,7 @@ $string['unsuspendusers'] = 'Unsuspend Users';
$string['usersdeletedsuccessfully'] = 'Users deleted successfully';
$string['usersunsuspendedsuccessfully'] = 'Users unsuspended successfully';
$string['suspendingadmin'] = 'Suspending Admin';
$string['usersuspended'] = 'User suspended';
// Institutions
$string['admininstitutions'] = 'Admininster Institutions';
......
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