protected function processActionDefault() { if ($this->storage->isEnabledBizProc()) { $documentData = array('DISK' => \Bitrix\Disk\BizProcDocument::generateDocumentComplexType($this->storage->getId()), 'WEBDAV' => \Bitrix\Disk\BizProcDocumentCompatible::generateDocumentComplexType($this->storage->getId())); if (!empty($this->arParams['FILE_ID'])) { $autoExecute = CBPDocumentEventType::Edit; } else { $autoExecute = CBPDocumentEventType::Create; } $this->arParams['BIZPROC_PARAMETERS'] = false; $this->arParams['BIZPROC_PARAMETERS_REQUIRED'] = array(); $workflowTemplateId = ''; foreach ($documentData as $nameModule => $data) { $workflowTemplateObject = CBPWorkflowTemplateLoader::getList(array(), array("DOCUMENT_TYPE" => $data, "AUTO_EXECUTE" => $autoExecute, "ACTIVE" => "Y"), false, false, array("ID", "PARAMETERS")); while ($workflowTemplate = $workflowTemplateObject->getNext()) { if (!empty($workflowTemplate['PARAMETERS'])) { foreach ($workflowTemplate['PARAMETERS'] as $parametersId => $parameters) { if ($parameters['Required']) { $this->arParams['BIZPROC_PARAMETERS_REQUIRED'][] = 'bizproc' . $workflowTemplate['ID'] . '_' . $parametersId; } } $this->arParams['BIZPROC_PARAMETERS'] = true; } $workflowTemplateId = $workflowTemplate['ID']; } } $this->arParams['STATUS_START_BIZPROC'] = !empty($workflowTemplateId); } $this->arParams['STORAGE_ID'] = $this->storage->getId(); $this->includeComponentTemplate(); }
protected function processBeforeAction($actionName) { parent::processBeforeAction($actionName); if (strlen($this->arParams['STORAGE_ID']) <= 0) { ShowError(Loc::getMessage('ACCESS_DENIED') . ' ' . Loc::getMessage('BIZPROC_WFEDIT_ERROR_TYPE')); return false; } if ($this->arResult['ID'] > 0) { $templatesList = CBPWorkflowTemplateLoader::getList(array(), array('ID' => $this->arResult['ID'])); if ($template = $templatesList->fetch()) { if (!CBPDocument::canUserOperateDocumentType(CBPCanUserOperateOperation::CreateWorkflow, $this->getUser()->getID(), $template['DOCUMENT_TYPE'])) { $this->showAccessDenied(); return false; } $this->arResult['TEMPLATE_NAME'] = $template['NAME']; $this->arResult['TEMPLATE_DESC'] = $template['DESCRIPTION']; $this->arResult['TEMPLATE_AUTOSTART'] = $template['AUTO_EXECUTE']; $this->arResult['TEMPLATE'] = $template['TEMPLATE']; $this->arResult['PARAMETERS'] = $template['PARAMETERS']; $this->arResult['VARIABLES'] = $template['VARIABLES']; $this->arResult['CONSTANTS'] = $template['CONSTANTS']; } else { $this->arResult['ID'] = 0; } if ($template["ENTITY"] == Bitrix\Disk\BizProcDocument::className()) { $this->arResult['DOCUMENT_COMPLEX_TYPE'] = \Bitrix\Disk\BizProcDocument::generateDocumentComplexType($this->arParams['STORAGE_ID']); $this->arResult['ENTITY'] = $template['ENTITY']; } else { $this->arResult['DOCUMENT_COMPLEX_TYPE'] = \Bitrix\Disk\BizProcDocumentCompatible::generateDocumentComplexType($this->arParams['STORAGE_ID']); $this->arResult['ENTITY'] = $template['ENTITY']; } } else { $this->arResult['ENTITY'] = Bitrix\Disk\BizProcDocument::className(); $this->arResult['DOCUMENT_COMPLEX_TYPE'] = \Bitrix\Disk\BizProcDocument::generateDocumentComplexType($this->arParams['STORAGE_ID']); if (!CBPDocument::canUserOperateDocumentType(CBPCanUserOperateOperation::CreateWorkflow, $this->getUser()->getID(), $this->arResult['DOCUMENT_COMPLEX_TYPE'])) { $this->showAccessDenied(); return false; } $this->arResult['TEMPLATE_NAME'] = Loc::getMessage("BIZPROC_WFEDIT_DEFAULT_TITLE"); $this->arResult['TEMPLATE_DESC'] = ''; $this->arResult['TEMPLATE_AUTOSTART'] = 1; $this->arResult['PARAMETERS'] = array(); $this->arResult['VARIABLES'] = array(); $this->arResult['CONSTANTS'] = array(); if ($this->request->getQuery('init') == 'statemachine') { $this->arResult['TEMPLATE'] = array(array('Type' => 'StateMachineWorkflowActivity', 'Name' => 'Template', 'Properties' => array(), 'Children' => array())); } else { $this->arResult['TEMPLATE'] = array(array('Type' => 'SequentialWorkflowActivity', 'Name' => 'Template', 'Properties' => array(), 'Children' => array())); } } return true; }
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; }
protected function prepareParams() { $this->arParams['TEMPLATE_ID'] = intval($this->request->getQuery('workflow_template_id')); $this->arParams['SET_TITLE'] = $this->arParams['SET_TITLE'] == 'N' ? 'N' : 'Y'; 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('BPABS_EMPTY_DOC_TYPE'), self::ERROR_COULD_NOT_FIND_STORAGE_ID))); } if (!isset($this->arParams['DOCUMENT_ID'])) { $this->errorCollection->add(array(new Error(Loc::getMessage('BPABS_EMPTY_DOC_ID'), self::ERROR_COULD_NOT_FIND_DOCUMENT_ID))); } if ($this->errorCollection->hasErrors()) { $error = array_shift($this->getErrors()); throw new ArgumentException($error->getMessage()); } $this->arResult['DOCUMENT_DATA'] = array('DISK' => array('DOCUMENT_TYPE' => \Bitrix\Disk\BizProcDocument::generateDocumentComplexType($this->arParams['STORAGE_ID']), 'DOCUMENT_ID' => \Bitrix\Disk\BizProcDocument::getDocumentComplexId($this->arParams['DOCUMENT_ID'])), 'WEBDAV' => array('DOCUMENT_TYPE' => \Bitrix\Disk\BizProcDocumentCompatible::generateDocumentComplexType($this->arParams['STORAGE_ID']), 'DOCUMENT_ID' => \Bitrix\Disk\BizProcDocumentCompatible::getDocumentComplexId($this->arParams['DOCUMENT_ID']))); return $this; }
protected function getBizProcData(BaseObject $object, SecurityContext $securityContext, array $actions, array $columnsBizProc, array $bizprocIcon, array $exportData) { $documentData = array('DISK' => array('DOCUMENT_TYPE' => \Bitrix\Disk\BizProcDocument::generateDocumentComplexType($this->storage->getId()), 'DOCUMENT_ID' => \Bitrix\Disk\BizProcDocument::getDocumentComplexId($object->getId())), 'WEBDAV' => array('DOCUMENT_TYPE' => \Bitrix\Disk\BizProcDocumentCompatible::generateDocumentComplexType($this->storage->getId()), 'DOCUMENT_ID' => \Bitrix\Disk\BizProcDocumentCompatible::getDocumentComplexId($object->getId()))); $listBpTemplates = array(); foreach ($this->arParams['TEMPLATE_BIZPROC'] as $idTemplate => $valueTemplate) { $url = CComponentEngine::MakePathFromTemplate($valueTemplate['URL'], array("ELEMENT_ID" => $object->getId())); $listBpTemplates[] = array("ICONCLASS" => "", "TEXT" => $valueTemplate['NAME'], "ONCLICK" => "jsUtils.Redirect([], '" . CUtil::JSEscape($url) . "');"); } if ($object->canStartBizProc($securityContext) && !empty($listBpTemplates)) { $actions[] = array("ICONCLASS" => "bizproc_start", "TEXT" => Loc::getMessage("DISK_FOLDER_LIST_ACT_START_BIZPROC"), "MENU" => $listBpTemplates); } $webdavFileId = $object->getXmlId(); if (!empty($webdavFileId)) { if (Loader::includeModule("iblock")) { if ($this->storage->getProxyType() instanceof ProxyType\Group) { $iblock = CIBlockElement::getList(array(), array("ID" => $webdavFileId, 'SHOW_NEW' => 'Y'), false, false, array('ID', 'IBLOCK_ID'))->fetch(); $entity = 'CIBlockDocumentWebdavSocnet'; } else { $iblock = CIBlockElement::getList(array(), array("ID" => $webdavFileId, 'SHOW_NEW' => 'Y'), false, false, array('ID', 'IBLOCK_ID'))->fetch(); $entity = 'CIBlockDocumentWebdav'; } if (!empty($iblock)) { $documentData['OLD_FILE'] = array('DOCUMENT_TYPE' => array('webdav', $entity, "iblock_" . $iblock['IBLOCK_ID']), 'DOCUMENT_ID' => array('webdav', $entity, $iblock['ID'])); } } } foreach ($documentData as $nameModuleId => $data) { $temporary[$nameModuleId] = CBPDocument::getDocumentStates($data['DOCUMENT_TYPE'], $data['DOCUMENT_ID']); } if (isset($temporary['OLD_FILE'])) { $documentStates = array_merge($temporary['DISK'], $temporary['WEBDAV'], $temporary['OLD_FILE']); } else { $documentStates = array_merge($temporary['DISK'], $temporary['WEBDAV']); } foreach ($documentStates as $key => $documentState) { if (empty($documentState['ID'])) { unset($documentStates[$key]); } } $columnsBizProc['BIZPROC'] = ""; $bizprocIcon['BIZPROC'] = ""; if (!empty($documentStates)) { if (count($documentStates) == 1) { $documentState = reset($documentStates); if ($documentState['WORKFLOW_STATUS'] > 0 || empty($documentState['WORKFLOW_STATUS'])) { $tasksWorkflow = CBPDocument::getUserTasksForWorkflow($this->getUser()->GetID(), $documentState["ID"]); $columnsBizProc["BIZPROC"] = '<div class="bizproc-item-title">' . htmlspecialcharsbx($documentState["TEMPLATE_NAME"]) . ': ' . '<span class="bizproc-item-title bizproc-state-title" style="">' . '<a href="' . $exportData["OPEN_URL"] . '#tab-bp">' . (strlen($documentState["STATE_TITLE"]) > 0 ? htmlspecialcharsbx($documentState["STATE_TITLE"]) : htmlspecialcharsbx($documentState["STATE_NAME"])) . '</a>' . '</span>' . '</div>'; $columnsBizProc['BIZPROC'] = str_replace("'", "\"", $columnsBizProc['BIZPROC']); $bizprocIcon["BIZPROC"] = "<div class=\"element-bizproc-status bizproc-statuses " . (!(strlen($documentState["ID"]) <= 0 || strlen($documentState["WORKFLOW_STATUS"]) <= 0) ? 'bizproc-status-' . (empty($tasksWorkflow) ? "inprogress" : "attention") : '') . "\" onmouseover='BX.hint(this, \"" . addslashes($columnsBizProc["BIZPROC"]) . "\")'></div>"; if (!empty($tasksWorkflow)) { $tmp = array(); foreach ($tasksWorkflow as $val) { $url = CComponentEngine::makePathFromTemplate($this->arParams["PATH_TO_DISK_TASK"], array("ID" => $val["ID"])); $url .= "?back_url=" . urlencode($this->getApplication()->getCurPageParam()); $tmp[] = '<a href="' . $url . '">' . $val["NAME"] . '</a>'; } $columnsBizProc["BIZPROC"] .= '<div class="bizproc-tasks">' . implode(", ", $tmp) . '</div>'; return array($actions, $columnsBizProc, $bizprocIcon); } return array($actions, $columnsBizProc, $bizprocIcon); } return array($actions, $columnsBizProc, $bizprocIcon); } else { $tasks = array(); $inprogress = false; foreach ($documentStates as $key => $documentState) { if ($documentState['WORKFLOW_STATUS'] > 0 || empty($documentState['WORKFLOW_STATUS'])) { $tasksWorkflow = CBPDocument::getUserTasksForWorkflow($this->getUser()->GetID(), $documentState["ID"]); if (!$inprogress) { $inprogress = strlen($documentState['ID']) > 0 && strlen($documentState['WORKFLOW_STATUS']) > 0; } if (!empty($tasksWorkflow)) { foreach ($tasksWorkflow as $val) { $tasks[] = $val; } } } } $columnsBizProc["BIZPROC"] = '<span class="bizproc-item-title">' . Loc::getMessage("DISK_FOLDER_LIST_GRID_BIZPROC") . ': <a href="' . $exportData["OPEN_URL"] . '#tab-bp" title="' . Loc::getMessage("DISK_FOLDER_LIST_GRID_BIZPROC_TITLE") . '">' . count($documentStates) . '</a></span>' . (!empty($tasks) ? '<br /><span class="bizproc-item-title">' . Loc::getMessage("DISK_FOLDER_LIST_GRID_BIZPROC_TASKS") . ': <a href="' . $this->arParams["PATH_TO_DISK_TASK_LIST"] . '" title="' . Loc::getMessage("DISK_FOLDER_LIST_GRID_BIZPROC_TASKS_TITLE") . '">' . count($tasks) . '</a></span>' : ''); $bizprocIcon["BIZPROC"] = "<div class=\"element-bizproc-status bizproc-statuses " . ($inprogress ? ' bizproc-status-' . (empty($tasks) ? "inprogress" : "attention") : '') . "\" onmouseover='BX.hint(this, \"" . addslashes($columnsBizProc['BIZPROC']) . "\")'></div>"; return array($actions, $columnsBizProc, $bizprocIcon); } } return array($actions, $columnsBizProc, $bizprocIcon); }
/***************** STANDART ****************************************/ $arParams["SET_TITLE"] = $arParams["SET_TITLE"] == "N" ? "N" : "Y"; /******************************************************************** Main data ********************************************************************/ $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_type", "text" => GetMessage("BPABS_EMPTY_DOC_TYPE")); } if (strlen($arParams["DOCUMENT_ID"]) <= 0) { $arError[] = array("id" => "empty_document_id", "text" => GetMessage("BPABS_EMPTY_DOC_ID")); } $documentData = array('DISK' => array('DOCUMENT_TYPE' => \Bitrix\Disk\BizProcDocument::generateDocumentComplexType($arParams['STORAGE_ID']), 'DOCUMENT_ID' => \Bitrix\Disk\BizProcDocument::getDocumentComplexId($arParams["DOCUMENT_ID"])), 'WEBDAV' => array('DOCUMENT_TYPE' => \Bitrix\Disk\BizProcDocumentCompatible::generateDocumentComplexType($arParams['STORAGE_ID']), 'DOCUMENT_ID' => \Bitrix\Disk\BizProcDocumentCompatible::getDocumentComplexId($arParams["DOCUMENT_ID"]))); if (!check_bitrix_sessid()) { $arError[] = array("id" => "access_denied", "text" => GetMessage("BPABS_NO_PERMS")); } if (empty($arError)) { if (!CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::StartWorkflow, $GLOBALS["USER"]->GetID(), $documentData['DISK']["DOCUMENT_ID"], array())) { $arError[] = array("id" => "access_denied", "text" => GetMessage("BPABS_NO_PERMS")); } } if (!empty($arError)) { $e = new CAdminException($arError); ShowError($e->GetString()); return false; } elseif (!empty($_REQUEST["cancel"]) && !empty($_REQUEST["back_url"])) { LocalRedirect(str_replace("#WF#", "", $_REQUEST["back_url"])); }
public static function deleteWorkflowsFile($fileId) { $documentData = array('DISK' => \Bitrix\Disk\BizProcDocument::getDocumentComplexId($fileId), 'WEBDAV' => \Bitrix\Disk\BizProcDocumentCompatible::getDocumentComplexId($fileId)); $errors = array(); foreach ($documentData as $nameModule => $data) { \CBPDocument::onDocumentDelete($data, $errors); } }
if (isset($_REQUEST["action"])) { $backUrl = CComponentEngine::MakePathFromTemplate($arResult["PATH_TO_GROUP_DISK_FILE"], array('group_id' => $arResult['VARIABLES']['group_id'], "FILE_PATH" => $_REQUEST["file"])); $backUrl .= '#tab-bp'; } else { $backUrl = urldecode($_REQUEST["back_url"]); $backUrl .= '#tab-bp'; } if (!preg_match('#^(?:/|\\?|https?://)(?:\\w|$)#D', $backUrl)) { $backUrl = '#'; } $arResult['TOOLBAR'] = array('BUTTONS' => array(array('TEXT' => Loc::getMessage('DISK_FILE_VIEW_START_BIZPROC_GO_BACK_TEXT'), 'TITLE' => Loc::getMessage('DISK_FILE_VIEW_START_BIZPROC__GO_BACK_TITLE'), 'LINK' => $backUrl, 'ICON' => 'back'))); $APPLICATION->includeComponent('bitrix:disk.interface.toolbar', '', array('TOOLBAR_ID' => 'bp_task_toolbar', 'CLASS_NAME' => 'bx-filepage', 'BUTTONS' => $arResult['TOOLBAR']['BUTTONS']), $component, array('HIDE_ICONS' => 'Y')); $arParams["TASK_ID"] = intval($arResult["VARIABLES"]["ID"]); $arParams["USER_ID"] = $GLOBALS["USER"]->GetID(); if ($arParams["TASK_ID"] > 0) { $dbTask = \Bitrix\Disk\BizProcDocument::getTaskServiceList($arParams["TASK_ID"], $arParams["USER_ID"]); $arResult["TASK"] = $dbTask->GetNext(); } ?> <div class="bx-disk-tab-container"></div> <div class="bx-disk-filepage-title"><?php echo Loc::getMessage('DISK_BP'); ?> </div> <div class="bx-disk-filepage-section"> <?php if ($arResult["TASK"]) { $docID = $arResult["TASK"]["PARAMETERS"]["DOCUMENT_ID"][2]; $arResult["VARIABLES"]["ELEMENT_ID"] = $docID; $arResult["VARIABLES"]["ACTION"] = "EDIT"; $APPLICATION->IncludeComponent("bitrix:bizproc.task", "", array("TASK_ID" => $arResult["VARIABLES"]["ID"], "NAME_TEMPLATE" => $arParams["NAME_TEMPLATE"]), $component, array("HIDE_ICONS" => "Y"));
?> </select> <input type="hidden" name="bizproc_index" value="1" /> <input type="submit" name="save" value="<?php echo Loc::getMessage("DISK_FILE_VIEW_BIZPROC_APPLY"); ?> " /> </td> </tr> <?php } ?> <tr class="bizproc-item-row-last"> <td colspan="2"> <?php $APPLICATION->IncludeComponent("bitrix:bizproc.log", "", array("MODULE_ID" => \Bitrix\Disk\Driver::INTERNAL_MODULE_ID, "ENTITY" => \Bitrix\Disk\BizProcDocument::className(), "DOCUMENT_TYPE" => $arResult['STORAGE_ID'], "COMPONENT_VERSION" => 2, "DOCUMENT_ID" => $arResult['FILE']['ID'], "ID" => $idWorkflow), $component, array("HIDE_ICONS" => "Y")); ?> </td> </tr> </table> </li> </ul> <?php } ?> </form> </div> <?php } ?>
/** * Deletes file and all connected data and entities (@see Sharing, @see Rights, etc). * @param int $deletedBy Id of user. * @return bool * @throws \Bitrix\Main\ArgumentNullException */ public function delete($deletedBy) { $this->errorCollection->clear(); $success = EditSessionTable::deleteByFilter(array('OBJECT_ID' => $this->id)); if (!$success) { return false; } $success = ExternalLinkTable::deleteByFilter(array('OBJECT_ID' => $this->id)); if (!$success) { return false; } foreach ($this->getSharingsAsReal() as $sharing) { $sharing->delete($deletedBy); } //with status unreplied, declined (not approved) $success = SharingTable::deleteByFilter(array('REAL_OBJECT_ID' => $this->id)); if (!$success) { return false; } foreach ($this->getAttachedObjects() as $attached) { $attached->delete(); } unset($attached); BizProcDocument::deleteWorkflowsFile($this->id); SimpleRightTable::deleteBatch(array('OBJECT_ID' => $this->id)); $success = RightTable::deleteByFilter(array('OBJECT_ID' => $this->id)); if (!$success) { return false; } $success = VersionTable::deleteByFilter(array('OBJECT_ID' => $this->id)); if (!$success) { return false; } DeletedLog::addFile($this, $deletedBy, $this->errorCollection); \CFile::delete($this->fileId); $deleteResult = FileTable::delete($this->id); if (!$deleteResult->isSuccess()) { return false; } Driver::getInstance()->getIndexManager()->dropIndex($this); if (!$this->isLink()) { //todo potential - very hard operation. foreach (File::getModelList(array('filter' => array('REAL_OBJECT_ID' => $this->id, '!=REAL_OBJECT_ID' => $this->id))) as $link) { $link->delete($deletedBy); } unset($link); } $event = new Event(Driver::INTERNAL_MODULE_ID, "onAfterDeleteFile", array($this->getId(), $deletedBy)); $event->send(); return true; }
} /***************** 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']);
public function processActionStopBizProc() { $this->checkRequiredPostParams(array('fileId', 'idBizProc')); if (!Loader::includeModule("bizproc")) { $this->errorCollection->addOne(new Error(Loc::getMessage('DISK_FILE_VIEW_BIZPROC_LOAD'))); } if ($this->errorCollection->hasErrors()) { $this->sendJsonErrorResponse(); } $fileId = (int) $this->request->getPost('fileId'); /** @var File $file */ $file = File::loadById($fileId); if (!$file) { $this->errorCollection->addOne(new Error(Loc::getMessage('DISK_FILE_VIEW_ERROR_COULD_NOT_FIND_OBJECT'), self::ERROR_COULD_NOT_FIND_OBJECT)); $this->sendJsonErrorResponse(); } $documentData = array('DISK' => array('DOCUMENT_ID' => \Bitrix\Disk\BizProcDocument::getDocumentComplexId($fileId)), 'WEBDAV' => array('DOCUMENT_ID' => \Bitrix\Disk\BizProcDocumentCompatible::getDocumentComplexId($fileId))); $webdavFileId = $file->getXmlId(); if (!empty($webdavFileId)) { $documentData['OLD_FILE_COMMON'] = array('DOCUMENT_ID' => array('webdav', 'CIBlockDocumentWebdav', $webdavFileId)); $documentData['OLD_FILE_GROUP'] = array('DOCUMENT_ID' => array('webdav', 'CIBlockDocumentWebdavSocnet', $webdavFileId)); } $workflowId = $this->request->getPost('idBizProc'); $error = array(); foreach ($documentData as $nameModule => $data) { $availabilityProcess = CBPDocument::GetDocumentState($data['DOCUMENT_ID'], $workflowId); if (!empty($availabilityProcess)) { if (CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::StartWorkflow, $this->getUser()->getId(), $data['DOCUMENT_ID'])) { CBPDocument::TerminateWorkflow($workflowId, $data['DOCUMENT_ID'], $error); } } } if ($error) { $this->errorCollection->addOne(new Error(array_shift($error))); $this->sendJsonErrorResponse(); } $this->sendJsonSuccessResponse(); }
protected function processActionUpdateFile($hash, &$fileData, &$package, &$upload, &$error) { $this->checkRequiredInputParams($_POST, array('targetFileId')); $file = false; if (!$this->errorCollection->hasErrors()) { /** @var File $file */ $file = File::loadById((int) $_POST['targetFileId'], array('STORAGE')); if ($file && isset($_POST['checkBp'])) { $workflowParameters = array(); $search = 'bizproc'; foreach ($_POST as $idParameter => $valueParameter) { $res = strpos($idParameter, $search); if ($res === 0) { $workflowParameters[$idParameter] = $valueParameter; } } $autoExecute = intval($_POST['autoExecute']); \Bitrix\Disk\BizProcDocument::startAutoBizProc($file->getStorageId(), $file->getId(), $autoExecute, $workflowParameters); } if (!$file) { $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_FILE_UPLOAD_ERROR_COULD_NOT_FIND_FILE'), self::ERROR_COULD_NOT_FIND_FILE))); } else { if (!$file->canUpdate($file->getStorage()->getCurrentUserSecurityContext())) { $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_FILE_UPLOAD_ERROR_BAD_RIGHTS2'), self::ERROR_BAD_RIGHTS))); } else { if (!$file->uploadVersion($fileData["files"]["default"], $this->getUser()->getId())) { $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_FILE_UPLOAD_ERROR_COULD_UPLOAD_VERSION'), self::ERROR_COULD_UPLOAD_VERSION))); } } } } $error = implode(" ", (is_object($file) ? $file->getErrors() : array()) + $this->errorCollection->toArray()); return empty($error); }
protected function processActionShowBp() { $this->getApplication()->setTitle($this->storage->getProxyType()->getTitleForCurrentUser()); $viewFile = CComponentEngine::makePathFromTemplate($this->arParams['PATH_TO_FILE_VIEW'], array('FILE_ID' => $this->file->getId(), 'FILE_PATH' => $this->arParams['RELATIVE_PATH'])); $urlStartBizproc = \CComponentEngine::makePathFromTemplate($this->arParams['PATH_TO_DISK_START_BIZPROC'], array("ELEMENT_ID" => $this->file->getId())); $urlStartBizproc .= "?back_url=" . urlencode($this->getApplication()->getCurPage()); $urlStartBizproc .= (strpos($urlStartBizproc, "?") === false ? "?" : "&") . 'workflow_template_id=0&' . bitrix_sessid_get(); $this->arResult = array('STORAGE' => $this->storage, 'FILE' => array('ID' => $this->file->getId()), 'PATH_TO_FILE_VIEW' => $viewFile, 'PATH_TO_START_BIZPROC' => $urlStartBizproc, 'STORAGE_ID' => 'STORAGE_' . $this->storage->getId()); $this->arParams['STATUS_BIZPROC'] = $this->storage->isEnabledBizProc() && Loader::includeModule("bizproc"); if ($this->arParams['STATUS_BIZPROC']) { $documentData = array('DISK' => array('DOCUMENT_TYPE' => \Bitrix\Disk\BizProcDocument::generateDocumentComplexType($this->storage->getId()), 'DOCUMENT_ID' => \Bitrix\Disk\BizProcDocument::getDocumentComplexId($this->file->getId())), 'WEBDAV' => array('DOCUMENT_TYPE' => \Bitrix\Disk\BizProcDocumentCompatible::generateDocumentComplexType($this->storage->getId()), 'DOCUMENT_ID' => \Bitrix\Disk\BizProcDocumentCompatible::getDocumentComplexId($this->file->getId()))); $webdavFileId = $this->file->getXmlId(); if (!empty($webdavFileId)) { if (Loader::includeModule("iblock")) { if ($this->storage->getProxyType() instanceof ProxyType\Group) { $iblock = CIBlockElement::getList(array(), array("ID" => $webdavFileId, 'SHOW_NEW' => 'Y'), false, false, array('ID', 'IBLOCK_ID'))->fetch(); $entity = 'CIBlockDocumentWebdavSocnet'; } else { $iblock = CIBlockElement::getList(array(), array("ID" => $webdavFileId, 'SHOW_NEW' => 'Y'), false, false, array('ID', 'IBLOCK_ID'))->fetch(); $entity = 'CIBlockDocumentWebdav'; } if (!empty($iblock)) { $documentData['OLD_FILE'] = array('DOCUMENT_TYPE' => array('webdav', $entity, "iblock_" . $iblock['IBLOCK_ID']), 'DOCUMENT_ID' => array('webdav', $entity, $iblock['ID'])); } } } $this->showBizProc($documentData); } $this->includeComponentTemplate('bp'); $this->end(); }
$arWorkflowParameters = $arTemplate["PARAMETERS"]; $arWorkflowVariables = $arTemplate["VARIABLES"]; } else { $ID = 0; } if ($arTemplate["ENTITY"] == 'Bitrix\\Disk\\BizProcDocument') { $documentType = \Bitrix\Disk\BizProcDocument::generateDocumentComplexType($arParams['STORAGE_ID']); $arResult['ENTITY'] = $arTemplate["ENTITY"]; } else { $documentType = \Bitrix\Disk\BizProcDocumentCompatible::generateDocumentComplexType($arParams['STORAGE_ID']); $arResult['ENTITY'] = $arTemplate["ENTITY"]; } } if ($ID <= 0) { $arResult['ENTITY'] = $arParams["ENTITY_DISK"]; $documentType = \Bitrix\Disk\BizProcDocument::generateDocumentComplexType($arParams['STORAGE_ID']); if (strlen($storageId) <= 0) { $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED") . " " . GetMessage("BIZPROC_WFEDIT_ERROR_TYPE")); } $canWrite = CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::CreateWorkflow, $GLOBALS["USER"]->GetID(), $documentType); $workflowTemplateName = GetMessage("BIZPROC_WFEDIT_DEFAULT_TITLE"); $workflowTemplateDescription = ''; $workflowTemplateAutostart = 1; if ($_GET['init'] == 'statemachine') { $arWorkflowTemplate = array(array("Type" => "StateMachineWorkflowActivity", "Name" => "Template", "Properties" => array(), "Children" => array())); } else { $arWorkflowTemplate = array(array("Type" => "SequentialWorkflowActivity", "Name" => "Template", "Properties" => array(), "Children" => array())); } $arWorkflowParameters = array(); $arWorkflowVariables = array(); }