Overview

Packages

  • Horde
    • Icalendar
      • UnitTests
  • Ingo
    • UnitTests
  • None

Classes

  • Horde_Core_Ui_VarRenderer_Ingo
  • Ingo
  • Ingo_Api
  • Ingo_Exception
  • Ingo_Exception_Pear
  • Ingo_LoginTasks_SystemTask_Upgrade
  • Ingo_Script
  • Ingo_Script_Imap
  • Ingo_Script_Imap_Api
  • Ingo_Script_Imap_Live
  • Ingo_Script_Maildrop
  • Ingo_Script_Maildrop_Comment
  • Ingo_Script_Maildrop_Recipe
  • Ingo_Script_Maildrop_Variable
  • Ingo_Script_Procmail
  • Ingo_Script_Procmail_Comment
  • Ingo_Script_Procmail_Recipe
  • Ingo_Script_Procmail_Variable
  • Ingo_Script_Sieve
  • Ingo_Script_Sieve_Action
  • Ingo_Script_Sieve_Action_Addflag
  • Ingo_Script_Sieve_Action_Discard
  • Ingo_Script_Sieve_Action_Fileinto
  • Ingo_Script_Sieve_Action_Flag
  • Ingo_Script_Sieve_Action_Keep
  • Ingo_Script_Sieve_Action_Notify
  • Ingo_Script_Sieve_Action_Redirect
  • Ingo_Script_Sieve_Action_Reject
  • Ingo_Script_Sieve_Action_Removeflag
  • Ingo_Script_Sieve_Action_Stop
  • Ingo_Script_Sieve_Action_Vacation
  • Ingo_Script_Sieve_Comment
  • Ingo_Script_Sieve_Else
  • Ingo_Script_Sieve_Elsif
  • Ingo_Script_Sieve_If
  • Ingo_Script_Sieve_Test
  • Ingo_Script_Sieve_Test_Address
  • Ingo_Script_Sieve_Test_Allof
  • Ingo_Script_Sieve_Test_Anyof
  • Ingo_Script_Sieve_Test_Body
  • Ingo_Script_Sieve_Test_Exists
  • Ingo_Script_Sieve_Test_False
  • Ingo_Script_Sieve_Test_Header
  • Ingo_Script_Sieve_Test_Not
  • Ingo_Script_Sieve_Test_Relational
  • Ingo_Script_Sieve_Test_Size
  • Ingo_Script_Sieve_Test_True
  • Ingo_Storage
  • Ingo_Storage_Blacklist
  • Ingo_Storage_Filters
  • Ingo_Storage_Filters_Sql
  • Ingo_Storage_Forward
  • Ingo_Storage_Mock
  • Ingo_Storage_Prefs
  • Ingo_Storage_Rule
  • Ingo_Storage_Spam
  • Ingo_Storage_Sql
  • Ingo_Storage_Vacation
  • Ingo_Storage_VacationTest
  • Ingo_Storage_Whitelist
  • Ingo_Test
  • Ingo_Transport
  • Ingo_Transport_Ldap
  • Ingo_Transport_Null
  • Ingo_Transport_Sivtest
  • Ingo_Transport_Timsieved
  • Ingo_Transport_Vfs
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Ingo_Storage_Prefs:: implements the Ingo_Storage:: API to save Ingo data
  4:  * via the Horde preferences system.
  5:  *
  6:  * See the enclosed file LICENSE for license information (ASL).  If you
  7:  * did not receive this file, see http://www.horde.org/licenses/apache.
  8:  *
  9:  * @author  Michael Slusarz <slusarz@horde.org>
 10:  * @author  Jan Schneider <jan@horde.org>
 11:  * @package Ingo
 12:  */
 13: class Ingo_Storage_Prefs extends Ingo_Storage
 14: {
 15:     /**
 16:      * Constructor.
 17:      *
 18:      * @param array $params  Additional parameters for the subclass.
 19:      */
 20:     public function __construct($params = array())
 21:     {
 22:         $this->_params = $params;
 23:         parent::__construct();
 24:     }
 25: 
 26:     /**
 27:      * Retrieves the specified data from the storage backend.
 28:      *
 29:      * @param integer $field     The field name of the desired data.
 30:      *                           See lib/Storage.php for the available fields.
 31:      * @param boolean $readonly  Whether to disable any write operations.
 32:      *
 33:      * @return Ingo_Storage_Rule|Ingo_Storage_Filters  The specified data.
 34:      */
 35:     protected function _retrieve($field, $readonly = false)
 36:     {
 37:         $prefs = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Prefs')->create('ingo', array(
 38:             'cache' => false,
 39:             'user' => Ingo::getUser()
 40:         ));
 41: 
 42:         switch ($field) {
 43:         case self::ACTION_BLACKLIST:
 44:             $ob = new Ingo_Storage_Blacklist();
 45:             if ($data = @unserialize($prefs->getValue('blacklist'))) {
 46:                 $ob->setBlacklist($data['a'], true);
 47:                 $ob->setBlacklistFolder($data['f']);
 48:             }
 49:             break;
 50: 
 51:         case self::ACTION_WHITELIST:
 52:             $ob = new Ingo_Storage_Whitelist();
 53:             if ($data = @unserialize($prefs->getValue('whitelist'))) {
 54:                 $ob->setWhitelist($data, true);
 55:             }
 56:             break;
 57: 
 58:         case self::ACTION_FILTERS:
 59:             $ob = new Ingo_Storage_Filters();
 60:             if ($data = @unserialize($prefs->getValue('rules'))) {
 61:                 $ob->setFilterlist($data);
 62:             }
 63:             break;
 64: 
 65:         case self::ACTION_FORWARD:
 66:             $ob = new Ingo_Storage_Forward();
 67:             if ($data = @unserialize($prefs->getValue('forward'))) {
 68:                 $ob->setForwardAddresses($data['a'], false);
 69:                 $ob->setForwardKeep($data['k']);
 70:             }
 71:             break;
 72: 
 73:         case self::ACTION_VACATION:
 74:             $ob = new Ingo_Storage_Vacation();
 75:             if ($data = @unserialize($prefs->getValue('vacation'))) {
 76:                 $ob->setVacationAddresses($data['addresses'], false);
 77:                 $ob->setVacationDays($data['days']);
 78:                 $ob->setVacationExcludes($data['excludes'], false);
 79:                 $ob->setVacationIgnorelist($data['ignorelist']);
 80:                 $ob->setVacationReason($data['reason']);
 81:                 $ob->setVacationSubject($data['subject']);
 82:                 if (isset($data['start'])) {
 83:                     $ob->setVacationStart($data['start']);
 84:                 }
 85:                 if (isset($data['end'])) {
 86:                     $ob->setVacationEnd($data['end']);
 87:                 }
 88:             }
 89:             break;
 90: 
 91:         case self::ACTION_SPAM:
 92:             $ob = new Ingo_Storage_Spam();
 93:             if ($data = @unserialize($prefs->getValue('spam'))) {
 94:                 $ob->setSpamFolder($data['folder']);
 95:                 $ob->setSpamLevel($data['level']);
 96:             }
 97:             break;
 98: 
 99:         default:
100:             $ob = false;
101:             break;
102:         }
103: 
104:         return $ob;
105:     }
106: 
107:     /**
108:      * Stores the specified data in the storage backend.
109:      *
110:      * @param Ingo_Storage_Rule|Ingo_Storage_Filters $ob  The object to store.
111:      */
112:     protected function _store($ob)
113:     {
114:         $prefs = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Prefs')->create('ingo', array(
115:             'cache' => false,
116:             'user' => Ingo::getUser()
117:         ));
118: 
119:         switch ($ob->obType()) {
120:         case self::ACTION_BLACKLIST:
121:             $data = array(
122:                 'a' => $ob->getBlacklist(),
123:                 'f' => $ob->getBlacklistFolder(),
124:             );
125:             $prefs->setValue('blacklist', serialize($data));
126:             break;
127: 
128:         case self::ACTION_FILTERS:
129:             $prefs->setValue('rules', serialize($ob->getFilterList()));
130:             break;
131: 
132:         case self::ACTION_FORWARD:
133:             $data = array(
134:                 'a' => $ob->getForwardAddresses(),
135:                 'k' => $ob->getForwardKeep(),
136:             );
137:             $prefs->setValue('forward', serialize($data));
138:             break;
139: 
140:         case self::ACTION_VACATION:
141:             $data = array(
142:                 'addresses' => $ob->getVacationAddresses(),
143:                 'days' => $ob->getVacationDays(),
144:                 'excludes' => $ob->getVacationExcludes(),
145:                 'ignorelist' => $ob->getVacationIgnorelist(),
146:                 'reason' => $ob->getVacationReason(),
147:                 'subject' => $ob->getVacationSubject(),
148:                 'start' => $ob->getVacationStart(),
149:                 'end' => $ob->getVacationEnd(),
150:             );
151:             $prefs->setValue('vacation', serialize($data));
152:             break;
153: 
154:         case self::ACTION_WHITELIST:
155:             $prefs->setValue('whitelist', serialize($ob->getWhitelist()));
156:             break;
157: 
158:         case self::ACTION_SPAM:
159:             $data = array(
160:                 'folder' => $ob->getSpamFolder(),
161:                 'level' => $ob->getSpamLevel(),
162:             );
163:             $prefs->setValue('spam', serialize($data));
164:             break;
165:         }
166:     }
167: }
168: 
API documentation generated by ApiGen