/** * Check permission for a given ARO to a given ACO. * * @return void */ public function check() { extract($this->_getParams()); if ($this->Acl->check($aro, $aco, $action)) { $this->out(__d('cake_console', '%s is <success>allowed</success>.', $aroName), true); } else { $this->out(__d('cake_console', '%s is <error>not allowed</error>.', $aroName), true); } }
/** * Check permission for a given ARO to a given ACO. * * @access public */ function check() { $this->_checkArgs(3, 'check'); extract($this->__getParams()); if ($this->Acl->check($aro, $aco, $action)) { $this->out(sprintf(__("%s is allowed.", true), $aroName), true); } else { $this->out(sprintf(__("%s is not allowed.", true), $aroName), true); } }
/** * Pass-thru function for ACL check instance. Check methods * are used to check whether or not an ARO can access an ACO * * @param string $aro ARO The requesting object identifier. * @param string $aco ACO The controlled object identifier. * @param string $action Action (defaults to *) * @return boolean Success * @access public */ function check($aro, $aco, $action = "*") { $path = $this->__cachePath($aro, $aco, $action); if ($this->Session->check($path)) { return $this->Session->read($path); } else { $check = parent::check($aro, $aco, $action); $this->Session->write($path, $check); return $check; } }
/** * Check method. * * This method overrides and uses the original * method. It only adds cache to it. * * @param string $aro ARO * @param string $aco ACO * @param string $action Action (defaults to *) * @access public */ function check($aro, $aco, $action = "*") { $path = $this->__cachePath($aro, $aco, $action); $check = Cache::read($path, 'acl'); if ($check === false) { $check = parent::check($aro, $aco, $action); Cache::write($path, $check ? true : 0, 'acl'); } else { $check = $check === true; } return $check; }
function checkHelper($aro, $aco, $action = "*") { if (isset($this->cached[$aro . '/aco:' . $aco . '/action:' . $action])) { return $this->cached[$aro . '/aco:' . $aco . '/action:' . $action] == 'true' ? true : false; } $cache = Cache::read(Inflector::slug('acl/' . $aro . '/aco:' . $aco . '/action:' . $action), 'one day'); if (empty($cache)) { $acl = new AclComponent(); App::import('Component', 'Acl'); $cache = $acl->check($aro, $aco, $action) ? 'true' : 'false'; Cache::write(Inflector::slug('acl/' . $aro . '/aco:' . $aco . '/action:' . $action), $cache, 'one day'); $this->cached[$aro . '/aco:' . $aco . '/action:' . $action] = $cache; } return $cache == 'true' ? true : false; }
protected function _aclCheck($url) { $plugin = ''; if (isset($url['plugin'])) { $plugin = Inflector::camelize($url['plugin']) . '/'; } $controller = ''; if (isset($url['controller'])) { $controller = Inflector::camelize($url['controller']) . '/'; } $action = 'index'; if (isset($url['action'])) { $action = $url['action']; } $collection = new ComponentCollection(); $acl = new AclComponent($collection); $aro = array($this->userModel => array($this->primaryKey => AuthComponent::user($this->primaryKey))); $aco = $plugin . $controller . $action; return $acl->check($aro, $aco); }
public function check($aco) { App::import('Component', 'Acl'); $acl = new AclComponent(new ComponentCollection()); switch ($_SESSION['Auth']['user_type']) { case 'Employee': $current_user_id = $_SESSION['Auth']['User']['vc_emp_id_makess']; //$Session->read('Auth.Employees.vc_emp_id_makess'); //Cache::delete("{$current_user_id}_{$aco}","default"); $acl_permission = Cache::read("{$current_user_id}_{$aco}", "default"); if ($acl_permission !== false) { //CakeLog::write('activity', 'TESTING JAI SHREE RAM'.$acl_permission); return (bool) $acl_permission; } $aros = $acl->Aro->find('all', array('conditions' => array('model' => 'Employee', 'foreign_key' => $current_user_id))); break; case 'Customer': $aros = $acl->Aro->find('all', array('conditions' => array('model' => 'Customer', 'foreign_key' => $current_user_id))); break; } //$query_end_time = microtime(true); //$time = $query_end_time - $start_time; //CakeLog::write('activity', 'QUERY '.$time); foreach ($aros as $aro) { if ($acl->check($aro['Aro'], $aco)) { //$end_time = microtime(true); //$time = $end_time - $start_time; //CakeLog::write('activity', '-- END '.$time.' COUNT '.count($aros)); Cache::write("{$current_user_id}_{$aco}", "1", "default"); return true; } } //$end_time = microtime(true); //$time = $end_time - $start_time; //CakeLog::write('activity', '-- END '.$time.' COUNT '.count($aros)); Cache::write("{$current_user_id}_{$aco}", "0", "default"); return false; }
/** * Check DB * * Verifica a permissão diretamente no banco de dados * * @param array $aro ARO * @param array $aco ACO * @param string $action Action * @return boolean * @access public */ function checkDB($aro, $aco, $action = "*") { return parent::check($aro, $aco, $action); }
function checkHelper($aro, $aco, $action = "*") { App::import('Component', 'Acl'); $acl = new AclComponent(); return $acl->check($aro, $aco, $action); }
/** * Validates a user against an abstract object. * * @param mixed $object The object to validate the user against. * @param mixed $user Optional. The identity of the user to be validated. * Uses the current user session if none specified. For * valid forms of identifying users, see * AuthComponent::identify(). * @param string $action Optional. The action to validate against. * @see AuthComponent::identify() * @return boolean True if the user validates, false otherwise. */ public function validate($object, $user = null, $action = null) { if (empty($user)) { $user = $this->user(); } if (empty($user)) { return false; } return $this->Acl->check($user, $object, $action); }