diff --git a/include/class.staff.php b/include/class.staff.php index da2473c0e75d45d05d9d6cf52e05f16c602f3164..38c46b772aa44496181839b558e7c27d561fb234 100644 --- a/include/class.staff.php +++ b/include/class.staff.php @@ -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;