Aleksander Machniak
2013-10-14 5a2d2a6f75b115183459997cc2aa787d9a085fe8
commit | author | age
c321a9 1 <?php
T 2
3 /*
4  +-----------------------------------------------------------------------+
5  | This file is part of the Roundcube Webmail client                     |
6  | Copyright (C) 2005-2012, The Roundcube Dev Team                       |
7  | Copyright (C) 2012, Kolab Systems AG                                  |
7fe381 8  |                                                                       |
T 9  | Licensed under the GNU General Public License version 3 or            |
10  | any later version with exceptions for skins & plugins.                |
11  | See the README file for a full license statement.                     |
c321a9 12  |                                                                       |
T 13  | PURPOSE:                                                              |
14  |   Mail Storage Engine                                                 |
15  +-----------------------------------------------------------------------+
16  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
17  | Author: Aleksander Machniak <alec@alec.pl>                            |
18  +-----------------------------------------------------------------------+
19 */
20
21 /**
22  * Abstract class for accessing mail messages storage server
23  *
9ab346 24  * @package    Framework
AM 25  * @subpackage Storage
26  * @author     Thomas Bruederli <roundcube@gmail.com>
27  * @author     Aleksander Machniak <alec@alec.pl>
c321a9 28  */
T 29 abstract class rcube_storage
30 {
31     /**
32      * Instance of connection object e.g. rcube_imap_generic
33      *
34      * @var mixed
35      */
36     public $conn;
37
38     protected $folder = 'INBOX';
39     protected $default_charset = 'ISO-8859-1';
40     protected $default_folders = array('INBOX');
41     protected $search_set;
05da15 42     protected $options = array('auth_type' => 'check');
c321a9 43     protected $page_size = 10;
T 44     protected $threading = false;
45
46     /**
47      * All (additional) headers used (in any way) by Roundcube
48      * Not listed here: DATE, FROM, TO, CC, REPLY-TO, SUBJECT, CONTENT-TYPE, LIST-POST
49      * (used for messages listing) are hardcoded in rcube_imap_generic::fetchHeaders()
50      *
51      * @var array
52      */
53     protected $all_headers = array(
54         'IN-REPLY-TO',
55         'BCC',
83370e 56         'SENDER',
c321a9 57         'MESSAGE-ID',
T 58         'CONTENT-TRANSFER-ENCODING',
59         'REFERENCES',
60         'X-DRAFT-INFO',
61         'MAIL-FOLLOWUP-TO',
62         'MAIL-REPLY-TO',
63         'RETURN-PATH',
64     );
65
66     const UNKNOWN       = 0;
67     const NOPERM        = 1;
68     const READONLY      = 2;
69     const TRYCREATE     = 3;
70     const INUSE         = 4;
71     const OVERQUOTA     = 5;
72     const ALREADYEXISTS = 6;
73     const NONEXISTENT   = 7;
74     const CONTACTADMIN  = 8;
75
76
77     /**
78      * Connect to the server
79      *
80      * @param  string   $host    Host to connect
81      * @param  string   $user    Username for IMAP account
82      * @param  string   $pass    Password for IMAP account
83      * @param  integer  $port    Port to connect to
84      * @param  string   $use_ssl SSL schema (either ssl or tls) or null if plain connection
85      *
86      * @return boolean  TRUE on success, FALSE on failure
87      */
88     abstract function connect($host, $user, $pass, $port = 143, $use_ssl = null);
89
90
91     /**
92      * Close connection. Usually done on script shutdown
93      */
94     abstract function close();
95
96
97     /**
98      * Checks connection state.
99      *
100      * @return boolean  TRUE on success, FALSE on failure
101      */
102     abstract function is_connected();
103
104
105     /**
8eae72 106      * Check connection state, connect if not connected.
A 107      *
108      * @return bool Connection state.
109      */
110     abstract function check_connection();
111
112
113     /**
c321a9 114      * Returns code of last error
T 115      *
116      * @return int Error code
117      */
118     abstract function get_error_code();
119
120
121     /**
122      * Returns message of last error
123      *
124      * @return string Error message
125      */
126     abstract function get_error_str();
127
128
129     /**
130      * Returns code of last command response
131      *
132      * @return int Response code (class constant)
133      */
134     abstract function get_response_code();
135
136
137     /**
138      * Set connection and class options
139      *
140      * @param array $opt Options array
141      */
142     public function set_options($opt)
143     {
144         $this->options = array_merge($this->options, (array)$opt);
145     }
146
147
148     /**
149      * Activate/deactivate debug mode.
150      *
151      * @param boolean $dbg True if conversation with the server should be logged
152      */
153     abstract function set_debug($dbg = true);
154
155
156     /**
157      * Set default message charset.
158      *
159      * This will be used for message decoding if a charset specification is not available
160      *
161      * @param  string $cs Charset string
162      */
163     public function set_charset($cs)
164     {
165         $this->default_charset = $cs;
166     }
167
168
169     /**
170      * This list of folders will be listed above all other folders
171      *
172      * @param  array $arr Indexed list of folder names
173      */
174     public function set_default_folders($arr)
175     {
176         if (is_array($arr)) {
177             $this->default_folders = $arr;
178
179             // add inbox if not included
180             if (!in_array('INBOX', $this->default_folders)) {
181                 array_unshift($this->default_folders, 'INBOX');
182             }
183         }
184     }
185
186
187     /**
188      * Set internal folder reference.
189      * All operations will be perfomed on this folder.
190      *
191      * @param  string $folder  Folder name
192      */
193     public function set_folder($folder)
194     {
10562d 195         if ($this->folder === $folder) {
c321a9 196             return;
T 197         }
198
199         $this->folder = $folder;
200     }
201
202
203     /**
204      * Returns the currently used folder name
205      *
206      * @return string Name of the folder
207      */
208     public function get_folder()
209     {
210         return $this->folder;
211     }
212
213
214     /**
215      * Set internal list page number.
216      *
217      * @param int $page Page number to list
218      */
219     public function set_page($page)
220     {
221         $this->list_page = (int) $page;
222     }
223
224
225     /**
226      * Gets internal list page number.
227      *
228      * @return int Page number
229      */
230     public function get_page()
231     {
232         return $this->list_page;
233     }
234
235
236     /**
237      * Set internal page size
238      *
239      * @param int $size Number of messages to display on one page
240      */
241     public function set_pagesize($size)
242     {
243         $this->page_size = (int) $size;
244     }
245
246
247     /**
248      * Get internal page size
249      *
250      * @return int Number of messages to display on one page
251      */
252     public function get_pagesize()
253     {
254         return $this->page_size;
255     }
256
257
258     /**
259      * Save a search result for future message listing methods.
260      *
261      * @param  mixed  $set  Search set in driver specific format
262      */
263     abstract function set_search_set($set);
264
265
266     /**
267      * Return the saved search set.
268      *
269      * @return array Search set in driver specific format, NULL if search wasn't initialized
270      */
271     abstract function get_search_set();
272
273
274     /**
275      * Returns the storage server's (IMAP) capability
276      *
277      * @param   string  $cap Capability name
278      *
279      * @return  mixed   Capability value or TRUE if supported, FALSE if not
280      */
281     abstract function get_capability($cap);
282
283
284     /**
285      * Sets threading flag to the best supported THREAD algorithm.
286      * Enable/Disable threaded mode.
287      *
288      * @param  boolean  $enable TRUE to enable and FALSE
289      *
290      * @return mixed   Threading algorithm or False if THREAD is not supported
291      */
292     public function set_threading($enable = false)
293     {
294         $this->threading = false;
295
296         if ($enable && ($caps = $this->get_capability('THREAD'))) {
297             $methods = array('REFS', 'REFERENCES', 'ORDEREDSUBJECT');
298             $methods = array_intersect($methods, $caps);
299
300             $this->threading = array_shift($methods);
301         }
302
303         return $this->threading;
304     }
305
306
307     /**
308      * Get current threading flag.
309      *
310      * @return mixed  Threading algorithm or False if THREAD is not supported or disabled
311      */
312     public function get_threading()
313     {
314         return $this->threading;
315     }
316
317
318     /**
319      * Checks the PERMANENTFLAGS capability of the current folder
320      * and returns true if the given flag is supported by the server.
321      *
322      * @param   string  $flag Permanentflag name
323      *
324      * @return  boolean True if this flag is supported
325      */
326     abstract function check_permflag($flag);
327
328
329     /**
330      * Returns the delimiter that is used by the server
331      * for folder hierarchy separation.
332      *
333      * @return  string  Delimiter string
334      */
335     abstract function get_hierarchy_delimiter();
336
337
338     /**
339      * Get namespace
340      *
341      * @param string $name Namespace array index: personal, other, shared, prefix
342      *
343      * @return  array  Namespace data
344      */
345     abstract function get_namespace($name = null);
346
347
348     /**
349      * Get messages count for a specific folder.
350      *
351      * @param  string  $folder  Folder name
0435f4 352      * @param  string  $mode    Mode for count [ALL|THREADS|UNSEEN|RECENT|EXISTS]
c321a9 353      * @param  boolean $force   Force reading from server and update cache
T 354      * @param  boolean $status  Enables storing folder status info (max UID/count),
355      *                          required for folder_status()
356      *
357      * @return int     Number of messages
358      */
359     abstract function count($folder = null, $mode = 'ALL', $force = false, $status = true);
360
361
362     /**
363      * Public method for listing headers.
364      *
365      * @param   string   $folder     Folder name
366      * @param   int      $page       Current page to list
367      * @param   string   $sort_field Header field to sort by
368      * @param   string   $sort_order Sort order [ASC|DESC]
369      * @param   int      $slice      Number of slice items to extract from result array
370      *
371      * @return  array    Indexed array with message header objects
372      */
373     abstract function list_messages($folder = null, $page = null, $sort_field = null, $sort_order = null, $slice = 0);
374
375
376     /**
377      * Return sorted list of message UIDs
378      *
379      * @param string $folder     Folder to get index from
380      * @param string $sort_field Sort column
381      * @param string $sort_order Sort order [ASC, DESC]
382      *
383      * @return rcube_result_index|rcube_result_thread List of messages (UIDs)
384      */
385     abstract function index($folder = null, $sort_field = null, $sort_order = null);
386
387
388     /**
389      * Invoke search request to the server.
390      *
391      * @param  string  $folder     Folder name to search in
392      * @param  string  $str        Search criteria
393      * @param  string  $charset    Search charset
394      * @param  string  $sort_field Header field to sort by
395      *
396      * @todo: Search criteria should be provided in non-IMAP format, eg. array
397      */
398     abstract function search($folder = null, $str = 'ALL', $charset = null, $sort_field = null);
399
400
401     /**
402      * Direct (real and simple) search request (without result sorting and caching).
403      *
404      * @param  string  $folder  Folder name to search in
405      * @param  string  $str     Search string
406      *
407      * @return rcube_result_index  Search result (UIDs)
408      */
409     abstract function search_once($folder = null, $str = 'ALL');
410
411
412     /**
413      * Refresh saved search set
414      *
415      * @return array Current search set
416      */
417     abstract function refresh_search();
418
419
420     /* --------------------------------
421      *        messages management
422      * --------------------------------*/
423
424     /**
425      * Fetch message headers and body structure from the server and build
426      * an object structure similar to the one generated by PEAR::Mail_mimeDecode
427      *
428      * @param int     $uid     Message UID to fetch
429      * @param string  $folder  Folder to read from
430      *
0c2596 431      * @return object rcube_message_header Message data
c321a9 432      */
T 433     abstract function get_message($uid, $folder = null);
434
435
436     /**
437      * Return message headers object of a specific message
438      *
439      * @param int     $id       Message sequence ID or UID
440      * @param string  $folder   Folder to read from
441      * @param bool    $force    True to skip cache
442      *
0c2596 443      * @return rcube_message_header Message headers
c321a9 444      */
T 445     abstract function get_message_headers($uid, $folder = null, $force = false);
446
447
448     /**
449      * Fetch message body of a specific message from the server
450      *
451      * @param  int                $uid    Message UID
452      * @param  string             $part   Part number
453      * @param  rcube_message_part $o_part Part object created by get_structure()
454      * @param  mixed              $print  True to print part, ressource to write part contents in
455      * @param  resource           $fp     File pointer to save the message part
456      * @param  boolean            $skip_charset_conv Disables charset conversion
457      *
458      * @return string Message/part body if not printed
459      */
460     abstract function get_message_part($uid, $part = 1, $o_part = null, $print = null, $fp = null, $skip_charset_conv = false);
461
462
463     /**
464      * Fetch message body of a specific message from the server
465      *
466      * @param  int    $uid  Message UID
467      *
468      * @return string $part Message/part body
469      * @see    rcube_imap::get_message_part()
470      */
471     public function get_body($uid, $part = 1)
472     {
473         $headers = $this->get_message_headers($uid);
0c2596 474         return rcube_charset::convert($this->get_message_part($uid, $part, null),
c321a9 475             $headers->charset ? $headers->charset : $this->default_charset);
T 476     }
477
478
479     /**
480      * Returns the whole message source as string (or saves to a file)
481      *
482      * @param int      $uid Message UID
483      * @param resource $fp  File pointer to save the message
484      *
485      * @return string Message source string
486      */
487     abstract function get_raw_body($uid, $fp = null);
488
489
490     /**
491      * Returns the message headers as string
492      *
493      * @param int $uid  Message UID
494      *
495      * @return string Message headers string
496      */
497     abstract function get_raw_headers($uid);
498
499
500     /**
501      * Sends the whole message source to stdout
fb2f82 502      *
AM 503      * @param int  $uid       Message UID
504      * @param bool $formatted Enables line-ending formatting
c321a9 505      */
fb2f82 506     abstract function print_raw_body($uid, $formatted = true);
c321a9 507
T 508
509     /**
510      * Set message flag to one or several messages
511      *
512      * @param mixed   $uids       Message UIDs as array or comma-separated string, or '*'
513      * @param string  $flag       Flag to set: SEEN, UNDELETED, DELETED, RECENT, ANSWERED, DRAFT, MDNSENT
514      * @param string  $folder     Folder name
515      * @param boolean $skip_cache True to skip message cache clean up
516      *
517      * @return bool  Operation status
518      */
519     abstract function set_flag($uids, $flag, $folder = null, $skip_cache = false);
520
521
522     /**
523      * Remove message flag for one or several messages
524      *
525      * @param mixed  $uids    Message UIDs as array or comma-separated string, or '*'
526      * @param string $flag    Flag to unset: SEEN, DELETED, RECENT, ANSWERED, DRAFT, MDNSENT
527      * @param string $folder  Folder name
528      *
529      * @return bool   Operation status
530      * @see set_flag
531      */
532     public function unset_flag($uids, $flag, $folder = null)
533     {
534         return $this->set_flag($uids, 'UN'.$flag, $folder);
535     }
536
537
538     /**
539      * Append a mail message (source) to a specific folder.
540      *
d76472 541      * @param string       $folder  Target folder
AM 542      * @param string|array $message The message source string or filename
543      *                              or array (of strings and file pointers)
544      * @param string       $headers Headers string if $message contains only the body
545      * @param boolean      $is_file True if $message is a filename
546      * @param array        $flags   Message flags
547      * @param mixed        $date    Message internal date
c321a9 548      *
T 549      * @return int|bool Appended message UID or True on success, False on error
550      */
7ac533 551     abstract function save_message($folder, &$message, $headers = '', $is_file = false, $flags = array(), $date = null);
c321a9 552
T 553
554     /**
555      * Move message(s) from one folder to another.
556      *
557      * @param mixed  $uids  Message UIDs as array or comma-separated string, or '*'
558      * @param string $to    Target folder
559      * @param string $from  Source folder
560      *
561      * @return boolean True on success, False on error
562      */
563     abstract function move_message($uids, $to, $from = null);
564
565
566     /**
567      * Copy message(s) from one mailbox to another.
568      *
569      * @param mixed  $uids  Message UIDs as array or comma-separated string, or '*'
570      * @param string $to    Target folder
571      * @param string $from  Source folder
572      *
573      * @return boolean True on success, False on error
574      */
575     abstract function copy_message($uids, $to, $from = null);
576
577
578     /**
579      * Mark message(s) as deleted and expunge.
580      *
581      * @param mixed  $uids    Message UIDs as array or comma-separated string, or '*'
582      * @param string $folder  Source folder
583      *
584      * @return boolean True on success, False on error
585      */
586     abstract function delete_message($uids, $folder = null);
587
588
589     /**
590      * Expunge message(s) and clear the cache.
591      *
592      * @param mixed   $uids        Message UIDs as array or comma-separated string, or '*'
593      * @param string  $folder      Folder name
594      * @param boolean $clear_cache False if cache should not be cleared
595      *
596      * @return boolean True on success, False on error
597      */
598     abstract function expunge_message($uids, $folder = null, $clear_cache = true);
599
600
601     /**
602      * Parse message UIDs input
603      *
604      * @param mixed  $uids  UIDs array or comma-separated list or '*' or '1:*'
605      *
606      * @return array Two elements array with UIDs converted to list and ALL flag
607      */
608     protected function parse_uids($uids)
609     {
610         if ($uids === '*' || $uids === '1:*') {
611             if (empty($this->search_set)) {
612                 $uids = '1:*';
613                 $all = true;
614             }
615             // get UIDs from current search set
616             else {
617                 $uids = join(',', $this->search_set->get());
618             }
619         }
620         else {
621             if (is_array($uids)) {
622                 $uids = join(',', $uids);
623             }
624
625             if (preg_match('/[^0-9,]/', $uids)) {
626                 $uids = '';
627             }
628         }
629
630         return array($uids, (bool) $all);
631     }
632
633
634     /* --------------------------------
635      *        folder managment
636      * --------------------------------*/
637
638     /**
639      * Get a list of subscribed folders.
640      *
641      * @param   string  $root      Optional root folder
642      * @param   string  $name      Optional name pattern
643      * @param   string  $filter    Optional filter
644      * @param   string  $rights    Optional ACL requirements
645      * @param   bool    $skip_sort Enable to return unsorted list (for better performance)
646      *
647      * @return  array   List of folders
648      */
649     abstract function list_folders_subscribed($root = '', $name = '*', $filter = null, $rights = null, $skip_sort = false);
650
651
652     /**
653      * Get a list of all folders available on the server.
654      *
655      * @param string  $root      IMAP root dir
656      * @param string  $name      Optional name pattern
657      * @param mixed   $filter    Optional filter
658      * @param string  $rights    Optional ACL requirements
659      * @param bool    $skip_sort Enable to return unsorted list (for better performance)
660      *
661      * @return array Indexed array with folder names
662      */
663     abstract function list_folders($root = '', $name = '*', $filter = null, $rights = null, $skip_sort = false);
664
665
666     /**
667      * Subscribe to a specific folder(s)
668      *
669      * @param array $folders Folder name(s)
670      *
671      * @return boolean True on success
672      */
673     abstract function subscribe($folders);
674
675
676     /**
677      * Unsubscribe folder(s)
678      *
679      * @param array $folders Folder name(s)
680      *
681      * @return boolean True on success
682      */
683     abstract function unsubscribe($folders);
684
685
686     /**
687      * Create a new folder on the server.
688      *
689      * @param string  $folder    New folder name
690      * @param boolean $subscribe True if the newvfolder should be subscribed
691      *
692      * @return boolean True on success, False on error
693      */
694     abstract function create_folder($folder, $subscribe = false);
695
696
697     /**
698      * Set a new name to an existing folder
699      *
700      * @param string $folder   Folder to rename
701      * @param string $new_name New folder name
702      *
703      * @return boolean True on success, False on error
704      */
705     abstract function rename_folder($folder, $new_name);
706
707
708     /**
709      * Remove a folder from the server.
710      *
711      * @param string $folder Folder name
712      *
713      * @return boolean True on success, False on error
714      */
715     abstract function delete_folder($folder);
716
717
718     /**
719      * Send expunge command and clear the cache.
720      *
721      * @param string  $folder      Folder name
722      * @param boolean $clear_cache False if cache should not be cleared
723      *
724      * @return boolean True on success, False on error
725      */
726     public function expunge_folder($folder = null, $clear_cache = true)
727     {
728         return $this->expunge_message('*', $folder, $clear_cache);
729     }
730
731
732     /**
733      * Remove all messages in a folder..
734      *
735      * @param string  $folder  Folder name
736      *
737      * @return boolean True on success, False on error
738      */
739     public function clear_folder($folder = null)
740     {
741         return $this->delete_message('*', $folder);
742     }
743
744
745     /**
746      * Checks if folder exists and is subscribed
747      *
748      * @param string   $folder       Folder name
749      * @param boolean  $subscription Enable subscription checking
750      *
751      * @return boolean True if folder exists, False otherwise
752      */
753     abstract function folder_exists($folder, $subscription = false);
754
755
756     /**
757      * Get folder size (size of all messages in a folder)
758      *
759      * @param string $folder Folder name
760      *
761      * @return int Folder size in bytes, False on error
762      */
763     abstract function folder_size($folder);
764
765
766     /**
767      * Returns the namespace where the folder is in
768      *
769      * @param string $folder Folder name
770      *
771      * @return string One of 'personal', 'other' or 'shared'
772      */
773     abstract function folder_namespace($folder);
774
775
776     /**
777      * Gets folder attributes (from LIST response, e.g. \Noselect, \Noinferiors).
778      *
779      * @param string $folder  Folder name
780      * @param bool   $force   Set to True if attributes should be refreshed
781      *
782      * @return array Options list
783      */
784     abstract function folder_attributes($folder, $force = false);
785
786
787     /**
788      * Gets connection (and current folder) data: UIDVALIDITY, EXISTS, RECENT,
789      * PERMANENTFLAGS, UIDNEXT, UNSEEN
790      *
791      * @param string $folder Folder name
792      *
793      * @return array Data
794      */
795     abstract function folder_data($folder);
796
797
798     /**
799      * Returns extended information about the folder.
800      *
801      * @param string $folder Folder name
802      *
803      * @return array Data
804      */
805     abstract function folder_info($folder);
806
807
808     /**
6e8f2a 809      * Returns current status of a folder (compared to the last time use)
c321a9 810      *
T 811      * @param string $folder Folder name
6e8f2a 812      * @param array  $diff   Difference data
c321a9 813      *
T 814      * @return int Folder status
815      */
6e8f2a 816     abstract function folder_status($folder = null, &$diff = array());
c321a9 817
T 818
819     /**
820      * Synchronizes messages cache.
821      *
822      * @param string $folder Folder name
823      */
824     abstract function folder_sync($folder);
825
826
827     /**
828      * Modify folder name according to namespace.
829      * For output it removes prefix of the personal namespace if it's possible.
830      * For input it adds the prefix. Use it before creating a folder in root
831      * of the folders tree.
832      *
833      * @param string $folder  Folder name
834      * @param string $mode    Mode name (out/in)
835      *
836      * @return string Folder name
837      */
838     abstract function mod_folder($folder, $mode = 'out');
839
840
841     /**
842      * Create all folders specified as default
843      */
844     public function create_default_folders()
845     {
846         // create default folders if they do not exist
847         foreach ($this->default_folders as $folder) {
848             if (!$this->folder_exists($folder)) {
849                 $this->create_folder($folder, true);
850             }
851             else if (!$this->folder_exists($folder, true)) {
852                 $this->subscribe($folder);
853             }
854         }
855     }
856
857
858     /**
859      * Get mailbox quota information.
860      *
861      * @return mixed Quota info or False if not supported
862      */
863     abstract function get_quota();
864
865
866     /* -----------------------------------------
867      *   ACL and METADATA methods
868      * ----------------------------------------*/
869
870     /**
871      * Changes the ACL on the specified folder (SETACL)
872      *
873      * @param string $folder  Folder name
874      * @param string $user    User name
875      * @param string $acl     ACL string
876      *
877      * @return boolean True on success, False on failure
878      */
879     abstract function set_acl($folder, $user, $acl);
880
881
882     /**
883      * Removes any <identifier,rights> pair for the
884      * specified user from the ACL for the specified
885      * folder (DELETEACL).
886      *
887      * @param string $folder  Folder name
888      * @param string $user    User name
889      *
890      * @return boolean True on success, False on failure
891      */
892     abstract function delete_acl($folder, $user);
893
894
895     /**
896      * Returns the access control list for a folder (GETACL).
897      *
898      * @param string $folder Folder name
899      *
900      * @return array User-rights array on success, NULL on error
901      */
902     abstract function get_acl($folder);
903
904
905     /**
906      * Returns information about what rights can be granted to the
907      * user (identifier) in the ACL for the folder (LISTRIGHTS).
908      *
909      * @param string $folder  Folder name
910      * @param string $user    User name
911      *
912      * @return array List of user rights
913      */
914     abstract function list_rights($folder, $user);
915
916
917     /**
918      * Returns the set of rights that the current user has to a folder (MYRIGHTS).
919      *
920      * @param string $folder Folder name
921      *
922      * @return array MYRIGHTS response on success, NULL on error
923      */
924     abstract function my_rights($folder);
925
926
927     /**
928      * Sets metadata/annotations (SETMETADATA/SETANNOTATION)
929      *
930      * @param string $folder  Folder name (empty for server metadata)
931      * @param array  $entries Entry-value array (use NULL value as NIL)
932      *
933      * @return boolean True on success, False on failure
934      */
935     abstract function set_metadata($folder, $entries);
936
937
938     /**
939      * Unsets metadata/annotations (SETMETADATA/SETANNOTATION)
940      *
941      * @param string $folder  Folder name (empty for server metadata)
942      * @param array  $entries Entry names array
943      *
944      * @return boolean True on success, False on failure
945      */
946     abstract function delete_metadata($folder, $entries);
947
948
949     /**
950      * Returns folder metadata/annotations (GETMETADATA/GETANNOTATION).
951      *
952      * @param string $folder   Folder name (empty for server metadata)
953      * @param array  $entries  Entries
954      * @param array  $options  Command options (with MAXSIZE and DEPTH keys)
955      *
956      * @return array Metadata entry-value hash array on success, NULL on error
957      */
958     abstract function get_metadata($folder, $entries, $options = array());
959
960
961     /* -----------------------------------------
962      *   Cache related functions
963      * ----------------------------------------*/
964
965     /**
966      * Clears the cache.
967      *
968      * @param string  $key         Cache key name or pattern
969      * @param boolean $prefix_mode Enable it to clear all keys starting
970      *                             with prefix specified in $key
971      */
972     abstract function clear_cache($key = null, $prefix_mode = false);
973
0c2596 974
c321a9 975     /**
T 976      * Returns cached value
977      *
978      * @param string $key Cache key
979      *
980      * @return mixed Cached value
981      */
982     abstract function get_cache($key);
983
0c2596 984
fec2d8 985     /**
T 986      * Delete outdated cache entries
987      */
60b6d7 988     abstract function cache_gc();
fec2d8 989
c321a9 990 }  // end class rcube_storage