From 252ae047d5dad0db60729782d5a1b680641a564f Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Sun, 8 Dec 2013 19:41:01 +0000 Subject: [PATCH] various files: - get rid of global $table_* variables, use table_by_key() instead git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1601 a1433add-5e2c-0410-b055-b7f2511e0802 --- functions.inc.php | 25 +++++++------------------ list-virtual.php | 6 ++++++ scripts/postfixadmin-cli.php | 16 ++-------------- viewlog.php | 1 + 4 files changed, 16 insertions(+), 32 deletions(-) diff --git a/functions.inc.php b/functions.inc.php index e00effa6..22984531 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -538,7 +538,7 @@ function divide_quota ($quota) { // Call: check_owner (string admin, string domain) // function check_owner ($username, $domain) { - global $table_domain_admins; + $table_domain_admins = table_by_key('domain_admins'); $E_username = escape_string($username); $E_domain = escape_string($domain); $result = db_query ("SELECT 1 FROM $table_domain_admins WHERE username='$E_username' AND (domain='$E_domain' OR domain='ALL') AND active='1'"); @@ -580,7 +580,8 @@ function check_alias_owner ($username, $alias) { * @return array of domain names. */ function list_domains_for_admin ($username) { - global $table_domain, $table_domain_admins; + $table_domain = table_by_key('domain'); + $table_domain_admins = table_by_key('domain_admins'); $E_username = escape_string($username); @@ -618,9 +619,9 @@ function list_domains_for_admin ($username) { // Call: list_domains () // function list_domains () { - global $table_domain; $list = array(); + $table_domain = table_by_key('domain'); $result = db_query ("SELECT domain FROM $table_domain WHERE domain!='ALL' ORDER BY domain"); if ($result['rows'] > 0) { $i = 0; @@ -1535,7 +1536,7 @@ function db_rollback () { * Possible actions are defined in $action_list */ function db_log ($domain,$action,$data) { - global $table_log; + $table_log = table_by_key('log'); $REMOTE_ADDR = getRemoteAddr(); $username = authentication_get_username(); @@ -1663,7 +1664,8 @@ function alias_domain_postdeletion($alias_domain) { // Call: gen_show_status (string alias_address) // function gen_show_status ($show_alias) { - global $CONF, $table_alias; + global $CONF; + $table_alias = table_by_key('alias'); $stat_string = ""; $stat_goto = ""; @@ -1753,17 +1755,4 @@ function getRemoteAddr() { return $REMOTE_ADDR; } - - -#$table_admin = table_by_key ('admin'); -$table_alias = table_by_key ('alias'); -#$table_alias_domain = table_by_key ('alias_domain'); -$table_domain = table_by_key ('domain'); -$table_domain_admins = table_by_key ('domain_admins'); -$table_log = table_by_key ('log'); -$table_mailbox = table_by_key ('mailbox'); -$table_vacation = table_by_key ('vacation'); -$table_vacation_notification = table_by_key('vacation_notification'); -$table_quota = table_by_key ('quota'); -$table_quota2 = table_by_key ('quota2'); /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ diff --git a/list-virtual.php b/list-virtual.php index 45c84c2b..8c5d8263 100644 --- a/list-virtual.php +++ b/list-virtual.php @@ -108,6 +108,9 @@ if (Config::bool('alias_domain')) { # aliases # +$table_alias = table_by_key('alias'); +$table_mailbox = table_by_key('mailbox'); + if ($search == "") { $list_param = "domain='$fDomain'"; $sql_domain = " $table_alias.domain='$fDomain' "; @@ -158,16 +161,19 @@ if ($display_mailbox_aliases) { } if (Config::bool('vacation_control_admin')) { + $table_vacation = table_by_key('vacation'); $sql_select .= ", $table_vacation.active AS v_active "; $sql_join .= " LEFT JOIN $table_vacation ON $table_mailbox.username=$table_vacation.email "; } if (Config::bool('used_quotas') && Config::bool('new_quota_table')) { + $table_quota2 = table_by_key('quota2'); $sql_select .= ", $table_quota2.bytes as current "; $sql_join .= " LEFT JOIN $table_quota2 ON $table_mailbox.username=$table_quota2.username "; } if (Config::bool('used_quotas') && ( ! Config::bool('new_quota_table') ) ) { + $table_quota = table_by_key('quota'); $sql_select .= ", $table_quota.current "; $sql_join .= " LEFT JOIN $table_quota ON $table_mailbox.username=$table_quota.username "; $sql_where .= " AND ( $table_quota.path='quota/storage' OR $table_quota.path IS NULL ) "; diff --git a/scripts/postfixadmin-cli.php b/scripts/postfixadmin-cli.php index 028d2b69..00442548 100644 --- a/scripts/postfixadmin-cli.php +++ b/scripts/postfixadmin-cli.php @@ -544,19 +544,7 @@ $dispatcher = new PostfixAdmin($argv); $CONF = Config::read('all'); -//bugfix shitty globals and OOP..... - -#$table_admin = table_by_key ('admin'); -$table_alias = table_by_key ('alias'); -#$table_alias_domain = table_by_key ('alias_domain'); -$table_domain = table_by_key ('domain'); -$table_domain_admins = table_by_key ('domain_admins'); -$table_log = table_by_key ('log'); -$table_mailbox = table_by_key ('mailbox'); -$table_vacation = table_by_key ('vacation'); -$table_vacation_notification = table_by_key('vacation_notification'); -$table_quota = table_by_key ('quota'); -$table_quota2 = table_by_key ('quota2'); - $dispatcher->dispatch(); + +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> diff --git a/viewlog.php b/viewlog.php index 8273f487..a6d4080b 100644 --- a/viewlog.php +++ b/viewlog.php @@ -56,6 +56,7 @@ $tLog = array(); if ($error != 1) { + $table_log = table_by_key('log'); $query = "SELECT timestamp,username,domain,action,data FROM $table_log WHERE domain='$fDomain' ORDER BY timestamp DESC LIMIT 10"; if (db_pgsql()) { $query = "SELECT extract(epoch from timestamp) as timestamp,username,domain,action,data FROM $table_log WHERE domain='$fDomain' ORDER BY timestamp DESC LIMIT 10";