Exemple #1
0
 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')));
 }
Exemple #2
0
if (!$arResult["TASK"]) {
    ShowError(GetMessage("BPAT_NO_TASK"));
    return false;
}
if ($arResult["TASK"]['STATUS'] > CBPTaskStatus::Running || $arResult["TASK"]['USER_STATUS'] > CBPTaskUserStatus::Waiting) {
    $arResult["ShowMode"] = "Success";
    $arResult['IsComplete'] = true;
}
if ($arResult['ReadOnly'] && isset($arResult['TASK']['PARAMETERS']['AccessControl']) && $arResult['TASK']['PARAMETERS']['AccessControl'] == 'Y') {
    $arResult['TASK']['DESCRIPTION'] = '';
}
$arState = CBPStateService::GetWorkflowState($arResult['TASK']['WORKFLOW_ID']);
if (!$arState) {
    ShowError(GetMessage("BPAT_NO_STATE"));
    // Let`s clean up!
    CBPTaskService::DeleteByWorkflow($arResult['TASK']['WORKFLOW_ID']);
    return false;
}
$arResult['TASK']['PARAMETERS']['DOCUMENT_ID'] = $arState['DOCUMENT_ID'];
$arResult["TASK"]["MODULE_ID"] = $arResult["TASK"]["PARAMETERS"]["DOCUMENT_ID"][0];
$arResult["TASK"]["ENTITY"] = $arResult["TASK"]["PARAMETERS"]["DOCUMENT_ID"][1];
$arResult["TASK"]["DOCUMENT_ID"] = $arResult["TASK"]["PARAMETERS"]["DOCUMENT_ID"][2];
$arParams["DOCUMENT_URL"] = trim($arParams["DOCUMENT_URL"]);
if (empty($arParams["DOCUMENT_URL"])) {
    $arParams["DOCUMENT_URL"] = CBPDocument::GetDocumentAdminPage($arResult["TASK"]["PARAMETERS"]["DOCUMENT_ID"]);
} else {
    $arParams["DOCUMENT_URL"] = CComponentEngine::MakePathFromTemplate($arParams["DOCUMENT_URL"], $arResult["TASK"]);
}
$arResult["TASK"]["URL"] = array("VIEW" => htmlspecialcharsbx($arParams["DOCUMENT_URL"]), "~VIEW" => $arParams["DOCUMENT_URL"]);
if ($_SERVER["REQUEST_METHOD"] == "POST" && $_POST["action"] == "doTask" && check_bitrix_sessid()) {
    $arErrorsTmp = array();
Exemple #3
0
	/**
	* Метод удаляет все связанные с документом записи.
	*
	* @param array $documentId - код документа в виде массива array(модуль, сущность, код_документа_в_модуле).
	* @param array $arErrors - массив ошибок, которые произошли при удалении в виде array(array("code" => код_ошибки, "message" => сообщение, "file" => путь_к_файлу), ...).
	*/
	public static function OnDocumentDelete($documentId, &$arErrors)
	{
		$arErrors = array();

		$arStates = CBPStateService::GetDocumentStates($documentId);
		foreach ($arStates as $workflowId => $arState)
		{
			if (strlen($arState["ID"]) > 0 && strlen($arState["WORKFLOW_STATUS"]) > 0)
				self::TerminateWorkflow($workflowId, $documentId, $arErrors);

			CBPTrackingService::DeleteByWorkflow($workflowId);
			CBPTaskService::DeleteByWorkflow($workflowId);
		}

		CBPStateService::DeleteByDocument($documentId);
		CBPHistoryService::DeleteByDocument($documentId);
	}
Exemple #4
0
 } elseif ($_REQUEST["action"] == "del_bizproc") {
     if ($arParams["DropWorkflowPermission"] != "Y") {
         $arError[] = array("id" => "access_denied", "text" => GetMessage("BPADH_NO_PERMS"));
     } else {
         $ar = array();
         if (isset($arDocumentStates[$_REQUEST['id']]['WORKFLOW_STATUS']) && $arDocumentStates[$_REQUEST['id']]['WORKFLOW_STATUS'] !== null) {
             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);
         } else {
             CBPTaskService::DeleteByWorkflow($_REQUEST["id"]);
             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"]);
     $needUpdateStatesList = false;
     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)) {
Exemple #5
0
 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;
 }