$runtime->StartRuntime(); $documentService = $runtime->GetService("DocumentService"); $arResult["DocumentFields"] = $arDocumentFields = $documentService->GetDocumentFields($documentType); foreach ($arDocumentFields as $key => $value) { if (strpos($key, 'PROPERTY_') === false) { $arSelectFields[] = $key; } } /*$db = CIBlockElement::GetList( array(), array("ID" => $arParams["BP_ID"], "IBLOCK_ID" => $arParams["BLOCK_ID"], "CHECK_BP_VIRTUAL_PERMISSIONS" => "read"), false, false, $arSelectFields );*/ list($dbRecordsList, $dbRecordsList1) = CBPVirtualDocument::GetList(array(), array("ID" => $arParams["BP_ID"], "IBLOCK_ID" => $arParams["BLOCK_ID"], "CHECK_BP_VIRTUAL_PERMISSIONS" => "read"), false, false, $arSelectFields); if ($arRecord = $dbRecordsList->GetNext()) { $arKeys = array_keys($arRecord); foreach ($arKeys as $key) { if ($arDocumentFields[$key]["BaseType"] == "file") { $ar = array_filter((array) $arRecord[$key]); $arRecord[$key] = ''; if (sizeof($ar) > 0) { $fileIterator = CFile::getList(array('ID' => 'ASC'), array('@ID' => $ar)); while ($file = $fileIterator->fetch()) { if ($arRecord[$key] != '') { $arRecord[$key] .= ' '; } $arRecord[$key] .= '<a href="/bitrix/tools/bizproc_show_file.php?bp_id=' . $arParams['BP_ID'] . '&iblock_id=' . $arParams['BLOCK_ID'] . '&f=' . urlencode($key) . '&i=' . $file['ID'] . '">' . htmlspecialcharsbx($file['ORIGINAL_NAME']) . '</a>'; } }
foreach ($arResult["TEMPLATE"]["PARAMETERS"] as $parameterKey => $arParameter) { $arErrorsTmp = array(); $arWorkflowParameters[$parameterKey] = $arResult["DocumentService"]->GetFieldInputValue($documentType, $arParameter, $parameterKey, $arRequest, $arErrorsTmp); if ($arParameter["Required"] && ($arParameter["Multiple"] && count($arWorkflowParameters[$parameterKey]) <= 0 || !$arParameter["Multiple"] && $arWorkflowParameters[$parameterKey] === null)) { $arErrorsTmp[] = array("code" => "RequiredValue", "message" => str_replace("#NAME#", $arParameter["Name"], GetMessage("BPCGWTL_INVALID81")), "parameter" => $parameterKey); } if (count($arErrorsTmp) > 0) { $bCanStartWorkflow = false; foreach ($arErrorsTmp as $e) { $arResult["ErrorMessage"] .= $e["message"] . "<br />"; } } } } if ($bCanStartWorkflow) { $documentId = CBPVirtualDocument::CreateDocument(0, array("IBLOCK_ID" => $arParams["BLOCK_ID"], "NAME" => GetMessage("BPWC_WRC_Z"), "CREATED_BY" => "user_" . $GLOBALS["USER"]->GetID())); $arErrorsTmp = array(); $wfId = CBPDocument::StartWorkflow($workflowTemplateId, array("bizproc", "CBPVirtualDocument", $documentId), array_merge($arWorkflowParameters, array("TargetUser" => "user_" . intval($GLOBALS["USER"]->GetID()))), $arErrorsTmp); if (count($arErrorsTmp) > 0) { $arResult["ShowMode"] = "StartWorkflowError"; foreach ($arErrorsTmp as $e) { $arResult["ErrorMessage"] .= "[" . $e["code"] . "] " . $e["message"] . "<br />"; } } else { $arResult["ShowMode"] = "StartWorkflowSuccess"; $d = CBPTaskService::GetList(array(), array("WORKFLOW_ID" => $wfId, "USER_ID" => intval($GLOBALS["USER"]->GetID())), false, false, array("ID")); if ($r = $d->Fetch()) { $backUrl = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_TASK"], array("task_id" => $r["ID"], "block_id" => $arParams["BLOCK_ID"])); } else { $backUrl = $arResult["BackUrl"]; }
$fileId = intval($_REQUEST["i"]); $fileAction = $_REQUEST["act"] == "v" ? "view" : "download"; $filePathHash = trim($_REQUEST["h"]); if (strlen($fileName) <= 0 || $fileId <= 0 || strlen($fileAction) <= 0) { die("Error1"); } $bpId = !empty($_REQUEST['bp_id']) ? (int) $_REQUEST['bp_id'] : 0; $iblockId = !empty($_REQUEST['iblock_id']) ? (int) $_REQUEST['iblock_id'] : 0; $options = array(); if ($fileAction == "download") { $options["force_download"] = true; } if ($bpId > 0 && $iblockId > 0 && $fileName !== '') { $fields = CBPVirtualDocument::GetDocumentFields("type_" . $iblockId); if (isset($fields[$fileName]) && $fields[$fileName]["BaseType"] == "file") { list($dbRecordsList, $dbRecordsList1) = CBPVirtualDocument::GetList(array(), array("ID" => $bpId, "IBLOCK_ID" => $iblockId, "CHECK_BP_VIRTUAL_PERMISSIONS" => "read"), false, false, array($fileName)); $row = $dbRecordsList->fetch(); if (!$row) { die("Error: BP not found"); } $files = (array) $row[$fileName]; $key = array_search($fileId, $files); if ($key !== false) { set_time_limit(0); CFile::ViewByUser($files[$key], $options); } else { die("Error: File not found"); } } die; }
} } if ($newKey == "ACTIVE_FROM") { $newKey = "DATE_ACTIVE_FROM"; } if ($newKey == "ACTIVE_TO") { $newKey = "DATE_ACTIVE_TO"; } $arFilter[$op . $newKey] = $value; } } $arResult["SORT"] = $gridSort["sort"]; $arResult["ShowStateEvents"] = false; $arResult["ShowTasks"] = false; $arResult["RECORDS"] = array(); list($dbRecordsList, $dbRecordsList1) = CBPVirtualDocument::GetList($gridSort["sort"], $arFilter, false, $gridOptions->GetNavParams(), $arSelectFields); while ($arRecord = $dbRecordsList->fetch()) { $arKeys = array_keys($arRecord); foreach ($arKeys as $key) { if ($arDocumentFields[$key]["BaseType"] == "file") { $ar = $arRecord[$key]; if (!is_array($ar)) { $ar = array($ar); } $arRecord[$key] = ""; foreach ($ar as $v) { if (strlen($arRecord[$key]) > 0) { $arRecord[$key] .= " "; } $arRecord[$key] .= CFile::ShowFile($v, 100000, 50, 50, true); }