/** * 以指定的格式输出资源列表 * * @param boolean $style 直接输出数组还是按样式输出 * @param integer $count 总数 * @param integer $offset 起始位置 * @return array|ZtChart_System_View_Helper_ResourceList */ public function resourceList($style = true, $count = null, $offset = 0) { $resource = new ZtChart_System_Model_Resource(); $rowset = $resource->fetchRowset($count, $offset); if (!$style) { return $rowset->toArray(); } $this->_resourceRowset = $rowset; return $this; }
/** * 覆盖 */ public function replaceAction() { if ($this->_request->isPost()) { if (Zend_Registry::isRegistered('Zend_Navigation')) { $container = Zend_Registry::get('Zend_Navigation'); if ($container instanceof Zend_Navigation_Container) { $resource = new ZtChart_System_Model_Resource(); $resource->import($container, 3); ZtChart_Model_Acl_Loader::resetCache(); return; } } $this->_helper->dialog('数据追加错误', Zend_Log::ERR); } }
/** * 设置权限 */ public function assignAction() { if (!$this->_hasParam('role_id')) { return $this->render('deny'); } $roleId = $this->_getParam('role_id'); $resourceAccess = new ZtChart_System_Model_Resource(); $allowedResourceId = $resourceAccess->findRoleSelfAndDescendants(Zend_Registry::get('user')->getRoleId()); $roleAccess = new ZtChart_System_Model_Role(); if ($this->_request->isPost()) { if ($roleAccess->saveAcl($this->_request->getPost('resource_id'), $allowedResourceId, $roleId)) { ZtChart_Model_Acl_Loader::resetCache(); $this->_helper->dialog('设置权限成功', Zend_Log::INFO); } else { $this->_helper->dialog('设置权限失败', Zend_Log::WARN); } } $this->view->resourceId = $roleAccess->fetchResourceId($roleId); $this->view->allowedResourceId = $allowedResourceId; }