Skip to content
Snippets Groups Projects
Commit e7d20033 authored by Jared Hancock's avatar Jared Hancock
Browse files

staff: Ensure an active admin always exists

parent 9c9bfae1
No related branches found
No related tags found
No related merge requests found
......@@ -774,6 +774,20 @@ class Staff extends AuthenticatedUser {
if(!$vars['timezone_id'])
$errors['timezone_id']=__('Time zone selection is required');
// Ensure we will still have an administrator with access
if ($vars['isadmin'] !== '1' || $vars['isactive'] !== '1') {
$sql = 'select count(*), max(staff_id) from '.STAFF_TABLE
.' WHERE isadmin=1 and isactive=1';
if (($res = db_query($sql))
&& (list($count, $sid) = db_fetch_row($res))) {
if ($count == 1 && $sid = $id) {
$errors['isadmin'] = __(
'Cowardly refusing to remove or lock out the only active administrator'
);
}
}
}
if($errors) return false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment