SF.net SVN: postfixadmin:[1282] trunk
Brought to you by:
christian_boltz,
gingerdog
From: <chr...@us...> - 2011-11-26 01:09:44
|
Revision: 1282 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1282&view=rev Author: christian_boltz Date: 2011-11-26 01:09:38 +0000 (Sat, 26 Nov 2011) Log Message: ----------- list-admin.php: - use AdminHandler - move displaying the superadmin flag to the template templates/adminlistadmin.tpl: - update to the fieldnames provided by AdminHandler (name->username) - move displaying the superadmin flag to the template functions.inc.php: - delete function get_admin_properties() (was only used by list-admin and is not needed anymore) -> 48 lines less :-) - add TODO to list_admins() to use AdminHandler Modified Paths: -------------- trunk/functions.inc.php trunk/list-admin.php trunk/templates/adminlistadmin.tpl Modified: trunk/functions.inc.php =================================================================== --- trunk/functions.inc.php 2011-11-26 00:50:44 UTC (rev 1281) +++ trunk/functions.inc.php 2011-11-26 01:09:38 UTC (rev 1282) @@ -869,6 +869,7 @@ // was admin_list_admins // function list_admins () { + # TODO: use AdminHandler global $table_admin; $list = ""; @@ -886,54 +887,6 @@ // -// get_admin_properties -// Action: Get all the admin properties. -// Call: get_admin_properties (string admin) -// -function get_admin_properties ($username) { - global $CONF; - global $table_admin, $table_domain_admins; - $list = array (); - - $E_username = escape_string($username); - - $result = db_query ("SELECT * FROM $table_domain_admins WHERE username='$E_username' AND domain='ALL'"); - if ($result['rows'] == 1) { - $list['domain_count'] = 'ALL'; - } else { - $result = db_query ("SELECT COUNT(*) FROM $table_domain_admins WHERE username='$E_username'"); - $row = db_row ($result['result']); - $list['domain_count'] = $row[0]; - } - - $query = "SELECT * FROM $table_admin WHERE username='$E_username'"; - if ('pgsql'==$CONF['database_type']) { - $query=" - SELECT - *, - EXTRACT(epoch FROM created) AS uts_created, - EXTRACT (epoch FROM modified) AS uts_modified - FROM $table_admin - WHERE username='$E_username' - "; - } - - $result = db_query ($query); - $row = db_array ($result['result']); - $list['created'] = $row['created']; - $list['modified'] = $row['modified']; - $list['active'] = $row['active']; - if ('pgsql'==$CONF['database_type']) { - $list['active'] = ('t'==$row['active']) ? 1 : 0; - $list['created']= gmstrftime('%c %Z',$row['uts_created']); - $list['modified']= gmstrftime('%c %Z',$row['uts_modified']); - } - return $list; -} - - - -// // encode_header // Action: Encode a string according to RFC 1522 for use in headers if it contains 8-bit characters. // Call: encode_header (string header, string charset) Modified: trunk/list-admin.php =================================================================== --- trunk/list-admin.php 2011-11-26 00:50:44 UTC (rev 1281) +++ trunk/list-admin.php 2011-11-26 01:09:38 UTC (rev 1282) @@ -25,20 +25,16 @@ authentication_require_role('global-admin'); -$_active = array ($PALANG ['NO'], $PALANG ['YES']); +# TODO: move code to list_admins() in functions.inc.php? +$handler = new AdminHandler(0 /*, $admin_username*/ ); -$list_admins = list_admins(); -if ((is_array ($list_admins) and sizeof ($list_admins) > 0)) -{ - for ($i = 0; $i < sizeof ($list_admins); $i++) - { - $admin_properties[$i] = get_admin_properties ($list_admins[$i]); - $admin_properties[$i] ['name'] = $list_admins[$i]; - if ($admin_properties [$i] ['domain_count'] == 'ALL') - $admin_properties [$i] ['domain_count'] = $PALANG ['pAdminEdit_admin_super_admin']; - $admin_properties [$i] ['active'] = $_active [$admin_properties [$i] ['active']]; - } +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/templates/adminlistadmin.tpl =================================================================== --- trunk/templates/adminlistadmin.tpl 2011-11-26 00:50:44 UTC (rev 1281) +++ trunk/templates/adminlistadmin.tpl 2011-11-26 01:09:38 UTC (rev 1282) @@ -9,12 +9,18 @@ </tr> {foreach from=$admin_properties item=admin} {#tr_hilightoff#} - <td><a href="list-domain.php?username={$admin.name|escape:"url"}">{$admin.name}</a></td> - <td>{$admin.domain_count}</td> + <td><a href="list-domain.php?username={$admin.username|escape:"url"}">{$admin.username}</a></td> + <td> + {if $admin.superadmin == 1} + {$PALANG.pAdminEdit_admin_super_admin} + {else} + {$admin.domain_count} + {/if} + </td> <td>{$admin.modified}</td> - <td><a href="{#url_edit_active_admin#}?username={$admin.name|escape:"url"}">{$admin.active}</a></td> - <td><a href="{#url_edit_admin#}?username={$admin.name|escape:"url"}">{$PALANG.edit}</a></td> - <td><a href="{#url_delete#}?table=admin&delete={$admin.name|escape:"url"}" onclick="return confirm ('{$PALANG.confirm}{$PALANG.pAdminList_admin_username}: {$admin.name}');">{$PALANG.del}</a></td> + <td><a href="{#url_edit_active_admin#}?username={$admin.username|escape:"url"}">{$admin._active}</a></td> + <td><a href="{#url_edit_admin#}?username={$admin.username|escape:"url"}">{$PALANG.edit}</a></td> + <td><a href="{#url_delete#}?table=admin&delete={$admin.username|escape:"url"}" onclick="return confirm ('{$PALANG.confirm}{$PALANG.pAdminList_admin_username}: {$admin.username}');">{$PALANG.del}</a></td> </tr> {/foreach} </table> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |