1: <?php
2: /**
3: * Maps Kolab_Storage ACL 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 Kolab_Storage ACL 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: class Horde_Perms_Permission_Kolab_AclIterator
29: implements IteratorAggregate
30: {
31: /**
32: * The ACL elements.
33: *
34: * @var array
35: */
36: private $_acl = array();
37:
38: /**
39: * Constructor.
40: *
41: * @param array $acl The folder ACL as provided by the driver.
42: * @param string $creator The ID of the folder creator.
43: */
44: public function __construct(array $acl, $creator)
45: {
46: foreach ($acl as $user => $rights) {
47: if ($user == $creator) {
48: $this->_acl[] = new Horde_Perms_Permission_Kolab_Acl_Creator(
49: $rights
50: );
51: } else if (substr($user, 0, 6) == 'group:') {
52: $this->_acl[] = new Horde_Perms_Permission_Kolab_Acl_Group(
53: $rights, substr($user, 6)
54: );
55: } else if ($user == 'anyone' || $user == 'anonymous'){
56: $class = 'Horde_Perms_Permission_Kolab_Acl_' . ucfirst($user);
57: $this->_acl[] = new $class(
58: $rights
59: );
60: } else {
61: $this->_acl[] = new Horde_Perms_Permission_Kolab_Acl_User(
62: $rights, $user
63: );
64: }
65: }
66: }
67:
68: public function getIterator()
69: {
70: return new ArrayIterator($this->_acl);
71: }
72: }
73: