From 5f99922eb6fbda82da55ccf728eda6add48cb4f1 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sun, 22 May 2016 02:50:17 -0400 Subject: Add function User::getNumAdmins() Function to count the number of admin accounts that exist. This is used to make sure that while deleteing accounts, the number of administrators never drops to zero. --- app/class/user.class.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'app/class/user.class.php') diff --git a/app/class/user.class.php b/app/class/user.class.php index 1d17dfe..07bd0d6 100644 --- a/app/class/user.class.php +++ b/app/class/user.class.php @@ -74,6 +74,16 @@ class User extends Object return $users; } + /* + * Get the number of administrative accounts in the system + */ + function getNumAdmins() + { + $query = "SELECT count(*) as cnt FROM user WHERE admin = 1"; + $results = $this->db->query($query); + return $results[0]['cnt']; + } + /* * Check whether a given username is currently in use */ -- cgit v1.2.3