10 defined(
'JPATH_PLATFORM') or die;
27 protected $data = array();
39 public function __construct($identities)
42 if (is_string($identities))
44 $identities = json_decode($identities,
true);
47 $this->mergeIdentities($identities);
57 public function getData()
71 public function mergeIdentities($identities)
73 if ($identities instanceof JAccessRule)
75 $identities = $identities->getData();
78 if (is_array($identities))
80 foreach ($identities as $identity => $allow)
82 $this->mergeIdentity($identity, $allow);
97 public function mergeIdentity($identity, $allow)
99 $identity = (int) $identity;
100 $allow = (int) ((
boolean) $allow);
103 if (isset($this->data[$identity]))
106 if ($this->data[$identity] !== 0)
108 $this->data[$identity] = $allow;
113 $this->data[$identity] = $allow;
129 public function allow($identities)
135 if (!empty($identities))
137 if (!is_array($identities))
139 $identities = array($identities);
142 foreach ($identities as $identity)
145 $identity = (int) $identity;
148 if (isset($this->data[$identity]))
150 $result = (boolean) $this->data[$identity];
153 if ($result ===
false)
172 public function __toString()
174 return json_encode($this->data);