protected function prepareParams() { $this->arResult['ID'] = intval($this->arParams['ID']); if (!empty($this->arParams['HIDE_TAB_PERMISSION']) && $this->arParams['HIDE_TAB_PERMISSION'] == 'Y') { $this->arResult['HIDE_TAB_PERMISSION'] = true; } else { $this->arResult['HIDE_TAB_PERMISSION'] = false; } $this->arResult['LIST_PAGE_URL'] = $this->arParams['LIST_PAGE_URL']; $this->arResult['EDIT_PAGE_TEMPLATE'] = $this->arParams['EDIT_PAGE_TEMPLATE']; $this->arResult['DOCUMENT_TYPE'] = \Bitrix\Disk\BizProcDocument::generateDocumentType($this->arParams['STORAGE_ID']); $this->arResult['MODULE_ID'] = $this->arParams['MODULE_ID']; return $this; }
protected function prepareParams() { $this->arParams['STORAGE_ID'] = isset($this->arParams['DOCUMENT_ID']) ? intval(str_replace('STORAGE_', '', $this->arParams['DOCUMENT_ID'])) : $this->arParams['STORAGE_ID']; $this->arParams['SET_TITLE'] = $this->arParams['SET_TITLE'] == 'N' ? 'N' : 'Y'; $this->arParams['NAME_TEMPLATE'] = empty($this->arParams['NAME_TEMPLATE']) ? COption::getOptionString('bizproc', 'name_template', CSite::getNameFormat(false), SITE_ID) : str_replace(array('#NOBR#', '#/NOBR#'), array('', ''), $this->arParams['NAME_TEMPLATE']); if (!isset($this->arParams['MODULE_ID'])) { $this->errorCollection->add(array(new Error(Loc::getMessage('BPATT_NO_MODULE_ID'), self::ERROR_COULD_NOT_FIND_MODULE_ID))); } if (!isset($this->arParams['STORAGE_ID'])) { $this->errorCollection->add(array(new Error(Loc::getMessage('BPATT_NO_DOCUMENT_TYPE'), self::ERROR_COULD_NOT_FIND_STORAGE_ID))); } if ($this->errorCollection->hasErrors()) { $error = array_shift($this->getErrors()); throw new ArgumentException($error->getMessage()); } $this->arParams['DOCUMENT_DATA'] = array('DISK' => array('DOCUMENT_TYPE' => \Bitrix\Disk\BizProcDocument::generateDocumentComplexType($this->arParams['STORAGE_ID'])), 'WEBDAV' => array('DOCUMENT_TYPE' => \Bitrix\Disk\BizProcDocumentCompatible::generateDocumentComplexType($this->arParams['STORAGE_ID']))); $this->arParams['DOCUMENT_TYPE'] = \Bitrix\Disk\BizProcDocument::generateDocumentType($this->arParams['STORAGE_ID']); return $this; }
} /***************** STANDART ****************************************/ $arParams["SET_TITLE"] = $arParams["SET_TITLE"] == "N" ? "N" : "Y"; $arParams['NAME_TEMPLATE'] = empty($arParams['NAME_TEMPLATE']) ? COption::GetOptionString("bizproc", "name_template", CSite::GetNameFormat(false), SITE_ID) : str_replace(array("#NOBR#", "#/NOBR#"), array("", ""), $arParams["NAME_TEMPLATE"]); /******************************************************************** /Input params ********************************************************************/ $arError = array(); if (strlen($arParams["MODULE_ID"]) <= 0) { $arError[] = array("id" => "empty_module_id", "text" => GetMessage("BPATT_NO_MODULE_ID")); } if (strlen($arParams["STORAGE_ID"]) <= 0) { $arError[] = array("id" => "empty_document_id", "text" => GetMessage("BPATT_NO_DOCUMENT_TYPE")); } $documentData = array('DISK' => array('DOCUMENT_TYPE' => \Bitrix\Disk\BizProcDocument::generateDocumentComplexType($arParams["STORAGE_ID"])), 'WEBDAV' => array('DOCUMENT_TYPE' => \Bitrix\Disk\BizProcDocumentCompatible::generateDocumentComplexType($arParams["STORAGE_ID"]))); $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']);