1: <?php
2: /**
3: * Maps Horde permission elements into Kolab_Storage ACL.
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 Horde permission elements into Kolab_Storage ACL.
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_ElementIterator
29: implements IteratorAggregate
30: {
31: /**
32: * The Horde permission elements.
33: *
34: * @var array
35: */
36: private $_elements = array();
37:
38: /**
39: * Constructor.
40: *
41: * @param array $permissions The folder permissions as provided by
42: * Horde.
43: * @param Horde_Group_Base $groups The group handler.
44: * @param string $creator The ID of the folder creator.
45: */
46: public function __construct(array $permissions, Horde_Group_Base $groups,
47: $creator)
48: {
49: foreach ($permissions as $user => $user_perms) {
50: if ($user == 'default') {
51: $this->_elements[] = new Horde_Perms_Permission_Kolab_Element_Default(
52: $user_perms
53: );
54: } else if ($user == 'guest') {
55: $this->_elements[] = new Horde_Perms_Permission_Kolab_Element_Guest(
56: $user_perms
57: );
58: } else if ($user == 'creator') {
59: $this->_elements[] = new Horde_Perms_Permission_Kolab_Element_Creator(
60: $user_perms, $creator
61: );
62: } else if ($user == 'groups') {
63: foreach ($user_perms as $user_entry => $perms) {
64: $this->_elements[] = new Horde_Perms_Permission_Kolab_Element_Group(
65: $perms, $user_entry, $groups
66: );
67: }
68: } else if ($user == 'users') {
69: foreach ($user_perms as $user_entry => $perms) {
70: $this->_elements[] = new Horde_Perms_Permission_Kolab_Element_User(
71: $perms, $user_entry
72: );
73: }
74: }
75: }
76: }
77:
78: public function getIterator()
79: {
80: return new ArrayIterator($this->_elements);
81: }
82: }
83: