예제 #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;
 }
예제 #2
0
}
if (strlen($arResult["FatalErrorMessage"]) <= 0) {
    if ($_SERVER["REQUEST_METHOD"] == "GET" && strlen($_REQUEST["process_state_event"]) > 0 && check_bitrix_sessid()) {
        $bizprocId = trim($_REQUEST["bizproc_id"]);
        $bizprocEvent = trim($_REQUEST["bizproc_event"]);
        if (strlen($bizprocEvent) > 0) {
            $arState = CBPStateService::GetWorkflowState($bizprocId);
            if (count($arState) > 0) {
                list($dbRecordsList, $dbRecordsList1) = CBPVirtualDocument::GetList(array(), array("IBLOCK_ID" => $arParams["BLOCK_ID"], "ID" => $arState["DOCUMENT_ID"][2]), false, false, array("ID", "IBLOCK_ID", "CREATED_BY"));
                if ($arRecord = $dbRecordsList->Fetch()) {
                    $arCurrentUserGroups = $GLOBALS["USER"]->GetUserGroupArray();
                    if ("user_" . $GLOBALS["USER"]->GetID() == $arRecord["CREATED_BY"]) {
                        $arCurrentUserGroups[] = "author";
                    }
                    $arErrorTmp = array();
                    CBPDocument::SendExternalEvent($bizprocId, $bizprocEvent, array("Groups" => $arCurrentUserGroups, "User" => $GLOBALS["USER"]->GetID()), $arErrorTmp);
                    if (count($arErrorsTmp) > 0) {
                        foreach ($arErrorsTmp as $e) {
                            $arResult["FatalErrorMessage"] .= $e["message"] . ". ";
                        }
                    }
                } else {
                    $arResult["FatalErrorMessage"] .= GetMessage("BPWC_WLC_MISSING_DOCUMENT") . ". ";
                }
            } else {
                $arResult["FatalErrorMessage"] .= GetMessage("BPWC_WLC_MISSING_DOCUMENT") . ". ";
            }
            if (strlen($arResult["FatalErrorMessage"]) <= 0) {
                LocalRedirect($APPLICATION->GetCurPageParam("", array("sessid", "stop_bizproc_id", "process_state_event", "bizproc_event", "bizproc_id", "delete_bizproc_id")));
            }
        }
예제 #3
0
         $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" => $arParams["USER_GROUPS"], "User" => $GLOBALS["USER"]->GetID()), $arErrorTmp);
             if (count($arErrorsTmp) > 0) {
                 foreach ($arErrorsTmp as $e) {
                     $strWarning .= $e["message"] . "<br />";
                 }
                 $arError[] = array("id" => "update_workfow", "text" => $strWarning);
             }
         }
     }
 }
 if (!empty($arError)) {
     $e = new CAdminException($arError);
     $arResult["ERROR_MESSAGE"] = $e->GetString();
 } else {
     $url = !empty($arParams["back_url"]) ? $arParams["back_url"] : $APPLICATION->GetCurPageParam("", array("action", "id", "sessid"));
     $url = empty($_POST["apply"]) ? $url : $APPLICATION->GetCurPageParam("", array("action", "id", "sessid"));
예제 #4
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" => $arCurrentUserGroups, "User" => $USER->GetID()),
										$arErrorTmp
									);

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

						$arDocumentStates = null;
						CBPDocument::AddDocumentToHistory(array(MODULE_ID, ENTITY, $ID), $BP_HISTORY_NAME, $GLOBALS["USER"]->GetID());
					}
예제 #5
0
 function ChangeStatus($taskId, $newStatus, $userId = 0)
 {
     CModule::IncludeModule("socialnetwork");
     $taskId = intval($taskId);
     $userId = intval($userId);
     if ($userId == 0) {
         $userId = $GLOBALS["USER"]->GetID();
     }
     $arTask = CIntranetTasks::GetById($taskId);
     if (!$arTask) {
         return;
     }
     $arDocumentStates = CBPDocument::GetDocumentStates(array("intranet", "CIntranetTasksDocument", "x" . $arTask["IBLOCK_ID"]), array("intranet", "CIntranetTasksDocument", $taskId));
     $arCurrentUserGroups = array();
     if ($arTask["TaskType"] == "group") {
         $arCurrentUserGroups[] = SONET_ROLES_ALL;
         if ($GLOBALS["USER"]->IsAuthorized()) {
             $arCurrentUserGroups[] = SONET_ROLES_AUTHORIZED;
         }
         $r = CSocNetUserToGroup::GetUserRole($userId, $arTask["OwnerId"]);
         if (strlen($r) > 0) {
             $arCurrentUserGroups[] = $r;
         }
     }
     if ($userId == $arTask["CREATED_BY"]) {
         $arCurrentUserGroups[] = "author";
     }
     if ($userId == $arTask["PROPERTY_TaskAssignedTo"]) {
         $arCurrentUserGroups[] = "responsible";
     }
     if (is_array($arTask["PROPERTY_TaskTrackers"]) && in_array($userId, $arTask["PROPERTY_TaskTrackers"])) {
         $arCurrentUserGroups[] = "trackers";
     }
     $arStateCommand = array("NotAccepted" => array("NotStarted" => array("HEEA_NotAccepted_ApproveEvent"), "InProgress" => array("HEEA_NotAccepted_InProgressEvent"), "Completed" => array("HEEA_NotAccepted_CompleteEvent"), "Closed" => array("HEEA_NotAccepted_CloseEvent"), "Waiting" => array("HEEA_NotAccepted_ApproveEvent", "HEEA_NotStarted_WaitingEvent"), "Deferred" => array("HEEA_NotAccepted_ApproveEvent", "HEEA_NotStarted_DeferredEvent")), "NotStarted" => array("InProgress" => array("HEEA_NotStarted_InProgressEvent"), "Completed" => array("HEEA_NotStarted_CompleteEvent"), "Closed" => array("HEEA_NotStarted_CloseEvent"), "Waiting" => array("HEEA_NotStarted_WaitingEvent"), "Deferred" => array("HEEA_NotStarted_DeferredEvent")), "InProgress" => array("Completed" => array("HEEA_InProgress_CompleteEvent"), "Closed" => array("HEEA_InProgress_CloseEvent"), "Waiting" => array("HEEA_InProgress_WaitingEvent"), "Deferred" => array("HEEA_InProgress_DeferredEvent")), "Completed" => array("InProgress" => array("HEEA_Completed_InProgressEvent"), "Closed" => array("HEEA_Completed_CloseEvent")), "Waiting" => array("NotStarted" => array("HEEA_Waiting_NotStartedEvent"), "InProgress" => array("HEEA_Waiting_InProgressEvent"), "Completed" => array("HEEA_Waiting_CompleteEvent"), "Closed" => array("HEEA_Waiting_CloseEvent"), "Deferred" => array("HEEA_Waiting_DeferredEvent")), "Deferred" => array("NotStarted" => array("HEEA_Deferred_NotStartedEvent"), "InProgress" => array("HEEA_Deferred_InProgressEvent"), "Completed" => array("HEEA_Deferred_CompleteEvent"), "Closed" => array("HEEA_Deferred_CloseEvent"), "Waiting" => array("HEEA_Deferred_WaitingEvent")));
     foreach ($arDocumentStates as $documentState) {
         $oldState = $documentState["STATE_NAME"];
         if (!array_key_exists($oldState, $arStateCommand) || count($arStateCommand[$oldState]) <= 0) {
             continue;
         }
         if (!array_key_exists($newStatus, $arStateCommand[$oldState]) || count($arStateCommand[$oldState][$newStatus]) <= 0) {
             continue;
         }
         foreach ($arStateCommand[$oldState][$newStatus] as $sc) {
             CBPDocument::SendExternalEvent($documentState["ID"], $sc, array("Groups" => $arCurrentUserGroups, "User" => $userId), $arErrorTmp);
         }
     }
 }
예제 #6
0
        $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);
    CopyDirFiles(dirname(__FILE__) . "/public/language/" . LANGUAGE_ID . "/content/articles/", $_SERVER["DOCUMENT_ROOT"] . "/content/articles", false, true);
    //Add menu item
    DEMO_IBlock_AddMenuItem("/content/.left.menu.php", array(GetMessage("DEMO_IBLOCK_CONTENT_ARTICLES_MENU"), "/content/articles/", array(), array(), ""));
    CUrlRewriter::Add(array("CONDITION" => "#^/content/articles/#", "RULE" => "", "ID" => "bitrix:news", "PATH" => "/content/articles/index.php"));
}
예제 #7
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);
 }
예제 #8
0
                 }
             }
             if ($USER->GetID() == $arTaskTmp["CREATED_BY"]) {
                 $arCurrentUserGroups[] = "author";
             }
             if ($USER->GetID() == $arTaskTmp["PROPERTY_TaskAssignedTo"]) {
                 $arCurrentUserGroups[] = "responsible";
             }
             if (is_array($arTaskTmp["PROPERTY_TaskTrackers"]) && in_array($USER->GetID(), $arTaskTmp["PROPERTY_TaskTrackers"])) {
                 $arCurrentUserGroups[] = "trackers";
             }
         }
         if (count($arErrorsTmp) <= 0) {
             $iblockElementObject = new CIBlockElement();
             $iblockElementObject->Update(intval($actionTaskId), array("MODIFIED_BY" => $GLOBALS["USER"]->GetID()));
             CBPDocument::SendExternalEvent($wf, $_GET['action'], array("Groups" => $arCurrentUserGroups, "User" => $GLOBALS["USER"]->GetID()), $arErrorTmp);
         }
         if (count($arErrorsTmp) > 0) {
             foreach ($arErrorsTmp as $e) {
                 $arResult["ErrorMessage"] .= $e["message"] . "<br />";
             }
         }
     }
 }
 if (strlen($arResult["ErrorMessage"]) <= 0) {
     if (array_key_exists("back_url", $_REQUEST) && strlen($_REQUEST["back_url"]) > 0) {
         $redirectPath = $_REQUEST["back_url"];
     } else {
         $redirectPath = $APPLICATION->GetCurPageParam("", array("action", "del_task_id", "del_view_id", 'action_task_id', 'wf'));
     }
     LocalRedirect($redirectPath);
예제 #9
0
             }
             if ($taskAssignedToUserId <= 0) {
                 $taskAssignedToUserId = $arResult["Task"]["PROPERTY_TaskAssignedTo"];
             }
         }
         if (strlen($arResult["ErrorMessage"]) <= 0) {
             $arErrorsTmp = array();
             foreach ($arDocumentStates as $arDocumentState) {
                 CBPDocument::SendExternalEvent($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 />";
                     }
                 }
                 if ($bizProcEvent == "SetResponsibleEvent" && $GLOBALS["USER"]->GetID() == $taskAssignedToUserId) {
                     CBPDocument::SendExternalEvent($arDocumentState["ID"], "HEEA_NotAccepted_ApproveEvent", array("Groups" => $arCurrentUserGroups, "User" => $GLOBALS["USER"]->GetID()), $arErrorTmp);
                     if (count($arErrorsTmp) > 0) {
                         foreach ($arErrorsTmp as $e) {
                             $arResult["ErrorMessage"] .= $e["message"] . "<br />";
                         }
                     }
                 }
             }
         }
     }
 }
 if ($bTextModified) {
     $arFields = array("MODIFIED_BY" => $GLOBALS["USER"]->GetID(), "DETAIL_TEXT" => $detailText);
     $arErrorsTmp = array();
     CIntranetTasks::Update($arParams["TASK_ID"], $arFields, $arErrorsTmp);
     if (count($arErrorsTmp) > 0) {