AAAAhome/academiac/www/libraries/joomla/access/rule.php000064400000010113151372603020016360 0ustar00 true, 3 => true, 4 => false) * or an equivalent JSON encoded string. * * @param mixed $identities A JSON format string (probably from the database) or a named array. * * @since 11.1 */ public function __construct($identities) { // Convert string input to an array. if (is_string($identities)) { $identities = json_decode($identities, true); } $this->mergeIdentities($identities); } /** * Get the data for the action. * * @return array A named array * * @since 11.1 */ public function getData() { return $this->data; } /** * Merges the identities * * @param mixed $identities An integer or array of integers representing the identities to check. * * @return void * * @since 11.1 */ public function mergeIdentities($identities) { if ($identities instanceof JAccessRule) { $identities = $identities->getData(); } if (is_array($identities)) { foreach ($identities as $identity => $allow) { $this->mergeIdentity($identity, $allow); } } } /** * Merges the values for an identity. * * @param integer $identity The identity. * @param boolean $allow The value for the identity (true == allow, false == deny). * * @return void * * @since 11.1 */ public function mergeIdentity($identity, $allow) { $identity = (int) $identity; $allow = (int) ((boolean) $allow); // Check that the identity exists. if (isset($this->data[$identity])) { // Explicit deny always wins a merge. if ($this->data[$identity] !== 0) { $this->data[$identity] = $allow; } } else { $this->data[$identity] = $allow; } } /** * Checks that this action can be performed by an identity. * * The identity is an integer where +ve represents a user group, * and -ve represents a user. * * @param mixed $identities An integer or array of integers representing the identities to check. * * @return mixed True if allowed, false for an explicit deny, null for an implicit deny. * * @since 11.1 */ public function allow($identities) { // Implicit deny by default. $result = null; // Check that the inputs are valid. if (!empty($identities)) { if (!is_array($identities)) { $identities = array($identities); } foreach ($identities as $identity) { // Technically the identity just needs to be unique. $identity = (int) $identity; // Check if the identity is known. if (isset($this->data[$identity])) { $result = (boolean) $this->data[$identity]; // An explicit deny wins. if ($result === false) { break; } } } } return $result; } /** * Convert this object into a JSON encoded string. * * @return string JSON encoded string * * @since 11.1 */ public function __toString() { return json_encode($this->data); } } /** * Deprecated class placeholder. You should use JAccessRule instead. * * @package Joomla.Platform * @subpackage Access * @since 11.1 * @deprecated 12.3 */ class JRule extends JAccessRule { /** * Constructor. * * The input array must be in the form: array(-42 => true, 3 => true, 4 => false) * or an equivalent JSON encoded string. * * @param mixed $identities A JSON format string (probably from the database) or a named array. * * @since 11.1 * @deprecated 12.3 */ public function __construct($identities) { JLog::add('JRule is deprecated. Use JAccessRule instead.', JLog::WARNING, 'deprecated'); parent::__construct($identities); } } home/academiac/www/libraries/joomla/form/rule.php000064400000004525151372646130016105 0ustar00 tag for the form field object. * @param mixed $value The form field value to validate. * @param string $group The field name group control value. This acts as as an array container for the field. * For example if the field has name="foo" and the group value is set to "bar" then the * full field name would end up being "bar[foo]". * @param object &$input An optional JRegistry object with the entire data set to validate against the entire form. * @param object &$form The form object for which the field is being tested. * * @return boolean True if the value is valid, false otherwise. * * @since 11.1 * @throws JException on invalid rule. */ public function test(&$element, $value, $group = null, &$input = null, &$form = null) { // Check for a valid regex. if (empty($this->regex)) { throw new JException(JText::sprintf('JLIB_FORM_INVALID_FORM_RULE', get_class($this))); } // Add unicode property support if available. if (JCOMPAT_UNICODE_PROPERTIES) { $this->modifiers = (strpos($this->modifiers, 'u') !== false) ? $this->modifiers : $this->modifiers . 'u'; } // Test the value against the regular expression. if (preg_match(chr(1) . $this->regex . chr(1) . $this->modifiers, $value)) { return true; } return false; } }