Source for file rules.php
Documentation is available at rules.php
* @package Joomla.Platform
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* @package Joomla.Platform
protected $data =
array();
* The input array must be in the form: array('action' => array(-42 => true, 3 => true, 4 => false))
* or an equivalent JSON encoded string, or an object where properties are arrays.
* @param mixed $input A JSON format string (probably from the database) or a nested array.
// Convert in input to an array.
// Top level keys represent the actions.
foreach ($input as $action =>
$identities)
* Get the data for the action.
* @return array A named array of JAccessRule objects.
* Method to merge a collection of JAccessRules.
* @param mixed $input JAccessRule or array of JAccessRules
// Check if the input is an array.
foreach ($input as $actions)
* Method to merge actions with this object.
* @param mixed $actions JAccessRule object, an array of actions or a JSON string array of actions.
public function merge($actions)
foreach ($actions as $action =>
$identities)
$data =
$actions->getData();
foreach ($data as $name =>
$identities)
* Merges an array of identities for an action.
* @param string $action The name of the action.
* @param array $identities An array of identities
if (isset
($this->data[$action]))
// If exists, merge the action.
$this->data[$action]->mergeIdentities($identities);
// If new, add the action.
* Checks that an action can be performed by an identity.
* The identity is an integer where +ve represents a user group,
* and -ve represents a user.
* @param string $action The name of the action.
* @param mixed $identity An integer representing the identity, or an array of identities
* @return mixed Object or null if there is no information about the action.
public function allow($action, $identity)
// Check we have information about this action.
if (isset
($this->data[$action]))
return $this->data[$action]->allow($identity);
* Get the allowed actions for an identity.
* @param mixed $identity An integer representing the identity or an array of identities
* @return JObject Allowed actions for the identity or identities
// Sweep for the allowed actions.
foreach ($this->data as $name =>
&$action)
if ($action->allow($identity))
$allowed->set($name, true);
* Magic method to convert the object to JSON string representation.
* @return string JSON representation of the actions array
foreach ($this->data as $name =>
$rule)
// Convert the action to JSON, then back into an array otherwise
// re-encoding will quote the JSON for the identities in the action.
Documentation generated on Tue, 19 Nov 2013 15:12:34 +0100 by phpDocumentor 1.4.3