1<?php 2/** 3 * The basic driver decorator definition for accessing Kolab storage. 4 * 5 * PHP version 5 6 * 7 * @category Kolab 8 * @package Kolab_Storage 9 * @author Gunnar Wrobel <wrobel@pardus.de> 10 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 11 */ 12 13/** 14 * The basic driver decorator definition for accessing Kolab storage. 15 * 16 * Copyright 2010-2017 Horde LLC (http://www.horde.org/) 17 * 18 * See the enclosed file COPYING for license information (LGPL). If you 19 * did not receive this file, see http://www.horde.org/licenses/lgpl21. 20 * 21 * @category Kolab 22 * @package Kolab_Storage 23 * @author Gunnar Wrobel <wrobel@pardus.de> 24 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 25 */ 26class Horde_Kolab_Storage_Driver_Decorator_Base 27implements Horde_Kolab_Storage_Driver 28{ 29 /** 30 * The decorated driver. 31 * 32 * @var Horde_Kolab_Storage_Driver 33 */ 34 private $_driver; 35 36 /** 37 * Constructor. 38 * 39 * @param Horde_Kolab_Storage_Driver $driver The decorated driver. 40 */ 41 public function __construct(Horde_Kolab_Storage_Driver $driver) 42 { 43 $this->_driver = $driver; 44 } 45 46 /** 47 * Return the class name of the decorated driver. 48 * 49 * @return string The class name of the decorated driver. 50 */ 51 public function getDriverName() 52 { 53 return get_class($this->_driver); 54 } 55 56 /** 57 * Create the backend driver. 58 * 59 * @return mixed The backend driver. 60 */ 61 public function createBackend() 62 { 63 return $this->_driver->createBackend(); 64 } 65 66 /** 67 * Returns the actual backend driver. 68 * 69 * If there is no driver set the driver should be constructed within this 70 * method. 71 * 72 * @return mixed The backend driver. 73 */ 74 public function getBackend() 75 { 76 return $this->_driver->getBackend(); 77 } 78 79 /** 80 * Set the backend driver. 81 * 82 * @param mixed $backend The driver that should be used. 83 * 84 * @return NULL 85 */ 86 public function setBackend($backend) 87 { 88 $this->_driver->setBackend($backend); 89 } 90 91 /** 92 * Returns the parser for data objects. 93 * 94 * @return Horde_Kolab_Storage_Data_Parser The parser. 95 */ 96 public function getParser() 97 { 98 return $this->_driver->getParser(); 99 } 100 101 /** 102 * Set the data parser. 103 * 104 * @param mixed $parser The parser that should be used. 105 * 106 * @return NULL 107 */ 108 public function setParser(Horde_Kolab_Storage_Data_Parser $parser) 109 { 110 $this->_driver->setParser($parser); 111 } 112 113 /** 114 * Return the id of the user currently authenticated. 115 * 116 * @return string The id of the user that opened the connection. 117 */ 118 public function getAuth() 119 { 120 return $this->_driver->getAuth(); 121 } 122 123 /** 124 * Return the unique connection id. 125 * 126 * @return string The connection id. 127 */ 128 public function getId() 129 { 130 return $this->_driver->getId(); 131 } 132 133 /** 134 * Return the connection parameters. 135 * 136 * @return array The connection parameters. 137 */ 138 public function getParameters() 139 { 140 return $this->_driver->getParameters(); 141 } 142 143 /** 144 * Checks if the backend supports CATENATE. 145 * 146 * @return boolean True if the backend supports CATENATE. 147 */ 148 public function hasCatenateSupport() 149 { 150 return $this->_driver->hasCatenateSupport(); 151 } 152 153 /** 154 * Retrieves a list of mailboxes from the server. 155 * 156 * @return array The list of mailboxes. 157 */ 158 public function listFolders() 159 { 160 return $this->_driver->listFolders(); 161 } 162 163 /** 164 * Create the specified folder. 165 * 166 * @param string $folder The folder to create. 167 * 168 * @return NULL 169 */ 170 public function create($folder) 171 { 172 $this->_driver->create($folder); 173 } 174 175 /** 176 * Delete the specified folder. 177 * 178 * @param string $folder The folder to delete. 179 * 180 * @return NULL 181 */ 182 public function delete($folder) 183 { 184 $this->_driver->delete($folder); 185 } 186 187 /** 188 * Rename the specified folder. 189 * 190 * @param string $old The folder to rename. 191 * @param string $new The new name of the folder. 192 * 193 * @return NULL 194 */ 195 public function rename($old, $new) 196 { 197 return $this->_driver->rename($old, $new); 198 } 199 200 /** 201 * Does the backend support ACL? 202 * 203 * @return boolean True if the backend supports ACLs. 204 */ 205 public function hasAclSupport() 206 { 207 return $this->_driver->hasAclSupport(); 208 } 209 210 /** 211 * Retrieve the access rights for a folder. 212 * 213 * @param string $folder The folder to retrieve the ACL for. 214 * 215 * @return array An array of rights. 216 */ 217 public function getAcl($folder) 218 { 219 return $this->_driver->getAcl($folder); 220 } 221 222 /** 223 * Retrieve the access rights the current user has on a folder. 224 * 225 * @param string $folder The folder to retrieve the user ACL for. 226 * 227 * @return string The user rights. 228 */ 229 public function getMyAcl($folder) 230 { 231 return $this->_driver->getMyAcl($folder); 232 } 233 234 /** 235 * Set the access rights for a folder. 236 * 237 * @param string $folder The folder to act upon. 238 * @param string $user The user to set the ACL for. 239 * @param string $acl The ACL. 240 * 241 * @return NULL 242 */ 243 public function setAcl($folder, $user, $acl) 244 { 245 $this->_driver->setAcl($folder, $user, $acl); 246 } 247 248 /** 249 * Delete the access rights for user on a folder. 250 * 251 * @param string $folder The folder to act upon. 252 * @param string $user The user to delete the ACL for 253 * 254 * @return NULL 255 */ 256 public function deleteAcl($folder, $user) 257 { 258 $this->_driver->deleteAcl($folder, $user); 259 } 260 261 /** 262 * Retrieves the specified annotation for the complete list of mailboxes. 263 * 264 * @param string $annotation The name of the annotation to retrieve. 265 * 266 * @return array An associative array combining the folder names as key with 267 * the corresponding annotation value. 268 */ 269 public function listAnnotation($annotation) 270 { 271 return $this->_driver->listAnnotation($annotation); 272 } 273 274 /** 275 * Fetches the annotation on a folder. 276 * 277 * @param string $entry The entry to fetch. 278 * @param string $folder The name of the folder. 279 * 280 * @return string The annotation value. 281 */ 282 public function getAnnotation($entry, $folder) 283 { 284 return $this->_driver->getAnnotation($entry, $folder); 285 } 286 287 /** 288 * Sets the annotation on a folder. 289 * 290 * @param string $folder The name of the folder. 291 * @param string $annotation The annotation to set. 292 * @param array $value The values to set 293 * 294 * @return NULL 295 */ 296 public function setAnnotation($folder, $annotation, $value) 297 { 298 $this->_driver->setAnnotation($folder, $annotation, $value); 299 } 300 301 /** 302 * Retrieve the namespace information for this connection. 303 * 304 * @return Horde_Kolab_Storage_Driver_Namespace The initialized namespace handler. 305 */ 306 public function getNamespace() 307 { 308 return $this->_driver->getNamespace(); 309 } 310 311 /** 312 * Returns a stamp for the current folder status. This stamp can be used to 313 * identify changes in the folder data. 314 * 315 * @param string $folder Return the stamp for this folder. 316 * 317 * @return Horde_Kolab_Storage_Folder_Stamp A stamp indicating the current 318 * folder status. 319 */ 320 public function getStamp($folder) 321 { 322 return $this->_driver->getStamp($folder); 323 } 324 325 /** 326 * Returns a stamp for the current folder status. This stamp can be used to 327 * identify changes in the folder data. This method, as opposed to 328 * self::getStamp(), uses the IMAP client's token to calculate the changes. 329 * 330 * @param string $folder Return the stamp for this folder. 331 * @param string $token A sync token provided by the IMAP server. 332 * @param array $ids An array of UIDs that we know about. 333 * 334 * @return Horde_Kolab_Storage_Folder_Stamp A stamp indicating the current 335 * folder status. 336 */ 337 public function getStampFromToken($folder, $token, array $ids) 338 { 339 return $this->_driver->getStampFromToken($folder, $token, $ids); 340 } 341 342 /** 343 * Returns the status of the current folder. 344 * 345 * @param string $folder Check the status of this folder. 346 * 347 * @return array An array that contains 'uidvalidity' and 'uidnext'. 348 */ 349 public function status($folder) 350 { 351 return $this->_driver->status($folder); 352 } 353 354 /** 355 * Returns the message ids of the messages in this folder. 356 * 357 * @param string $folder Check the status of this folder. 358 * 359 * @return array The message ids. 360 */ 361 public function getUids($folder) 362 { 363 return $this->_driver->getUids($folder); 364 } 365 366 /** 367 * Fetches the objects for the specified UIDs. 368 * 369 * @param string $folder The folder to access. 370 * 371 * @return array The parsed objects. 372 */ 373 public function fetch($folder, $uids, $options = array()) 374 { 375 return $this->_driver->fetch($folder, $uids, $options); 376 } 377 378 /** 379 * Retrieves the messages for the given message ids. 380 * 381 * @param string $folder The folder to fetch the messages from. 382 * @param array $uids The message UIDs. 383 * 384 * @return array An array of message structures parsed into Horde_Mime_Part 385 * instances. 386 */ 387 public function fetchStructure($folder, $uids) 388 { 389 return $this->_driver->fetchStructure($folder, $uids); 390 } 391 392 /** 393 * Retrieves a bodypart for the given message ID and mime part ID. 394 * 395 * @param string $folder The folder to fetch the messages from. 396 * @param array $uid The message UID. 397 * @param array $id The mime part ID. 398 * 399 * @return resource The body part, as a stream resource. 400 */ 401 public function fetchBodypart($folder, $uid, $id) 402 { 403 return $this->_driver->fetchBodypart($folder, $uid, $id); 404 } 405 406 /** 407 * Retrieves a complete message. 408 * 409 * @param string $folder The folder to fetch the messages from. 410 * @param array $uid The message UID. 411 * 412 * @return array The message encapsuled as an array that contains a 413 * Horde_Mime_Headers and a Horde_Mime_Part object. 414 */ 415 public function fetchComplete($folder, $uid) 416 { 417 return $this->_driver->fetchComplete($folder, $uid); 418 } 419 420 /** 421 * Retrieves the message headers. 422 * 423 * @param string $folder The folder to fetch the message from. 424 * @param array $uid The message UID. 425 * 426 * @return Horde_Mime_Headers The message headers. 427 */ 428 public function fetchHeaders($folder, $uid) 429 { 430 return $this->_driver->fetchHeaders($folder, $uid); 431 } 432 433 /** 434 * Appends a message to the given folder. 435 * 436 * @param string $folder The folder to append the message(s) to. 437 * @param resource $msg The message to append. 438 * 439 * @return mixed True or the UID of the new message in case the backend 440 * supports UIDPLUS. 441 */ 442 public function appendMessage($folder, $msg) 443 { 444 return $this->_driver->appendMessage($folder, $msg); 445 } 446 447 /** 448 * Deletes messages from the specified folder. 449 * 450 * @param string $folder The folder to delete messages from. 451 * @param integer $uids IMAP message ids. 452 * 453 * @return NULL 454 */ 455 public function deleteMessages($folder, $uids) 456 { 457 $this->_driver->deleteMessages($folder, $uids); 458 } 459 460 /** 461 * Moves a message to a new folder. 462 * 463 * @param integer $uid IMAP message id. 464 * @param string $old_folder Source folder. 465 * @param string $new_folder Target folder. 466 * 467 * @return NULL 468 */ 469 public function moveMessage($uid, $old_folder, $new_folder) 470 { 471 $this->_driver->moveMessage($uid, $old_folder, $new_folder); 472 } 473 474 /** 475 * Expunges messages in the current folder. 476 * 477 * @param string $folder The folder to expunge. 478 * 479 * @return NULL 480 */ 481 public function expunge($folder) 482 { 483 $this->_driver->expunge($folder); 484 } 485}