diff --git a/list-virtual.php b/list-virtual.php index e4ca3611..6f60875c 100644 --- a/list-virtual.php +++ b/list-virtual.php @@ -89,10 +89,11 @@ $_SESSION['list-virtual:limit'] = $fDisplay; if (Config::bool('alias_domain')) { $handler = new AliasdomainHandler(0, $admin_username); + $formconf = $handler->webformConfig(); # might change struct $aliasdomain_data = array( 'struct' => $handler->getStruct(), 'msg' => $handler->getMsg(), - 'formconf' => $handler->webformConfig(), + 'formconf' => $formconf, ); $aliasdomain_data['msg']['show_simple_search'] = False; # hide search box @@ -142,6 +143,16 @@ if (count($search) == 0 || !isset($search['_'])) { } $handler = new AliasHandler(0, $admin_username); +$formconf = $handler->webformConfig(); # might change struct +$alias_data = array( + 'formconf' => $formconf, + 'struct' => $handler->getStruct(), + 'msg' => $handler->getMsg(), +); +$alias_data['struct']['goto_mailbox']['display_in_list'] = 0; # not useful/defined for non-mailbox aliases +$alias_data['struct']['on_vacation']['display_in_list'] = 0; +$alias_data['msg']['show_simple_search'] = False; # hide search box + $handler->getList($list_param, array(), $page_size, $fDisplay); $pagebrowser_alias = $handler->getPagebrowser($list_param, array()); $tAlias = $handler->result(); @@ -241,7 +252,7 @@ if ($result['rows'] > 0) { } } -$tCanAddAlias = false; +$alias_data['msg']['can_create'] = false; $tCanAddMailbox = false; $tDisplay_back = ""; @@ -268,11 +279,12 @@ if (isset ($limit)) { } if($limit['aliases'] == 0) { - $tCanAddAlias = true; + $alias_data['msg']['can_create'] = true; } elseif($limit['alias_count'] < $limit['aliases']) { - $tCanAddAlias = true; + $alias_data['msg']['can_create'] = true; } + if($limit['mailboxes'] == 0) { $tCanAddMailbox = true; } @@ -287,14 +299,6 @@ if (isset ($limit)) { } } -$gen_show_status = array (); - -if ((is_array ($tAlias) and sizeof ($tAlias) > 0)) { - foreach (array_keys($tAlias) as $i) { - $gen_show_status [$i] = gen_show_status($tAlias[$i]['address']); - } -} - $gen_show_status_mailbox = array (); $divide_quota = array ('current' => array(), 'quota' => array()); if ((is_array ($tMailbox) and sizeof ($tMailbox) > 0)) { @@ -450,8 +454,8 @@ $smarty->assign ('tAliasDomains', $tAliasDomains); $smarty->assign ('aliasdomain_data', $aliasdomain_data); $smarty->assign ('tAlias', $tAlias); -$smarty->assign ('gen_show_status', $gen_show_status, false); -$smarty->assign ('tCanAddAlias', $tCanAddAlias); +$smarty->assign ('alias_data', $alias_data); + $smarty->assign ('tMailbox', $tMailbox); $smarty->assign ('gen_show_status_mailbox', $gen_show_status_mailbox, false); $smarty->assign ('boolconf_used_quotas', Config::bool('used_quotas')); diff --git a/model/AliasHandler.php b/model/AliasHandler.php index 6a26c1bb..23e08234 100644 --- a/model/AliasHandler.php +++ b/model/AliasHandler.php @@ -27,6 +27,8 @@ class AliasHandler extends PFAHandler { $this->struct=array( # field name allow display in... type $PALANG label $PALANG description default / ... # editing? form list + 'status' => pacol( 0, 0, 0, 'html', '' , '' , '', '', + array('not_in_db' => 1) ), 'address' => pacol( $this->new, 1, 1, 'mail', 'alias' , 'pCreate_alias_catchall_text' ), 'localpart' => pacol( $this->new, 0, 0, 'text', 'alias' , 'pCreate_alias_catchall_text' , '', /*options*/ '', @@ -53,9 +55,9 @@ class AliasHandler extends PFAHandler { 'on_vacation' => pacol( 1, 0, 1, 'bool', 'pUsersMenu_vacation' , '' , 0 , /*options*/ '', /*not_in_db*/ 1 ), # read_from_db_postprocess() sets the value - TODO: read active flag from vacation table instead? - 'active' => pacol( 1, 1, 1, 'bool', 'active' , '' , 1 ), - 'created' => pacol( 0, 0, 1, 'ts', 'created' , '' ), + 'created' => pacol( 0, 0, 0, 'ts', 'created' , '' ), 'modified' => pacol( 0, 0, 1, 'ts', 'last_modified' , '' ), + 'active' => pacol( 1, 1, 1, 'bool', 'active' , '' , 1 ), '_can_edit' => pacol( 0, 0, 1, 'vnum', '' , '' , 0 , '', array('select' => '1 as _can_edit') ), '_can_delete' => pacol( 0, 0, 1, 'vnum', '' , '' , 0 , '', @@ -68,6 +70,7 @@ class AliasHandler extends PFAHandler { $this->msg['error_already_exists'] = 'email_address_already_exists'; $this->msg['error_does_not_exist'] = 'alias_does_not_exist'; $this->msg['confirm_delete'] = 'confirm_delete_alias'; + $this->msg['list_header'] = 'pOverview_alias_title'; if ($this->new) { $this->msg['logname'] = 'create_alias'; @@ -88,6 +91,11 @@ class AliasHandler extends PFAHandler { $this->struct['domain']['display_in_form'] = 1; } + if (Config::bool('show_status')) { + $this->struct['status']['display_in_list'] = 1; + $this->struct['status']['label'] = ' '; + } + return array( # $PALANG labels 'formtitle_create' => 'pMain_create_alias', @@ -286,6 +294,10 @@ class AliasHandler extends PFAHandler { $db_result[$key]['_can_edit'] = 0; $db_result[$key]['_can_delete'] = 0; } + + if ($this->struct['status']['display_in_list'] && Config::Bool('show_status')) { + $db_result[$key]['status'] = gen_show_status($db_result[$key]['address']); + } } return $db_result; diff --git a/templates/list-virtual.tpl b/templates/list-virtual.tpl index 1c4aa28d..73c3cd68 100644 --- a/templates/list-virtual.tpl +++ b/templates/list-virtual.tpl @@ -35,18 +35,8 @@ {*** Aliases ***} {if $tab=='alias' || $tab=='all'} {$nav_bar_alias.top} - - - - - {if $tAlias} - {include file="list-virtual_alias.tpl"} - {/if} -
{$PALANG.pOverview_alias_title}
+ {include file="list-virtual_alias.tpl"} {$nav_bar_alias.bottom} - {if $tCanAddAlias} -
{$PALANG.add_alias}
- {/if} {/if} {if $tab=='all'}
{/if} {if $tab=='mailbox' || $tab=='all'} diff --git a/templates/list-virtual_alias.tpl b/templates/list-virtual_alias.tpl index 5b31d975..4587b7c0 100644 --- a/templates/list-virtual_alias.tpl +++ b/templates/list-virtual_alias.tpl @@ -1,58 +1,10 @@ -{if isset($search._)} - {assign var="search" value=$search._} -{else} - {assign var="search" value=''} -{/if} - - {#tr_header#} - {if $CONF.show_status===YES} - - {/if} - {$PALANG.pOverview_alias_address} - {$PALANG.to} - {$PALANG.last_modified} - {$PALANG.active} -   - - {foreach from=$tAlias item=item key=i} - {#tr_hilightoff#} - {if $CONF.show_status===YES} - {$gen_show_status[$i]} - {/if} - - {if $search eq ""} - {$item.address} - {else} - {$item.address|replace:$search:"$search"} - {/if} - - {if $CONF.alias_goto_limit>0} - sorry, alias_goto_limit > 0 not handled - {else} - - {foreach key=key2 item=singlegoto from=$item.goto} - - {if $search eq ""} - {$singlegoto}
- {else} - {$singlegoto|replace:$search:"$search"}
- {/if} - - {/foreach} - - {/if} - {$item.modified} - {if $item._can_edit} - {if $item.active==1}{$PALANG.YES}{else}{$PALANG.NO}{/if} - {$PALANG.edit} - {$PALANG.del} - {else} - {if $item.active==1}{$PALANG.YES}{else}{$PALANG.NO}{/if} -   -   - {/if} - - {/foreach} +{assign var="table" value='alias'} +{assign var="struct" value=$alias_data.struct} +{assign var="msg" value=$alias_data.msg} +{assign var="id_field" value=$msg.id_field} +{assign var="formconf" value=$alias_data.formconf} +{assign var="items" value=$tAlias} +{assign var="RAW_items" value=$RAW_tAlias} + +{include 'list.tpl'}