/usr/share/php/Horde/Kolab/Storage/List/Query/List/Cache.php is in php-horde-kolab-storage 2.2.3-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 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | <?php
/**
* The cached list query.
*
* PHP version 5
*
* @category Kolab
* @package Kolab_Storage
* @author Gunnar Wrobel <wrobel@pardus.de>
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Kolab_Storage
*/
/**
* The cached list query.
*
* Copyright 2010-2016 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Kolab
* @package Kolab_Storage
* @author Gunnar Wrobel <wrobel@pardus.de>
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Kolab_Storage
*/
class Horde_Kolab_Storage_List_Query_List_Cache
extends Horde_Kolab_Storage_List_Query_List
implements Horde_Kolab_Storage_List_Manipulation_Listener,
Horde_Kolab_Storage_List_Synchronization_Listener
{
/** The list of folder types */
const TYPES = 'TYPES';
/** The folder list sorted by type */
const BY_TYPE = 'BY_TYPE';
/** The list of folder data */
const FOLDERS = 'FOLDERS';
/** The folder owner list */
const OWNERS = 'OWNERS';
/** The default folder list for the current user */
const PERSONAL_DEFAULTS = 'PERSONAL_DEFAULTS';
/** The default folder list */
const DEFAULTS = 'DEFAULTS';
/**
* The synchronization handler.
*
* @var Horde_Kolab_Storage_List_Query_List_Cache_Synchronization
*/
private $_sync;
/**
* The list cache.
*
* @var Horde_Kolab_Storage_List_Cache
*/
private $_list_cache;
/**
* Constructor.
*
* @param Horde_Kolab_Storage_List_Query_List_Cache_Synchronization $sync The synchronization handler..
* @param Horde_Kolab_Storage_List_Cache $cache The list cache.
*/
public function __construct(Horde_Kolab_Storage_List_Query_List_Cache_Synchronization $sync,
Horde_Kolab_Storage_List_Cache $cache)
{
$this->_sync = $sync;
$this->_list_cache = $cache;
$this->_sync->setCache($cache);
}
/**
* Ensure we have the query data.
*
* @param string $query The query data required.
*
* @return NULL
*/
private function _initQuery($query)
{
if (!$this->_list_cache->hasQuery($query)) {
$this->_sync->synchronize($this->_list_cache);
}
}
/**
* Returns the folder types as associative array.
*
* @return array The list folder types with the folder names as key and the
* type as values.
*/
public function listTypes()
{
$this->_initQuery(self::TYPES);
return $this->_list_cache->getQuery(self::TYPES);
}
/**
* List all folders of a specific type.
*
* @param string $type The folder type the listing should be limited to.
*
* @return array The list of folders.
*/
public function listByType($type)
{
$this->_initQuery(self::BY_TYPE);
$by_type = $this->_list_cache->getQuery(self::BY_TYPE);
if (isset($by_type[$type])) {
return array_keys($by_type[$type]);
} else {
return array();
}
}
/**
* List basic folder data for the folders of a specific type.
*
* @param string $type The folder type the listing should be limited to.
*
* @return array The list of folders.
*/
public function dataByType($type)
{
$this->_initQuery(self::BY_TYPE);
$data_by_type = $this->_list_cache->getQuery(self::BY_TYPE);
if (isset($data_by_type[$type])) {
return $data_by_type[$type];
} else {
return array();
}
}
/**
* List basic folder data for the specified folder.
*
* @param string $folder The folder path.
*
* @return array The folder data.
*/
public function folderData($folder)
{
$this->_initQuery(self::FOLDERS);
$folders = $this->_list_cache->getQuery(self::FOLDERS);
if (isset($folders[$folder])) {
return $folders[$folder];
} else {
throw new Horde_Kolab_Storage_List_Exception(
sprintf('Folder %s does not exist!', $folder)
);
}
}
/**
* Get the folder owners.
*
* @return array The folder owners with the folder names as key and the
* owner as values.
*/
public function listOwners()
{
$this->_initQuery(self::OWNERS);
return $this->_list_cache->getQuery(self::OWNERS);
}
/**
* Set the specified folder as default for its current type.
*
* @param string $folder The folder name.
*/
public function setDefault($folder)
{
$data = $this->folderData($folder);
$this->_sync->setDefault($data, $this->getDefault($data['type']));
}
/**
* Return the list of personal default folders.
*
* @return array An array that associates type (key) with the corresponding
* default folder name (value).
*/
public function listPersonalDefaults()
{
$this->_initQuery(self::PERSONAL_DEFAULTS);
return $this->_list_cache->getQuery(self::PERSONAL_DEFAULTS);
}
/**
* Return the list of default folders.
*
* @return array An array with owners as keys and another array as
* value. The second array associates type (key) with the
* corresponding default folder (value).
*/
public function listDefaults()
{
$this->_initQuery(self::DEFAULTS);
return $this->_list_cache->getQuery(self::DEFAULTS);
}
/**
* Get the default folder for a certain type.
*
* @param string $type The type of the share/folder.
*
* @return string|boolean The name of the default folder, false if there is no default.
*/
public function getDefault($type)
{
$this->_initQuery(self::PERSONAL_DEFAULTS);
$defaults = $this->_list_cache->getQuery(self::PERSONAL_DEFAULTS);
if (isset($defaults[$type])) {
return $defaults[$type];
} else {
return false;
}
}
/**
* Get the default folder for a certain type from a different owner.
*
* @param string $owner The folder owner.
* @param string $type The type of the share/folder.
*
* @return string|boolean The name of the default folder, false if there is no default.
*/
public function getForeignDefault($owner, $type)
{
$this->_initQuery(self::DEFAULTS);
$defaults = $this->_list_cache->getQuery(self::DEFAULTS);
if (isset($defaults[$owner][$type])) {
return $defaults[$owner][$type];
} else {
return false;
}
}
/**
* Update the listener after creating a new folder.
*
* @param string $folder The path of the folder that has been created.
* @param string $type An optional type for the folder.
*
* @return NULL
*/
public function updateAfterCreateFolder($folder, $type = null)
{
$this->_sync->updateAfterCreateFolder($folder, $type);
}
/**
* Update the listener after deleting folder.
*
* @param string $folder The path of the folder that has been deleted.
*
* @return NULL
*/
public function updateAfterDeleteFolder($folder)
{
$this->_sync->updateAfterDeleteFolder($folder);
}
/**
* Update the listener after renaming a folder.
*
* @param string $old The old path of the folder.
* @param string $new The new path of the folder.
*
* @return NULL
*/
public function updateAfterRenameFolder($old, $new)
{
$this->_sync->updateAfterRenameFolder($old, $new);
}
/**
* Return the last sync stamp.
*
* @return string The stamp.
*/
public function getStamp()
{
return $this->_list_cache->getStamp();
}
/**
* Return any default folder duplicates.
*
* @return array The list of duplicate default folders accessible to the current user.
*/
public function getDuplicateDefaults()
{
return $this->_sync->getDuplicateDefaults();
}
/**
* Synchronize the listener.
*/
public function synchronize()
{
$this->_sync->synchronize();
}
}
|