protected function terminateWorkflow($workflowId, $elementId) { $this->checkPermission(); if (!CBPDocument::canUserOperateDocument(CBPCanUserOperateOperation::StartWorkflow, $this->getUser(), BizProcDocument::getDocumentComplexId($this->iblockTypeId, $elementId), array("DocumentStates" => $this->documentStates))) { $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_LAC_ACCESS_DENIED')))); } if ($this->errorCollection->hasErrors()) { $this->sendJsonErrorResponse(); } if (CIBlockElementRights::userHasRightTo($this->iblockId, $elementId, "element_rights_edit")) { $errors = array(); CBPDocument::terminateWorkflow($workflowId, BizProcDocument::getDocumentComplexId($this->iblockTypeId, $elementId), $errors); foreach ($errors as $error) { $this->errorCollection->add(array(new Error($error["message"]))); } } else { $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_LAC_ACCESS_DENIED')))); } if ($this->errorCollection->hasErrors()) { $this->sendJsonErrorResponse(); } }
$listProcesses = array(); $backUrl = $APPLICATION->GetCurPageParam(); foreach ($documentStates as $documentState) { if (!$documentState["ID"]) { continue; } $actionsProcess = array(); $canViewWorkflow = CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::ViewWorkflow, $GLOBALS["USER"]->GetID(), BizProcDocument::getDocumentComplexId($arIBlock["IBLOCK_TYPE_ID"], $data["ID"]), array("AllUserGroups" => $currentUserGroups, "DocumentStates" => $documentStates, "WorkflowId" => $documentState["ID"])); if ($canViewWorkflow) { /* Stop workflow */ if (strlen($documentState["ID"]) && CIBlockElementRights::UserHasRightTo($arIBlock["ID"], $data["ID"], "element_rights_edit") && strlen($documentState["WORKFLOW_STATUS"])) { $actionsProcess[] = array("TEXT" => GetMessage("CT_BLL_BIZPROC_STOP"), "ONCLICK" => "javascript:BX['ListClass_" . $arResult["RAND_STRING"] . "']\n\t\t\t\t\t\t\t\t.performActionBp('" . $documentState['ID'] . "', " . $data["ID"] . ", 'stop');"); } /* Removal workflow */ if (strlen($documentState["STATE_NAME"]) && strlen($documentState["ID"])) { if (CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::CreateWorkflow, $GLOBALS["USER"]->GetID(), BizProcDocument::getDocumentComplexId($arIBlock["IBLOCK_TYPE_ID"], $data["ID"]), array("UserGroups" => $currentUserGroups))) { $actionsProcess[] = array("TEXT" => GetMessage("CT_BLL_BIZPROC_DELETE"), "ONCLICK" => "javascript:BX['ListClass_" . $arResult["RAND_STRING"] . "']\n\t\t\t\t\t\t\t\t.performActionBp('" . $documentState['ID'] . "', " . $data["ID"] . ", 'delete');"); } } /* Tasks workflow */ if (strlen($documentState["ID"])) { $tasks = CBPDocument::getUserTasksForWorkflow($GLOBALS["USER"]->GetID(), $documentState["ID"]); if (!empty($tasks)) { foreach ($tasks as $task) { $url = CHTTP::urlAddParams(str_replace(array("#list_id#", "#section_id#", "#element_id#", "#task_id#", "#group_id#"), array($arIBlock["ID"], intval($arResult["SECTION_ID"]), $data["ID"], $task["ID"], $arParams["SOCNET_GROUP_ID"]), $arParams["~BIZPROC_TASK_URL"]), array("back_url" => $backUrl), array("skip_empty" => true, "encode" => true)); $actionsProcess[] = array("TEXT" => $task["NAME"], "ONCLICK" => "jsUtils.Redirect(arguments, '" . CUtil::JSEscape($url) . "')"); } } } if (!empty($actionsProcess)) { $listProcesses[] = array("TEXT" => $documentState["TEMPLATE_NAME"] . " (" . $documentState["STARTED"] . ")", "MENU" => $actionsProcess);
} else { if (!array_key_exists($bpTemplateId, $arDocumentStates)) { continue; } $bpId = $arBizProcWorkflowId[$bpTemplateId]; } $arErrorTmp = array(); CBPDocument::SendExternalEvent($bpId, $bpEvent, array("Groups" => $arCurrentUserGroups, "User" => $GLOBALS["USER"]->GetID()), $arErrorTmp); foreach ($arErrorsTmp as $e) { $strWarning .= $e["message"] . "<br />"; } } } } $arDocumentStates = null; CBPDocument::AddDocumentToHistory(BizProcDocument::getDocumentComplexId($arParams["IBLOCK_TYPE_ID"], $arResult["ELEMENT_ID"]), $arElement["NAME"], $GLOBALS["USER"]->GetID()); } } if (!$strError) { //Successfull update //And go to proper page if (isset($_POST["save"])) { LocalRedirect($arResult["~LIST_SECTION_URL"]); } elseif ($lists_perm < CListPermissions::CAN_READ && !CIBlockElementRights::UserHasRightTo($arResult["IBLOCK_ID"], $arResult["ELEMENT_ID"], "element_read")) { LocalRedirect($arResult["~LIST_SECTION_URL"]); } else { $url = CHTTP::urlAddParams(str_replace(array("#list_id#", "#section_id#", "#element_id#", "#group_id#"), array($arResult["IBLOCK_ID"], intval($_POST["IBLOCK_SECTION_ID"]), $arResult["ELEMENT_ID"], $arParams["SOCNET_GROUP_ID"]), $arParams["~LIST_ELEMENT_URL"]), array($tab_name => $_POST[$tab_name]), array("skip_empty" => true, "encode" => true)); if (isset($_GET["list_section_id"]) && strlen($_GET["list_section_id"]) == 0) { $url = CHTTP::urlAddParams($url, array("list_section_id" => "")); } LocalRedirect($url);
foreach ($arTasks as $arTask) { $backUrl = CHTTP::urlAddParams($APPLICATION->GetCurPageParam("", array($arResult["FORM_ID"] . "_active_tab")), array($arResult["FORM_ID"] . "_active_tab" => "tab_bp")); $url = CHTTP::urlAddParams(str_replace(array("#list_id#", "#section_id#", "#element_id#", "#task_id#", "#group_id#"), array($arResult["IBLOCK_ID"], intval($arResult["SECTION_ID"]), $arResult["ELEMENT_ID"], $arTask["ID"], $arParams["SOCNET_GROUP_ID"]), $arParams["~BIZPROC_TASK_URL"]), array("back_url" => $backUrl), array("skip_empty" => true, "encode" => true)); $html .= '<a href="' . htmlspecialcharsbx($url) . '" title="' . strip_tags($arTask["DESCRIPTION"]) . '">' . $arTask["NAME"] . '</a><br />'; } $arTab2Fields[] = array("id" => "BIZPROC_TASKS" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_TASKS"), "type" => "label", "value" => $html); } } } } if (!$bizProcIndex) { $arTab2Fields[] = array("id" => "BIZPROC_NO", "name" => GetMessage("CT_BLEE_BIZPROC_NA_LABEL"), "type" => "label", "value" => GetMessage("CT_BLEE_BIZPROC_NA")); } $custom_html .= '<input type="hidden" name="bizproc_index" value="' . $bizProcIndex . '">'; if ($arResult["ELEMENT_ID"]) { $bStartWorkflowPermission = CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::StartWorkflow, $USER->GetID(), BizProcDocument::getDocumentComplexId($arParams["IBLOCK_TYPE_ID"], $arResult["ELEMENT_ID"]), array("AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates, "WorkflowId" => $arDocumentState["TEMPLATE_ID"])); if ($bStartWorkflowPermission) { $arTab2Fields[] = array("id" => "BIZPROC_NEW", "name" => GetMessage("CT_BLEE_BIZPROC_NEW"), "type" => "section"); $backUrl = CHTTP::urlAddParams($APPLICATION->GetCurPageParam("", array($arResult["FORM_ID"] . "_active_tab")), array($arResult["FORM_ID"] . "_active_tab" => "tab_bp")); $url = CHTTP::urlAddParams(str_replace(array("#list_id#", "#section_id#", "#element_id#", "#group_id#"), array($arResult["IBLOCK_ID"], intval($arResult["SECTION_ID"]), $arResult["ELEMENT_ID"], $arParams["SOCNET_GROUP_ID"]), $arParams["~BIZPROC_WORKFLOW_START_URL"]), array("back_url" => $backUrl, "sessid" => bitrix_sessid()), array("skip_empty" => true, "encode" => true)); $arTab2Fields[] = array("id" => "BIZPROC_NEW_START", "name" => GetMessage("CT_BLEE_BIZPROC_START"), "type" => "custom", "colspan" => true, "value" => '<a href="' . htmlspecialcharsbx($url) . '">' . GetMessage("CT_BLEE_BIZPROC_START") . '</a>'); } } $arTabs[] = array("id" => "tab_bp", "name" => GetMessage("CT_BLEE_BIZPROC_TAB"), "icon" => "", "fields" => $arTab2Fields); } if (isset($arResult["RIGHTS"])) { ob_start(); IBlockShowRights('element', $arResult["IBLOCK_ID"], $arResult["ELEMENT_ID"], "", "RIGHTS", $arResult["TASKS"], $arResult["RIGHTS"], true, $arResult["ELEMENT_ID"] <= 0, $arResult["SELECTED"], $arResult["HIGHLIGHT"]); $rights_html = ob_get_contents(); ob_end_clean(); $rights_fields = array(array("id" => "RIGHTS", "name" => GetMessage("CT_BLEE_ACCESS_RIGHTS"), "type" => "custom", "colspan" => true, "value" => $rights_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; }
public static function OnAfterIBlockDelete($iblock_id) { if (CModule::includeModule('bizproc')) { BizProcDocument::deleteDataIblock($iblock_id); } }
protected function getCommentsProcess($elementId) { $countComments = 0; $this->arResult["ELEMENTS_HEADERS"]["COMMENTS"] = Loc::getMessage("CC_BLL_COMMENTS"); if (!$this->arResult["BIZPROC"] || !$elementId) { return $countComments; } $documentStates = CBPDocument::GetDocumentStates(BizProcDocument::generateDocumentComplexType($this->arParams["IBLOCK_TYPE_ID"], $this->arResult["IBLOCK_ID"]), BizProcDocument::getDocumentComplexId($this->arParams["IBLOCK_TYPE_ID"], $elementId)); if (!empty($documentStates)) { $state = current($documentStates); } else { return $countComments; } $query = CForumTopic::getList(array(), array("@XML_ID" => 'WF_' . $state["ID"])); while ($row = $query->fetch()) { $countComments = $row["POSTS"]; } return $countComments; }
<?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));