1: <?php
2: /**
3: * Maps a single Kolab_Storage ACL element to the Horde permission system.
4: *
5: * PHP version 5
6: *
7: * @category Horde
8: * @package Perms
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=Perms
12: */
13:
14: /**
15: * Maps a single Kolab_Storage ACL element to the Horde permission system.
16: *
17: * Copyright 2006-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 Horde
23: * @package Perms
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=Perms
27: */
28: abstract class Horde_Perms_Permission_Kolab_Acl
29: {
30: /**
31: * The ACL.
32: *
33: * @var string
34: */
35: private $_acl;
36:
37: /**
38: * Constructor.
39: *
40: * @param string $acl The folder ACL element as provided by the driver.
41: */
42: public function __construct($acl)
43: {
44: $this->_acl = $acl;
45: }
46:
47: /**
48: * Convert the Acl string to a Horde_Perms:: mask and store it in the
49: * provided data array.
50: *
51: * @param array &$data The horde permission data.
52: *
53: * @return NULL
54: */
55: abstract public function toHorde(array &$data);
56:
57: /**
58: * Convert the Acl string to a Horde_Perms:: mask.
59: *
60: * @return int The permission mask
61: */
62: protected function convertAclToMask()
63: {
64: $result = 0;
65: if (strpos($this->_acl, 'l') !== false) {
66: $result |= Horde_Perms::SHOW;
67: }
68: if (strpos($this->_acl, 'r') !== false) {
69: $result |= Horde_Perms::READ;
70: }
71: if (strpos($this->_acl, 'i') !== false) {
72: $result |= Horde_Perms::EDIT;
73: }
74: if (strpos($this->_acl, 'd') !== false ||
75: strpos($this->_acl, 't') !== false) {
76: $result |= Horde_Perms::DELETE;
77: }
78: return $result;
79: }
80: }
81: