merged overview.php into list-domain.php and list-virtual.php
list-domain.php: - added several admin/superadmin switches and permission checks - merged GET and POST code - Note: still different templates for superadmins (admin_list-domain.tpl) and admins (overview-get.tpl) because of large layout difference list-virtual.php: - added several admin/superadmin switches and permission checks - added check for admins without any domains (redirects to domain list, which can handle this situation) - migrated FIXME from overview.php -> David, please review the query and remove the FIXME afterwards overview.php: - DELETED - no longer needed overview.tpl: - RENAMED overview.tpl to list-virtual.tpl - removed admin/superadmin filename switch - removed $incpath switch for images menu.tpl: - menu for domain admins now has "domain list" and "virtual list" instead of "overview" delete.php, edit-active.php, edit-alias.php, edit-mailbox.php, search.php: - changed redirect to list-virtual.php overview-get.tpl: - changed link to list-virtual.php main.tpl: - changed overview link to list-domain.php git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@181 a1433add-5e2c-0410-b055-b7f2511e0802postfixadmin-2.3
parent
ef7b6f0925
commit
c51b27a9c9
@ -1,249 +0,0 @@
|
||||
<?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://www.postfixadmin.com or http://postfixadmin.sf.net
|
||||
*
|
||||
* @version $Id$
|
||||
* @license GNU GPL v2 or later.
|
||||
*
|
||||
* File: overview.php
|
||||
* Shows an overview for admins.
|
||||
*
|
||||
* Template File: overview.tpl
|
||||
*
|
||||
* Template Variables:
|
||||
*
|
||||
* tAlias
|
||||
* tDomain
|
||||
* tMailbox
|
||||
* tDisplay_back
|
||||
* tDisplay_next
|
||||
*
|
||||
* Form POST \ GET Variables:
|
||||
*
|
||||
* domain
|
||||
* fDomain
|
||||
* limit
|
||||
*/
|
||||
|
||||
require_once('common.php');
|
||||
|
||||
authentication_require_role('admin');
|
||||
|
||||
$SESSID_USERNAME = authentication_get_username();
|
||||
|
||||
if(authentication_has_role('global-admin')) {
|
||||
$list_domains = list_domains ();
|
||||
}
|
||||
else {
|
||||
$list_domains = list_domains_for_admin ($SESSID_USERNAME);
|
||||
}
|
||||
|
||||
$tAlias = array();
|
||||
$tMailbox = array();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET")
|
||||
{
|
||||
$fDisplay = 0;
|
||||
$page_size = $CONF['page_size'];
|
||||
|
||||
if (isset ($_GET['domain'])) $fDomain = escape_string ($_GET['domain']);
|
||||
if (isset ($_GET['limit'])) $fDisplay = escape_string ($_GET['limit']);
|
||||
|
||||
$limit = get_domain_properties ($fDomain);
|
||||
|
||||
$limitSql=('pgsql'==$CONF['database_type']) ? "$page_size OFFSET $fDisplay" : "$fDisplay, $page_size";
|
||||
|
||||
if (check_owner ($SESSID_USERNAME, $fDomain))
|
||||
{
|
||||
$tCanAddAlias = 1; # TODO: workaround for undefined variable
|
||||
$tCanAddMailbox = 1; # TODO: workaround for undefined variable
|
||||
|
||||
$query = "SELECT $table_alias.address,$table_alias.goto,$table_alias.modified,$table_alias.active FROM $table_alias LEFT JOIN $table_mailbox ON $table_alias.address=$table_mailbox.username WHERE $table_alias.domain='$fDomain' AND $table_mailbox.maildir IS NULL ORDER BY $table_alias.address LIMIT $limitSql";
|
||||
if ('pgsql'==$CONF['database_type'])
|
||||
{
|
||||
$query = "SELECT address,goto,extract(epoch from modified) as modified,active FROM $table_alias WHERE domain='$fDomain' AND NOT EXISTS(SELECT 1 FROM $table_mailbox WHERE username=$table_alias.address) ORDER BY address LIMIT $limitSql";
|
||||
}
|
||||
|
||||
$result = db_query ($query);
|
||||
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;
|
||||
}
|
||||
$tAlias[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
if ($CONF['vacation_control_admin'] == 'YES')
|
||||
{
|
||||
$query = ("SELECT $table_mailbox.*, $table_vacation.active AS v_active FROM $table_mailbox LEFT JOIN $table_vacation ON $table_mailbox.username=$table_vacation.email WHERE $table_mailbox.domain='$fDomain' ORDER BY $table_mailbox.username LIMIT $limitSql");
|
||||
if ('pgsql'==$CONF['database_type'])
|
||||
{
|
||||
//FIXME: postgres query needs to be rewrited
|
||||
$query = "SELECT *,extract(epoch from created) as uts_created,extract(epoch from modified) as uts_modified FROM $table_mailbox WHERE domain='$fDomain' ORDER BY username LIMIT $limitSql";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$query = "SELECT * FROM $table_mailbox WHERE domain='$fDomain' ORDER BY username LIMIT $limitSql";
|
||||
if ('pgsql'==$CONF['database_type'])
|
||||
{
|
||||
$query = "SELECT *,extract(epoch from created) as uts_created,extract(epoch from modified) as uts_modified FROM $table_mailbox WHERE domain='$fDomain' ORDER BY username LIMIT $limitSql";
|
||||
}
|
||||
}
|
||||
|
||||
$result = db_query ($query);
|
||||
if ($result['rows'] > 0)
|
||||
{
|
||||
while ($row = db_array ($result['result']))
|
||||
{
|
||||
if ('pgsql'==$CONF['database_type'])
|
||||
{
|
||||
$row['created']=gmstrftime('%c %Z',$row['uts_created']);
|
||||
$row['modified']=gmstrftime('%c %Z',$row['uts_modified']);
|
||||
$row['active']=('t'==$row['active']) ? 1 : 0;
|
||||
if(isset($row['v_active'])) {
|
||||
$row['v_active']=('t'==$row['v_active']) ? 1 : 0;
|
||||
}
|
||||
else {
|
||||
$row['v_active'] = -1 ; //unknown; broken query above..
|
||||
}
|
||||
unset($row['uts_created']);
|
||||
unset($row['uts_modified']);
|
||||
}
|
||||
$tMailbox[] = $row;
|
||||
}
|
||||
}
|
||||
$template = "overview.tpl";
|
||||
}
|
||||
else
|
||||
{
|
||||
$template = "overview-get.tpl";
|
||||
}
|
||||
|
||||
$tDomain = $fDomain;
|
||||
|
||||
if (isset ($limit))
|
||||
{
|
||||
if ($fDisplay >= $page_size)
|
||||
{
|
||||
$tDisplay_back_show = 1;
|
||||
$tDisplay_back = $fDisplay - $page_size;
|
||||
}
|
||||
if (($limit['alias_count'] > $page_size) or ($limit['mailbox_count'] > $page_size))
|
||||
{
|
||||
$tDisplay_up_show = 1;
|
||||
}
|
||||
if ((($fDisplay + $page_size) < $limit['alias_count']) or (($fDisplay + $page_size) < $limit['mailbox_count']))
|
||||
{
|
||||
$tDisplay_next_show = 1;
|
||||
$tDisplay_next = $fDisplay + $page_size;
|
||||
}
|
||||
}
|
||||
|
||||
include ("./templates/header.tpl");
|
||||
include ("./templates/menu.tpl");
|
||||
include ("./templates/$template");
|
||||
include ("./templates/footer.tpl");
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
{
|
||||
$fDisplay = 0;
|
||||
$page_size = $CONF['page_size'];
|
||||
|
||||
if (isset ($_POST['limit'])) $fDisplay = escape_string ($_POST['limit']);
|
||||
if (isset ($_POST['domain'])) $fDomain = escape_string ($_POST['fDomain']);
|
||||
|
||||
if (check_owner ($SESSID_USERNAME, escape_string ($_POST['fDomain'])))
|
||||
{
|
||||
$limitSql=('pgsql'==$CONF['database_type']) ? "$page_size OFFSET $fDisplay" : "$fDisplay, $page_size";
|
||||
|
||||
if ($CONF['alias_control_admin'] == "YES")
|
||||
{
|
||||
$query = "SELECT address,goto,modified,active FROM $table_alias WHERE domain='$fDomain' ORDER BY address LIMIT $limitSql";
|
||||
if ('pgsql'==$CONF['database_type'])
|
||||
{
|
||||
$query = "SELECT address,goto,extract(epoch from modified) as modified,active FROM $table_alias WHERE domain='$fDomain' ORDER BY address LIMIT $limitSql";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$query = "SELECT $table_alias.address,$table_alias.goto,$table_alias.modified,$table_alias.active FROM $table_alias LEFT JOIN $table_mailbox ON $table_alias.address=$table_mailbox.username WHERE $table_alias.domain='$fDomain' AND $table_mailbox.maildir IS NULL ORDER BY $table_alias.address LIMIT $limitSql";
|
||||
if ('pgsql'==$CONF['database_type'])
|
||||
{
|
||||
$query="SELECT address,goto,extract(epoch from modified) as modified,active FROM $table_alias WHERE domain='$fDomain' AND NOT EXISTS(SELECT 1 FROM $table_mailbox WHERE username=$table_alias.address) ORDER BY address LIMIT $limitSql";
|
||||
}
|
||||
}
|
||||
|
||||
$result = db_query ("$query");
|
||||
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;
|
||||
}
|
||||
$tAlias[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
$query = "SELECT * FROM $table_mailbox WHERE domain='$fDomain' ORDER BY username LIMIT $limitSql";
|
||||
if ('pgsql'==$CONF['database_type'])
|
||||
{
|
||||
$query = "SELECT *,,extract(epoch from created) as uts_created,extract(epoch from modified) as uts_modified FROM $table_mailbox WHERE domain='$fDomain' ORDER BY username LIMIT $limitSql";
|
||||
}
|
||||
$result = db_query ($query);
|
||||
if ($result['rows'] > 0)
|
||||
{
|
||||
while ($row = db_array ($result['result']))
|
||||
{
|
||||
if ('pgsql'==$CONF['database_type'])
|
||||
{
|
||||
$row['created']=gmstrftime('%c %Z',$row['uts_created']);
|
||||
$row['modified']=gmstrftime('%c %Z',$row['uts_modified']);
|
||||
$row['active']=('t'==$row['active']) ? 1 : 0;
|
||||
}
|
||||
$tMailbox[] = $row;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset ($limit))
|
||||
{
|
||||
if ($fDisplay >= $page_size)
|
||||
{
|
||||
$tDisplay_back_show = 1;
|
||||
$tDisplay_back = $fDisplay - $page_size;
|
||||
}
|
||||
if (($limit['alias_count'] > $page_size) or ($limit['mailbox_count'] > $page_size))
|
||||
{
|
||||
$tDisplay_up_show = 1;
|
||||
}
|
||||
if ((($fDisplay + $page_size) < $limit['alias_count']) or (($fDisplay + $page_size) < $limit['mailbox_count']))
|
||||
{
|
||||
$tDisplay_next_show = 1;
|
||||
$tDisplay_next = $fDisplay + $page_size;
|
||||
}
|
||||
}
|
||||
|
||||
include ("./templates/header.tpl");
|
||||
include ("./templates/menu.tpl");
|
||||
include ("./templates/overview.tpl");
|
||||
include ("./templates/footer.tpl");
|
||||
}
|
||||
/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
|
||||
?>
|
Loading…
Reference in New Issue