From: Michael Slusarz Date: Sun, 14 Feb 2010 21:42:41 +0000 (-0700) Subject: Do array filtering on store, not retrieve X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=4e74a7c2c12e42da8194f041b3fe69dcf3511ecc;p=horde.git Do array filtering on store, not retrieve --- diff --git a/ingo/lib/Api.php b/ingo/lib/Api.php index 0b3596b5e..17b9a3d74 100644 --- a/ingo/lib/Api.php +++ b/ingo/lib/Api.php @@ -29,18 +29,13 @@ class Ingo_Api extends Horde_Registry_Api */ public function blacklistFrom($addresses) { - /* Check for '@' entries in $addresses - this would call all mail to - * be blacklisted which is most likely not what is desired. */ - $addresses = array_flip($addresses); - unset($addresses['@']); - if (!empty($addresses)) { try { $blacklist = $GLOBALS['ingo_storage']->retrieve(Ingo_Storage::ACTION_BLACKLIST); - $blacklist->setBlacklist(array_merge($blacklist->getBlacklist(), array_keys($addresses))); + $blacklist->setBlacklist(array_merge($blacklist->getBlacklist(), $addresses)); $GLOBALS['ingo_storage']->store($blacklist); Ingo::updateScript(); - foreach (array_keys($addresses) as $from) { + foreach ($addresses as $from) { $GLOBALS['notification']->push(sprintf(_("The address \"%s\" has been added to your blacklist."), $from)); } } catch (Ingo_Exception $e) { diff --git a/ingo/lib/Storage/Blacklist.php b/ingo/lib/Storage/Blacklist.php index faf7fe80b..912338dea 100644 --- a/ingo/lib/Storage/Blacklist.php +++ b/ingo/lib/Storage/Blacklist.php @@ -26,7 +26,7 @@ class Ingo_Storage_Blacklist extends Ingo_Storage_Rule */ public function setBlacklist($data, $sort = true) { - $addr = $this->_addressList($data, $sort); + $addr = array_filter($this->_addressList($data, $sort), array('Ingo', 'filterEmptyAddress')); if (!empty($GLOBALS['conf']['storage']['maxblacklist'])) { $addr_count = count($addr); if ($addr_count > $GLOBALS['conf']['storage']['maxblacklist']) { @@ -49,9 +49,7 @@ class Ingo_Storage_Blacklist extends Ingo_Storage_Rule */ public function getBlacklist() { - return empty($this->_addr) - ? array() - : array_filter($this->_addr, array('Ingo', 'filterEmptyAddress')); + return $this->_addr; } /** diff --git a/ingo/lib/Storage/Whitelist.php b/ingo/lib/Storage/Whitelist.php index 6d3218141..9194afcee 100644 --- a/ingo/lib/Storage/Whitelist.php +++ b/ingo/lib/Storage/Whitelist.php @@ -30,8 +30,7 @@ class Ingo_Storage_Whitelist extends Ingo_Storage_Rule */ public function setWhitelist($data, $sort = true) { - $addr = $this->_addressList($data, $sort); - $addr = array_filter($addr, array('Ingo', 'filterEmptyAddress')); + $addr = array_filter($this->_addressList($data, $sort), array('Ingo', 'filterEmptyAddress')); if (!empty($GLOBALS['conf']['storage']['maxwhitelist'])) { $addr_count = count($addr); if ($addr_count > $GLOBALS['conf']['storage']['maxwhitelist']) { @@ -47,9 +46,7 @@ class Ingo_Storage_Whitelist extends Ingo_Storage_Rule */ public function getWhitelist() { - return empty($this->_addr) - ? array() - : array_filter($this->_addr, array('Ingo', 'filterEmptyAddress')); + return $this->_addr; } }