示例#1
0
 public static function useGroupOnAgent($groupId, $agentId, $zoneId, $contextId, $override)
 {
     $db = Zend_Registry::get('my_db');
     $items = GroupPermissionItem::getGroupItems($groupId);
     foreach ($items as $item) {
         $exists = Permission::checkIfPermissionExist($zoneId, $agentId, $contextId, $item->objectId);
         if ($exists == 1 && $override == 1) {
             $db->delete(DBConvertor::convertCase('agent_permissions'), DBConvertor::convertCase('zone_id') . ' = ' . $zoneId . ' and ' . DBConvertor::convertCase('agent_id') . ' = ' . $agentId . ' and ' . DBConvertor::convertCase('context_id') . ' = ' . $contextId);
             Permission::addPermission($zoneId, $agentId, $contextId, $item->objectId, $item->provide, $item->subscribe, $item->add, $item->update, $item->delete_, $item->request, $item->respond);
         }
         if ($exists == 0) {
             Permission::addPermission($zoneId, $agentId, $contextId, $item->objectId, $item->provide, $item->subscribe, $item->add, $item->update, $item->delete_, $item->request, $item->respond);
         }
     }
 }
 public function getgroupsitemsAction()
 {
     $auth = Zend_Auth::getInstance();
     $lic = $_REQUEST['lic'];
     if ($lic != $_SESSION['OPENZISKEYHOLE']) {
         $this->view->msg = 'Not Ajax Request';
         $this->_forward('error', 'error');
     } else {
         if ($auth->hasIdentity()) {
             if (!$this->getRequest()->isXmlHttpRequest()) {
                 $this->view->msg = 'Not Ajax Request';
                 $this->_forward('error', 'error');
             } else {
                 $filterChain = new Zend_Filter();
                 $filterChain->addFilter(new Zend_Filter_Digits());
                 $id = $filterChain->filter($_POST['GROUP_ID']);
                 $items = GroupPermissionItem::getGroupItems($id);
                 $json = Zend_Json::encode($items);
                 $this->view->json = $json;
                 $this->render('ajaxsuccessjson');
             }
         } else {
             if (!$this->getRequest()->isXmlHttpRequest()) {
                 $this->view->msg = 'Not Ajax Request';
                 $this->_forward('error', 'error');
             } else {
                 $this->view->msg = 'errors:{reason:"Invalid User"}';
                 $this->_forward('error', 'error');
             }
         }
     }
 }