functions.inc.php:

- change list_admins() to use AdminHandler (code from list-admin.php)
  Note: this changes the return value format to include all details, 
  not only the usernames. Use array_keys(list_admins()) if you need
  the previous return format.
 
list-admin.php:
- replace code with a list_admins() call

list-domain.php:
- adopt to new list_admins() return value



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1386 a1433add-5e2c-0410-b055-b7f2511e0802
pull/2/head
Christian Boltz 13 years ago
parent 232cee9d5f
commit 102cb4ed50

@ -266,6 +266,7 @@ function check_domain ($domain) {
* @param String $email - a string that may be an email address. * @param String $email - a string that may be an email address.
* @return boolean true if it's an email address, else false. * @return boolean true if it's an email address, else false.
* TODO: make check_email able to handle already added domains * TODO: make check_email able to handle already added domains
* TODO: don't use flash_error, use return value instead
*/ */
function check_email ($email) { function check_email ($email) {
global $CONF; global $CONF;
@ -857,18 +858,15 @@ function domain_exist ($domain) {
// was admin_list_admins // was admin_list_admins
// //
function list_admins () { function list_admins () {
# TODO: use AdminHandler $handler = new AdminHandler();
global $table_admin;
$list = "";
$result = db_query ("SELECT username FROM $table_admin ORDER BY username"); if ($handler->getList('1=1')) {
if ($result['rows'] > 0) { $list = $handler->result();
$i = 0; } else {
while ($row = db_array ($result['result'])) { $list = array();
$list[$i] = $row['username']; # TODO: check if there was an error or simply no admins (which shouldn't happen because nobody could login then...)
$i++;
}
} }
return $list; return $list;
} }

@ -25,15 +25,7 @@ require_once("common.php");
authentication_require_role('global-admin'); authentication_require_role('global-admin');
# TODO: move code to list_admins() in functions.inc.php? $admin_properties = list_admins();
$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...)
}
$smarty->assign ('admin_properties', $admin_properties); $smarty->assign ('admin_properties', $admin_properties);
$smarty->assign ('smarty_template', 'adminlistadmin'); $smarty->assign ('smarty_template', 'adminlistadmin');

@ -27,7 +27,7 @@ $is_superadmin = 0;
$fUsername = ""; $fUsername = "";
if (authentication_has_role('global-admin')) { # more permissions? Fine! if (authentication_has_role('global-admin')) { # more permissions? Fine!
$list_admins = list_admins (); $list_admins = array_keys(list_admins());
$is_superadmin = 1; $is_superadmin = 1;
$fUsername = safepost('fUsername', safeget('username', authentication_get_username())); # prefer POST over GET variable $fUsername = safepost('fUsername', safeget('username', authentication_get_username())); # prefer POST over GET variable

Loading…
Cancel
Save