Beispiel #1
0
 public function StartWorkflow($ID, $arBizProcParametersValues = false)
 {
     if (!CModule::IncludeModule('bizproc')) {
         return true;
     }
     global $USER;
     $arBizProcWorkflowId = array();
     $bresult = true;
     foreach ($this->arDocumentStates as $arDocumentState) {
         if (strlen($arDocumentState['ID']) <= 0) {
             $arErrorsTmp = array();
             $arBizProcWorkflowId[$arDocumentState['TEMPLATE_ID']] = CBPDocument::StartWorkflow($arDocumentState['TEMPLATE_ID'], array('crm', $this->sDocument, $this->sEntityType . '_' . $ID), $arBizProcParametersValues[$arDocumentState['TEMPLATE_ID']], $arErrorsTmp);
             if (count($arErrorsTmp) > 0) {
                 $this->LAST_ERROR = '';
                 foreach ($arErrorsTmp as $e) {
                     $this->LAST_ERROR .= $e['message'] . '<br />';
                 }
                 $bresult = false;
             }
         }
     }
     if ($bresult) {
         $bizprocIndex = (int) $_REQUEST['bizproc_index'];
         if ($bizprocIndex > 0) {
             for ($i = 1; $i <= $bizprocIndex; $i++) {
                 $bpId = trim($_REQUEST['bizproc_id_' . $i]);
                 $bpTemplateId = intval($_REQUEST['bizproc_template_id_' . $i]);
                 $bpEvent = trim($_REQUEST['bizproc_event_' . $i]);
                 if (strlen($bpEvent) > 0) {
                     if (strlen($bpId) > 0) {
                         if (!array_key_exists($bpId, $this->arDocumentStates)) {
                             continue;
                         }
                     } else {
                         if (!array_key_exists($bpTemplateId, $this->arDocumentStates)) {
                             continue;
                         }
                         $bpId = $arBizProcWorkflowId[$bpTemplateId];
                     }
                     $arErrorTmp = array();
                     CBPDocument::SendExternalEvent($bpId, $bpEvent, array('Groups' => $this->arCurrentUserGroups, 'User' => $USER->GetID()), $arErrorTmp);
                     if (count($arErrorsTmp) > 0) {
                         foreach ($arErrorsTmp as $e) {
                             $this->LAST_ERROR .= $e['message'] . '<br />';
                         }
                         $bresult = false;
                     }
                 }
             }
         }
     }
     return $bresult;
 }
Beispiel #2
0
 public function Execute()
 {
     if (!CModule::IncludeModule("intranet")) {
         return CBPActivityExecutionStatus::Closed;
     }
     $iblockId = COption::GetOptionInt("intranet", "iblock_tasks", 0);
     if ($iblockId <= 0) {
         return CBPActivityExecutionStatus::Closed;
     }
     $parentSectionId = 0;
     $dbSectionsList = CIBlockSection::GetList(array(), array("GLOBAL_ACTIVE" => "Y", "XML_ID" => $this->TaskType == "group" ? $this->TaskOwnerId : "users_tasks", "IBLOCK_ID" => $iblockId, "SECTION_ID" => 0), false);
     if ($arSection = $dbSectionsList->GetNext()) {
         $parentSectionId = $arSection["ID"];
     }
     if ($parentSectionId <= 0) {
         $dbSectionsList = CIBlockSection::GetList(array(), array("GLOBAL_ACTIVE" => "Y", "XML_ID" => "users_tasks", "IBLOCK_ID" => $iblockId, "SECTION_ID" => 0), false);
         if ($arSection = $dbSectionsList->GetNext()) {
             $parentSectionId = $arSection["ID"];
         }
     }
     if ($parentSectionId <= 0) {
         return CBPActivityExecutionStatus::Closed;
     }
     $rootActivity = $this->GetRootActivity();
     $documentId = $rootActivity->GetDocumentId();
     $arTaskCreatedBy = CBPHelper::ExtractUsers($this->TaskCreatedBy, $documentId, true);
     $arTaskAssignedTo = CBPHelper::ExtractUsers($this->TaskAssignedTo, $documentId, true);
     if (!$arTaskCreatedBy || !$arTaskAssignedTo) {
         return CBPActivityExecutionStatus::Closed;
     }
     if ($this->TaskType != "group") {
         $this->TaskOwnerId = $arTaskAssignedTo;
     }
     $arTaskTrackers = CBPHelper::ExtractUsers($this->TaskTrackers, $documentId);
     $arFields = array("IBLOCK_SECTION_ID" => $parentSectionId, "MODIFIED_BY" => $arTaskCreatedBy, "CREATED_BY" => $arTaskCreatedBy, "DATE_CREATE" => date($GLOBALS["DB"]->DateFormatToPHP(FORMAT_DATETIME)), "ACTIVE_FROM" => $this->TaskActiveFrom, "ACTIVE_TO" => $this->TaskActiveTo, "NAME" => $this->TaskName, "DETAIL_TEXT" => $this->TaskDetailText, "PROPERTY_TaskPriority" => $this->TaskPriority, "PROPERTY_TaskAssignedTo" => $arTaskAssignedTo, "PROPERTY_TaskTrackers" => $arTaskTrackers);
     $taskId = CIntranetTasksDocument::CreateDocument($arFields);
     if ($this->TaskType == "group") {
         $pathTemplate = str_replace(array("#GROUP_ID#", "#TASK_ID#"), array($this->TaskOwnerId, "{=Document:ID}"), COption::GetOptionString("intranet", "path_task_group_entry", "/workgroups/group/#GROUP_ID#/tasks/task/view/#TASK_ID#/"));
     } else {
         $pathTemplate = str_replace(array("#USER_ID#", "#TASK_ID#"), array($this->TaskOwnerId, "{=Document:ID}"), COption::GetOptionString("intranet", "path_task_user_entry", "/company/personal/user/#USER_ID#/tasks/task/view/#TASK_ID#/"));
     }
     $pathTemplate = str_replace('#HTTP_HOST#', $_SERVER['HTTP_HOST'], "http://#HTTP_HOST#" . $pathTemplate);
     $arTemplateStates = CBPWorkflowTemplateLoader::GetDocumentTypeStates(array("intranet", "CIntranetTasksDocument", "x" . $iblockId), CBPDocumentEventType::Create);
     foreach ($arTemplateStates as $arState) {
         CBPDocument::StartWorkflow($arState["TEMPLATE_ID"], array("intranet", "CIntranetTasksDocument", $taskId), array("OwnerId" => $this->TaskOwnerId, "TaskType" => $this->TaskType, "PathTemplate" => $pathTemplate, "ForumId" => intval($this->TaskForumId), "IBlockId" => $iblockId), $arErrorsTmp);
     }
     return CBPActivityExecutionStatus::Closed;
 }
Beispiel #3
0
 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());
 }
Beispiel #4
0
 public static function StartRestTime($task_name, $doc_id)
 {
     $arErrorsTmp = array();
     $wf = CBPDocument::StartWorkflow(66, array("iblock", "CIBlockDocument", $doc_id), array("TaskName" => $task_name), $arErrorsTmp);
 }
Beispiel #5
0
                     if (!empty($differences)) {
                         $modifiedFields[] = $fieldName;
                     }
                 }
             } else {
                 if (strcmp((string) $fieldValue, (string) $elementOldData[$fieldName]) !== 0) {
                     $modifiedFields[] = $fieldName;
                 }
             }
         }
     }
     $arBizProcWorkflowId = array();
     foreach ($arDocumentStates as $arDocumentState) {
         if (strlen($arDocumentState["ID"]) <= 0) {
             $arErrorsTmp = array();
             $arBizProcWorkflowId[$arDocumentState["TEMPLATE_ID"]] = CBPDocument::StartWorkflow($arDocumentState["TEMPLATE_ID"], BizProcDocument::getDocumentComplexId($arParams["IBLOCK_TYPE_ID"], $arResult["ELEMENT_ID"]), array_merge($arBizProcParametersValues[$arDocumentState["TEMPLATE_ID"]], array(CBPDocument::PARAM_TAGRET_USER => "user_" . intval($GLOBALS["USER"]->GetID()), CBPDocument::PARAM_MODIFIED_DOCUMENT_FIELDS => $modifiedFields)), $arErrorsTmp);
             foreach ($arErrorsTmp as $e) {
                 $strError .= $e["message"] . "<br />";
             }
         }
     }
 }
 if (!$strError) {
     $bizprocIndex = intval($_REQUEST["bizproc_index"]);
     if ($bizprocIndex > 0) {
         for ($i = 1; $i <= $bizprocIndex; $i++) {
             $bpId = trim($_REQUEST["bizproc_id_" . $i]);
             $bpTemplateId = intval($_REQUEST["bizproc_template_id_" . $i]);
             $bpEvent = trim($_REQUEST["bizproc_event_" . $i]);
             if (strlen($bpEvent) > 0) {
                 if (strlen($bpId) > 0) {
				} // if ($strWarning)

				if ($bBizproc)
				{
					if ($strWarning == '')
					{
						$arBizProcWorkflowId = array();
						foreach ($arDocumentStates as $arDocumentState)
						{
							if (strlen($arDocumentState["ID"]) <= 0)
							{
								$arErrorsTmp = array();

								$arBizProcWorkflowId[$arDocumentState["TEMPLATE_ID"]] = CBPDocument::StartWorkflow(
									$arDocumentState["TEMPLATE_ID"],
									array(MODULE_ID, ENTITY, $ID),
									$arBizProcParametersValues[$arDocumentState["TEMPLATE_ID"]],
									$arErrorsTmp
								);

								if (!empty($arErrorsTmp))
								{
									foreach ($arErrorsTmp as $e)
										$strWarning .= $e["message"]."<br />";
								}
							}
						}
					}

					if ($strWarning == '')
					{
						$bizprocIndex = intval($_REQUEST["bizproc_index"]);
         if (!empty($_REQUEST["iblock_apply"]) && strlen($SEF_URL) > 0) {
             if (strpos($SEF_URL, "?") === false) {
                 $SEF_URL .= "?edit=Y";
             } elseif (strpos($SEF_URL, "edit=") === false) {
                 $SEF_URL .= "&edit=Y";
             }
             $SEF_URL .= "&CODE=" . $arParams["ID"];
         }
     }
 }
 if ($bBizproc && count($arResult["ERRORS"]) == 0) {
     $arBizProcWorkflowId = array();
     foreach ($arDocumentStates as $arDocumentState) {
         if (strlen($arDocumentState["ID"]) <= 0) {
             $arErrorsTmp = array();
             $arBizProcWorkflowId[$arDocumentState["TEMPLATE_ID"]] = CBPDocument::StartWorkflow($arDocumentState["TEMPLATE_ID"], array("iblock", "CIBlockDocument", $arParams["ID"]), $arBizProcParametersValues[$arDocumentState["TEMPLATE_ID"]], $arErrorsTmp);
             foreach ($arErrorsTmp as $e) {
                 $arResult["ERRORS"][] = $e["message"];
             }
         }
     }
 }
 if ($bBizproc && count($arResult["ERRORS"]) == 0) {
     $arDocumentStates = null;
     CBPDocument::AddDocumentToHistory(array("iblock", "CIBlockDocument", $arParams["ID"]), $arUpdateValues["NAME"], $USER->GetID());
 }
 // redirect to element edit form or to elements list
 if (count($arResult["ERRORS"]) == 0) {
     if (!empty($_REQUEST["iblock_submit_c"])) {
         if (strlen($arParams["LIST_URL"]) > 0) {
             $sRedirectUrl = $arParams["LIST_URL"];
Beispiel #8
0
     } else {
         $res = $obElement->Add($arElement, false, true, true);
         if ($res) {
             $arResult["ELEMENT_ID"] = $res;
         } else {
             $strError = $obElement->LAST_ERROR;
         }
     }
 }
 if ($bBizproc) {
     if (!$strError) {
         $arBizProcWorkflowId = array();
         foreach ($arDocumentStates as $arDocumentState) {
             if (strlen($arDocumentState["ID"]) <= 0) {
                 $arErrorsTmp = array();
                 $arBizProcWorkflowId[$arDocumentState["TEMPLATE_ID"]] = CBPDocument::StartWorkflow($arDocumentState["TEMPLATE_ID"], BizprocDocument::getDocumentComplexId($arParams["IBLOCK_TYPE_ID"], $arResult["ELEMENT_ID"]), array_merge($arBizProcParametersValues[$arDocumentState["TEMPLATE_ID"]], array("TargetUser" => "user_" . intval($GLOBALS["USER"]->GetID()))), $arErrorsTmp);
                 foreach ($arErrorsTmp as $e) {
                     $strError .= $e["message"] . "<br />";
                 }
             }
         }
     }
     if (!$strError) {
         $bizprocIndex = intval($_REQUEST["bizproc_index"]);
         if ($bizprocIndex > 0) {
             for ($i = 1; $i <= $bizprocIndex; $i++) {
                 $bpId = trim($_REQUEST["bizproc_id_" . $i]);
                 $bpTemplateId = intval($_REQUEST["bizproc_template_id_" . $i]);
                 $bpEvent = trim($_REQUEST["bizproc_event_" . $i]);
                 if (strlen($bpEvent) > 0) {
                     if (strlen($bpId) > 0) {
Beispiel #9
0
             }
         }
     }
     $arWorkflowParameters = CBPWorkflowTemplateLoader::CheckWorkflowParameters($workflowTemplate["PARAMETERS"], $arRequest, $documentParameters["DOCUMENT_TYPE"], $arErrorsTmp);
     if (count($arErrorsTmp) > 0) {
         $bCanStartWorkflow = false;
         foreach ($arErrorsTmp as $e) {
             $arError[] = array("id" => "CheckWorkflowParameters", "text" => $e["message"]);
         }
     } else {
         $bCanStartWorkflow = true;
     }
 }
 if ($bCanStartWorkflow) {
     $arErrorsTmp = array();
     $wfId = CBPDocument::StartWorkflow($arParams["TEMPLATE_ID"], $documentParameters["DOCUMENT_ID"], array_merge($arWorkflowParameters, array("TargetUser" => "user_" . intval($GLOBALS["USER"]->GetID()))), $arErrorsTmp);
     if (count($arErrorsTmp) > 0) {
         $arResult["SHOW_MODE"] = "StartWorkflowError";
         foreach ($arErrorsTmp as $e) {
             $arError[] = array("id" => "StartWorkflowError", "text" => "[" . $e["code"] . "] " . $e["message"]);
         }
     } else {
         $arResult["SHOW_MODE"] = "StartWorkflowSuccess";
         if (strlen($arResult["back_url"]) > 0) {
             LocalRedirect(str_replace("#WF#", $wfId, $_REQUEST["back_url"]));
             die;
         }
     }
 } else {
     $p = $_SERVER["REQUEST_METHOD"] == "POST" && strlen($_POST["DoStartParamWorkflow"]) > 0;
     $keys = array_keys($workflowTemplate["PARAMETERS"]);
Beispiel #10
0
             }
         }
     }
     $arWorkflowParameters = CBPWorkflowTemplateLoader::CheckWorkflowParameters($arWorkflowTemplate["PARAMETERS"], $arRequest, $documentType, $arErrorsTmp);
     if (count($arErrorsTmp) > 0) {
         $bCanStartWorkflow = false;
         foreach ($arErrorsTmp as $e) {
             $errorMessage .= $e["message"] . "<br />";
         }
     } else {
         $bCanStartWorkflow = true;
     }
 }
 if ($bCanStartWorkflow) {
     $arErrorsTmp = array();
     $wfId = CBPDocument::StartWorkflow($workflowTemplateId, $documentId, $arWorkflowParameters, $arErrorsTmp);
     if (count($arErrorsTmp) > 0) {
         $showMode = "StartWorkflowError";
         foreach ($arErrorsTmp as $e) {
             $errorMessage .= "[" . $e["code"] . "] " . $e["message"] . "<br />";
         }
     } else {
         $showMode = "StartWorkflowSuccess";
         if (strlen($backUrl) <= 0) {
             $backUrl = "/bitrix/admin/bizproc_log.php?ID=#WF#";
         }
         LocalRedirect(str_replace("#WF#", $wfId, $backUrl));
         die;
     }
 } else {
     $p = $_SERVER["REQUEST_METHOD"] == "POST" && strlen($_POST["DoStartParamWorkflow"]) > 0;
Beispiel #11
0
         $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"];
         }
         LocalRedirect($backUrl);
         die;
Beispiel #12
0
 function UpdateListItems($listName, $updates)
 {
     global $USER;
     $arPaths = array('user' => COption::GetOptionString('intranet', 'path_task_user_entry', '/company/personal/user/#USER_ID#/tasks/task/view/#TASK_ID#/'), 'group' => COption::GetOptionString('intranet', 'path_task_group_entry', '/workgroups/group/#GROUP_ID#/tasks/task/view/#TASK_ID#/'));
     if (!$this->__Init()) {
         return $this->error;
     }
     if (!($listName_original = CIntranetUtils::checkGUID($listName))) {
         return new CSoapFault('Data error', 'Wrong GUID - ' . $listName);
     }
     $listName = ToUpper(CIntranetUtils::makeGUID($listName_original));
     // one more dirty hack. now for bx.
     //define('BX_INTASKS_FROM_COMPONENT', true);
     //CModule::IncludeModule('socialnetwork');
     //include($_SERVER['DOCUMENT_ROOT'].BX_PERSONAL_ROOT.'/components/bitrix/intranet.tasks/init.php');
     //include($_SERVER['DOCUMENT_ROOT'].BX_PERSONAL_ROOT.'/components/bitrix/intranet.tasks/action.php');
     $obResponse = new CXMLCreator('Results');
     $arStatusValues = array();
     $obStatus = CIBlockProperty::GetPropertyEnum('TaskStatus', array('SORT' => 'asc'), array('IBLOCK_ID' => $this->IBLOCK_ID));
     while ($arStatus = $obStatus->Fetch()) {
         $arStatusValues[$arStatus['XML_ID']] = $arStatus['ID'];
         if ($arStatus['XML_ID'] == 'NotAccepted') {
             $arStatusValues[$arStatus['VALUE']] = $arStatus['ID'];
         }
     }
     /*
     $arPriorityValues = array();
     $obPriority = CIBlockProperty::GetPropertyEnum('TaskPriority', array('SORT' => 'asc'), array('IBLOCK_ID' => $this->IBLOCK_ID));
     while ($arPriority = $obPriority->Fetch())
     	$arPriorityValues[$arPriority['XML_ID']] = $arPriority['ID'];
     */
     $arPriorityValues = array_flip($this->arProperties['TaskPriority']['VARIANTS_ID']);
     $arStatusValues = array_flip($this->arProperties['TaskStatus']['VARIANTS_ID']);
     $arStatusXML_ID = array_flip($this->arProperties['TaskStatus']['VARIANTS']);
     $obBatch = $updates->children[0];
     $atrONERROR = $obBatch->getAttribute('OnError');
     $atrDATEINUTC = $obBatch->getAttribute('DateInUtc');
     $atrPROPERTIES = $obBatch->getAttribute('Properties');
     $arChanges = $obBatch->children;
     $arResultIDs = array();
     $dateStart = ConvertTimeStamp(strtotime('-1 hour'), 'FULL');
     $arResponseRows = array();
     $arResponseRowsError = array();
     $arReplicationIDs = array();
     foreach ($arChanges as $obMethod) {
         $arData = array('_command' => $obMethod->getAttribute('Cmd'));
         $ID = false;
         $bUpdate = true;
         $arElement = false;
         $arSection = $this->arUsersSection;
         foreach ($obMethod->children as $obField) {
             $name = $obField->getAttribute('Name');
             if ($name == 'MetaInfo') {
                 $name .= '_' . $obField->getAttribute('Property');
             }
             $arData[$name] = $obField->content;
         }
         $obResponseRow = new CXMLCreator('Result');
         $obResponseRow->setAttribute('ID', $obMethod->getAttribute('ID') . ',' . $arData['_command']);
         $obResponseRow->setAttribute('List', $listName);
         $obResponseRow->addChild($obErrorCode = new CXMLCreator('ErrorCode'));
         if ($arData['ID'] > 0) {
             //$dbRes = CIBlockElement::GetByID($arData['ID']);
             $arElement = CIntranetTasks::GetById($arData['ID']);
             if (!is_array($arElement)) {
                 $obErrorCode->setData('0x81020016');
                 $bUpdate = false;
             } else {
                 //$arElement = $obElement->GetFields();
                 //$arElement['prop'] = $obElement->GetProperties();
                 if ($arElement['IBLOCK_SECTION_ID'] != $arSection['ID']) {
                     if (!($arSection = $this->__getSection($arElement['IBLOCK_SECTION_ID']))) {
                         return new CSoapFault('Some error', 'Unknown error with iblock sections');
                     }
                 }
                 // don't forget about depth of sections, Max has modification
                 if ($arElement['taskType'] == "group") {
                     $arGroupTmp = CSocNetGroup::GetByID($arElement['ownerId']);
                     if ($arGroupTmp["CLOSED"] == "Y") {
                         if (COption::GetOptionString("socialnetwork", "work_with_closed_groups", "N") != "Y") {
                             return new CSoapFault('Cannot modify archive group task', 'Cannot modify archive group task');
                         }
                     }
                 }
                 $arElement['arParams'] = array($arElement['taskType'] == 'user' ? 'PATH_TO_USER_TASKS_TASK' : 'PATH_TO_GROUP_TASKS_TASK' => str_replace(array('#USER_ID#', '#GROUP_ID#', '#TASK_ID#'), array($USER->GetID(), $arSection['XML_ID'], $arElement['ID']), $arPaths[$arElement['taskType']]));
             }
         }
         if ($bUpdate) {
             if ($arData['_command'] == 'Delete') {
                 $arError = false;
                 if (CIntranetTasksDocument::CanUserOperateDocument(INTASK_DOCUMENT_OPERATION_DELETE_DOCUMENT, $USER->GetID(), $arElement['ID'], array())) {
                     if (!CIntranetTasks::Delete($arElement['ID'], $arError)) {
                         $obErrorCode->setData('0x81020014');
                     } else {
                         $obErrorCode->setData('0x00000000');
                     }
                 } else {
                     $obErrorCode->setData('0x81020014');
                 }
                 /*
                 	0x00000000 - ok
                 	0x81020015 - data conflict
                 	0x81020014 - generic error such as invalid value for Field
                 	0x81020016 - item does not exist
                 */
             } elseif ($arData['_command'] == 'New' || $arData['_command'] == 'Update') {
                 /*
                 $arData['Body'] = str_replace('</DIV>', "\r\n</DIV>", $arData['Body']);
                 $arData['Body'] = strip_tags($arData['Body']);
                 $arData['Body'] = trim($arData['Body']);
                 $arData['Body'] = htmlspecialcharsback($arData['Body']);
                 */
                 $arData['Body'] = trim($arData['Body']);
                 $arData['Body'] = str_replace(array("&#10;", "&#13;", '&nbsp;'), "", $arData['Body']);
                 $arData['Body'] = preg_replace("/<![^>]*>/", '', $arData['Body']);
                 if (($pos = strpos($arData['Body'], '<BODY>')) !== false) {
                     $arData['Body'] = substr($arData['Body'], $pos + 6);
                 }
                 echo $pos . ' ';
                 if (($pos = strpos($arData['Body'], '</BODY>')) !== false) {
                     $arData['Body'] = substr($arData['Body'], 0, $pos);
                 }
                 echo $pos . ' ';
                 $TZBias = intval(date('Z'));
                 $arData['StartDate'] = $arData['StartDate'] ? $this->__makeTS($arData['StartDate']) + $TZBias : '';
                 $arData['DueDate'] = $arData['DueDate'] ? $this->__makeTS($arData['DueDate']) + $TZBias : '';
                 $arData['MetaInfo_DateComplete'] = $arData['MetaInfo_DateComplete'] ? $this->__makeTS($arData['EndDate']) + $TZBias : '';
                 if ($arData['Status'] == $arStatusValues['NotAccepted']) {
                     $arData['Status'] = 'NotAccepted';
                 }
                 $arFields = array('IBLOCK_ID' => $this->IBLOCK_ID, 'IBLOCK_SECTION_ID' => $arSection['ID'], 'MODIFIED_BY' => $USER->GetID(), 'NAME' => $arData['Title'] ? $arData['Title'] : GetMessage('INTR_OUTLOOK_TASK_NO_TITLE'), 'DATE_ACTIVE_FROM' => $arData['StartDate'] ? ConvertTimeStamp($arData['StartDate']) : '', 'DATE_ACTIVE_TO' => $arData['DueDate'] ? ConvertTimeStamp($arData['DueDate']) : '', 'DETAIL_TEXT_TYPE' => 'html', 'DETAIL_TEXT' => $arData['Body'], 'PROPERTY_TaskPriority' => $arData['Priority'] ? $arPriorityValues[$arData['Priority']] : false, 'PROPERTY_TaskComplete' => $arData['PercentComplete'] * 100, 'PROPERTY_TaskSize' => $arData['MetaInfo_TotalWork'] / 60, 'PROPERTY_TaskSizeReal' => $arData['MetaInfo_ActualWork'] / 60, 'PROPERTY_TaskFinish' => $arData['MetaInfo_DateComplete'] ? ConvertTimeStamp($arData['MetaInfo_DateComplete']) : '');
                 if (false === $arFields['PROPERTY_TaskPriority']) {
                     $arPrior = array_keys($arElement['PROPERTY_TaskPriority']);
                     $arFields['PROPERTY_TaskPriority'] = $arPrior[0];
                 }
                 if ($assigned_to = $arData['AssignedTo']) {
                     if ($USER_ID = $this->__getUser($assigned_to)) {
                         $arFields['PROPERTY_TaskAssignedTo'] = $USER_ID;
                     } else {
                         $obErrorCode->setData('0x81020054');
                         $bUpdate = false;
                     }
                 }
                 if ($bUpdate) {
                     $bConfirm = false;
                     $bComplete = false;
                     if ($arData['_command'] != 'New') {
                         if (false && $arElement['PROPERTY_VERSION'] > $arData['owshiddenversion']) {
                             $obErrorCode->setData('0x81020015');
                             $bUpdate = false;
                         } else {
                             foreach ($arElement as $fld => $value) {
                                 if (substr($fld, 0, 9) == 'PROPERTY_') {
                                     if (!$arFields[$fld] && $fld != 'PROPERTY_TaskFiles') {
                                         $arFields[$fld] = $arElement[$fld];
                                     }
                                 }
                             }
                             $arFields['PROPERTY_VERSION']++;
                         }
                         $statusOld = $this->__GetTaskStatus($arElement['ID'], $arElement['IBLOCK_ID']);
                     } else {
                         $arFields['PROPERTY_VERSION'] = $arData['owshiddenversion'];
                         $statusOld = -1;
                     }
                     if (!$arFields['PROPERTY_TaskPriority']) {
                         $arFields['PROPERTY_TaskPriority'] = 2;
                     }
                     if (!$arFields['PROPERTY_TaskAssignedTo']) {
                         $arFields['PROPERTY_TaskAssignedTo'] = $USER->GetID();
                     } elseif ($arFields['PROPERTY_TaskAssignedTo'] != $USER->GetID()) {
                         $arData['Status'] = 'NotAccepted';
                     }
                     $statusNew = $arData['Status'] ? $arStatusXML_ID[$arData['Status']] : $statusOld;
                     $ID = 0;
                     if ($bUpdate) {
                         $arError = false;
                         if ($arData['_command'] == 'New') {
                             if ($ID = CIntranetTasks::Add($arFields, $arError)) {
                                 $arDocumentStates = CBPDocument::GetDocumentStates(array("intranet", "CIntranetTasksDocument", "x" . $this->IBLOCK_ID), null);
                                 $arDocumentStates = array_values($arDocumentStates);
                                 $pathTemplate = str_replace(array("#USER_ID#", "#TASK_ID#"), array($USER->GetID(), "{=Document:ID}"), COption::GetOptionString("intranet", "path_task_user_entry", "/company/personal/user/#USER_ID#/tasks/task/view/#TASK_ID#/"));
                                 $arErrors = array();
                                 CBPDocument::StartWorkflow($arDocumentStates[0]["TEMPLATE_ID"], array("intranet", "CIntranetTasksDocument", $ID), array("OwnerId" => $arFields['PROPERTY_TaskAssignedTo'], "TaskType" => 'user', "PathTemplate" => $pathTemplate, "ForumId" => COption::GetOptionInt('intranet', 'task_forum_id', 0), "IBlockId" => $this->IBLOCK_ID), $arErrors);
                                 CIntranetTasks::ChangeStatus($ID, $statusNew);
                                 $arReplicationIDs[$ID] = $arData['MetaInfo_ReplicationID'];
                                 $obErrorCode->setData('0x00000000');
                             }
                         } else {
                             if (CIntranetTasks::Update($arData['ID'], $arFields, $arError)) {
                                 if ($statusOld != $statusNew) {
                                     CIntranetTasks::ChangeStatus($arData['ID'], $statusNew);
                                 }
                                 $ID = $arData['ID'];
                                 $obErrorCode->setData('0x00000000');
                             }
                         }
                         if (is_array($arError) && count($arError) > 0) {
                             $ID = 0;
                             $obErrorCode->setData('0x81020014');
                             $bUpdate = false;
                         } else {
                             $taskType = $arElement ? $arElement['taskType'] : 'user';
                             $ownerId = $arElement ? $arElement['ownerId'] : $USER->GetID();
                             $arParams = $arElement ? $arElement['arParams'] : array('PATH_TO_USER_TASKS_TASK' => str_replace(array('#USER_ID#', '#GROUP_ID#', '#TASK_ID#'), array($USER->GetID(), $arSection['XML_ID'], $ID), $arPaths['user']));
                         }
                     }
                 }
             }
         }
         if ($ID > 0) {
             $arResponseRows[$ID] = $obResponseRow;
         } else {
             $arResponseRowsError[] = $obResponseRow;
         }
     }
     $dbRes = CIntranetTasks::GetList(array('ID' => 'ASC'), array('IBLOCK_ID' => $this->IBLOCK_ID, 'ID' => array_keys($arResponseRows)));
     while ($arRes = $dbRes->Fetch()) {
         if ($arResponseRows[$arRes['ID']]) {
             $obRow = $this->__getRow($arRes, $listName, $last_change = 0);
             if ($arReplicationIDs[$arRes['ID']]) {
                 $obRow->setAttribute('ows_MetaInfo_ReplicationID', $arReplicationIDs[$arRes['ID']]);
             }
             $obRow->setAttribute('xmlns:z', "#RowsetSchema");
             $arResponseRows[$arRes['ID']]->addChild($obRow);
             $obResponse->addChild($arResponseRows[$arRes['ID']]);
         }
     }
     foreach ($arResponseRowsError as $obChange) {
         $obResponse->addChild($obChange);
     }
     return array('UpdateListItemsResult' => $obResponse);
 }
Beispiel #13
0
     				$logID = CSocNetLog::Add($arSoFields, false);
     
     				if (intval($logID) > 0)
     					CSocNetLog::Update($logID, array("TMP_ID" => $logID));
     
     				CSocNetLog::SendEvent($logID, "SONET_NEW_EVENT", $logID);
     			}
     */
 }
 if ($bBizproc) {
     if (!$strError) {
         $arBizProcWorkflowId = array();
         foreach ($arDocumentStates as $arDocumentState) {
             if (strlen($arDocumentState["ID"]) <= 0) {
                 $arErrorsTmp = array();
                 $arBizProcWorkflowId[$arDocumentState["TEMPLATE_ID"]] = CBPDocument::StartWorkflow($arDocumentState["TEMPLATE_ID"], array("iblock", "CIBlockDocument", $arResult["ELEMENT_ID"]), array_merge($arBizProcParametersValues[$arDocumentState["TEMPLATE_ID"]], array("TargetUser" => "user_" . intval($GLOBALS["USER"]->GetID()))), $arErrorsTmp);
                 foreach ($arErrorsTmp as $e) {
                     $strError .= $e["message"] . "<br />";
                 }
             }
         }
     }
     if (!$strError) {
         $bizprocIndex = intval($_REQUEST["bizproc_index"]);
         if ($bizprocIndex > 0) {
             for ($i = 1; $i <= $bizprocIndex; $i++) {
                 $bpId = trim($_REQUEST["bizproc_id_" . $i]);
                 $bpTemplateId = intval($_REQUEST["bizproc_template_id_" . $i]);
                 $bpEvent = trim($_REQUEST["bizproc_event_" . $i]);
                 if (strlen($bpEvent) > 0) {
                     if (strlen($bpId) > 0) {
 }
 if (CModule::IncludeModule('bizproc')) {
     if (CBPDocument::GetNumberOfWorkflowTemplatesForDocumentType(array("iblock", "CIBlockDocument", "iblock_" . $IBLOCK_ID)) <= 0) {
         CBPDocument::AddDefaultWorkflowTemplates(array("iblock", "CIBlockDocument", "iblock_" . $IBLOCK_ID));
     }
     $TEMPLATE_ID = 0;
     $dbWorkflowTemplate = CBPWorkflowTemplateLoader::GetList(array(), array("DOCUMENT_TYPE" => array("iblock", "CIBlockDocument", "iblock_" . $IBLOCK_ID), "SYSTEM_CODE" => "status.php", "ACTIVE" => "Y"), false, false, array("ID"));
     if ($arWorkflowTemplate = $dbWorkflowTemplate->Fetch()) {
         $TEMPLATE_ID = $arWorkflowTemplate["ID"];
     }
     $arElement = array("IBLOCK_ID" => $IBLOCK_ID, "NAME" => GetMessage("DEMO_IBLOCK_CONTENT_ARTICLES_NAME"), "PREVIEW_TEXT" => GetMessage("DEMO_IBLOCK_CONTENT_ARTICLES_PREVIEW_TEXT"), "WF_STATUS_ID" => 2, "WF_NEW" => "Y", "PROPERTY_VALUES" => array("KEYWORDS" => GetMessage("DEMO_IBLOCK_CONTENT_ARTICLES_KEYWORDS"), "THEMES" => 4));
     $obElement = new CIBlockElement();
     $element_id = $obElement->Add($arElement);
     if ($element_id && $TEMPLATE_ID > 0) {
         $arErrorsTmp = array();
         $bpId = CBPDocument::StartWorkflow($TEMPLATE_ID, array("iblock", "CIBlockDocument", $element_id), array("Creators" => array("author"), "Approvers" => array(1)), $arErrorsTmp);
         if (count($arErrorsTmp) <= 0) {
             $arDocumentStates = CBPDocument::GetDocumentStates(array("iblock", "CIBlockDocument", "iblock_" . $IBLOCK_ID), array("iblock", "CIBlockDocument", $element_id));
             $arCurrentUserGroups = $GLOBALS["USER"]->GetUserGroupArray();
             $arCurrentUserGroups[] = "Author";
             $arEvents = CBPDocument::GetAllowableEvents($GLOBALS["USER"]->GetID(), $arCurrentUserGroups, array_pop($arDocumentStates));
             CBPDocument::SendExternalEvent($bpId, $arEvents[0]["NAME"], array("Groups" => $arCurrentUserGroups, "User" => $GLOBALS["USER"]->GetID()), $arErrorTmp);
         }
     }
 }
 //Include language one more time (after forum creation)
 __IncludeLang(GetLangFileName(dirname(__FILE__) . "/lang/", "/" . basename(__FILE__)));
 //Create directory and copy files
 $search = array("#IBLOCK.ID(XML_ID=content-articles)#", "#IBLOCK.ID(XML_ID=content-news)#", "#MODULE.INSTALLED(ID=forum)#", "#FORUM.ID(NAME=content-articles)#");
 $replace = array($IBLOCK_ID, CIBlockCMLImport::GetIBlockByXML_ID("content-news"), IsModuleInstalled("forum") ? "Y" : "N", $arForum["ID"]);
 DEMO_IBlock_CopyFiles("/public/content/articles/", "/content/articles/", false, $search, $replace);
Beispiel #15
0
 /**
  * Метод - просто агрегатор действий, запускающий БП и выполняющий события
  *
  * @param string $documentId - код документа.
  * @param array $arDocumentStates - массив шаблонов БП документа.
  * @param array $arBizProcParametersValues - массив входных параметров для шаблонов.
  * @param array $arUserGroups - массив групп пользователей.
  * @param array $arErrors - массив ошибок.
  */
 public function StartWorkflowsExecuting($documentId, $arDocumentStates, $arBizProcParametersValues, $arUserGroups, &$arErrors)
 {
     $documentId = $documentId;
     $arErrors = array();
     $arBizProcWorkflowId = array();
     $arDocumentStates = is_array($arDocumentStates) ? $arDocumentStates : array();
     $arBizProcParametersValues = is_array($arBizProcParametersValues) ? $arBizProcParametersValues : array();
     $arUserGroups = is_array($arUserGroups) ? $arUserGroups : array();
     foreach ($arDocumentStates as $arDocumentState) {
         if (strlen($arDocumentState["ID"]) <= 0) {
             $arErrorsTmp = array();
             $arBizProcWorkflowId[$arDocumentState["TEMPLATE_ID"]] = CBPDocument::StartWorkflow($arDocumentState["TEMPLATE_ID"], $documentId, $arBizProcParametersValues[$arDocumentState["TEMPLATE_ID"]], $arErrorsTmp);
             foreach ($arErrorsTmp as $e) {
                 $arError[] = array("id" => "bizproc_start_workflow", "text" => $e["message"]);
             }
         }
     }
     if (empty($arError) && intval($_REQUEST["bizproc_index"]) > 0) {
         if (empty($arUserGroups)) {
             $arUserGroups = call_user_func_array(array($this->wfParams['DOCUMENT_TYPE'][1], "GetUserGroups"), array(null, $documentId, $GLOBALS["USER"]->GetID()));
         }
         $bizprocIndex = intval($_REQUEST["bizproc_index"]);
         for ($i = 1; $i <= $bizprocIndex; $i++) {
             $bpId = trim($_REQUEST["bizproc_id_" . $i]);
             $bpTemplateId = intval($_REQUEST["bizproc_template_id_" . $i]);
             $bpEvent = trim($_REQUEST["bizproc_event_" . $i]);
             if (strlen($bpEvent) > 0) {
                 if (strlen($bpId) > 0) {
                     if (!array_key_exists($bpId, $arDocumentStates)) {
                         continue;
                     }
                 } else {
                     if (!array_key_exists($bpTemplateId, $arDocumentStates)) {
                         continue;
                     }
                     $bpId = $arBizProcWorkflowId[$bpTemplateId];
                 }
                 $arErrorTmp = array();
                 CBPDocument::SendExternalEvent($bpId, $bpEvent, array("Groups" => $arUserGroups, "User" => $GLOBALS["USER"]->GetID()), $arErrorTmp);
                 foreach ($arErrorsTmp as $e) {
                     $arError[] = array("id" => "bizproc_send_external_event", "text" => $e["message"]);
                 }
             }
         }
     }
     return empty($arError);
 }
Beispiel #16
0
             $arResult["ErrorMessage"] .= $e["message"] . "<br />";
         }
     }
 }
 if (strlen($arResult["ErrorMessage"]) <= 0) {
     $arWorkflowIds = array();
     if ($taskType == "group") {
         $pathTemplate = str_replace(array("#GROUP_ID#", "#TASK_ID#"), array($ownerId, "{=Document:ID}"), COption::GetOptionString("intranet", "path_task_group_entry", "/workgroups/group/#GROUP_ID#/tasks/task/view/#TASK_ID#/"));
     } else {
         $pathTemplate = str_replace(array("#USER_ID#", "#TASK_ID#"), array($ownerId, "{=Document:ID}"), COption::GetOptionString("intranet", "path_task_user_entry", "/company/personal/user/#USER_ID#/tasks/task/view/#TASK_ID#/"));
     }
     $pathTemplate = str_replace('#HTTP_HOST#', $_SERVER['HTTP_HOST'], "http://#HTTP_HOST#" . $pathTemplate);
     foreach ($arDocumentStates as $arDocumentState) {
         if (strlen($arDocumentState["ID"]) <= 0) {
             $arErrorsTmp = array();
             $arWorkflowIds[$arDocumentState["TEMPLATE_ID"]] = CBPDocument::StartWorkflow($arDocumentState["TEMPLATE_ID"], array("intranet", "CIntranetTasksDocument", $arParams["TASK_ID"]), array("OwnerId" => $ownerId, "TaskType" => $taskType, "PathTemplate" => $pathTemplate, "ForumId" => intval($arParams["FORUM_ID"]), "IBlockId" => intval($arParams["IBLOCK_ID"])), $arErrorsTmp);
             if (count($arErrorsTmp) > 0) {
                 foreach ($arErrorsTmp as $e) {
                     $arResult["ErrorMessage"] .= $e["message"] . "<br />";
                 }
             }
         }
     }
     if (array_key_exists("bizproc_event", $_POST) && strlen($_POST["bizproc_event"]) > 0) {
         $arErrorsTmp = array();
         foreach ($arDocumentStates as $arDocumentState) {
             CBPDocument::SendExternalEvent(strlen($arDocumentState["ID"]) <= 0 ? $arWorkflowIds[$arDocumentState["TEMPLATE_ID"]] : $arDocumentState["ID"], $_POST["bizproc_event"], array("Groups" => $arCurrentUserGroups, "User" => $GLOBALS["USER"]->GetID()), $arErrorTmp);
             if (count($arErrorsTmp) > 0) {
                 foreach ($arErrorsTmp as $e) {
                     $arResult["ErrorMessage"] .= $e["message"] . "<br />";
                 }