SF.net SVN: postfixadmin:[1352] trunk
Brought to you by:
christian_boltz,
gingerdog
From: <chr...@us...> - 2012-04-08 22:21:02
|
Revision: 1352 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1352&view=rev Author: christian_boltz Date: 2012-04-08 22:20:55 +0000 (Sun, 08 Apr 2012) Log Message: ----------- list-virtual.php: - use AliasdomainHander instead of doing direct database queries - add search support for alias domains - display "create alias domain" button only if this is possible - always assign $tAliasDomains smarty variable (even if empty) to avoid warnings - always escape $fDomain (even if it comes from $list_domains) - rename $SESSID_USERNAME to $admin_username templates/list-virtual_alias_domain.tpl: - remove reference to non-existing variable $tTargetDomain Modified Paths: -------------- trunk/list-virtual.php trunk/templates/list-virtual_alias_domain.tpl Modified: trunk/list-virtual.php =================================================================== --- trunk/list-virtual.php 2012-04-08 21:25:25 UTC (rev 1351) +++ trunk/list-virtual.php 2012-04-08 22:20:55 UTC (rev 1352) @@ -33,7 +33,7 @@ authentication_require_role('admin'); $fDomain = false; -$SESSID_USERNAME = authentication_get_username(); +$admin_username = authentication_get_username(); if (authentication_has_role('global-admin')) { $list_domains = list_domains (); @@ -69,7 +69,7 @@ if ((is_array ($list_domains) and sizeof ($list_domains) > 0)) { if (empty ($fDomain)) { - $fDomain = $list_domains[0]; + $fDomain = escape_string($list_domains[0]); } } @@ -95,35 +95,29 @@ # alias domain # -# TODO: add search support for alias domains - if (boolconf('alias_domain')) { - $modified_field = 'modified'; - if ('pgsql'==$CONF['database_type']) { # TODO: do we really need the extract(epoch from modified) for pgsql? We ust gmstrftime anyway (see below) - $modified_field = 'extract(epoch from modified) as modified'; + if ($search == "") { + $list_param = "alias_domain='$fDomain' OR target_domain='$fDomain'"; + } else { + $list_param = "alias_domain LIKE '%$search%' OR target_domain LIKE '%$search%'"; } - $query = " - SELECT alias_domain,target_domain,$modified_field,active FROM $table_alias_domain - WHERE alias_domain='$fDomain' OR target_domain='$fDomain' - ORDER BY alias_domain - LIMIT $page_size OFFSET $fDisplay - "; + $handler = new AliasdomainHandler(0, $admin_username); + if ($handler->getList($list_param)) { + $tAliasDomains = $handler->result(); + } else { + $tAliasDomains = array(); + # TODO: check if there was an error or simply no alias domains + } - $result = db_query ($query); - $tAliasDomains = array(); $can_create_alias_domain = 1; - if ($result['rows'] > 0) { - while ($row = db_array ($result['result'])) { - if ('pgsql'==$CONF['database_type']) { - $row['modified']=gmstrftime('%c %Z',$row['modified']); - $row['active']=('t'==$row['active']) ? 1 : 0; - } - $tAliasDomains[] = $row; - if ($row['target_domain'] == $fDomain) $can_create_alias_domain = 0; - } - } - # TODO: set $can_create_alias_domain = 0; if all domains (of this admin) are already used as alias domains + foreach ($tAliasDomains as $row) { + if ($row['alias_domain'] == $fDomain) $can_create_alias_domain = 0; # domain is already an alias domain + } + # set $can_create_alias_domain = 0 if all domains (of this admin) are already used as alias domains + if ($handler->getList("1=1")) { + if ( count($handler->result()) + 1 >= count($list_domains) ) $can_create_alias_domain = 0; # all domains (of this admin) are already alias domains + } } # @@ -303,7 +297,7 @@ if ((is_array ($tAlias) and sizeof ($tAlias) > 0)) for ($i = 0; $i < sizeof ($tAlias); $i++) { $gen_show_status [$i] = gen_show_status($tAlias[$i]['address']); - $check_alias_owner [$i] = check_alias_owner($SESSID_USERNAME, $tAlias[$i]['address']); + $check_alias_owner [$i] = check_alias_owner($admin_username, $tAlias[$i]['address']); } $gen_show_status_mailbox = array (); @@ -448,9 +442,7 @@ $smarty->assign ('tDisplay_next_show', $tDisplay_next_show); $smarty->assign ('tDisplay_next', $tDisplay_next); -if(sizeof ($tAliasDomains) > 0) - $smarty->assign ('tAliasDomains', $tAliasDomains); - +$smarty->assign ('tAliasDomains', $tAliasDomains); $smarty->assign ('can_create_alias_domain', $can_create_alias_domain); $smarty->assign ('tAlias', $tAlias); $smarty->assign ('gen_show_status', $gen_show_status, false); Modified: trunk/templates/list-virtual_alias_domain.tpl =================================================================== --- trunk/templates/list-virtual_alias_domain.tpl 2012-04-08 21:25:25 UTC (rev 1351) +++ trunk/templates/list-virtual_alias_domain.tpl 2012-04-08 22:20:55 UTC (rev 1352) @@ -3,7 +3,7 @@ <tr> <th colspan="6">{$PALANG.pOverview_alias_domain_title}</th> </tr> - {if $tAliasDomains|@count>0 || $tTargetDomain|@count>1} + {if $tAliasDomains|@count>0} {if $tAliasDomains|@count>0} {* -> HAT alias-domains *} {#tr_header#} <td>{$PALANG.pOverview_alias_address}</td> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |