protected function processActionPerformActionBp() { if (!Loader::includeModule('bizproc')) { $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_LAC_MODULE_NOT_INSTALLED')))); } $this->checkRequiredPostParams(array('iblockTypeId', 'iblockId', 'sectionId', 'workflowId', 'elementId', 'action')); if ($this->request->getPost('iblockTypeId') == COption::getOptionString('lists', 'livefeed_iblock_type_id')) { $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_LAC_UNKNOWN_ERROR')))); } if ($this->errorCollection->hasErrors()) { $this->sendJsonErrorResponse(); } $this->iblockTypeId = $this->request->getPost('iblockTypeId'); $this->iblockId = $this->request->getPost('iblockId'); $this->sectionId = $this->request->getPost('sectionId'); $workflowId = $this->request->getPost('workflowId'); $elementId = $this->request->getPost('elementId'); $action = $this->request->getPost('action'); $this->documentStates = CBPDocument::getDocumentStates(BizProcDocument::generateDocumentComplexType($this->iblockTypeId, $this->iblockId), BizProcDocument::getDocumentComplexId($this->iblockTypeId, $elementId)); if (isset($this->documentStates[$workflowId]['WORKFLOW_STATUS']) && $this->documentStates[$workflowId]['WORKFLOW_STATUS'] !== null) { $this->terminateWorkflow($workflowId, $elementId); } if ($action == 'delete') { if (CBPDocument::canUserOperateDocument(CBPCanUserOperateOperation::CreateWorkflow, $this->getUser(), BizProcDocument::getDocumentComplexId($this->iblockTypeId, $elementId), array("DocumentStates" => $this->documentStates))) { CBPTaskService::DeleteByWorkflow($workflowId); CBPTrackingService::DeleteByWorkflow($workflowId); CBPStateService::DeleteWorkflow($workflowId); } else { $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_LAC_ACCESS_DENIED')))); } if ($this->errorCollection->hasErrors()) { $this->sendJsonErrorResponse(); } } $this->sendJsonSuccessResponse(array('message' => Loc::getMessage('LISTS_LAC_MESSAGE_SUCCESS'))); }
} else { CBPDocument::TerminateWorkflow($_REQUEST["id"], $arParams["DOCUMENT_ID"], $ar); if (count($ar) > 0) { $str = ""; foreach ($ar as $a) { $str .= $a["message"]; } $arError[] = array("id" => "stop_bizproc", "text" => $str); } } } elseif ($_REQUEST["action"] == "del_bizproc") { if ($arParams["DropWorkflowPermission"] != "Y") { $arError[] = array("id" => "access_denied", "text" => GetMessage("BPADH_NO_PERMS")); } else { CBPTrackingService::DeleteByWorkflow($_REQUEST["id"]); CBPStateService::DeleteWorkflow($_REQUEST["id"]); } } elseif ($_SERVER['REQUEST_METHOD'] == "POST" && intval($_REQUEST["bizproc_index"]) > 0) { $arBizProcWorkflowId = array(); $bizprocIndex = intval($_REQUEST["bizproc_index"]); for ($i = 1; $i <= $bizprocIndex; $i++) { $bpId = trim($_REQUEST["bizproc_id_" . $i]); $bpTemplateId = intval($_REQUEST["bizproc_template_id_" . $i]); $bpEvent = trim($_REQUEST["bizproc_event_" . $i]); if (strlen($bpEvent) > 0) { if (strlen($bpId) > 0) { if (!array_key_exists($bpId, $arDocumentStates)) { continue; } } else { if (!array_key_exists($bpTemplateId, $arDocumentStates)) {
public static function killWorkflow($workflowId, $terminate = true, $documentId = null) { $errors = array(); if ($terminate) { static::TerminateWorkflow($workflowId, $documentId, $errors); } \Bitrix\Bizproc\WorkflowInstanceTable::delete($workflowId); CBPTaskService::DeleteByWorkflow($workflowId); CBPTrackingService::DeleteByWorkflow($workflowId); CBPStateService::DeleteWorkflow($workflowId); return $errors; }