Skip to content
Snippets Groups Projects
Commit 8400b7ad authored by Peter Rotich's avatar Peter Rotich
Browse files

Merge pull request #1569 from greezybacon/issue/1554


staff: Ensure an active admin always exists

Reviewed-By: default avatarPeter Rotich <peter@osticket.com>
parents 101d54e2 e7d20033
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