Example #1
0
 /**
  * Function makes some actions based on what is in $this->request
  * @return void
  */
 protected function performAction()
 {
     $this->dbResult['REQUEST'] = array('GET' => $this->request->getQueryList(), 'POST' => $this->request->getPostList());
     $this->componentData['LIST_HEADERS'] = Helper::getListGridColumns();
     // columns figure in list
     $this->componentData['FILTER_HEADERS'] = Helper::getFilterColumns();
     // columns figure in filter
     //_print_r($this->dbResult['REQUEST']);
     $requestMethod = \Bitrix\Main\Context::getCurrent()->getServer()->getRequestMethod();
     $this->getGridOpts();
     $gridId = $this->dbResult['GRID_ID'];
     $parameters = array();
     $actionSupposeToBeDone = false;
     if ($requestMethod === 'POST' && check_bitrix_sessid() && isset($this->dbResult['REQUEST']['POST']['action_button_' . $gridId])) {
         // group delete
         $action = $this->dbResult['REQUEST']['POST']['action_button_' . $gridId];
         if ($this->dbResult['CAN_DELETE'] && $action === 'delete') {
             if ($this->dbResult['REQUEST']['POST']['action_all_rows_' . $gridId] == 'Y') {
                 $parameters = $this->getListParameters();
             } else {
                 // delete all by list
                 $parameters['ID'] = $this->dbResult['REQUEST']['POST']['ID'];
             }
             $actionSupposeToBeDone = true;
         }
     } elseif ($requestMethod == 'GET' && check_bitrix_sessid() && isset($this->dbResult['REQUEST']['GET']['action_' . $gridId])) {
         // single delete
         if ($this->dbResult['CAN_DELETE'] && $this->dbResult['REQUEST']['GET']['action_' . $gridId] === 'delete') {
             if (isset($this->dbResult['REQUEST']['GET']['ID'])) {
                 $parameters['ID'] = array($this->dbResult['REQUEST']['GET']['ID']);
             }
         }
         $actionSupposeToBeDone = true;
     }
     $parameters['OPERATION'] = 'DELETE';
     $result = Helper::performGridOperations($parameters);
     if (is_array($result['errors'])) {
         $this->errors['NONFATAL'] = array_merge($this->errors['NONFATAL'], $result['errors']);
     }
     if ($actionSupposeToBeDone && !$this->checkHasErrors() && !isset($this->dbResult['REQUEST']['POST']['AJAX_CALL'])) {
         LocalRedirect($GLOBALS['APPLICATION']->GetCurPage());
     }
 }