Ejemplo n.º 1
0
 public static function addGroupItem($groupId, $objectId, $provide, $subscribe, $add, $update, $delete, $request, $respond)
 {
     //$db = ZitDBAdapter::getDBAdapter();
     $db = Zend_Registry::get('my_db');
     $data = array(DBConvertor::convertCase('object_id') => $objectId, DBConvertor::convertCase('can_provide') => Utility::convertCheckBoxValue($provide), DBConvertor::convertCase('can_subscribe') => Utility::convertCheckBoxValue($subscribe), DBConvertor::convertCase('can_add') => Utility::convertCheckBoxValue($add), DBConvertor::convertCase('can_update') => Utility::convertCheckBoxValue($update), DBConvertor::convertCase('can_delete') => Utility::convertCheckBoxValue($delete), DBConvertor::convertCase('can_request') => Utility::convertCheckBoxValue($request), DBConvertor::convertCase('can_respond') => Utility::convertCheckBoxValue($respond), DBConvertor::convertCase('group_permission_id') => $groupId);
     if ($db->insert(DBConvertor::convertCase('group_permission_item'), $data)) {
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 2
0
 public function savenewpermissionAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         Zend_Session::regenerateId();
         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());
             $default = null;
             $zoneId = $filterChain->filter($_POST['ZONE_ID']);
             $contextId = $filterChain->filter($_POST['CONTEXT_ID']);
             $agentId = $filterChain->filter($_POST['AGENT_ID']);
             $dataObjectId = $filterChain->filter($_POST['DATA_OBJECT_ID']);
             $provide = $filterChain->filter(Utility::convertCheckBoxValue(isset($_POST['PROVIDE']) ? $_POST['PROVIDE'] : $default));
             $subscribe = $filterChain->filter(Utility::convertCheckBoxValue(isset($_POST['SUBSCRIBE']) ? $_POST['SUBSCRIBE'] : $default));
             $request = $filterChain->filter(Utility::convertCheckBoxValue(isset($_POST['REQUEST']) ? $_POST['REQUEST'] : $default));
             $respond = $filterChain->filter(Utility::convertCheckBoxValue(isset($_POST['RESPOND']) ? $_POST['RESPOND'] : $default));
             $add = $filterChain->filter(Utility::convertCheckBoxValue(isset($_POST['ADD']) ? $_POST['ADD'] : $default));
             $change = $filterChain->filter(Utility::convertCheckBoxValue(isset($_POST['CHANGE']) ? $_POST['CHANGE'] : $default));
             $delete = $filterChain->filter(Utility::convertCheckBoxValue(isset($_POST['DELETE']) ? $_POST['DELETE'] : $default));
             $validatorChain = new Zend_Validate();
             $validatorChain->addValidator(new Zend_Validate_Digits())->addValidator(new Zend_Validate_Between(array('min' => 0, 'max' => 1)));
             /*
             if (!$validatorChain->isValid($provide) &&
             	!$validatorChain->isValid($subscribe) &&
             	!$validatorChain->isValid($request) &&
             	!$validatorChain->isValid($respond) &&
             	!$validatorChain->isValid($add) &&
             	!$validatorChain->isValid($change) &&
             	!$validatorChain->isValid($delete)
             ) {
             	$this->view->msg = 'Data Validation Error';
             	$this->_forward('error', 'error');			
             }
             */
             $exist = Permission::checkIfPermissionExist($zoneId, $agentId, $contextId, $dataObjectId);
             if ($exist) {
                 $this->view->msg = 'Permission Already Exists';
                 $this->_forward('error', 'error');
             } else {
                 Permission::addPermission($zoneId, $agentId, $contextId, $dataObjectId, $provide, $subscribe, $add, $change, $delete, $request, $respond);
                 $this->render('ajaxsuccessjson');
             }
         }
     } else {
         if (!$this->getRequest()->isXmlHttpRequest()) {
             $this->view->msg = 'Not Ajax Request';
             $this->_forward('error', 'error');
         } else {
             $this->view->msg = 'Invalid User';
             $this->_forward('error', 'error');
         }
     }
 }
Ejemplo n.º 3
0
 public static function updatePermission($permissionId, $provide, $subscribe, $add, $update, $delete, $request, $respond)
 {
     $db = Zend_Registry::get('my_db');
     $data = array(DBConvertor::convertCase('can_provide') => Utility::convertCheckBoxValue($provide), DBConvertor::convertCase('can_subscribe') => Utility::convertCheckBoxValue($subscribe), DBConvertor::convertCase('can_add') => Utility::convertCheckBoxValue($add), DBConvertor::convertCase('can_update') => Utility::convertCheckBoxValue($update), DBConvertor::convertCase('can_delete') => Utility::convertCheckBoxValue($delete), DBConvertor::convertCase('can_request') => Utility::convertCheckBoxValue($request), DBConvertor::convertCase('can_respond') => Utility::convertCheckBoxValue($respond));
     $n = $db->update(DBConvertor::convertCase('agent_permissions'), $data, 'permission_id = ' . $permissionId);
 }
Ejemplo n.º 4
0
 public function updategroupitemAction()
 {
     $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 {
                 Zend_Session::regenerateId();
                 $filterChain = new Zend_Filter();
                 $filterChain->addFilter(new Zend_Filter_StripTags());
                 $filterChain2 = new Zend_Filter();
                 $filterChain2->addFilter(new Zend_Filter_Digits());
                 $itemId = $filterChain2->filter($_POST['ITEM_ID']);
                 $provide = $filterChain2->filter(Utility::convertCheckBoxValue($_POST['PROVIDE']));
                 $subscribe = $filterChain2->filter(Utility::convertCheckBoxValue($_POST['SUBSCRIBE']));
                 $request = $filterChain2->filter(Utility::convertCheckBoxValue($_POST['REQUEST']));
                 $respond = $filterChain2->filter(Utility::convertCheckBoxValue($_POST['RESPOND']));
                 $add = $filterChain2->filter(Utility::convertCheckBoxValue($_POST['ADD']));
                 $change = $filterChain2->filter(Utility::convertCheckBoxValue($_POST['CHANGE']));
                 $delete = $filterChain2->filter(Utility::convertCheckBoxValue($_POST['DELETE']));
                 GroupPermissionItem::updateGroupItem($itemId, $provide, $subscribe, $add, $change, $delete, $request, $respond);
                 $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');
             }
         }
     }
 }