1: <?php
2: /**
3: * Handles a list of folder acls.
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: * Handles a list of folder acls.
16: *
17: * Copyright 2011-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_List_Query_Acl_Base
29: implements Horde_Kolab_Storage_List_Query_Acl
30: {
31: /**
32: * The queriable list.
33: *
34: * @var Horde_Kolab_Storage_List
35: */
36: private $_list;
37:
38: /**
39: * The driver for accessing the Kolab storage system.
40: *
41: * @var Horde_Kolab_Storage_Driver
42: */
43: private $_driver;
44:
45: /**
46: * Constructor.
47: *
48: * @param Horde_Kolab_Storage_List $list The queriable list.
49: * @param array $params Additional parameters.
50: */
51: public function __construct(Horde_Kolab_Storage_List $list,
52: $params)
53: {
54: $this->_list = $list;
55: $this->_driver = $this->_list->getDriver();
56: }
57:
58: /**
59: * Does the backend support ACL?
60: *
61: * @return boolean True if the backend supports ACLs.
62: */
63: public function hasAclSupport()
64: {
65: return $this->_driver->hasAclSupport();
66: }
67:
68: /**
69: * Retrieve the access rights for a folder.
70: *
71: * @param string $folder The folder to retrieve the ACL for.
72: *
73: * @return array An array of rights.
74: */
75: public function getAcl($folder)
76: {
77: if (!$this->hasAclSupport()) {
78: return array($this->_driver->getAuth() => 'lrid');
79: }
80:
81: $acl = $this->getMyAcl($folder);
82: if (strpos($acl, 'a') !== false) {
83: try {
84: return $this->_driver->getAcl($folder);
85: } catch (Horde_Kolab_Storage_Exception $e) {
86: }
87: }
88:
89: return array($this->_driver->getAuth() => $acl);
90: }
91:
92: /**
93: * Retrieve the access rights the current user has on a folder.
94: *
95: * @param string $folder The folder to retrieve the user ACL for.
96: *
97: * @return string The user rights.
98: */
99: public function getMyAcl($folder)
100: {
101: if (!$this->hasAclSupport()) {
102: return 'lrid';
103: }
104: return $this->_driver->getMyAcl($folder);
105: }
106:
107: /**
108: * Retrieve the all access rights on a folder.
109: *
110: * @param string $folder The folder to retrieve the ACL for.
111: *
112: * @since Horde_Kolab_Storage 1.1.0
113: *
114: * @return string The folder rights.
115: */
116: public function getAllAcl($folder)
117: {
118: if (!$this->hasAclSupport()) {
119: return array($this->_driver->getAuth() => 'lrid');
120: }
121: return $this->_driver->getAcl($folder);
122: }
123:
124: /**
125: * Set the access rights for a folder.
126: *
127: * @param string $folder The folder to act upon.
128: * @param string $user The user to set the ACL for.
129: * @param string $acl The ACL.
130: *
131: * @return NULL
132: */
133: public function setAcl($folder, $user, $acl)
134: {
135: $this->_failOnMissingAcl();
136: return $this->_driver->setAcl($folder, $user, $acl);
137: }
138:
139: /**
140: * Delete the access rights for user on a folder.
141: *
142: * @param string $folder The folder to act upon.
143: * @param string $user The user to delete the ACL for
144: *
145: * @return NULL
146: */
147: public function deleteAcl($folder, $user)
148: {
149: $this->_failOnMissingAcl();
150: return $this->_driver->deleteAcl($folder, $user);
151: }
152:
153: private function _failOnMissingAcl()
154: {
155: if (!$this->hasAclSupport()) {
156: throw new Horde_Kolab_Storage_Exception('The backend does not support ACL.');
157: }
158: }
159:
160: /**
161: * Create a new folder.
162: *
163: * @param string $folder The path of the folder to create.
164: * @param string $type An optional type for the folder.
165: *
166: * @return NULL
167: */
168: public function createFolder($folder, $type = null)
169: {
170: }
171:
172: /**
173: * Delete a folder.
174: *
175: * @param string $folder The path of the folder to delete.
176: *
177: * @return NULL
178: */
179: public function deleteFolder($folder)
180: {
181: }
182:
183: /**
184: * Rename a folder.
185: *
186: * @param string $old The old path of the folder.
187: * @param string $new The new path of the folder.
188: *
189: * @return NULL
190: */
191: public function renameFolder($old, $new)
192: {
193: }
194:
195: /**
196: * Return the last sync stamp.
197: *
198: * @return string The stamp.
199: */
200: public function getStamp()
201: {
202: return $this->_list->getStamp();
203: }
204:
205: /**
206: * Synchronize the ACL information with the information from the backend.
207: *
208: * @param array $params Additional parameters.
209: *
210: * @return NULL
211: */
212: public function synchronize($params = array())
213: {
214: }
215: }