public function getRolePrivilegeById($id)
 {
     $db = Zend_DB_table_Abstract::getDefaultAdapter();
     $dbUser = $this->getDbTable()->info();
     $dbUserName = $dbUser['name'];
     $roleMapper = new Cloud_Model_Role_CloudRoleMapper();
     $dbRole = $roleMapper->getDbTable()->info();
     $dbRoleName = $dbRole['name'];
     $rolePrivilegeMapper = new Cloud_Model_RolePrivilege_CloudRolePrivilegeMapper();
     $dbRolePrivilege = $rolePrivilegeMapper->getDbTable()->info();
     $dbRolePrivilegeName = $dbRolePrivilege['name'];
     $privilegeMapper = new Cloud_Model_Privilege_CloudPrivilegeMapper();
     $dbPrivilege = $privilegeMapper->getDbTable()->info();
     $dbPrivilegeName = $dbPrivilege['name'];
     $privilegeTypeMapper = new Cloud_Model_PrivilegeType_CloudPrivilegeTypeMapper();
     $dbPrivilegeType = $privilegeTypeMapper->getDbTable()->info();
     $dbPrivilegeTypeName = $dbPrivilegeType['name'];
     $select = $db->select()->from(array('u' => $dbUserName), array())->join(array('r' => $dbRoleName), 'u.role_id = r.id', array())->join(array('rp' => $dbRolePrivilegeName), 'rp.role_id = r.id', array())->join(array('p' => $dbPrivilegeName), 'p.id = rp.pri_id', array('id'))->join(array('pt' => $dbPrivilegeTypeName), 'pt.id = p.pri_type_id', array('description'))->where('u.id = ?', $id);
     return $db->fetchAll($select);
 }
 public function getButton2V2ById($id, $moduleId)
 {
     $db = Zend_DB_table_Abstract::getDefaultAdapter();
     $dbPrivilegeType = $this->getDbTable()->info();
     $dbPrivilegeTypeName = $dbPrivilegeType['name'];
     $privilegeMapper = new Cloud_Model_Privilege_CloudPrivilegeMapper();
     $dbPrivilege = $privilegeMapper->getDbTable()->info();
     $dbPrivilegeName = $dbPrivilege['name'];
     $select = $db->select()->from(array('p' => $dbPrivilegeName), array())->join(array('pt' => $dbPrivilegeTypeName), 'p.pri_type_id = pt.id', array('button2'))->where("p.id in ({$id})")->where('p.module_id = ?', $moduleId)->where("pt.description != 'access'")->where("pt.description != 'Edit'")->where("pt.description != 'Delete'");
     return $db->fetchAll($select);
 }
 public function editItemAction()
 {
     $this->view->headTitle($this->config['title']['editMenuItem']);
     if ($this->request->getParam('id') != null) {
         $id = $this->request->getParam('id');
         $privilegeMapper = new Cloud_Model_Privilege_CloudPrivilegeMapper();
         $currentItem = new Cloud_Model_MenuItem_CloudMenuItem();
         $this->menuItemMapper->find($id, $currentItem);
         $form = new Cloud_Form_Admin_MenuItem_Edit(array('item' => $currentItem, 'privileges' => $privilegeMapper->getAccessPrivilege()));
         if ($this->getRequest()->isPost()) {
             if ($form->isValid($this->request->getPost())) {
                 $values = $form->getValues();
                 $item = new Cloud_Model_MenuItem_CloudMenuItem($values);
                 $this->menuItemMapper->save($item);
                 $this->menuItemMapper->updateHome($values['id'], $values['is_home'], $currentItem->getMenu_cat_id());
                 $this->view->message = 'Đã sửa item: ' . $item->getName();
             }
         }
         $this->view->form = $form;
     }
 }