/** * 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; }