Esempio n. 1
0
 protected function processActionPerformActionBp()
 {
     if (!Loader::includeModule('bizproc')) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_LAC_MODULE_NOT_INSTALLED'))));
     }
     $this->checkRequiredPostParams(array('iblockTypeId', 'iblockId', 'sectionId', 'workflowId', 'elementId', 'action'));
     if ($this->request->getPost('iblockTypeId') == COption::getOptionString('lists', 'livefeed_iblock_type_id')) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_LAC_UNKNOWN_ERROR'))));
     }
     if ($this->errorCollection->hasErrors()) {
         $this->sendJsonErrorResponse();
     }
     $this->iblockTypeId = $this->request->getPost('iblockTypeId');
     $this->iblockId = $this->request->getPost('iblockId');
     $this->sectionId = $this->request->getPost('sectionId');
     $workflowId = $this->request->getPost('workflowId');
     $elementId = $this->request->getPost('elementId');
     $action = $this->request->getPost('action');
     $this->documentStates = CBPDocument::getDocumentStates(BizProcDocument::generateDocumentComplexType($this->iblockTypeId, $this->iblockId), BizProcDocument::getDocumentComplexId($this->iblockTypeId, $elementId));
     if (isset($this->documentStates[$workflowId]['WORKFLOW_STATUS']) && $this->documentStates[$workflowId]['WORKFLOW_STATUS'] !== null) {
         $this->terminateWorkflow($workflowId, $elementId);
     }
     if ($action == 'delete') {
         if (CBPDocument::canUserOperateDocument(CBPCanUserOperateOperation::CreateWorkflow, $this->getUser(), BizProcDocument::getDocumentComplexId($this->iblockTypeId, $elementId), array("DocumentStates" => $this->documentStates))) {
             CBPTaskService::DeleteByWorkflow($workflowId);
             CBPTrackingService::DeleteByWorkflow($workflowId);
             CBPStateService::DeleteWorkflow($workflowId);
         } else {
             $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_LAC_ACCESS_DENIED'))));
         }
         if ($this->errorCollection->hasErrors()) {
             $this->sendJsonErrorResponse();
         }
     }
     $this->sendJsonSuccessResponse(array('message' => Loc::getMessage('LISTS_LAC_MESSAGE_SUCCESS')));
 }
Esempio n. 2
0
     $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 (CModule::IncludeModule("bizproc")) {
     $documentStates = CBPDocument::GetDocumentStates(BizProcDocument::generateDocumentComplexType($arIBlock["IBLOCK_TYPE_ID"], $arIBlock["ID"]), BizProcDocument::getDocumentComplexId($arIBlock["IBLOCK_TYPE_ID"], $data["ID"]));
     if ($arResult["PROCESSES"] && $arResult["USE_COMMENTS"]) {
         if (!empty($documentStates)) {
             $stateTemporary = current($documentStates);
             $data["WORKFLOW_ID"] = $stateTemporary["ID"];
         } else {
             $data["WORKFLOW_ID"] = '';
         }
     }
 }
 $arUserGroupsForBPTmp = $arUserGroupsForBP;
 if ($USER->GetID() == $data["CREATED_BY"]) {
     $arUserGroupsForBPTmp[] = "Author";
 }
 $arBPStart = array();
 if (CModule::IncludeModule('bizproc')) {
Esempio n. 3
0
         $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---
 $arResult["isConstantsTuned"] = false;
 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");
     $templatesOnStartup = false;
     $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) {
Esempio n. 4
0
     $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);
Esempio n. 5
0
 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;
 }
Esempio n. 6
0
 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;
 }
Esempio n. 7
0
<?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));