1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: 15: 16: 17: 18: 19: 20: 21: 22:
23: class IMP_Ftree_Account_Remote extends IMP_Ftree_Account_Imap
24: {
25:
26: const REMOTE_KEY = "remote\0";
27:
28: 29:
30: public function __construct($id = null)
31: {
32: if (is_null($id)) {
33: throw new InvalidArgumentException('Constructor requires an account ID.');
34: }
35:
36: parent::__construct($id);
37: }
38:
39: 40:
41: public function getList($query = array(), $mask = 0)
42: {
43: global $injector;
44:
45: $out = array();
46:
47: $init = $this->imp_imap->init;
48:
49: $remote = $injector->getInstance('IMP_Remote');
50: $raccount = $remote[strval($this)];
51:
52: $query = array_filter(
53: array_map(array($remote, 'getMailboxById'), $query)
54: );
55: if (empty($query)) {
56: $mask |= self::INIT;
57: }
58:
59: if ($mask & self::INIT) {
60: $out[] = array(
61: 'a' => IMP_Ftree::ELT_REMOTE | IMP_Ftree::ELT_NOSELECT | IMP_Ftree::ELT_NONIMAP,
62: 'v' => self::REMOTE_KEY
63: );
64:
65: $out[] = array(
66: 'a' => ($init ? IMP_Ftree::ELT_REMOTE_AUTH : 0) | IMP_Ftree::ELT_REMOTE | IMP_Ftree::ELT_IS_SUBSCRIBED | IMP_Ftree::ELT_NONIMAP,
67: 'p' => self::REMOTE_KEY,
68: 'v' => strval($this)
69: );
70: }
71:
72: if ($init) {
73: foreach (parent::getList($query, $mask) as $val) {
74: $out[] = array_filter(array(
75: 'a' => $val['a'] | IMP_Ftree::ELT_REMOTE_MBOX,
76: 'p' => isset($val['p']) ? $raccount->mailbox($val['p']) : strval($raccount),
77: 'v' => $raccount->mailbox($val['v'])
78: ));
79: }
80: }
81:
82: return $out;
83: }
84:
85: 86:
87: public function delete(IMP_Ftree_Element $elt)
88: {
89: if ($elt->remote_auth) {
90: return self::DELETE_ELEMENT_QUICK | self::DELETE_RECURSIVE;
91: }
92:
93: return $elt->remote
94: ? self::DELETE_ELEMENT_QUICK
95: : self::DELETE_ELEMENT;
96: }
97:
98: }
99: