$arResult["STORAGE_ID"] = \Bitrix\Disk\BizProcDocument::generateDocumentType($arParams["STORAGE_ID"]); $arParams["USER_GROUPS"] = $GLOBALS["USER"]->GetUserGroupArray(); if (method_exists($arParams["DOCUMENT_TYPE"][1], "GetUserGroups")) { $arParams["USER_GROUPS"] = call_user_func_array(array($arParams["ENTITY"], "GetUserGroups"), array($documentData['DISK']['DOCUMENT_TYPE'], $arResult["STORAGE_ID"], $GLOBALS["USER"]->GetID())); } if (empty($arError)) { if (!CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::CreateWorkflow, $GLOBALS["USER"]->GetID(), $documentData['DISK']['DOCUMENT_TYPE'], array("UserGroups" => $arParams["USER_GROUPS"]))) { $arError[] = array("id" => "access_denied", "text" => GetMessage("BPATT_NO_PERMS")); } } if (!empty($arError)) { $e = new CAdminException($arError); ShowError($e->GetString()); return false; } elseif ($_REQUEST['action'] == 'create_default') { CBPDocument::AddDefaultWorkflowTemplates($documentData['DISK']['DOCUMENT_TYPE']); LocalRedirect($APPLICATION->GetCurPageParam("", array("action", "sessid"))); } elseif ($_REQUEST['action'] == 'delete') { $arErrorsTmp = array(); foreach ($documentData as $nameModule => $data) { $dbRes = CBPWorkflowTemplateLoader::GetList(array($by => $order), array("DOCUMENT_TYPE" => $data["DOCUMENT_TYPE"], "ID" => $_REQUEST["ID"]), false, false, array("ID")); $availabilityTemplate = $dbRes->Fetch(); if (!empty($availabilityTemplate)) { CBPDocument::DeleteWorkflowTemplate($_REQUEST['ID'], $data["DOCUMENT_TYPE"], $arErrorsTmp); } } if (empty($arErrorsTmp)) { $url = !empty($_REQUEST["back_url"]) ? $_REQUEST["back_url"] : $APPLICATION->GetCurPageParam("", array("action", "sessid", "ID")); LocalRedirect($url); } elseif (!empty($arErrorsTmp)) { foreach ($arErrorsTmp as $e) {
} } } } } } if (false == $boolFlag) { if ($ex = $APPLICATION->GetException()) { $strWarning .= $ex->GetString() . "<br>"; $bVarsFromForm = true; } } } if (!$bVarsFromForm) { if ($bBizproc && $_REQUEST['BIZ_PROC_ADD_DEFAULT_TEMPLATES'] == 'Y' && CBPDocument::GetNumberOfWorkflowTemplatesForDocumentType(array("iblock", "CIBlockDocument", "iblock_" . $ID)) <= 0 && $arFields["BIZPROC"] == "Y") { CBPDocument::AddDefaultWorkflowTemplates(array("iblock", "CIBlockDocument", "iblock_" . $ID)); } $DB->Commit(); //Check if index needed CIBlock::CheckForIndexes($ID); if ($bCatalog) { if (isset($boolNeedAgent) && $boolNeedAgent == true) { $intYandexExport = CCatalog::GetList(array(), array('YANDEX_EXPORT' => 'Y'), array()); CAgent::RemoveAgent("CCatalog::PreGenerateXML(\"yandex\");", "catalog"); if (0 < $intYandexExport) { CAgent::AddAgent("CCatalog::PreGenerateXML(\"yandex\");", "catalog", "N", IntVal(COption::GetOptionString("catalog", "yandex_xml_period", "24")) * 60 * 60, "", "Y"); } } } $ob = new CAutoSave(); if (strlen($apply) <= 0) {
$arParams["USER_GROUPS"] = $GLOBALS["USER"]->GetUserGroupArray(); if (method_exists($arParams["DOCUMENT_TYPE"][1], "GetUserGroups")) { $arParams["USER_GROUPS"] = call_user_func_array(array($arParams["ENTITY"], "GetUserGroups"), array($documentType, $arParams["DOCUMENT_ID"], $GLOBALS["USER"]->GetID())); } if (empty($arError)) { if (!CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::CreateWorkflow, $GLOBALS["USER"]->GetID(), $documentType, array("UserGroups" => $arParams["USER_GROUPS"]))) { $arError[] = array("id" => "access_denied", "text" => GetMessage("BPATT_NO_PERMS")); } } if (!empty($arError)) { $e = new CAdminException($arError); ShowError($e->GetString()); return false; } elseif (!empty($_REQUEST['action']) && !check_bitrix_sessid()) { } elseif ($_REQUEST['action'] == 'create_default') { CBPDocument::AddDefaultWorkflowTemplates($documentType); LocalRedirect($APPLICATION->GetCurPageParam("", array("action", "sessid"))); } elseif ($_REQUEST['ID'] <= 0) { } elseif ($_REQUEST['action'] == 'delete') { $arErrorsTmp = array(); CBPDocument::DeleteWorkflowTemplate($_REQUEST['ID'], $documentType, $arErrorsTmp); if (empty($arErrorsTmp)) { $url = !empty($_REQUEST["back_url"]) ? $_REQUEST["back_url"] : $APPLICATION->GetCurPageParam("", array("action", "sessid", "ID")); LocalRedirect($url); } elseif (!empty($arErrorsTmp)) { foreach ($arErrorsTmp as $e) { $arError[] = array("id" => "delete_error", "text" => $e["message"]); } $e = new CAdminException($arError); ShowError($e->GetString()); }