/usr/share/horde/ingo/lib/Storage/Prefs.php is in php-horde-ingo 3.2.16-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | <?php
/**
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (ASL). If you
* did not receive this file, see http://www.horde.org/licenses/apache.
*
* @author Michael Slusarz <slusarz@horde.org>
* @author Jan Schneider <jan@horde.org>
* @category Horde
* @license http://www.horde.org/licenses/apache ASL
* @package Ingo
*/
/**
* Ingo_Storage_Prefs implements the Ingo_Storage API to save Ingo data via the
* Horde preferences system.
*
* @author Michael Slusarz <slusarz@horde.org>
* @author Jan Schneider <jan@horde.org>
* @category Horde
* @license http://www.horde.org/licenses/apache ASL
* @package Ingo
*/
class Ingo_Storage_Prefs extends Ingo_Storage
{
/**
* 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;
}
/**
* Stores the specified data in the storage backend.
*
* @param Ingo_Storage_Rule|Ingo_Storage_Filters $ob The object to store.
*/
protected function _store($ob)
{
$prefs = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Prefs')->create('ingo', array(
'cache' => false,
'user' => Ingo::getUser()
));
switch ($ob->obType()) {
case self::ACTION_BLACKLIST:
$data = array(
'a' => $ob->getBlacklist(),
'f' => $ob->getBlacklistFolder(),
);
$prefs->setValue('blacklist', serialize($data));
break;
case self::ACTION_FILTERS:
$prefs->setValue('rules', serialize($ob->getFilterList()));
break;
case self::ACTION_FORWARD:
$data = array(
'a' => $ob->getForwardAddresses(),
'k' => $ob->getForwardKeep(),
);
$prefs->setValue('forward', serialize($data));
break;
case self::ACTION_VACATION:
$data = array(
'addresses' => $ob->getVacationAddresses(),
'days' => $ob->getVacationDays(),
'excludes' => $ob->getVacationExcludes(),
'ignorelist' => $ob->getVacationIgnorelist(),
'reason' => $ob->getVacationReason(),
'subject' => $ob->getVacationSubject(),
'start' => $ob->getVacationStart(),
'end' => $ob->getVacationEnd(),
);
$prefs->setValue('vacation', serialize($data));
break;
case self::ACTION_WHITELIST:
$prefs->setValue('whitelist', serialize($ob->getWhitelist()));
break;
case self::ACTION_SPAM:
$data = array(
'folder' => $ob->getSpamFolder(),
'level' => $ob->getSpamLevel(),
);
$prefs->setValue('spam', serialize($data));
break;
}
}
}
|