protected function getTemplatesIdList() { if (!Loader::includeModule('bizproc') || empty($this->iblockTypeId) || empty($this->iblockId)) { return array(); } $documentType = BizprocDocument::generateDocumentComplexType($this->iblockTypeId, $this->iblockId); $templates = array_merge(\CBPWorkflowTemplateLoader::SearchTemplatesByDocumentType($documentType, CBPDocumentEventType::Create), \CBPWorkflowTemplateLoader::SearchTemplatesByDocumentType($documentType, CBPDocumentEventType::Edit)); $templateData = array(); foreach ($templates as $template) { $templateData[$template['ID']]['ID'] = $template['ID']; $templateData[$template['ID']]['NAME'] = $template['NAME']; } return $templateData; }
protected function processActionCheckDataElementCreation() { if ($_POST["save"] != "Y" && $_POST["changePostFormTab"] != "lists" && !check_bitrix_sessid()) { $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_SEAC_CONNECTION_MODULE_IBLOCK')))); } if (!Loader::IncludeModule('bizproc')) { $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_SEAC_CONNECTION_MODULE_BIZPROC')))); } if (!Loader::includeModule('iblock')) { $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_SEAC_CONNECTION_MODULE_IBLOCK')))); } $this->iblockId = intval($this->request->getPost('IBLOCK_ID')); $this->iblockTypeId = COption::GetOptionString("lists", "livefeed_iblock_type_id"); $this->checkPermissionElement(); if ($this->errorCollection->hasErrors()) { $this->sendJsonErrorResponse(); } $templateId = intval($_POST['TEMPLATE_ID']); $documentType = BizprocDocument::generateDocumentComplexType(COption::GetOptionString("lists", "livefeed_iblock_type_id"), $this->iblockId); if (!empty($templateId)) { if (CModule::IncludeModule('bizproc')) { if (!CBPWorkflowTemplateLoader::isConstantsTuned($templateId)) { $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_IS_CONSTANTS_TUNED_NEW')))); $this->sendJsonErrorResponse(); } } } else { if (CModule::IncludeModule("bizproc")) { $templateObject = CBPWorkflowTemplateLoader::getTemplatesList(array('ID' => 'DESC'), array('DOCUMENT_TYPE' => $documentType, 'AUTO_EXECUTE' => CBPDocumentEventType::Create), false, false, array('ID')); $template = $templateObject->fetch(); if (!empty($template)) { if (!CBPWorkflowTemplateLoader::isConstantsTuned($template["ID"])) { $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_IS_CONSTANTS_TUNED_NEW')))); $this->sendJsonErrorResponse(); } } else { $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_NOT_BIZPROC_TEMPLATE')))); $this->sendJsonErrorResponse(); } } } $list = new CList($this->iblockId); $fields = $list->getFields(); $elementData = array("IBLOCK_ID" => $this->iblockId, "NAME" => $_POST["NAME"]); $props = array(); foreach ($fields as $fieldId => $field) { if ($fieldId == "PREVIEW_PICTURE" || $fieldId == "DETAIL_PICTURE") { $elementData[$fieldId] = $_FILES[$fieldId]; if (isset($_POST[$fieldId . "_del"]) && $_POST[$fieldId . "_del"] == "Y") { $elementData[$fieldId]["del"] = "Y"; } } elseif ($fieldId == "PREVIEW_TEXT" || $fieldId == "DETAIL_TEXT") { if (isset($field["SETTINGS"]) && is_array($field["SETTINGS"]) && $field["SETTINGS"]["USE_EDITOR"] == "Y") { $elementData[$fieldId . "_TYPE"] = "html"; } else { $elementData[$fieldId . "_TYPE"] = "text"; } $elementData[$fieldId] = $_POST[$fieldId]; } elseif ($fieldId == 'ACTIVE_FROM' || $fieldId == 'ACTIVE_TO') { $elementData[$fieldId] = array_shift($_POST[$fieldId]); } elseif ($list->is_field($fieldId)) { $elementData[$fieldId] = $_POST[$fieldId]; } elseif ($field["PROPERTY_TYPE"] == "F") { if (isset($_POST[$fieldId . "_del"])) { $deleteArray = $_POST[$fieldId . "_del"]; } else { $deleteArray = array(); } $props[$field["ID"]] = array(); $files = $this->unEscape($_FILES); CFile::ConvertFilesToPost($files[$fieldId], $props[$field["ID"]]); foreach ($props[$field["ID"]] as $fileId => $file) { if (isset($deleteArray[$fileId]) && (!is_array($deleteArray[$fileId]) && $deleteArray[$fileId] == "Y" || is_array($deleteArray[$fileId]) && $deleteArray[$fileId]["VALUE"] == "Y")) { if (isset($props[$field["ID"]][$fileId]["VALUE"])) { $props[$field["ID"]][$fileId]["VALUE"]["del"] = "Y"; } else { $props[$field["ID"]][$fileId]["del"] = "Y"; } } } } elseif ($field["PROPERTY_TYPE"] == "N") { if (is_array($_POST[$fieldId]) && !array_key_exists("VALUE", $_POST[$fieldId])) { $props[$field["ID"]] = array(); foreach ($_POST[$fieldId] as $key => $value) { if (is_array($value)) { if (strlen($value["VALUE"])) { $value = str_replace(" ", "", str_replace(",", ".", $value["VALUE"])); if (!is_numeric($value)) { $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_IS_VALIDATE_FIELD_ERROR', array('#NAME#' => $field['NAME']))))); $this->sendJsonErrorResponse(); } $props[$field["ID"]][$key] = doubleval($value); } } else { if (strlen($value)) { $value = str_replace(" ", "", str_replace(",", ".", $value)); if (!is_numeric($value)) { $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_IS_VALIDATE_FIELD_ERROR', array('#NAME#' => $field['NAME']))))); $this->sendJsonErrorResponse(); } $props[$field["ID"]][$key] = doubleval($value); } } } } else { if (is_array($_POST[$fieldId])) { if (strlen($_POST[$fieldId]["VALUE"])) { $value = str_replace(" ", "", str_replace(",", ".", $_POST[$fieldId]["VALUE"])); if (!is_numeric($value)) { $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_IS_VALIDATE_FIELD_ERROR', array('#NAME#' => $field['NAME']))))); $this->sendJsonErrorResponse(); } $props[$field["ID"]] = doubleval($value); } } else { if (strlen($_POST[$fieldId])) { $value = str_replace(" ", "", str_replace(",", ".", $_POST[$fieldId])); if (!is_numeric($value)) { $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_IS_VALIDATE_FIELD_ERROR', array('#NAME#' => $field['NAME']))))); $this->sendJsonErrorResponse(); } $props[$field["ID"]] = doubleval($value); } } } } else { $props[$field["ID"]] = $_POST[$fieldId]; } } $elementData["MODIFIED_BY"] = $this->getUser()->getID(); unset($elementData["TIMESTAMP_X"]); if (!empty($props)) { $elementData["PROPERTY_VALUES"] = $props; } $documentStates = CBPDocument::GetDocumentStates($documentType, null); $userId = $this->getUser()->getId(); $write = CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::WriteDocument, $userId, $documentType, array('AllUserGroups' => array(), 'DocumentStates' => $documentStates)); if (!$write) { $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_IS_ACCESS_DENIED_STATUS')))); $this->sendJsonErrorResponse(); } $bizprocParametersValues = array(); foreach ($documentStates as $documentState) { if (strlen($documentState["ID"]) <= 0) { $errors = array(); $bizprocParametersValues[$documentState['TEMPLATE_ID']] = CBPDocument::StartWorkflowParametersValidate($documentState['TEMPLATE_ID'], $documentState['TEMPLATE_PARAMETERS'], $documentType, $errors); $stringError = ''; foreach ($errors as $e) { $stringError .= $e['message'] . '<br />'; } } } if (!empty($stringError)) { $this->errorCollection->add(array(new Error($stringError))); $this->sendJsonErrorResponse(); } $objectElement = new CIBlockElement(); $idElement = $objectElement->Add($elementData, false, true, true); if ($idElement) { $bizProcWorkflowId = array(); foreach ($documentStates as $documentState) { if (strlen($documentState["ID"]) <= 0) { $errorsTmp = array(); $bizProcWorkflowId[$documentState['TEMPLATE_ID']] = CBPDocument::StartWorkflow($documentState['TEMPLATE_ID'], array('lists', 'BizprocDocument', $idElement), array_merge($bizprocParametersValues[$documentState['TEMPLATE_ID']], array('TargetUser' => 'user_' . intval($this->getUser()->getID()))), $errorsTmp); } } if (!empty($errorsTmp)) { $documentStates = null; CBPDocument::AddDocumentToHistory(array('lists', 'BizprocDocument', $idElement), $elementData['NAME'], $this->getUser()->getID()); } } else { $this->errorCollection->add(array(new Error($objectElement->LAST_ERROR))); $this->sendJsonErrorResponse(); } $this->sendJsonSuccessResponse(array()); }
if (is_array($_POST["RIGHTS"])) { $arPOSTRights = CIBlockRights::Post2Array($_POST["RIGHTS"]); } else { $arPOSTRights = array(); } if ($ELEMENT_ID) { $obRights = new CIBlockElementRights($arResult["IBLOCK_ID"], $ELEMENT_ID); } else { $obRights = new CIBlockSectionRights($arResult["IBLOCK_ID"], $SECTION_ID); } $arDBRights = $obRights->GetRights(); $arElement["RIGHTS"] = CListPermissions::MergeRights($arParams["~IBLOCK_TYPE_ID"], $arDBRights, $arPOSTRights); } //---BP--- if ($bBizproc) { $documentType = BizprocDocument::generateDocumentComplexType($arParams["IBLOCK_TYPE_ID"], $arResult["IBLOCK_ID"]); $arDocumentStates = CBPDocument::GetDocumentStates($documentType, $arResult["ELEMENT_ID"] > 0 ? BizprocDocument::getDocumentComplexId($arParams["IBLOCK_TYPE_ID"], $arResult["ELEMENT_ID"]) : null, "Y"); $arCurrentUserGroups = $USER->GetUserGroupArray(); if (!$arResult["ELEMENT_FIELDS"] || $arResult["ELEMENT_FIELDS"]["CREATED_BY"] == $USER->GetID()) { $arCurrentUserGroups[] = "Author"; } if ($arResult["ELEMENT_ID"]) { $canWrite = CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::WriteDocument, $USER->GetID(), BizprocDocument::getDocumentComplexId($arParams["IBLOCK_TYPE_ID"], $arResult["ELEMENT_ID"]), array("AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates)); } else { $canWrite = CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::WriteDocument, $USER->GetID(), $documentType, array("AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates)); } if (!$canWrite) { $strError = GetMessage("CC_BLEE_ACCESS_DENIED_STATUS"); } if (!$strError) { $arBizProcParametersValues = array();
$data["MODIFIED_BY"] = "[" . $data["MODIFIED_BY"] . "] " . $data["USER_NAME"]; } if (isset($data["ACTIVE_FROM"])) { $data['ACTIVE_FROM'] = FormatDateFromDB($data['ACTIVE_FROM']); } if (isset($data["ACTIVE_TO"])) { $data['ACTIVE_TO'] = FormatDateFromDB($data['ACTIVE_TO']); } if (isset($data["DATE_CREATE"])) { $data['DATE_CREATE'] = FormatDateFromDB($data['DATE_CREATE']); } if (isset($data["TIMESTAMP_X"])) { $data['TIMESTAMP_X'] = FormatDateFromDB($data['TIMESTAMP_X']); } if ($arResult["PROCESSES"] && $arResult["USE_COMMENTS"]) { $documentState = CBPDocument::GetDocumentStates(BizprocDocument::generateDocumentComplexType($arIBlock["IBLOCK_TYPE_ID"], $arIBlock["ID"]), BizprocDocument::getDocumentComplexId($arIBlock["IBLOCK_TYPE_ID"], $data["ID"])); if (!empty($documentState)) { $documentState = current($documentState); $data["WORKFLOW_ID"] = $documentState["ID"]; } else { $data["WORKFLOW_ID"] = ''; } } $arUserGroupsForBPTmp = $arUserGroupsForBP; if ($USER->GetID() == $data["CREATED_BY"]) { $arUserGroupsForBPTmp[] = "Author"; } $arBPStart = array(); foreach ($arDocumentTemplates as $arWorkflowTemplate) { if (CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::StartWorkflow, $USER->GetID(), BizprocDocument::getDocumentComplexId($arParams["IBLOCK_TYPE_ID"], intval($data["~ID"])), array("IBlockId" => $arIBlock["ID"], "AllUserGroups" => $arUserGroupsForBPTmp, "DocumentStates" => $arDocumentStatesForBP, "WorkflowId" => $arWorkflowTemplate["ID"]))) { $backUrl = $APPLICATION->GetCurPageParam();
public function executeComponent() { if (!empty($this->arParams['ERROR'])) { ShowError(array_shift($this->arParams['ERROR'])); return; } $this->arResult['USER_ID'] = $this->arParams['USER_ID']; $this->arResult['GRID_ID'] = 'lists_processes'; $selectFields = array('ID', 'IBLOCK_TYPE_ID', 'IBLOCK_ID', 'NAME'); $gridOptions = new CGridOptions($this->arResult['GRID_ID']); $gridColumns = $gridOptions->getVisibleColumns(); $gridSort = $gridOptions->getSorting(array('sort' => array('ID' => 'desc'))); $this->arResult['HEADERS'] = array(array("id" => "ID", "name" => "ID", "default" => false, "sort" => "ID"), array('id' => 'DOCUMENT_NAME', 'name' => Loc::getMessage('CC_BLL_DOCUMENT_NAME'), 'default' => true, 'sort' => 'DOCUMENT_NAME'), array('id' => 'COMMENTS', 'name' => Loc::getMessage('CC_BLL_COMMENTS'), 'default' => true, 'sort' => '', 'hideName' => true, 'iconCls' => 'bp-comments-icon'), array('id' => 'WORKFLOW_PROGRESS', 'name' => Loc::getMessage('CC_BLL_WORKFLOW_PROGRESS'), 'default' => true, 'sort' => ''), array('id' => 'WORKFLOW_STATE', 'name' => Loc::getMessage('CC_BLL_WORKFLOW_STATE'), 'default' => false, 'sort' => '')); $this->arResult['FILTER'] = array(array("id" => "NAME", "name" => GetMessage("BPATL_NAME"), "type" => "string"), array('id' => 'TIMESTAMP_X', 'name' => Loc::getMessage('CC_BLL_MODIFIED'), 'type' => 'date'), array('id' => 'DATE_CREATE', 'name' => Loc::getMessage('CC_BLL_CREATED'), 'type' => 'date', 'default' => true)); $gridFilter = $gridOptions->getFilter($this->arResult['FILTER']); foreach ($gridFilter as $key => $value) { if (substr($key, -5) == "_from") { $op = ">="; $newKey = substr($key, 0, -5); } elseif (substr($key, -3) == "_to") { $op = "<="; $newKey = substr($key, 0, -3); if (in_array($newKey, array("TIMESTAMP_X", 'DATE_CREATE'))) { if (!preg_match("/\\d\\d:\\d\\d:\\d\\d\$/", $value)) { $value .= " 23:59:59"; } } } else { $op = ""; $newKey = $key; } $filter[$op . $newKey] = $value; } $this->arResult['SORT'] = $gridSort['sort']; $useComments = (bool) CModule::includeModule("forum"); $workflows = array(); $this->arResult['DATA'] = array(); $this->arResult["COMMENTS_COUNT"] = array(); $filter['CREATED_BY'] = $this->arParams['USER_ID']; $iblockTypeId = COption::GetOptionString("lists", "livefeed_iblock_type_id"); $filter['IBLOCK_TYPE'] = $iblockTypeId; $filter['CHECK_PERMISSIONS'] = $this->arParams['LIST_PERM'] >= CListPermissions::CAN_READ ? "N" : "Y"; $elementObject = CIBlockElement::getList($gridSort['sort'], $filter, false, $gridOptions->getNavParams(), $selectFields); $documentState = true; $path = rtrim(SITE_DIR, '/'); while ($element = $elementObject->fetch()) { $documentState = CBPDocument::GetDocumentStates(BizprocDocument::generateDocumentComplexType($iblockTypeId, $element['IBLOCK_ID']), BizprocDocument::getDocumentComplexId($iblockTypeId, $element['ID'])); $this->arResult['DATA'][$element['ID']]['ID'] = $element['ID']; $this->arResult['DATA'][$element['ID']]['DOCUMENT_NAME'] = $element['NAME']; $this->arResult['DATA'][$element['ID']]['DOCUMENT_URL'] = $path . COption::GetOptionString('lists', 'livefeed_url') . '?livefeed=y&list_id=' . $element["IBLOCK_ID"] . '&element_id=' . $element['ID']; if (!empty($documentState)) { $this->arResult['DATA'][$element['ID']]['DOCUMENT_STATE'] = true; $documentState = current($documentState); $this->arResult['DATA'][$element['ID']]['WORKFLOW_ID'] = $documentState['ID']; $this->arResult['DATA'][$element['ID']]["WORKFLOW_NAME"] = $documentState["TEMPLATE_NAME"]; $this->arResult['DATA'][$element['ID']]["WORKFLOW_STATE"] = $documentState["STATE_TITLE"]; $this->arResult['DATA'][$element['ID']]["WORKFLOW_STARTED"] = FormatDateFromDB($documentState["STARTED_FORMATTED"]); $this->arResult['DATA'][$element['ID']]["WORKFLOW_STARTED_BY"] = ""; if (intval($documentState["STARTED_BY"]) > 0) { $dbUserTmp = CUser::getByID($documentState["STARTED_BY"]); $arUserTmp = $dbUserTmp->fetch(); $this->arResult['DATA'][$element['ID']]["WORKFLOW_STARTED_BY"] = CUser::FormatName($this->arParams["NAME_TEMPLATE"], $arUserTmp, true); $this->arResult['DATA'][$element['ID']]["WORKFLOW_STARTED_BY"] .= " [" . $documentState["STARTED_BY"] . "]"; } $this->arResult['DATA'][$element['ID']]['MODULE_ID'] = $documentState["DOCUMENT_ID"][0]; $this->arResult['DATA'][$element['ID']]['ENTITY'] = $documentState["DOCUMENT_ID"][1]; $this->arResult['DATA'][$element['ID']]['DOCUMENT_ID'] = $documentState["DOCUMENT_ID"][2]; } else { $documentState = false; $this->arResult['DATA'][$element['ID']]['DOCUMENT_STATE'] = false; } } foreach ($this->arResult['DATA'] as $data) { if ($documentState) { if ($useComments) { $workflows[] = 'WF_' . $data['WORKFLOW_ID']; } } $actions = array(); if (strlen($data["DOCUMENT_URL"]) > 0) { $actions[] = array('ICONCLASS' => '', 'DEFAULT' => false, 'TEXT' => Loc::getMessage('CC_BLL_C_DOCUMENT'), 'ONCLICK' => 'window.open("' . $data["DOCUMENT_URL"] . '");'); } $this->arResult['RECORDS'][] = array('data' => $data, 'actions' => $actions); } if ($useComments && $documentState) { $workflows = array_unique($workflows); if ($workflows) { $iterator = CForumTopic::getList(array(), array("@XML_ID" => $workflows)); while ($row = $iterator->fetch()) { $this->arResult["COMMENTS_COUNT"][$row['XML_ID']] = $row['POSTS']; } } } $this->arResult['COUNTERS'] = array('all' => 0); $this->arResult["ROWS_COUNT"] = $elementObject->selectedRowsCount(); $this->arResult["NAV_RESULT"] = $elementObject; if ($this->arParams['SET_TITLE'] == 'Y') { $this->getApplication()->setTitle(Loc::getMessage('CC_BLL_TITLE')); } $this->includeComponentTemplate(); }
/** * @param string $workflowId * @param string $iblockType * @param int $elementId * @param int $iblockId * @param string $action Action stop or delete * @return string error */ public static function completeWorkflow($workflowId, $iblockType, $elementId, $iblockId, $action) { if (!Loader::includeModule('bizproc')) { return Loc::getMessage('LISTS_MODULE_BIZPROC_NOT_INSTALLED'); } global $USER; $userId = $USER->getID(); $documentType = BizprocDocument::generateDocumentComplexType($iblockType, $iblockId); $documentId = BizprocDocument::getDocumentComplexId($iblockType, $elementId); $documentStates = CBPDocument::getDocumentStates($documentType, $documentId); $permission = CBPDocument::canUserOperateDocument($action == 'stop' ? CBPCanUserOperateOperation::StartWorkflow : CBPCanUserOperateOperation::CreateWorkflow, $userId, $documentId, array("DocumentStates" => $documentStates)); if (!$permission) { return Loc::getMessage('LISTS_ACCESS_DENIED'); } $stringError = ''; if ($action == 'stop') { $errors = array(); CBPDocument::terminateWorkflow($workflowId, $documentId, $errors); if (!empty($errors)) { $stringError = ''; foreach ($errors as $error) { $stringError .= $error['message']; } $listError[] = array('id' => 'stopBizproc', 'text' => $stringError); } } else { $errors = array(); if (isset($documentStates[$workflowId]['WORKFLOW_STATUS']) && $documentStates[$workflowId]['WORKFLOW_STATUS'] !== null) { CBPDocument::terminateWorkflow($workflowId, $documentId, $errors); } if (!empty($errors)) { $stringError = ''; foreach ($errors as $error) { $stringError .= $error['message']; } $listError[] = array('id' => 'stopBizproc', 'text' => $stringError); } else { CBPTaskService::deleteByWorkflow($workflowId); CBPTrackingService::deleteByWorkflow($workflowId); CBPStateService::deleteWorkflow($workflowId); } } if (empty($listError) && Loader::includeModule('socialnetwork') && $iblockType == COption::getOptionString("lists", "livefeed_iblock_type_id")) { $sourceId = CBPStateService::getWorkflowIntegerId($workflowId); $resultQuery = CSocNetLog::getList(array(), array('EVENT_ID' => 'lists_new_element', 'SOURCE_ID' => $sourceId), false, false, array('ID')); while ($log = $resultQuery->fetch()) { CSocNetLog::delete($log['ID']); } } if (!empty($listError)) { $errorObject = new CAdminException($listError); $stringError = $errorObject->getString(); } return $stringError; }
$arParametersValues = array(); $keys = array_keys($arWorkflowParameters); foreach ($keys as $key) { $v = $bVarsFromForm ? $_REQUEST["bizproc" . $templateId . "_" . $key] : $arWorkflowParameters[$key]["Default"]; if (!is_array($v)) { $arParametersValues[$key] = htmlspecialcharsbx($v); } else { $keys1 = array_keys($v); foreach ($keys1 as $key1) { $arParametersValues[$key][$key1] = htmlspecialcharsbx($v[$key1]); } } } foreach ($arWorkflowParameters as $parameterKey => $arParameter) { $parameterKeyExt = "bizproc" . $templateId . "_" . $parameterKey; $html = $documentService->GetFieldInputControl(BizprocDocument::generateDocumentComplexType($arParams["IBLOCK_TYPE_ID"], $arResult["IBLOCK_ID"]), $arParameter, array("Form" => "start_workflow_form1", "Field" => $parameterKeyExt), $arParametersValues[$parameterKey], false, true); $arTab2Fields[] = array("id" => $parameterKeyExt . $bizProcIndex, "required" => $arParameter["Required"], "name" => $arParameter["Name"], "title" => $arParameter["Description"], "type" => "label", "value" => $html); } } $arEvents = CBPDocument::GetAllowableEvents($GLOBALS["USER"]->GetID(), $arCurrentUserGroups, $arDocumentState); if (count($arEvents)) { $html = ''; $html .= '<input type="hidden" name="bizproc_id_' . $bizProcIndex . '" value="' . $arDocumentState["ID"] . '">'; $html .= '<input type="hidden" name="bizproc_template_id_' . $bizProcIndex . '" value="' . $arDocumentState["TEMPLATE_ID"] . '">'; $html .= '<select name="bizproc_event_' . $bizProcIndex . '">'; $html .= '<option value="">' . GetMessage("CT_BLEE_BIZPROC_RUN_CMD_NO") . '</option>'; foreach ($arEvents as $e) { $html .= '<option value="' . htmlspecialcharsbx($e["NAME"]) . '"' . ($_REQUEST["bizproc_event_" . $bizProcIndex] == $e["NAME"] ? " selected" : "") . '>' . htmlspecialcharsbx($e["TITLE"]) . '</option>'; } $html .= '</select>'; $arTab2Fields[] = array("id" => "BIZPROC_RUN_CMD" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_RUN_CMD"), "type" => "label", "value" => $html);
protected function getArrayBizproc($data = array()) { $currentUserId = $GLOBALS["USER"]->GetID(); $html = ""; if ($this->arResult["IBLOCK"]["BIZPROC"] == "Y" && CModule::IncludeModule('bizproc')) { $this->arResult["ELEMENTS_HEADERS"]["BIZPROC"] = array("name" => Loc::getMessage("CC_BLL_COLUMN_BIZPROC"), "default" => true, "sort" => false); $arDocumentStates = CBPDocument::GetDocumentStates(BizprocDocument::generateDocumentComplexType($this->arParams["IBLOCK_TYPE_ID"], $this->arResult["IBLOCK_ID"]), BizprocDocument::getDocumentComplexId($this->arParams["IBLOCK_TYPE_ID"], $data["ID"])); $userGroups = $GLOBALS["USER"]->GetUserGroupArray(); if ($data["~CREATED_BY"] == $currentUserId) { $userGroups[] = "Author"; } $ii = 0; foreach ($arDocumentStates as $workflowId => $workflowState) { if (strlen($workflowState["TEMPLATE_NAME"]) > 0) { $html .= "" . $workflowState["TEMPLATE_NAME"] . ":\r\n"; } else { $html .= "" . ++$ii . ":\r\n"; } $html .= "" . (strlen($workflowState["STATE_TITLE"]) > 0 ? $workflowState["STATE_TITLE"] : $workflowState["STATE_NAME"]) . "\r\n"; } } return $html; }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } $file = trim(preg_replace("'[\\\\/]+'", "/", dirname(__FILE__) . "/lang/" . LANGUAGE_ID . "/result_modifier.php")); __IncludeLang($file); $arArrays = array(); $arElements = array(); $arSections = array(); $CURRENT_USER_ID = $GLOBALS["USER"]->GetID(); $CURRENT_USER_GROUPS = $GLOBALS["USER"]->GetUserGroupArray(); foreach ($arResult["ELEMENTS_ROWS"] as $i => $arRow) { if ($arResult["BIZPROC"] == "Y") { $arDocumentStates = CBPDocument::GetDocumentStates(BizprocDocument::generateDocumentComplexType($arParams["IBLOCK_TYPE_ID"], $arResult["IBLOCK_ID"]), BizprocDocument::getDocumentComplexId($arParams["IBLOCK_TYPE_ID"], $arRow["data"]["ID"])); $USER_GROUPS = $CURRENT_USER_GROUPS; if ($arRow["data"]["~CREATED_BY"] == $CURRENT_USER_ID) { $USER_GROUPS[] = "Author"; } $ii = 0; $html = ""; $proccesses = false; if ($arResult["PROCESSES"] && $arResult["USE_COMMENTS"]) { $proccesses = true; $workflows = array(); } foreach ($arDocumentStates as $kk => $vv) { if ($vv["ID"] && $proccesses && !empty($arRow["data"]["WORKFLOW_ID"])) { $workflows[] = 'WF_' . $vv["ID"]; } $canViewWorkflow = CIBlockDocument::CanUserOperateDocument(CBPCanUserOperateOperation::ViewWorkflow, $CURRENT_USER_ID, $arRow["data"]["ID"], array("IBlockPermission" => $arResult["IBLOCK_PERM"], "AllUserGroups" => $USER_GROUPS, "DocumentStates" => $arDocumentStates, "WorkflowId" => $kk));