_setPrefixMappings(); } /** * sets the crud mappings for prefix routes. * * @return void */ protected function _setPrefixMappings() { $crud = array('create', 'read', 'update', 'delete'); $map = array_combine($crud, $crud); $prefixes = Router::prefixes(); if (!empty($prefixes)) { foreach ($prefixes as $prefix) { $map = array_merge($map, array( $prefix . '_index' => 'read', $prefix . '_add' => 'create', $prefix . '_edit' => 'update', $prefix . '_view' => 'read', $prefix . '_remove' => 'delete', $prefix . '_create' => 'create', $prefix . '_read' => 'read', $prefix . '_update' => 'update', $prefix . '_delete' => 'delete' )); } } $this->mapActions($map); } /** * Authorize a user using the mapped actions and the AclComponent. * * @param array $user The user to authorize * @param CakeRequest $request The request needing authorization. * @return boolean */ public function authorize($user, CakeRequest $request) { if (!isset($this->settings['actionMap'][$request->params['action']])) { trigger_error(__d('cake_dev', 'CrudAuthorize::authorize() - Attempted access of un-mapped action "%1$s" in controller "%2$s"', $request->action, $request->controller ), E_USER_WARNING ); return false; } $Acl = $this->_Collection->load('Acl'); return $Acl->check( $user, $this->action($request, ':controller'), $this->settings['actionMap'][$request->params['action']] ); } }