add list.php and list.tpl - generic files to display lists
(will replace list-admin, list-domain etc.) list.php: - generic list view, select *Handler with ?table= list.tpl: - display list view - columns based on $struct (every column with display_in_list and non-empty label will be displayed) git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1722 a1433add-5e2c-0410-b055-b7f2511e0802pull/2/head
parent
1ad0d6832b
commit
b5a6417a6e
@ -0,0 +1,67 @@
|
||||
<?php /**
|
||||
* Postfix Admin
|
||||
*
|
||||
* LICENSE
|
||||
* This source file is subject to the GPL license that is bundled with
|
||||
* this package in the file LICENSE.TXT.
|
||||
*
|
||||
* Further details on the project are available at http://postfixadmin.sf.net
|
||||
*
|
||||
* @version $Id$
|
||||
* @license GNU GPL v2 or later.
|
||||
*
|
||||
* File: list.php
|
||||
* List all items as a quick overview.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once('common.php');
|
||||
|
||||
# if (safeget('token') != $_SESSION['PFA_token']) die('Invalid token!');
|
||||
|
||||
$username = authentication_get_username(); # enforce login
|
||||
|
||||
$table = safeget('table');
|
||||
|
||||
$handlerclass = ucfirst($table) . 'Handler';
|
||||
|
||||
if ( !preg_match('/^[a-z]+$/', $table) || !file_exists("model/$handlerclass.php")) { # validate $table
|
||||
die ("Invalid table name given!");
|
||||
}
|
||||
|
||||
# default: domain admin restrictions
|
||||
$list_admins = array($username);
|
||||
$is_superadmin = 0;
|
||||
|
||||
if (authentication_has_role('global-admin')) { # more permissions? Fine!
|
||||
$list_admins = array_keys(list_admins());
|
||||
$is_superadmin = 1;
|
||||
$username = safepost('username', safeget('username', authentication_get_username())); # prefer POST over GET variable
|
||||
}
|
||||
|
||||
$handler = new $handlerclass(0, $username);
|
||||
|
||||
$formconf = $handler->webformConfig();
|
||||
|
||||
authentication_require_role($formconf['required_role']);
|
||||
|
||||
$handler->getList('');
|
||||
$items = $handler->result();
|
||||
|
||||
$smarty->assign ('select_options', select_options($list_admins, array ($fUsername)), false);
|
||||
#if ($is_superadmin) {
|
||||
$smarty->assign('smarty_template', 'list');
|
||||
$smarty->assign('struct', $handler->getStruct());
|
||||
$smarty->assign('msg', $handler->getMsg());
|
||||
$smarty->assign('table', $table);
|
||||
$smarty->assign('items', $items);
|
||||
$smarty->assign('id_field', $handler->getId_field());
|
||||
$smarty->assign('formconf', $formconf);
|
||||
#} else {
|
||||
# $smarty->assign ('smarty_template', 'overview-get');
|
||||
#}
|
||||
|
||||
$smarty->display ('index.tpl');
|
||||
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
?>
|
@ -0,0 +1,68 @@
|
||||
<div id="overview">
|
||||
<form name="frmOverview" method="post" action="">
|
||||
<select name="username" onchange="this.form.submit();">
|
||||
{$select_options}
|
||||
</select>
|
||||
<input class="button" type="submit" name="go" value="{$PALANG.go}" />
|
||||
</form>
|
||||
{#form_search#}
|
||||
</div>
|
||||
|
||||
|
||||
<div id="list">
|
||||
<table border=0 id='admin_table'><!-- TODO: 'admin_table' needed because of CSS for table header -->
|
||||
|
||||
<tr class="header">
|
||||
{foreach key=key item=field from=$struct}
|
||||
{if $field.display_in_list == 1 && $field.label}{* don't show fields without a label *}
|
||||
<td>{$field.label}</td>
|
||||
{/if}
|
||||
{/foreach}
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
|
||||
{foreach from=$items item=item}
|
||||
{#tr_hilightoff#}
|
||||
|
||||
{foreach key=key item=field from=$struct}
|
||||
{if $field.display_in_list == 1 && $field.label}
|
||||
|
||||
{if $table == 'foo' && $key == 'bar'}
|
||||
<td>Special handling (complete table row) for {$table} / {$key}</td></tr>
|
||||
{else}
|
||||
<td>
|
||||
{if $table == 'foo' && $key == 'bar'}
|
||||
Special handling (td content) for {$table} / {$key}
|
||||
{* {elseif $table == 'domain' && $key == 'domain'}
|
||||
<a href="list.php?table=domain&domain={$item.domain|escape:"url"}">{$item.domain}</a>
|
||||
*}
|
||||
{elseif $key == 'active'}
|
||||
<a href="{#url_editactive#}{$table}&id={$item.$id_field|escape:"url"}&active={if ($item.active==0)}1{else}0{/if}&token={$smarty.session.PFA_token|escape:"url"}">{$item._active}</a>
|
||||
{elseif $field.type == 'bool'}
|
||||
{assign "tmpkey" "_{$key}"}{$item.{$tmpkey}}
|
||||
{elseif $field.type == 'list'}
|
||||
{foreach key=key2 item=field2 from=$value_{$key}}<p>{$field2} {/foreach}
|
||||
{elseif $field.type == 'pass'}
|
||||
(hidden)
|
||||
{elseif $field.type == 'txtl'}
|
||||
{foreach key=key2 item=field2 from=$value_{$key}}<p>{$field2} {/foreach}
|
||||
{else}
|
||||
{$item.{$key}}
|
||||
{/if}
|
||||
</td>
|
||||
{/if}
|
||||
{/if}
|
||||
{/foreach}
|
||||
|
||||
<td>{if $item._can_edit}<a href="edit.php?table={$table|escape:"url"}&edit={$item.$id_field|escape:"url"}">{$PALANG.edit}</a>{else} {/if}</td>
|
||||
<td>{if $item._can_delete}<a href="{#url_delete#}?table={$table}&delete={$item.$id_field|escape:"url"}&token={$smarty.session.PFA_token|escape:"url"}"
|
||||
onclick="return confirm ('{$PALANG.{$msg.confirm_delete}|replace:'%s':$item.$id_field}')">{$PALANG.del}</a>{else} {/if}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
|
||||
</table>
|
||||
|
||||
<br /><a href="edit.php?table={$table|escape:"url"}" class="button">{$PALANG.{$formconf.create_button}}</a><br />
|
||||
|
||||
</div>
|
Loading…
Reference in New Issue