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