/** * Retrieves the specified data from the storage backend. * * @param integer $field The field name of the desired data. * See lib/Storage.php for the available fields. * @param boolean $readonly Whether to disable any write operations. * * @return Ingo_Storage_Rule|Ingo_Storage_Filters The specified data. */ protected function _retrieve($field, $readonly = false) { $prefs = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Prefs')->create('ingo', array('cache' => false, 'user' => Ingo::getUser())); switch ($field) { case self::ACTION_BLACKLIST: $ob = new Ingo_Storage_Blacklist(); if ($data = @unserialize($prefs->getValue('blacklist'))) { $ob->setBlacklist($data['a']); $ob->setBlacklistFolder($data['f']); } break; case self::ACTION_WHITELIST: $ob = new Ingo_Storage_Whitelist(); if ($data = @unserialize($prefs->getValue('whitelist'))) { $ob->setWhitelist($data); } break; case self::ACTION_FILTERS: $ob = new Ingo_Storage_Filters(); if ($data = @unserialize($prefs->getValue('rules'))) { $ob->setFilterlist($data); } break; case self::ACTION_FORWARD: $ob = new Ingo_Storage_Forward(); if ($data = @unserialize($prefs->getValue('forward'))) { $ob->setForwardAddresses($data['a']); $ob->setForwardKeep($data['k']); } break; case self::ACTION_VACATION: $ob = new Ingo_Storage_Vacation(); if ($data = @unserialize($prefs->getValue('vacation'))) { $ob->setVacationAddresses($data['addresses']); $ob->setVacationDays($data['days']); $ob->setVacationExcludes($data['excludes']); $ob->setVacationIgnorelist($data['ignorelist']); $ob->setVacationReason($data['reason']); $ob->setVacationSubject($data['subject']); if (isset($data['start'])) { $ob->setVacationStart($data['start']); } if (isset($data['end'])) { $ob->setVacationEnd($data['end']); } } break; case self::ACTION_SPAM: $ob = new Ingo_Storage_Spam(); if ($data = @unserialize($prefs->getValue('spam'))) { $ob->setSpamFolder($data['folder']); $ob->setSpamLevel($data['level']); } break; default: $ob = false; break; } return $ob; }
function test_partial_blacklist_address_should_not_match() { $runner = ScriptTester::factory('all', $this); $bl = new Ingo_Storage_Blacklist(); $bl->setBlacklist(array('*****@*****.**')); $bl->setBlacklistFolder(''); $runner->addRule($bl); $runner->assertKeepsMessage('from_spammer'); }
public function testBlacklistMarker() { $bl = new Ingo_Storage_Blacklist(3); $bl->setBlacklist(array('*****@*****.**')); $bl->setBlacklistFolder(Ingo::BLACKLIST_MARKER); $this->storage->store($bl); $this->_assertScript('require "imap4flags"; if address :all :comparator "i;ascii-casemap" :is ["From", "Sender", "Resent-From"] "*****@*****.**" { addflag ["\\\\Deleted"]; keep; removeflag ["\\\\Deleted"]; stop; }'); }
public function testBlacklistDiscard() { $bl = new Ingo_Storage_Blacklist(3); $bl->setBlacklist(array('*****@*****.**')); $bl->setBlacklistFolder(null); $this->storage->store($bl); $this->_assertScript(':0 * ^From:(.*\\<)?spammer@example\\.com /dev/null'); }
public function testBlacklistDiscard() { $bl = new Ingo_Storage_Blacklist(3); $bl->setBlacklist(array('*****@*****.**')); $bl->setBlacklistFolder(null); $this->storage->store($bl); $this->_assertScript('if( \\ /^From:\\s*.*spammer@example\\.com/:h \\ ) exception { exit }'); }