Exemplo n.º 1
0
Arquivo: Acl.php Projeto: abdala/la
 protected function _getAcl()
 {
     $acl = false;
     if (Zend_Registry::isRegistered('cache')) {
         $cache = Zend_Registry::get('cache');
         $acl = $cache->load('acl');
     }
     if (!$acl) {
         $acl = new Zend_Acl();
         $role = new Auth_Model_DbTable_Role();
         $resource = new Auth_Model_DbTable_Resource();
         $roleResource = new Auth_Model_DbTable_RoleResource();
         $roles = $role->fetchAll("name <> 'Todos'");
         $resources = $resource->getDistinctModules();
         $relations = $roleResource->fetchAllRelations();
         $acl->addRole('Todos');
         foreach ($roles as $role) {
             $acl->addRole($role['name'], 'Todos');
         }
         foreach ($resources as $resource) {
             $acl->addResource($resource['module']);
         }
         foreach ($relations as $relation) {
             $acl->allow($relation['name'], $relation['module'], $relation['privilege']);
         }
         if (Zend_Registry::isRegistered('cache')) {
             $cache->save($acl, 'acl');
         }
     }
     Zend_Registry::set('acl', $acl);
     return $acl;
 }
Exemplo n.º 2
0
 /**
  * Save entity
  *
  * @param Auth_Model_Role $role
  */
 public function save(Auth_Model_Role $role)
 {
     $data = array();
     $data = $role->toArray();
     //        $this->_populateDataArr($data, $user, array('id','code','title',
     //            'content','application_id'));
     $id = $role->get_id();
     if (!isset($id) || $id <= 0) {
         unset($data['id']);
         $id = $this->_dbTable->insert($data);
         $role->set_id($id);
     } else {
         $this->_dbTable->update($data, array('id = ?' => $id));
     }
 }