config == null) { $this->config = $this->readConfigFile(APP . 'Config' . DS . 'acl.ini.php'); } $aclConfig = $this->config; if (is_array($aro)) { $aro = Hash::get($aro, $this->userPath); } if (isset($aclConfig[$aro]['deny'])) { $userDenies = $this->arrayTrim(explode(",", $aclConfig[$aro]['deny'])); if (array_search($aco, $userDenies)) { return false; } } if (isset($aclConfig[$aro]['allow'])) { $userAllows = $this->arrayTrim(explode(",", $aclConfig[$aro]['allow'])); if (array_search($aco, $userAllows)) { return true; } } if (isset($aclConfig[$aro]['groups'])) { $userGroups = $this->arrayTrim(explode(",", $aclConfig[$aro]['groups'])); foreach ($userGroups as $group) { if (array_key_exists($group, $aclConfig)) { if (isset($aclConfig[$group]['deny'])) { $groupDenies = $this->arrayTrim(explode(",", $aclConfig[$group]['deny'])); if (array_search($aco, $groupDenies)) { return false; } } if (isset($aclConfig[$group]['allow'])) { $groupAllows = $this->arrayTrim(explode(",", $aclConfig[$group]['allow'])); if (array_search($aco, $groupAllows)) { return true; } } } } } return false; } /** * Parses an INI file and returns an array that reflects the * INI file's section structure. Double-quote friendly. * * @param string $filename File * @return array INI section structure */ public function readConfigFile($filename) { App::uses('IniReader', 'Configure'); $iniFile = new IniReader(dirname($filename) . DS); return $iniFile->read(basename($filename)); } /** * Removes trailing spaces on all array elements (to prepare for searching) * * @param array $array Array to trim * @return array Trimmed array */ public function arrayTrim($array) { foreach ($array as $key => $value) { $array[$key] = trim($value); } array_unshift($array, ""); return $array; } }