<script> alert('<?php echo GetMessage("BIZPROC_WFEDIT_SAVE_ERROR"); ?> <?php echo AddSlashes(htmlspecialcharsbx($e->getMessage())); ?> '); </script> <?php die; } set_exception_handler('wfeexception_handler'); try { if ($ID > 0) { CBPWorkflowTemplateLoader::Update($ID, $arFields); } else { $ID = CBPWorkflowTemplateLoader::Add($arFields); } } catch (Exception $e) { wfeexception_handler($e); } restore_exception_handler(); ?> <script type="text/javascript"> window.location = '<?php echo $_REQUEST["apply"] == "Y" ? Cutil::JSEscape("/bitrix/admin/" . MODULE_ID . "_bizproc_workflow_edit.php?lang=" . LANGUAGE_ID . "&entity=" . AddSlashes(ENTITY) . "&ID=" . $ID . "&back_url_list=" . urlencode($_REQUEST["back_url_list"])) : Cutil::JSEscape($back_url); ?> '; </script> <?php
/** * Метод изменяет параметры шаблона рабочего потока. * * @param int $id - код шаблона рабочего потока. * @param array $documentType - код типа документа в виде массива array(модуль, сущность, код_типа_документа_в_модуле). * @param array $arFields - массив новых значений параметров шаблона рабочего потока. * @param array $arErrors - массив ошибок, которые произошли при выполнении в виде array(array("code" => код_ошибки, "message" => сообщение, "file" => путь_к_файлу), ...). */ public static function UpdateWorkflowTemplate($id, $documentType, $arFields, &$arErrors) { $arErrors = array(); $dbTemplates = CBPWorkflowTemplateLoader::GetList( array(), array("ID" => $id, "DOCUMENT_TYPE" => $documentType), false, false, array("ID") ); $arTemplate = $dbTemplates->Fetch(); if (!$arTemplate) { $arErrors[] = array( "code" => 0, "message" => str_replace("#ID#", $id, GetMessage("BPCGDOC_INVALID_WF_ID")), "file" => "" ); return; } try { CBPWorkflowTemplateLoader::Update($id, $arFields); } catch (Exception $e) { $arErrors[] = array( "code" => $e->getCode(), "message" => $e->getMessage(), "file" => $e->getFile()." [".$e->getLine()."]" ); } }
} } } $arKeys = array_keys($arResult["VARIABLES"]); foreach ($arKeys as $variableKey) { $arErrorsTmp = array(); $arResult["VARIABLES"][$variableKey]["Default"] = $arResult["DocumentService"]->GetFieldInputValue($arResult["DOCUMENT_TYPE"], $arResult["VARIABLES"][$variableKey], $variableKey, $arRequest, $arErrorsTmp); $arResult["VARIABLES"][$variableKey]['Default_printable'] = $arResult["DocumentService"]->GetFieldInputValuePrintable($arResult["DOCUMENT_TYPE"], $arResult["VARIABLES"][$variableKey], $arResult["VARIABLES"][$variableKey]["Default"]); if (count($arErrorsTmp) > 0) { foreach ($arErrorsTmp as $e) { $errorMessageTmp .= $e["message"]; } } } if (strlen($errorMessageTmp) <= 0) { CBPWorkflowTemplateLoader::Update($arResult["ID"], array("VARIABLES" => $arResult["VARIABLES"])); if (strlen($_REQUEST["save_variables"]) > 0) { LocalRedirect(CComponentEngine::MakePathFromTemplate($arResult['LIST_PAGE_URL'])); } else { LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams["EDIT_PAGE_TEMPLATE"], array("ID" => $arResult["ID"]))); } } else { $arResult["ErrorMessage"] .= $errorMessageTmp; } } } $this->IncludeComponentTemplate(); if (strlen($arResult["FatalErrorMessage"]) <= 0) { if ($arParams["SET_TITLE"] == "Y") { $APPLICATION->SetTitle(str_replace("#NAME#", $arResult["NAME"], GetMessage("BPWC_WVC_PAGE_TITLE"))); }
if (strpos($_REQUEST['action'], "create") !== false) { $tmp = CBPDocumentEventType::Create; } elseif (strpos($_REQUEST['action'], "edit") !== false) { $tmp = CBPDocumentEventType::Edit; } elseif (strpos($_REQUEST['action'], "delete") !== false) { $tmp = CBPDocumentEventType::Delete; } if ($tmp != false) { if (strpos($_REQUEST['action'], "_n") !== false) { $arFields["AUTO_EXECUTE"] = ($arFields["AUTO_EXECUTE"] & $tmp) != 0 ? $arFields["AUTO_EXECUTE"] ^ $tmp : $arFields["AUTO_EXECUTE"]; } else { $arFields["AUTO_EXECUTE"] = ($arFields["AUTO_EXECUTE"] & $tmp) == 0 ? $arFields["AUTO_EXECUTE"] ^ $tmp : $arFields["AUTO_EXECUTE"]; } } if ($arFields["AUTO_EXECUTE"] != $res["AUTO_EXECUTE"]) { CBPWorkflowTemplateLoader::Update($_REQUEST["ID"], $arFields); } } } $url = !empty($_REQUEST["back_url"]) ? $_REQUEST["back_url"] : $APPLICATION->GetCurPageParam("", array("action", "sessid", "ID")); LocalRedirect($url); } /******************************************************************** Default falues ********************************************************************/ $arResult["NAV_STRING"] = ""; $arResult["NAV_RESULT"] = ""; $arResult["TEMPLATES"] = array(); $arResult["GRID_TEMPLATES"] = array(); /******************************************************************** Data
$arResult["CONSTANTS"][$variableKey]['Default_printable'] = $arResult["DocumentService"]->GetFieldInputValuePrintable($arResult["DOCUMENT_TYPE"], $arResult["CONSTANTS"][$variableKey], $arResult["CONSTANTS"][$variableKey]["Default"]); if (count($arErrorsTmp) > 0) { foreach ($arErrorsTmp as $e) { $errorMessageTmp .= GetMessage("BPWFSC_ARGUMENT_ERROR", array('#PARAM#' => $arResult["CONSTANTS"][$variableKey]['Name'], '#ERROR#' => $e["message"])) . ' '; } } if (empty($arErrorsTmp)) { $required = !(!$arResult["CONSTANTS"][$variableKey]['Required'] || is_int($arResult["CONSTANTS"][$variableKey]['Required']) && $arResult["CONSTANTS"][$variableKey]['Required'] == 0 || strtoupper($arResult["CONSTANTS"][$variableKey]['Required']) == "N"); if ($required && (is_array($arResult["CONSTANTS"][$variableKey]["Default"]) && count($arResult["CONSTANTS"][$variableKey]["Default"]) <= 0 || !is_array($arResult["CONSTANTS"][$variableKey]["Default"]) && $arResult["CONSTANTS"][$variableKey]["Default"] === null)) { $errorMessageTmp .= GetMessage("BPWFSC_ARGUMENT_NULL", array('#PARAM#' => $arResult["CONSTANTS"][$variableKey]['Name'])) . ' '; } } } $errorMessageTmp = trim($errorMessageTmp); if (strlen($errorMessageTmp) <= 0) { CBPWorkflowTemplateLoader::Update($arResult["ID"], array("CONSTANTS" => $arResult["CONSTANTS"])); if ($arParams['AJAX_RESPONSE']) { $APPLICATION->RestartBuffer(); echo CUtil::PhpToJSObject(array('SUCCESS' => true)); CMain::FinalActions(); die; } LocalRedirect($arResult['BackUrl']); } else { $arResult["ErrorMessage"] .= $errorMessageTmp; if ($arParams['AJAX_RESPONSE']) { $APPLICATION->RestartBuffer(); echo CUtil::PhpToJSObject(array('ERROR_MESSAGE' => $arResult["ErrorMessage"])); CMain::FinalActions(); die; }
$arRequest[$k] = $v; } } } $arKeys = array_keys($arResult["WorkflowVariables"]); foreach ($arKeys as $variableKey) { $arErrorsTmp = array(); $arResult["WorkflowVariables"][$variableKey]["Default"] = $arResult["DocumentService"]->GetFieldInputValue(array("bizproc", "CBPVirtualDocument", "type_" . $arResult["Block"]["ID"]), $arResult["WorkflowVariables"][$variableKey], $variableKey, $arRequest, $arErrorsTmp); if (count($arErrorsTmp) > 0) { foreach ($arErrorsTmp as $e) { $errorMessageTmp .= $e["message"]; } } } if (strlen($errorMessageTmp) <= 0) { CBPWorkflowTemplateLoader::Update($arResult["WorkflowTemplateId"], array("VARIABLES" => $arResult["WorkflowVariables"])); if (strlen($_REQUEST["save_variables"]) > 0) { LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_LIST"], array("block_id" => $arResult["Block"]["ID"]))); } else { LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_SETVAR"], array("block_id" => $arResult["Block"]["ID"]))); } } else { $arResult["ErrorMessage"] .= $errorMessageTmp; } } } $this->IncludeComponentTemplate(); if (strlen($arResult["FatalErrorMessage"]) <= 0) { if ($arParams["SET_TITLE"] == "Y") { $APPLICATION->SetTitle(str_replace("#NAME#", $arResult["BlockType"]["NAME"], GetMessage("BPWC_WVC_PAGE_TITLE"))); }