/usr/share/php/Horde/Imap/Client/Data/Acl.php is in php-horde-imap-client 2.29.12-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | <?php
/**
* Copyright 2011-2016 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Horde
* @copyright 2011-2016 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Imap_Client
*/
/**
* ACL rights for a mailbox (see RFC 2086/4314).
*
* @author Michael Slusarz <slusarz@horde.org>
* @category Horde
* @copyright 2011-2016 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Imap_Client
*/
class Horde_Imap_Client_Data_Acl extends Horde_Imap_Client_Data_AclCommon implements ArrayAccess, IteratorAggregate, Serializable
{
/**
* ACL rights.
*
* @var array
*/
protected $_rights;
/**
* Constructor.
*
* @param string $rights The rights (see RFC 4314 [2.1]).
*/
public function __construct($rights = '')
{
$this->_rights = str_split($rights);
$this->_normalize();
}
/**
* String representation of the ACL.
*
* @return string String representation (RFC 4314 compliant).
*/
public function __toString()
{
return implode('', $this->_rights);
}
/**
* Computes the difference to another rights string.
* Virtual rights are ignored.
*
* @param string $rights The rights to compute against.
*
* @return array Two element array: added and removed.
*/
public function diff($rights)
{
$rlist = array_diff(str_split($rights), array_keys($this->_virtual));
return array(
'added' => implode('', array_diff($rlist, $this->_rights)),
'removed' => implode('', array_diff($this->_rights, $rlist))
);
}
/**
* Normalize virtual rights (see RFC 4314 [2.1.1]).
*/
protected function _normalize()
{
/* Clients conforming to RFC 4314 MUST ignore the virtual ACL_CREATE
* and ACL_DELETE rights. See RFC 4314 [2.1]. However, we still need
* to handle these rights when dealing with RFC 2086 servers since
* we are abstracting out use of ACL_CREATE/ACL_DELETE to their
* component RFC 4314 rights. */
foreach ($this->_virtual as $key => $val) {
foreach ($val as $right) {
if ($this[$right]) {
foreach (array_keys($this->_virtual) as $virtual) {
unset($this[$virtual]);
}
return;
}
}
}
foreach ($this->_virtual as $key => $val) {
if ($this[$key]) {
unset($this[$key]);
$this->_rights = array_unique(array_merge($this->_rights, $val));
}
}
}
/* ArrayAccess methods. */
/**
*/
public function offsetExists($offset)
{
return $this[$offset];
}
/**
*/
public function offsetGet($offset)
{
return in_array($offset, $this->_rights);
}
/**
*/
public function offsetSet($offset, $value)
{
if ($value) {
if (!$this[$offset]) {
$this->_rights[] = $offset;
$this->_normalize();
}
} elseif ($this[$offset]) {
if (isset($this->_virtual[$offset])) {
foreach ($this->_virtual[$offset] as $val) {
unset($this[$val]);
}
}
unset($this[$offset]);
}
}
/**
*/
public function offsetUnset($offset)
{
$this->_rights = array_values(array_diff($this->_rights, array($offset)));
}
/* IteratorAggregate method. */
public function getIterator()
{
return new ArrayIterator($this->_rights);
}
/* Serializable methods. */
/**
*/
public function serialize()
{
return json_encode($this->_rights);
}
/**
*/
public function unserialize($data)
{
$this->_rights = json_decode($data);
}
}
|