diff --git a/functions.inc.php b/functions.inc.php index 9005c924..50b9c1a4 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -266,6 +266,7 @@ function check_domain ($domain) { * @param String $email - a string that may be an email address. * @return boolean true if it's an email address, else false. * TODO: make check_email able to handle already added domains + * TODO: don't use flash_error, use return value instead */ function check_email ($email) { global $CONF; @@ -857,18 +858,15 @@ function domain_exist ($domain) { // was admin_list_admins // function list_admins () { - # TODO: use AdminHandler - global $table_admin; - $list = ""; + $handler = new AdminHandler(); - $result = db_query ("SELECT username FROM $table_admin ORDER BY username"); - if ($result['rows'] > 0) { - $i = 0; - while ($row = db_array ($result['result'])) { - $list[$i] = $row['username']; - $i++; - } + if ($handler->getList('1=1')) { + $list = $handler->result(); + } else { + $list = array(); + # TODO: check if there was an error or simply no admins (which shouldn't happen because nobody could login then...) } + return $list; } diff --git a/list-admin.php b/list-admin.php index ea9f576d..a979663a 100644 --- a/list-admin.php +++ b/list-admin.php @@ -25,15 +25,7 @@ require_once("common.php"); authentication_require_role('global-admin'); -# TODO: move code to list_admins() in functions.inc.php? -$handler = new AdminHandler(0 /*, $admin_username*/ ); - -if ($handler->getList('1=1')) { - $admin_properties = $handler->result(); -} else { - $admin_properties = array(); - # TODO: check if there was an error or simply no admins (which shouldn't happen because nobody could login then...) -} +$admin_properties = list_admins(); $smarty->assign ('admin_properties', $admin_properties); $smarty->assign ('smarty_template', 'adminlistadmin'); diff --git a/list-domain.php b/list-domain.php index 66529472..8e18c473 100644 --- a/list-domain.php +++ b/list-domain.php @@ -27,7 +27,7 @@ $is_superadmin = 0; $fUsername = ""; if (authentication_has_role('global-admin')) { # more permissions? Fine! - $list_admins = list_admins (); + $list_admins = array_keys(list_admins()); $is_superadmin = 1; $fUsername = safepost('fUsername', safeget('username', authentication_get_username())); # prefer POST over GET variable