diff --git a/functions.inc.php b/functions.inc.php index 187c87f2..6f3b21e7 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -410,7 +410,7 @@ function get_domain_properties ($domain) { die("Error: " . join("\n", $handler->errormsg)); } - $result = $handler->return; + $result = $handler->result(); return $result; } @@ -631,14 +631,8 @@ function list_domains () { function list_admins () { $handler = new AdminHandler(); - if ($handler->getList('1=1')) { - $list = $handler->result(); - } else { - $list = array(); - # TODO: check if there was an error or simply no admins (which shouldn't happen because nobody could login then...) - } - - return $list; + $handler->getList(''); + return $handler->result(); } diff --git a/list-domain.php b/list-domain.php index 8e18c473..60834522 100644 --- a/list-domain.php +++ b/list-domain.php @@ -37,13 +37,8 @@ if (authentication_has_role('global-admin')) { # more permissions? Fine! } $handler = new DomainHandler(0, $admin_username); -if ($handler->getList('1=1')) { - $domain_properties = $handler->result(); -} else { - $domain_properties = array(); - # TODO: check if there was an error or simply no domains -} - +$handler->getList(''); +$domain_properties = $handler->result(); $smarty->assign ('domain_properties', $domain_properties); $smarty->assign ('select_options', select_options($list_admins, array ($fUsername)), false); diff --git a/list-virtual.php b/list-virtual.php index f3f30fba..d2a8daea 100644 --- a/list-virtual.php +++ b/list-virtual.php @@ -103,21 +103,16 @@ if (Config::bool('alias_domain')) { } $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 - } + $handler->getList($list_param); + $tAliasDomains = $handler->result(); $can_create_alias_domain = 1; 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 - } + $handler->getList(""); + if ( count($handler->result()) + 1 >= count($list_domains) ) $can_create_alias_domain = 0; # all domains (of this admin) are already alias domains } # @@ -150,12 +145,8 @@ $query = " */ $handler = new AliasHandler(0, $admin_username); -if ($handler->getList($list_param, $page_size, $fDisplay)) { - $tAlias = $handler->result(); -} else { - $tAlias= array(); - # TODO: check if there was an error or simply no aliases -} +$handler->getList($list_param, $page_size, $fDisplay); +$tAlias = $handler->result(); diff --git a/model/PFAHandler.php b/model/PFAHandler.php index dda3f587..b968e033 100644 --- a/model/PFAHandler.php +++ b/model/PFAHandler.php @@ -513,19 +513,20 @@ abstract class PFAHandler { * @param array or string $condition - see read_from_db for details * @param integer limit - maximum number of rows to return * @param integer offset - number of first row to return - * @return bool - true if at least one item was found + * @return bool - always true, no need to check ;-) (if $result is not an array, getList die()s) * The data is stored in $this->result (as array of rows, each row is an associative array of column => value) */ public function getList($condition, $limit=-1, $offset=-1) { $result = $this->read_from_db($condition, $limit, $offset); - if (count($result) >= 1) { - $this->result = $result; - return true; + + if (!is_array($result)) { + error_log('getList: read_from_db didn\'t return an array. table: ' . $this->db_table . ' - condition: $condition - limit: $limit - offset: $offset'); + error_log('getList: This is most probably caused by read_from_db_postprocess()'); + die('Unexpected error while reading from database! (Please check the error log for details, and open a bugreport)'); } -# $this->errormsg[] = Lang::read($this->msg['error_does_not_exist']); -# $this->errormsg[] = $result['error']; - return false; + $this->result = $result; + return true; }