From 1ec52b4f4a81f2dcd4973514aea7ef225d6991e7 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Tue, 18 Jun 2013 00:18:38 +0200 Subject: [PATCH] Prevent lockouts --- frontend/modules/admin/user/edit.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/frontend/modules/admin/user/edit.php b/frontend/modules/admin/user/edit.php index 45bc91f..9cf61e0 100644 --- a/frontend/modules/admin/user/edit.php +++ b/frontend/modules/admin/user/edit.php @@ -40,6 +40,23 @@ if($router->uMethod == "post") { $sErrors[] = "You did not specify a valid user type."; } + else + { + if($sUser->sAccessLevel == 30 && $_POST['access'] < 30) + { + /* This user is a master admin, check if any other master admins exist before lowering + * the permissions of this one, to prevent lock-outs. */ + + try + { + User::CreateFromQuery("SELECT * FROM users WHERE `AccessLevel` = 30 AND `Id` != :Id", array(":Id" => $sUser->sId), 0); + } + catch (NotFoundException $e) + { + $sErrors[] = "You can't remove your master administrator permissions if no other master administrators exist!"; + } + } + } if(empty($sErrors)) {