SF.net SVN: postfixadmin:[1386] trunk
Brought to you by:
christian_boltz,
gingerdog
From: <chr...@us...> - 2012-05-07 22:53:10
|
Revision: 1386 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1386&view=rev Author: christian_boltz Date: 2012-05-07 22:53:04 +0000 (Mon, 07 May 2012) Log Message: ----------- 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 Modified Paths: -------------- trunk/functions.inc.php trunk/list-admin.php trunk/list-domain.php Modified: trunk/functions.inc.php =================================================================== --- trunk/functions.inc.php 2012-05-06 20:01:32 UTC (rev 1385) +++ trunk/functions.inc.php 2012-05-07 22:53:04 UTC (rev 1386) @@ -266,6 +266,7 @@ * @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 @@ // 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; } Modified: trunk/list-admin.php =================================================================== --- trunk/list-admin.php 2012-05-06 20:01:32 UTC (rev 1385) +++ trunk/list-admin.php 2012-05-07 22:53:04 UTC (rev 1386) @@ -25,16 +25,8 @@ authentication_require_role('global-admin'); -# TODO: move code to list_admins() in functions.inc.php? -$handler = new AdminHandler(0 /*, $admin_username*/ ); +$admin_properties = list_admins(); -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 ('smarty_template', 'adminlistadmin'); $smarty->display ('index.tpl'); Modified: trunk/list-domain.php =================================================================== --- trunk/list-domain.php 2012-05-06 20:01:32 UTC (rev 1385) +++ trunk/list-domain.php 2012-05-07 22:53:04 UTC (rev 1386) @@ -27,7 +27,7 @@ $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 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |