public function Execute() { $rootActivity = $this->GetRootActivity(); $documentId = $rootActivity->GetDocumentId(); CBPDocument::TerminateWorkflow($this->GetWorkflowInstanceId(), $documentId, $arErrorsTmp); throw new Exception("TerminateActivity"); return CBPActivityExecutionStatus::Closed; }
protected function processBeforeAction($actionName) { parent::processBeforeAction($actionName); if (strlen($this->arParams['STORAGE_ID']) <= 0) { ShowError(Loc::getMessage('ACCESS_DENIED') . ' ' . Loc::getMessage('BIZPROC_WFEDIT_ERROR_TYPE')); return false; } if ($this->arResult['ID'] > 0) { $templatesList = CBPWorkflowTemplateLoader::getList(array(), array('ID' => $this->arResult['ID'])); if ($template = $templatesList->fetch()) { if (!CBPDocument::canUserOperateDocumentType(CBPCanUserOperateOperation::CreateWorkflow, $this->getUser()->getID(), $template['DOCUMENT_TYPE'])) { $this->showAccessDenied(); return false; } $this->arResult['TEMPLATE_NAME'] = $template['NAME']; $this->arResult['TEMPLATE_DESC'] = $template['DESCRIPTION']; $this->arResult['TEMPLATE_AUTOSTART'] = $template['AUTO_EXECUTE']; $this->arResult['TEMPLATE'] = $template['TEMPLATE']; $this->arResult['PARAMETERS'] = $template['PARAMETERS']; $this->arResult['VARIABLES'] = $template['VARIABLES']; $this->arResult['CONSTANTS'] = $template['CONSTANTS']; } else { $this->arResult['ID'] = 0; } if ($template["ENTITY"] == Bitrix\Disk\BizProcDocument::className()) { $this->arResult['DOCUMENT_COMPLEX_TYPE'] = \Bitrix\Disk\BizProcDocument::generateDocumentComplexType($this->arParams['STORAGE_ID']); $this->arResult['ENTITY'] = $template['ENTITY']; } else { $this->arResult['DOCUMENT_COMPLEX_TYPE'] = \Bitrix\Disk\BizProcDocumentCompatible::generateDocumentComplexType($this->arParams['STORAGE_ID']); $this->arResult['ENTITY'] = $template['ENTITY']; } } else { $this->arResult['ENTITY'] = Bitrix\Disk\BizProcDocument::className(); $this->arResult['DOCUMENT_COMPLEX_TYPE'] = \Bitrix\Disk\BizProcDocument::generateDocumentComplexType($this->arParams['STORAGE_ID']); if (!CBPDocument::canUserOperateDocumentType(CBPCanUserOperateOperation::CreateWorkflow, $this->getUser()->getID(), $this->arResult['DOCUMENT_COMPLEX_TYPE'])) { $this->showAccessDenied(); return false; } $this->arResult['TEMPLATE_NAME'] = Loc::getMessage("BIZPROC_WFEDIT_DEFAULT_TITLE"); $this->arResult['TEMPLATE_DESC'] = ''; $this->arResult['TEMPLATE_AUTOSTART'] = 1; $this->arResult['PARAMETERS'] = array(); $this->arResult['VARIABLES'] = array(); $this->arResult['CONSTANTS'] = array(); if ($this->request->getQuery('init') == 'statemachine') { $this->arResult['TEMPLATE'] = array(array('Type' => 'StateMachineWorkflowActivity', 'Name' => 'Template', 'Properties' => array(), 'Children' => array())); } else { $this->arResult['TEMPLATE'] = array(array('Type' => 'SequentialWorkflowActivity', 'Name' => 'Template', 'Properties' => array(), 'Children' => array())); } } return true; }
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; }
public static function AutoStartWorkflows($ownerTypeID, $ownerID, $eventType, &$errors) { if (!(IsModuleInstalled('bizproc') && CModule::IncludeModule('bizproc'))) { return false; } $ownerTypeID = intval($ownerTypeID); $ownerID = intval($ownerID); $eventType = intval($eventType); $docName = self::ResolveDocumentName($ownerTypeID); if ($docName === '') { return false; } $ownerTypeName = CCrmOwnerType::ResolveName($ownerTypeID); if ($ownerTypeName === '') { return false; } CBPDocument::AutoStartWorkflows(array('crm', $docName, $ownerTypeName), $eventType, array('crm', $docName, $ownerTypeName . '_' . $ownerID), array(), $errors); return true; }
function Recover($HISTORY_ID, $ID, $IBLOCK_ID) { $this->CleanCacheById($ID, $IBLOCK_ID); $rIBlock = CIBlock::getList(array(), array('ID' => $IBLOCK_ID, 'CHECK_PERMISSIONS' => 'N')); $arIBlock = $rIBlock->GetNext(); if ($arIBlock['BIZPROC'] == 'Y' && CModule::IncludeModule('bizproc')) { $arErrorsTmp = array(); $arHistoryResult = CBPDocument::GetDocumentFromHistory($HISTORY_ID, $arErrorsTmp); $modifyComment = GetMessage('WIKI_RECOVER_COMMENT') . " " . $arHistoryResult["MODIFIED"]; if (CBPHistoryService::RecoverDocumentFromHistory($HISTORY_ID)) { if ($this->UpdateHistory($ID, $IBLOCK_ID, $modifyComment)) { return true; } else { return false; } } else { return false; } } else { return false; } }
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(); } }
protected function getBizprocData() { $userId = $this->getUser()->getID(); $currentUserGroups = $this->getUser()->getUserGroupArray(); if (!$this->lists['ELEMENT_FIELDS'] || $this->lists['ELEMENT_FIELDS']['CREATED_BY'] == $userId) { $currentUserGroups[] = 'Author'; } $documentType = 'iblock_' . $this->iblockId; CBPDocument::addShowParameterInit('lists', 'only_users', $documentType); $this->lists['BIZPROC_FIELDS'] = array(); $bizprocIndex = 0; $documentStates = CBPDocument::getDocumentStates(array('lists', 'BizprocDocument', $documentType), null); $runtime = CBPRuntime::getRuntime(); $runtime->startRuntime(); $documentService = $runtime->getService('DocumentService'); foreach ($documentStates as $documentState) { $bizprocIndex++; $viewWorkflow = CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::StartWorkflow, $userId, array('lists', 'BizprocDocument', $documentType), array('sectionId' => 0, 'AllUserGroups' => $currentUserGroups, 'DocumentStates' => $documentStates, 'WorkflowId' => $documentState['ID'] > 0 ? $documentState['ID'] : $documentState['TEMPLATE_ID'])); if ($viewWorkflow) { $templateId = intval($documentState['TEMPLATE_ID']); $workflowParameters = $documentState['TEMPLATE_PARAMETERS']; if (!is_array($workflowParameters)) { $workflowParameters = array(); } if (strlen($documentState["ID"]) <= 0 && $templateId > 0) { $parametersValues = array(); $keys = array_keys($workflowParameters); foreach ($keys as $key) { $value = $workflowParameters[$key]["Default"]; if (!is_array($value)) { $parametersValues[$key] = htmlspecialcharsbx($value); } else { $keys1 = array_keys($value); foreach ($keys1 as $key1) { $parametersValues[$key][$key1] = htmlspecialcharsbx($value[$key1]); } } } foreach ($workflowParameters as $parameterKey => $arParameter) { $parameterKeyExt = "bizproc" . $templateId . "_" . $parameterKey; $html = $documentService->GetFieldInputControl(array('lists', 'BizprocDocument', $documentType), $arParameter, array("Form" => "start_workflow_form1", "Field" => $parameterKeyExt), $parametersValues[$parameterKey], false, true); $this->lists['BIZPROC_FIELDS'][$parameterKeyExt . $bizprocIndex] = array("id" => $parameterKeyExt . $bizprocIndex, "required" => $arParameter["Required"], "name" => $arParameter["Name"], "title" => $arParameter["Description"], "type" => "custom", "value" => $html, 'show' => 'Y'); } } } } }
/** * Method return array with all information about document. Array used for method RecoverDocumentFromHistory. * * @param string $documentId - document id. * @return array - document information array. */ public function GetDocumentForHistory($documentId, $historyIndex) { $documentId = intval($documentId); if ($documentId <= 0) { throw new CBPArgumentNullException("documentId"); } $result = null; $dbDocumentList = CIBlockElement::getList(array(), array("ID" => $documentId, "SHOW_NEW" => "Y", "SHOW_HISTORY" => "Y")); if ($objDocument = $dbDocumentList->getNextElement()) { $fields = $objDocument->getFields(); $properties = $objDocument->getProperties(); $result["NAME"] = $fields["~NAME"]; $result["FIELDS"] = array(); foreach ($fields as $fieldKey => $fieldValue) { if ($fieldKey == "~PREVIEW_PICTURE" || $fieldKey == "~DETAIL_PICTURE") { $result["FIELDS"][substr($fieldKey, 1)] = CBPDocument::prepareFileForHistory(array("lists", get_called_class(), $documentId), $fieldValue, $historyIndex); } elseif (substr($fieldKey, 0, 1) == "~") { $result["FIELDS"][substr($fieldKey, 1)] = $fieldValue; } } $result["PROPERTIES"] = array(); foreach ($properties as $propertyKey => $propertyValue) { if (strlen($propertyValue["USER_TYPE"]) > 0) { $result["PROPERTIES"][$propertyKey] = array("VALUE" => $propertyValue["VALUE"], "DESCRIPTION" => $propertyValue["DESCRIPTION"]); } elseif ($propertyValue["PROPERTY_TYPE"] == "L") { $result["PROPERTIES"][$propertyKey] = array("VALUE" => $propertyValue["VALUE_ENUM_ID"], "DESCRIPTION" => $propertyValue["DESCRIPTION"]); } elseif ($propertyValue["PROPERTY_TYPE"] == "F") { $result["PROPERTIES"][$propertyKey] = array("VALUE" => CBPDocument::prepareFileForHistory(array("lists", get_called_class(), $documentId), $propertyValue["VALUE"], $historyIndex), "DESCRIPTION" => $propertyValue["DESCRIPTION"]); } else { $result["PROPERTIES"][$propertyKey] = array("VALUE" => $propertyValue["VALUE"], "DESCRIPTION" => $propertyValue["DESCRIPTION"]); } } } return $result; }
$showType = 'Success'; } else { try { $documentType = $documentService->GetDocumentType($arTask["PARAMETERS"]["DOCUMENT_ID"]); if (!array_key_exists("BP_AddShowParameterInit_" . $documentType[0] . "_" . $documentType[1] . "_" . $documentType[2], $GLOBALS)) { $GLOBALS["BP_AddShowParameterInit_" . $documentType[0] . "_" . $documentType[1] . "_" . $documentType[2]] = 1; CBPDocument::AddShowParameterInit($documentType[0], "only_users", $documentType[2], $documentType[1]); } } catch (Exception $e) { CAdminMessage::ShowMessage(GetMessage('BPAT_NO_STATE')); $showType = 'Success'; } } list($taskForm, $taskFormButtons) = array("", ""); if ($showType != "Success") { list($taskForm, $taskFormButtons) = CBPDocument::ShowTaskForm($arTask, $userId, "", $_SERVER["REQUEST_METHOD"] == "POST" && $_POST["action"] == "doTask" ? $_REQUEST : null); } ?> <form method="post" name="task_delegate" action="<?php echo GetPagePath(false, true); ?> "> <input type="hidden" name="action" value="delegate"> <input type="hidden" name="id" value="<?php echo intval($arTask["ID"]); ?> "> <input type="hidden" name="workflow_id" value="<?php echo htmlspecialcharsbx($arTask["WORKFLOW_ID"]); ?> ">
echo $arCurrentValues["show_comment"] == "N" ? " selected" : ""; ?> ><?php echo GetMessage("BPAA_PD_NO"); ?> </option> </select> </td> </tr> <tr> <td align="right"><?php echo GetMessage("BPAR_PD_COMMENT_LABEL_MESSAGE"); ?> :</td> <td><?php echo CBPDocument::ShowParameterField("string", 'comment_label_message', $arCurrentValues['comment_label_message'], array('size' => '50')); ?> </td> </tr> <tr> <td align="right"><?php echo GetMessage("BPAA_PD_TIMEOUT_DURATION"); ?> :<br/><?php echo GetMessage("BPAA_PD_TIMEOUT_DURATION_HINT"); ?> </td> <td valign="top"> <input type="text" name="timeout_duration" id="id_timeout_duration" value="<?php echo htmlspecialcharsbx($arCurrentValues["timeout_duration"]); ?>
public static function GetPropertiesDialog($documentType, $activityName, $workflowTemplate, $workflowParameters, $workflowVariables, $currentValues = null, $formName = "") { $runtime = CBPRuntime::GetRuntime(); $map = array('AuthUserId', 'SetStatusMessage', 'StatusMessage', 'UseSubscription', 'TimeoutDuration', 'TimeoutDurationType'); $activityData = self::getRestActivityData(); $properties = isset($activityData['PROPERTIES']) && is_array($activityData['PROPERTIES']) ? $activityData['PROPERTIES'] : array(); foreach ($properties as $name => $property) { if (!in_array($name, $map)) { $map[] = $name; } } if (!is_array($currentValues)) { $currentValues = array(); $currentActivity =& CBPWorkflowTemplateLoader::FindActivityByName($workflowTemplate, $activityName); if (is_array($currentActivity['Properties'])) { foreach ($map as $k) { if (array_key_exists($k, $currentActivity['Properties'])) { if ($k == 'AuthUserId') { $currentValues[strtolower($k)] = CBPHelper::UsersArrayToString('user_' . $currentActivity['Properties'][$k], $workflowTemplate, $documentType); } else { $currentValues[strtolower($k)] = $currentActivity['Properties'][$k]; } } else { if (!is_array($currentValues) || !array_key_exists($map[$k], $currentValues)) { $currentValues[strtolower($k)] = ""; } } } } else { foreach ($map as $k) { $currentValues[strtolower($k)] = ""; } } } if (strlen($currentValues['statusmessage']) <= 0) { $currentValues['statusmessage'] = Loc::getMessage('BPRA_DEFAULT_STATUS_MESSAGE'); } if (strlen($currentValues["timeoutdurationtype"]) <= 0) { $currentValues["timeoutdurationtype"] = "s"; } if ((int) $currentValues["authuserid"] <= 0) { $currentValues["authuserid"] = CBPHelper::UsersArrayToString('user_' . $activityData['AUTH_USER_ID'], $workflowTemplate, $documentType); } if (!empty($activityData['USE_SUBSCRIPTION'])) { $currentValues['usesubscription'] = $activityData['USE_SUBSCRIPTION']; } /** @var CBPDocumentService $documentService */ $documentService = $runtime->GetService("DocumentService"); $activityDocumentType = is_array($activityData['DOCUMENT_TYPE']) ? $activityData['DOCUMENT_TYPE'] : $documentType; foreach ($properties as $name => $property) { $required = CBPHelper::getBool($property['REQUIRED']); $value = !CBPHelper::isEmptyValue($currentValues[strtolower($name)]) ? $currentValues[strtolower($name)] : $property['DEFAULT']; ?> <tr> <td align="right" width="40%" valign="top"> <span class="<?php echo $required ? 'adm-required-field' : ''; ?> "> <?php echo htmlspecialcharsbx(RestActivityTable::getLocalization($property['NAME'], LANGUAGE_ID)); ?> : </span> <?php if (isset($property['DESCRIPTION'])) { ?> <br/><?php echo htmlspecialcharsbx(RestActivityTable::getLocalization($property['DESCRIPTION'], LANGUAGE_ID)); ?> <?php } ?> </td> <td width="60%"> <?php echo $documentService->getFieldInputControl($activityDocumentType, $property, array('Field' => strtolower($name), 'Form' => $formName), $value, true, false); ?> </td> </tr> <?php } if (static::checkAdminPermissions()) { ?> <tr> <td align="right" width="40%" valign="top"><span class=""><?php echo Loc::getMessage("BPRA_PD_USER_ID"); ?> :</span></td> <td width="60%"> <?php echo CBPDocument::ShowParameterField("user", 'authuserid', $currentValues['authuserid'], array('rows' => '1')); ?> </td> </tr> <?php } ?> <tr> <td align="right"><?php echo Loc::getMessage("BPRA_PD_SET_STATUS_MESSAGE"); ?> :</td> <td> <select name="setstatusmessage"> <option value="Y"<?php echo $currentValues["setstatusmessage"] == "Y" ? " selected" : ""; ?> ><?php echo Loc::getMessage("BPRA_PD_YES"); ?> </option> <option value="N"<?php echo $currentValues["setstatusmessage"] == "N" ? " selected" : ""; ?> ><?php echo Loc::getMessage("BPRA_PD_NO"); ?> </option> </select> </td> </tr> <tr> <td align="right"><?php echo Loc::getMessage("BPRA_PD_STATUS_MESSAGE"); ?> :</td> <td valign="top"><?php echo CBPDocument::ShowParameterField("string", 'statusmessage', $currentValues['statusmessage'], array('size' => '45')); ?> </td> </tr> <tr> <td align="right"><?php echo Loc::getMessage("BPRA_PD_USE_SUBSCRIPTION"); ?> :</td> <td> <select name="usesubscription" <?php echo !empty($activityData['USE_SUBSCRIPTION']) ? 'disabled' : ''; ?> > <option value="Y"<?php echo $currentValues["usesubscription"] == 'Y' ? " selected" : ""; ?> ><?php echo Loc::getMessage("BPRA_PD_YES"); ?> </option> <option value="N"<?php echo $currentValues["usesubscription"] == 'N' ? " selected" : ""; ?> ><?php echo Loc::getMessage("BPRA_PD_NO"); ?> </option> </select> </td> </tr> <?php if ($activityData['USE_SUBSCRIPTION'] != 'N') { ?> <tr> <td align="right"><?php echo Loc::getMessage("BPRA_PD_TIMEOUT_DURATION"); ?> :<br/><?php echo Loc::getMessage("BPRA_PD_TIMEOUT_DURATION_HINT"); ?> </td> <td valign="top"> <input type="text" name="timeoutduration" id="id_timeoutduration" value="<?php echo htmlspecialcharsbx($currentValues["timeoutduration"]); ?> " size="20" /> <input type="button" value="..." onclick="BPAShowSelector('id_timeoutduration', 'int');" /> <select name="timeoutdurationtype"> <option value="s"<?php echo $currentValues["timeoutdurationtype"] == "s" ? " selected" : ""; ?> ><?php echo Loc::getMessage("BPRA_PD_TIME_S"); ?> </option> <option value="m"<?php echo $currentValues["timeoutdurationtype"] == "m" ? " selected" : ""; ?> ><?php echo Loc::getMessage("BPRA_PD_TIME_M"); ?> </option> <option value="h"<?php echo $currentValues["timeoutdurationtype"] == "h" ? " selected" : ""; ?> ><?php echo Loc::getMessage("BPRA_PD_TIME_H"); ?> </option> <option value="d"<?php echo $currentValues["timeoutdurationtype"] == "d" ? " selected" : ""; ?> ><?php echo Loc::getMessage("BPRA_PD_TIME_D"); ?> </option> </select> </td> </tr> <?php } }
$arParams["SET_TITLE"] = $arParams["SET_TITLE"] == "N" ? "N" : "Y"; //Turn on by default /******************************************************************** /Input params ********************************************************************/ $arError = array(); $arResult["arWorkflowState"] = CBPStateService::GetWorkflowState($arParams["ID"]); $arParams["DOCUMENT_ID"] = $arResult["arWorkflowState"]["DOCUMENT_ID"]; $arParams["USER_GROUPS"] = $GLOBALS["USER"]->GetUserGroupArray(); if (method_exists($arParams["DOCUMENT_ID"][1], "GetUserGroups")) { $arParams["USER_GROUPS"] = call_user_func_array(array($arParams["DOCUMENT_ID"][1], "GetUserGroups"), array(null, $arParams["DOCUMENT_ID"], $GLOBALS["USER"]->GetID())); } if (!is_array($arResult["arWorkflowState"]) || count($arResult["arWorkflowState"]) <= 0) { $arError[] = array("id" => "error", "text" => GetMessage("BPABL_INVALID_WF")); } else { $bCanView = CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::ViewWorkflow, $GLOBALS["USER"]->GetID(), $arResult["arWorkflowState"]["DOCUMENT_ID"], array("WorkflowId" => $arParams["ID"], "DocumentStates" => array($arParams["ID"] => $arResult["arWorkflowState"]), "UserGroups" => $arParams["USER_GROUPS"])); if (!$bCanView) { $arError[] = array("id" => "access denied", "text" => GetMessage("BPABL_NO_PERMS")); } } if (!empty($arError)) { $e = new CAdminException($arError); ShowError($e->GetString()); return false; } /******************************************************************** Data ********************************************************************/ $arResult["arWorkflowTrack"] = CBPTrackingService::DumpWorkflow($arParams["ID"]); /******************************************************************** /Data
$arResult['WORKFLOW_TEMPLATE_NAME'] = $arState["TEMPLATE_NAME"]; $runtime = CBPRuntime::GetRuntime(); $runtime->StartRuntime(); $documentService = $runtime->GetService("DocumentService"); $arResult['DOCUMENT_ICON'] = $documentService->getDocumentIcon($arResult['TASK']['PARAMETERS']['DOCUMENT_ID']); if (empty($arResult['TASK']['DOCUMENT_NAME'])) { $arResult['TASK']['DOCUMENT_NAME'] = htmlspecialcharsbx($documentService->getDocumentName($arResult['TASK']['PARAMETERS']['DOCUMENT_ID'])); } if ($arResult["ShowMode"] != "Success") { try { $documentType = $documentService->GetDocumentType($arResult["TASK"]["PARAMETERS"]["DOCUMENT_ID"]); if (!array_key_exists("BP_AddShowParameterInit_" . $documentType[0] . "_" . $documentType[1] . "_" . $documentType[2], $GLOBALS)) { $GLOBALS["BP_AddShowParameterInit_" . $documentType[0] . "_" . $documentType[1] . "_" . $documentType[2]] = 1; CBPDocument::AddShowParameterInit($documentType[0], "only_users", $documentType[2], $documentType[1]); } // deprecated old style list($arResult["TaskForm"], $arResult["TaskFormButtons"]) = CBPDocument::ShowTaskForm($arResult["TASK"], $arParams["USER_ID"], "", $_SERVER["REQUEST_METHOD"] == "POST" && $_POST["action"] == "doTask" ? $_REQUEST : null); // new style $arResult['TaskControls'] = CBPDocument::getTaskControls($arResult["TASK"]); } catch (Exception $e) { ShowError(GetMessage("BPAT_NO_ACCESS")); return false; } } $this->IncludeComponentTemplate(); if ($arParams["SET_TITLE"] == "Y") { $APPLICATION->SetTitle(GetMessage("BPAT_TITLE")); } if ($arParams["SET_NAV_CHAIN"] == "Y") { $APPLICATION->AddChainItem(GetMessage("BPAT_TITLE")); }
$rsHistory->NavStart($arParams['HISTORY_COUNT'], false); $arResult['DB_LIST'] =& $rsHistory; $arResult['HISTORY'] = array(); if ($arResult['SOCNET']) { $arResult['AJAX_PAGE'] = $APPLICATION->GetCurPageParam('', array('bxajaxid', 'logout')); $arResult['PATH_TO_USER'] = $arParams['PATH_TO_USER']; $arResult['SHOW_LOGIN'] = $this->GetParent()->arParams['SHOW_LOGIN']; $arResult['NAME_TEMPLATE'] = $this->GetParent()->arParams['NAME_TEMPLATE']; $arResult['PATH_TO_CONPANY_DEPARTMENT'] = $this->GetParent()->arParams['PATH_TO_CONPANY_DEPARTMENT']; $arResult['PATH_TO_VIDEO_CALL'] = $this->GetParent()->arParams['PATH_TO_VIDEO_CALL']; $arResult['PATH_TO_SONET_MESSAGES_CHAT'] = $this->GetParent()->arParams['PATH_TO_MESSAGES_CHAT']; } $arErrorsTmp = array(); while ($arHistory = $rsHistory->GetNext()) { $arHistory['USER_LINK'] = ''; $arHistoryResult = CBPDocument::GetDocumentFromHistory($arHistory['ID'], $arErrorsTmp); $arHistory["MODIFY_COMMENT"] = $arHistoryResult["DOCUMENT"]["MODIFY_COMMENT"]; if (!empty($arParams['PATH_TO_USER'])) { $arHistory['USER_LINK'] = CHTTP::urlAddParams(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_USER'], array('wiki_name' => urlencode($arParams['ELEMENT_NAME']), 'group_id' => CWikiSocnet::$iSocNetId, 'user_id' => $arHistory['USER_ID'])), array()); } /*CBPHistoryService::GetHistoryList() returns specialchared values and CWikiUtils::GetUserLogin also do htmlspecialchars*/ foreach (array('USER_LOGIN', 'USER_NAME', 'USER_LAST_NAME', 'USER_SECOND_NAME') as $key) { $arHistory[$key] = CWikiUtils::htmlspecialchars_decode($arHistory[$key]); } $arHistory['USER_LOGIN'] = CWikiUtils::GetUserLogin($arHistory, $arParams["NAME_TEMPLATE"]); $arHistory['DISCUSSION_LINK'] = CHTTP::urlAddParams(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_DISCUSSION'], array('wiki_name' => urlencode($arParams['ELEMENT_NAME']), 'group_id' => CWikiSocnet::$iSocNetId)), $arParams['IN_COMPLEX'] == 'Y' && $arParams['SEF_MODE'] == 'N' ? array($arParams['OPER_VAR'] => 'discussion') : array()); $arHistory['SHOW_LINK'] = CHTTP::urlAddParams(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_POST'], array('wiki_name' => urlencode($arParams['ELEMENT_NAME']), 'group_id' => CWikiSocnet::$iSocNetId)), array('oldid' => $arHistory['ID'])); $arHp = array('oldid' => $arHistory['ID'], 'sessid' => bitrix_sessid()); if ($arParams['IN_COMPLEX'] == 'Y' && $arParams['SEF_MODE'] == 'N') { $arHp[$arParams['OPER_VAR']] = 'history';
protected function getData() { $this->arResult['SHOW_MODE'] = 'SelectWorkflow'; $this->arResult['TEMPLATES'] = array(); $this->arResult['PARAMETERS_VALUES'] = array(); $this->arResult['ERROR_MESSAGE'] = ''; $runtime = CBPRuntime::getRuntime(); $runtime->startRuntime(); $this->arResult['DocumentService'] = $runtime->getService('DocumentService'); foreach ($this->arResult['DOCUMENT_DATA'] as $nameModule => $data) { $workflowTemplateObject = CBPWorkflowTemplateLoader::getList(array(), array('DOCUMENT_TYPE' => $data['DOCUMENT_TYPE'], 'ACTIVE' => 'Y'), false, false, array('ID', 'NAME', 'DESCRIPTION', 'MODIFIED', 'USER_ID', 'PARAMETERS')); while ($workflowTemplate = $workflowTemplateObject->getNext()) { if (!CBPDocument::canUserOperateDocument(CBPCanUserOperateOperation::StartWorkflow, $this->getUser()->getID(), $data['DOCUMENT_ID'], array())) { continue; } if ($nameModule == 'DISK') { $this->arResult['TEMPLATES'][$workflowTemplate['ID']] = $workflowTemplate; $this->arResult['TEMPLATES'][$workflowTemplate['ID']]['URL'] = htmlspecialcharsex($this->getApplication()->getCurPageParam('workflow_template_id=' . $workflowTemplate['ID'] . '&' . bitrix_sessid_get(), array('workflow_template_id', 'sessid'))); } else { $this->arResult['TEMPLATES_OLD'][$workflowTemplate['ID']] = $workflowTemplate; $this->arResult['TEMPLATES_OLD'][$workflowTemplate['ID']]['URL'] = htmlspecialcharsex($this->getApplication()->getCurPageParam('workflow_template_id=' . $workflowTemplate['ID'] . '&old=1&' . bitrix_sessid_get(), array('workflow_template_id', 'sessid'))); } } } if ($this->arParams['TEMPLATE_ID'] > 0 && strlen($this->request->getPost('CancelStartParamWorkflow')) <= 0 && (array_key_exists($this->arParams['TEMPLATE_ID'], $this->arResult['TEMPLATES']) || array_key_exists($this->arParams['TEMPLATE_ID'], $this->arResult['TEMPLATES_OLD']))) { if (array_key_exists($this->arParams['TEMPLATE_ID'], $this->arResult['TEMPLATES'])) { $templates = $this->arResult['TEMPLATES']; $documentParameters = $this->arResult['DOCUMENT_DATA']['DISK']; $this->arResult['CHECK_TEMPLATE'] = 'DISK'; } else { $templates = $this->arResult['TEMPLATES_OLD']; $documentParameters = $this->arResult['DOCUMENT_DATA']['WEBDAV']; $this->arResult['CHECK_TEMPLATE'] = 'WEBDAV'; } $workflowTemplate = $templates[$this->arParams['TEMPLATE_ID']]; $arWorkflowParameters = array(); $canStartWorkflow = false; if (count($workflowTemplate['PARAMETERS']) <= 0) { $canStartWorkflow = true; } elseif ($this->request->isPost() && strlen($this->request->getPost('DoStartParamWorkflow')) > 0 && check_bitrix_sessid()) { $errorsTemporary = array(); $request = $this->request->getPostList()->toArray(); foreach ($_FILES as $key => $value) { if (array_key_exists('name', $value)) { if (is_array($value['name'])) { $keys = array_keys($value['name']); for ($i = 0, $cnt = count($keys); $i < $cnt; $i++) { $array = array(); foreach ($value as $k1 => $v1) { $array[$k1] = $v1[$keys[$i]]; } $request[$key][] = $array; } } else { $request[$key] = $value; } } } $arWorkflowParameters = CBPWorkflowTemplateLoader::checkWorkflowParameters($workflowTemplate['PARAMETERS'], $request, $documentParameters['DOCUMENT_TYPE'], $errorsTemporary); if (count($errorsTemporary) > 0) { $canStartWorkflow = false; foreach ($errorsTemporary as $e) { $this->errorCollection->add(array(new Error($e['message']))); } } else { $canStartWorkflow = true; } } if ($canStartWorkflow) { $errorsTemporary = array(); $workflowId = CBPDocument::startWorkflow($this->arParams['TEMPLATE_ID'], $documentParameters['DOCUMENT_ID'], array_merge($arWorkflowParameters, array('TargetUser' => 'user_' . intval($this->getUser()->getID()))), $errorsTemporary); if (count($errorsTemporary) > 0) { $this->arResult['SHOW_MODE'] = 'StartWorkflowError'; foreach ($errorsTemporary as $e) { $this->errorCollection->add(array(new Error('[' . $e['code'] . '] ' . $e['message']))); } } else { $this->arResult['SHOW_MODE'] = 'StartWorkflowSuccess'; if (strlen($this->arResult['back_url']) > 0) { LocalRedirect(str_replace('#WF#', $workflowId, $this->request->getQuery('back_url'))); $this->end(true); } } } else { $doStartParam = $this->request->isPost() && strlen($this->request->getPost('DoStartParamWorkflow') && check_bitrix_sessid()) > 0; $keys = array_keys($workflowTemplate['PARAMETERS']); foreach ($keys as $key) { $value = $doStartParam ? $this->request->getQuery($key) : $workflowTemplate['PARAMETERS'][$key]['Default']; if (!is_array($value)) { $this->arResult['PARAMETERS_VALUES'][$key] = CBPHelper::convertParameterValues($value); } else { $keys1 = array_keys($value); foreach ($keys1 as $key1) { $this->arResult['PARAMETERS_VALUES'][$key][$key1] = CBPHelper::convertParameterValues($value[$key1]); } } } $this->arResult['SHOW_MODE'] = 'WorkflowParameters'; } if ($this->errorCollection->hasErrors()) { $error = array_shift($this->getErrors()); ShowError($error->getMessage()); } } else { $this->arResult['SHOW_MODE'] = 'SelectWorkflow'; } }
$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 { $listProcesses[] = array("TEXT" => $documentState["TEMPLATE_NAME"] . " (" . $documentState["STARTED"] . ")"); } } } if (!empty($listProcesses)) {
$context->Show(); $APPLICATION->SetTitle(str_replace("#ID#", $taskId, GetMessage("BPAT_TITLE"))); if (strlen($errorMessage) > 0) { CAdminMessage::ShowMessage($errorMessage); } $runtime = CBPRuntime::GetRuntime(); $runtime->StartRuntime(); $documentService = $runtime->GetService("DocumentService"); $documentType = $documentService->GetDocumentType($arTask["PARAMETERS"]["DOCUMENT_ID"]); if (!array_key_exists("BP_AddShowParameterInit_" . $documentType[0] . "_" . $documentType[1] . "_" . $documentType[2], $GLOBALS)) { $GLOBALS["BP_AddShowParameterInit_" . $documentType[0] . "_" . $documentType[1] . "_" . $documentType[2]] = 1; CBPDocument::AddShowParameterInit($documentType[0], "only_users", $documentType[2], $documentType[1]); } list($taskForm, $taskFormButtons) = array("", ""); if ($showType != "Success") { list($taskForm, $taskFormButtons) = CBPDocument::ShowTaskForm($arTask, $allowAdminAccess ? $userId : $USER->GetID(), "", $_SERVER["REQUEST_METHOD"] == "POST" && $_POST["action"] == "doTask" ? $_REQUEST : null); } ?> <form method="post" name="task_form1" action="<?php echo GetPagePath(false, true); ?> " enctype="multipart/form-data"> <input type="hidden" name="action" value="doTask"> <input type="hidden" name="id" value="<?php echo intval($arTask["ID"]); ?> "> <input type="hidden" name="workflow_id" value="<?php echo htmlspecialcharsbx($arTask["WORKFLOW_ID"]); ?> ">
$record['data']["NAME"] = '<span class="bp-task"><a href="#" onclick="' . $popupJs . '" title="' . $record['data']["NAME"] . '">' . $record['data']["NAME"] . '</a></span>'; if ($record['data']['IS_MY']) { if ($record['data']['USER_STATUS'] > CBPTaskUserStatus::Waiting) { switch ($record['data']['USER_STATUS']) { case CBPTaskUserStatus::Yes: $record['data']["NAME"] .= '<span class="bp-status-ready">' . GetMessage('BPATL_USER_STATUS_YES') . '</span>'; break; case CBPTaskUserStatus::No: $record['data']["NAME"] .= '<span class="bp-status-cancel">' . GetMessage('BPATL_USER_STATUS_NO') . '</span>'; break; default: $record['data']["NAME"] .= '<span class="bp-status-ready">' . GetMessage('BPATL_USER_STATUS_OK') . '</span>'; } } elseif ($record['data']['IS_INLINE'] == 'Y') { $record['data']["NAME"] .= '<div class="bp-btn-panel">'; $controls = CBPDocument::getTaskControls($record['data']); foreach ($controls['BUTTONS'] as $control) { $class = $control['TARGET_USER_STATUS'] == CBPTaskUserStatus::No ? 'decline' : 'accept'; $props = CUtil::PhpToJSObject(array('TASK_ID' => $record['data']['ID'], $control['NAME'] => $control['VALUE'])); $record['data']["NAME"] .= '<a href="#" onclick="return BX.Bizproc.doInlineTask(' . $props . ', function(){window[\'bxGrid_' . $arResult["GRID_ID"] . '\'].Reload()}, this)" class="bp-button bp-button bp-button-' . $class . '"><span class="bp-button-icon"></span><span class="bp-button-text">' . $control['TEXT'] . '</span></a>'; } $record['data']["NAME"] .= '</div>'; } else { $anchor = '<a href="#" class="bp-button bp-button bp-button-blue" onclick="' . $popupJs . '">' . GetMessage("BPATL_BEGIN") . '</a>'; // @TODO: support RequestInformationActivity in popup mode if ($record['data']['ACTIVITY'] == 'RequestInformationActivity') { $anchor = '<a href="' . $record['data']['URL']['TASK'] . '" class="bp-button bp-button bp-button-blue">' . GetMessage("BPATL_BEGIN") . '</a>'; } $record['data']["NAME"] .= '<div class="bp-btn-panel">' . $anchor . '</div>'; } } else {
} if(strlen($sLastFolder)>0) { $aContext[] = Array( "TEXT" => GetMessage("IBLIST_A_UP"), "LINK" => $sLastFolder, "TITLE" => GetMessage("IBLIST_A_UP_TITLE"), ); } if($bBizproc && IsModuleInstalled("bizprocdesigner")) { $bCanDoIt = CBPDocument::CanUserOperateDocumentType( CBPCanUserOperateOperation::CreateWorkflow, $USER->GetID(), array(MODULE_ID, ENTITY, DOCUMENT_TYPE) ); if($bCanDoIt) { $aContext[] = array( "TEXT" => GetMessage("IBLIST_BTN_BP"), "ICON" => "btn_bp", "LINK" => 'iblock_bizproc_workflow_admin.php?document_type=iblock_'.$IBLOCK_ID.'&lang='.LANGUAGE_ID.'&back_url_list='.urlencode($REQUEST_URI), ); } } $lAdmin->AddAdminContextMenu($aContext);
<?php require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php"; CModule::IncludeModule('bizproc'); global $APPLICATION; if (!check_bitrix_sessid()) { die; } if (!CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::CreateWorkflow, $GLOBALS["USER"]->GetID(), $_REQUEST['document_type'])) { die; } CUtil::DecodeUriComponent($_REQUEST); $activityType = $_REQUEST['activity']; $runtime = CBPRuntime::GetRuntime(); $runtime->StartRuntime(); $arActivityDescription = $runtime->GetActivityDescription($activityType); if ($arActivityDescription == null) { die("Bad activity type!" . htmlspecialcharsbx($activityType)); } $runtime->IncludeActivityFile($activityType); $isHtml = !empty($_REQUEST['content_type']) && $_REQUEST['content_type'] == 'html'; if ($isHtml) { $APPLICATION->ShowAjaxHead(); } $res = CBPActivity::CallStaticMethod($activityType, "getAjaxResponse", array($_REQUEST)); echo $isHtml ? $res : CUtil::PhpToJSObject($res); require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php";
} } if (!empty($replace)) { $arPattern[] = "{=user:"******"}"; $arPattern[] = "{=user:user_" . $user . "}"; $arReplacement[] = $replace; $arReplacement[] = $replace; } } $strMessageTemplate = str_replace($arPattern, $arReplacement, $strMessageTemplate); } $arDumpWorkflow[] = $strMessageTemplate; $track = next($arDmpWorkflow); } while ($tmp["LEVEL"] == $track["LEVEL"]); } $arEvents = CBPDocument::GetAllowableEvents($GLOBALS["USER"]->GetID(), $arParams["USER_GROUPS"], $arDocumentState); $bEmpty = false; $iCount++; $iCountRow = 0; ?> <li class="bizproc-list-item bizproc-document-process <?php echo strlen($arDocumentState["WORKFLOW_STATUS"]) > 0 ? "bizproc-document-inprogress" : "bizproc-document-finished"; ?> <?php echo empty($arTasks) ? "" : "bizproc-document-hastasks"; ?> <?php echo $iCount == 1 ? "bizproc-list-item-first" : ""; ?> <?php echo $iCount % 2 == 1 ? "bizproc-list-item-odd " : "bizproc-list-item-even ";
<?php IncludeModuleLangFile(__FILE__); $arFields = array('AUTO_EXECUTE' => '0', 'ACTIVE' => 'Y', 'NAME' => GetMessage("BP_V1ST_NAME"), 'DESCRIPTION' => GetMessage("BP_V1ST_DESC"), 'TEMPLATE' => array(array('Type' => 'SequentialWorkflowActivity', 'Name' => 'Template', 'Properties' => array('Title' => GetMessage("BP_V1ST_SEQ"), 'Permission' => array('read' => array(array('Template', 'Voters'), 'author'))), 'Children' => array(array('Type' => 'MailActivity', 'Name' => 'A71936_98620_60725_95722', 'Properties' => array('MailSubject' => GetMessage("BP_V1ST_TASK_NAME"), 'MailText' => CBPDocument::_ReplaceTaskURL(GetMessage("BP_V1ST_TASK_TEXT"), $documentType), 'MailMessageType' => 'plain', 'MailCharset' => 'windows-1251', 'MailUserFrom' => '', 'MailUserFromArray' => array('user_1'), 'MailUserTo' => '', 'MailUserToArray' => array('Template', 'Voters'), 'Title' => GetMessage("BP_V1ST_MAIL_NAME"))), array('Type' => 'ApproveActivity', 'Name' => 'ApproveActivity1', 'Properties' => array('ApproveType' => 'any', 'OverdueDate' => '', 'ApproveMinPercent' => '50', 'ApproveWaitForAll' => 'N', 'Name' => GetMessage("BP_V1ST_TASK_T"), 'Description' => GetMessage("BP_V1ST_TASK_DESC"), 'Parameters' => '', 'Users' => array('Template', 'Voters'), 'Title' => GetMessage("BP_V1ST_VNAME")), 'Children' => array(array('Type' => 'SequenceActivity', 'Name' => 'A25099_16832_64072_25637', 'Properties' => array('Title' => GetMessage("BP_V1ST_S2")), 'Children' => array(array('Type' => 'MailActivity', 'Name' => 'A29301_24557_63118_91259', 'Properties' => array('MailSubject' => GetMessage("BP_V1ST_MAIL_SUBJ"), 'MailText' => GetMessage("BP_V1ST_MAIL_TEXT"), 'MailMessageType' => 'plain', 'MailCharset' => 'windows-1251', 'MailUserFrom' => '', 'MailUserFromArray' => array('user_1'), 'MailUserTo' => '', 'MailUserToArray' => array(array('Template', 'Voters'), 'author'), 'Title' => GetMessage("BP_V1ST_MAIL_NAME"))), array('Type' => 'SetStateTitleActivity', 'Name' => 'A93341_94449_30890_54582', 'Properties' => array('TargetStateTitle' => GetMessage("BP_V1ST_APPR"), 'Title' => GetMessage("BP_V1ST_APPR_S"))), array('Type' => 'PublishDocumentActivity', 'Name' => 'A50491_99266_37083_78593', 'Properties' => array('Title' => GetMessage("BP_V1ST_T3"))))), array('Type' => 'SequenceActivity', 'Name' => 'A28091_6558_3951_66191', 'Properties' => array('Title' => GetMessage("BP_V1ST_S2")), 'Children' => array(array('Type' => 'MailActivity', 'Name' => 'A7429_66097_71801_19761', 'Properties' => array('MailSubject' => GetMessage("BP_V1ST_MAIL2_NA"), 'MailText' => GetMessage("BP_V1ST_MAIL2_NA_TEXT"), 'MailMessageType' => 'plain', 'MailCharset' => 'windows-1251', 'MailUserFrom' => '', 'MailUserFromArray' => array('user_1'), 'MailUserTo' => '', 'MailUserToArray' => array(array('Template', 'Voters'), 'author'), 'Title' => GetMessage("BP_V1ST_TNA"))), array('Type' => 'SetStateTitleActivity', 'Name' => 'A81366_56581_39764_20787', 'Properties' => array('TargetStateTitle' => GetMessage("BP_V1ST_STAT_NA"), 'Title' => GetMessage("BP_V1ST_STAT_NA_T")))))))))), 'PARAMETERS' => array('Voters' => array('Name' => GetMessage("BP_V1ST_PARAM1"), 'Description' => GetMessage("BP_V1ST_PARAM1_DESC"), 'Type' => 'user', 'Required' => '1', 'Multiple' => '1', 'Default' => '')), 'VARIABLES' => array());
} $arResult['CONTACT'][$ar['ELEMENT_ID']]['~' . $ar['COMPLEX_ID']][] = $ar['VALUE']; } foreach ($arFmList as $elementId => $arFM) { foreach ($arFM as $complexId => $arComplexName) { $arResult['CONTACT'][$elementId][$complexId] = implode(', ', $arComplexName); } } // checkig access for operation $arContactAttr = CCrmPerms::GetEntityAttr('CONTACT', $arResult['CONTACT_ID']); foreach ($arResult['CONTACT_ID'] as $iContactId) { $arResult['CONTACT'][$iContactId]['EDIT'] = $CCrmPerms->CheckEnityAccess('CONTACT', 'WRITE', $arContactAttr[$iContactId]); $arResult['CONTACT'][$iContactId]['DELETE'] = $CCrmPerms->CheckEnityAccess('CONTACT', 'DELETE', $arContactAttr[$iContactId]); $arResult['CONTACT'][$iContactId]['BIZPROC_LIST'] = array(); foreach ($arBPData as $arBP) { if (!CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::StartWorkflow, $userID, array('crm', 'CCrmDocumentContact', 'CONTACT_' . $arResult['CONTACT'][$iContactId]['ID']), array('UserGroups' => $CCrmBizProc->arCurrentUserGroups, 'DocumentStates' => $arDocumentStates, 'WorkflowTemplateId' => $arBP['ID'], 'CreatedBy' => $arResult['CONTACT'][$iContactId]['ASSIGNED_BY'], 'UserIsAdmin' => $isAdmin, 'CRMEntityAttr' => $arContactAttr[$iContactId]))) { continue; } $arBP['PATH_TO_BIZPROC_START'] = CHTTP::urlAddParams(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CONTACT_SHOW'], array('contact_id' => $arResult['CONTACT'][$iContactId]['ID'])), array('workflow_template_id' => $arBP['ID'], 'bizproc_start' => 1, 'sessid' => $arResult['SESSION_ID'], 'CRM_CONTACT_SHOW_V12_active_tab' => 'tab_bizproc', 'back_url' => $arParams['PATH_TO_CONTACT_LIST'])); $arResult['CONTACT'][$iContactId]['BIZPROC_LIST'][] = $arBP; } } } if (!$isInExportMode) { $arResult['NEED_FOR_REBUILD_DUP_INDEX'] = false; $arResult['NEED_FOR_REBUILD_CONTACT_ATTRS'] = false; if (!$bInternal && CCrmPerms::IsAdmin()) { if (COption::GetOptionString('crm', '~CRM_REBUILD_CONTACT_DUP_INDEX', 'N') === 'Y') { $arResult['NEED_FOR_REBUILD_DUP_INDEX'] = true; } if (COption::GetOptionString('crm', '~CRM_REBUILD_CONTACT_ATTR', 'N') === 'Y') {
public function CheckFields($ID = false, $bAutoExec = false, $CreatedBy = 0, $arEntityAttr = array()) { global $USER; $this->LAST_ERROR = ''; if (!CModule::IncludeModule('bizproc')) { return true; } $this->arDocumentStates = CBPDocument::GetDocumentStates(array('crm', $this->sDocument, $this->sEntityType), $ID == false ? null : array('crm', $this->sDocument, $this->sEntityType . '_' . $ID)); $arCurrentUserGroups = $this->arCurrentUserGroups; if (is_object($USER)) { if ($ID == false) { $arCurrentUserGroups[] = 'Author'; $bCanWrite = CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::WriteDocument, $USER->GetID(), array('crm', $this->sDocument, $this->sEntityType), array('AllUserGroups' => $arCurrentUserGroups, 'DocumentStates' => $this->arDocumentStates, 'UserIsAdmin' => $USER->IsAdmin())); } else { if ($USER->GetID() == $CreatedBy) { $arCurrentUserGroups[] = 'Author'; } $bCanWrite = CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::WriteDocument, $USER->GetID(), array('crm', $this->sDocument, $this->sEntityType . '_' . $ID), array('AllUserGroups' => $arCurrentUserGroups, 'DocumentStates' => $this->arDocumentStates, 'CreatedBy' => $CreatedBy != 0 ? $CreatedBy : 0, 'UserIsAdmin' => $USER->IsAdmin(), 'CRMEntityAttr' => $arEntityAttr)); } } else { $bCanWrite = true; } if (!$bCanWrite) { $this->LAST_ERROR = GetMessage('CRM_PERMISSION_DENIED'); return false; } $arBizProcParametersValues = array(); foreach ($this->arDocumentStates as $arDocumentState) { if (strlen($arDocumentState['ID']) <= 0) { if ($bAutoExec) { foreach ($arDocumentState['TEMPLATE_PARAMETERS'] as $parameterKey => $arParam) { if ($arParam['Required'] && !isset($_REQUEST['bizproc' . $arDocumentState['TEMPLATE_ID'] . '_' . $parameterKey]) && strlen($arParam['Default']) > 0) { $_REQUEST['bizproc' . $arDocumentState['TEMPLATE_ID'] . '_' . $parameterKey] = $arParam['Default']; } } } $arErrorsTmp = array(); $arBizProcParametersValues[$arDocumentState['TEMPLATE_ID']] = CBPDocument::StartWorkflowParametersValidate($arDocumentState['TEMPLATE_ID'], $arDocumentState['TEMPLATE_PARAMETERS'], array('crm', $this->sDocument, $ID == false ? $this->sEntityType : $this->sEntityType . '_' . $ID), $arErrorsTmp); if (count($arErrorsTmp) > 0) { $this->LAST_ERROR = ''; foreach ($arErrorsTmp as $e) { $this->LAST_ERROR .= $e['message'] . '<br />'; } return false; } } } return $arBizProcParametersValues; }
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } ?> <?php foreach ($arAllowableOperations as $operationKey => $operationValue) { ?> <tr> <td align="right" width="40%"><?php echo str_replace("#OP#", $operationValue, GetMessage("BPSA_PD_PERM")); ?> :</td> <td width="60%"> <?php echo CBPDocument::ShowParameterField("user", 'permission_' . $operationKey, $arCurrentValues["permission_" . $operationKey], array()); ?> </td> </tr> <?php } ?> <tr> <td align="right" width="40%"><?php echo GetMessage("BPSA_PD_PERM_REWRITE"); ?> :</td> <td width="60%"> <input type="checkbox" name="rewrite" value="Y"<?php echo $arCurrentValues["rewrite"] != "N" ? " checked" : ""; ?>
public function GetGUIFieldEdit($parameterDocumentType, $formName, $fieldName, $fieldValue, $arDocumentField = array(), $bAllowSelection = false) { list($moduleId, $entity, $documentType) = CBPHelper::ParseDocumentId($parameterDocumentType); if (strlen($moduleId) > 0) { CModule::IncludeModule($moduleId); } if (!is_array($arDocumentField) || count($arDocumentField) <= 0) { $arDocumentFields = $this->GetDocumentFields($parameterDocumentType); $arDocumentField = $arDocumentFields[$fieldName]; } if (!array_key_exists("BP_AddShowParameterInit_" . $moduleId . "_" . $entity . "_" . $documentType, $GLOBALS)) { $GLOBALS["BP_AddShowParameterInit_" . $moduleId . "_" . $entity . "_" . $documentType] = 1; CBPDocument::AddShowParameterInit($moduleId, "only_users", $documentType, $entity); } if (class_exists($entity) && method_exists($entity, "GetGUIFieldEdit")) { return call_user_func_array(array($entity, "GetGUIFieldEdit"), array($documentType, $formName, $fieldName, $fieldValue, $arDocumentField, $bAllowSelection)); } return CBPHelper::GetGUIFieldEdit($parameterDocumentType, $formName, $fieldName, $fieldValue, $arDocumentField, $bAllowSelection); }
if ($allowAdminAccess && !empty($_REQUEST['action']) && check_bitrix_sessid()) { $ids = isset($_REQUEST['ID']) && is_array($_REQUEST['ID']) ? $_REQUEST['ID'] : array(); if ($ids) { $errors = array(); $action = $_REQUEST['action']; $status = 0; if (strpos($action, 'set_status_') === 0) { $status = substr($action, strlen('set_status_')); $action = 'set_status'; } foreach ($ids as $id) { list($taskId, $userId) = explode('_', $id); if ($action == 'set_status' && $status > 0) { CBPDocument::setTasksUserStatus($userId, $status, $taskId, $errors); } elseif ($action == 'delegate' && !empty($_REQUEST['delegate_to'])) { CBPDocument::delegateTasks($userId, $_REQUEST['delegate_to'], $taskId, $errors); } } if ($errors) { foreach ($errors as $error) { $actionErrorMessage .= $error . PHP_EOL; } } unset($ids, $errors, $action, $status, $taskId, $userId); } } if ($actionErrorMessage) { $lAdmin->BeginPrologContent(); CAdminMessage::ShowMessage($actionErrorMessage); $lAdmin->EndPrologContent(); }
<td><?php echo GetMessage("IB_E_ELEMENT_DELETE"); ?> </td> <td> <input type="text" name="ELEMENT_DELETE" size="40" maxlength="100" value="<?php echo htmlspecialcharsbx($arMessages["ELEMENT_DELETE"]); ?> "> </td> </tr> <?php if ($bBizprocTab) { $tabControl->BeginNextTab(); if (!isset($arWorkflowTemplates)) { $arWorkflowTemplates = CBPDocument::GetWorkflowTemplatesForDocumentType(array("iblock", "CIBlockDocument", "iblock_" . $ID)); } ?> <tr> <td colspan="2"> <?php if (count($arWorkflowTemplates) > 0) { ?> <table border="0" cellspacing="0" cellpadding="0" class="internal"> <tr class="heading"> <td><?php echo GetMessage("IB_E_BP_NAME"); ?> </td> <td><?php echo GetMessage("IB_E_BP_CHANGED");
$arParams["PATH_TO_BIZPROC_EDIT"] = trim($arParams["PATH_TO_BIZPROC_EDIT"]); if (strlen($arParams["PATH_TO_BIZPROC_EDIT"]) <= 0) { $arParams["PATH_TO_BIZPROC_EDIT"] = htmlspecialcharsbx($APPLICATION->GetCurPage() . "?" . $arParams["PAGE_VAR"] . "=bizproc_edit&" . $arParams["TASK_VAR"] . "=#task_id#"); } if (!$GLOBALS["USER"]->IsAuthorized()) { $arResult["NEED_AUTH"] = "Y"; } else { if ($arParams["SET_TITLE"] == "Y") { $APPLICATION->SetTitle(GetMessage("SONET_BIZPROC_TITLE")); } if ($arParams["SET_NAV_CHAIN"] != "N") { $APPLICATION->AddChainItem(GetMessage("SONET_BIZPROC_TITLE")); } $dbResultList = CBPTaskService::GetList(array("MODIFIED" => "DESC"), array("USER_ID" => $USER->GetID()), false, false, array("ID", "WORKFLOW_ID", "ACTIVITY", "ACTIVITY_NAME", "MODIFIED", "OVERDUE_DATE", "NAME", "DESCRIPTION", "PARAMETERS")); while ($arResultItem = $dbResultList->GetNext()) { if (strlen($arResultItem["DESCRIPTION"]) > 100) { $arResultItem["DESCRIPTION"] = substr($arResultItem["DESCRIPTION"], 0, 97) . "..."; } $arResultItem["EditUrl"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_BIZPROC_EDIT"], array("task_id" => $arResultItem["ID"])); $arResult["TASKS"][] = $arResultItem; } $dbTracking = CBPTrackingService::GetList(array("MODIFIED" => "DESC"), array("MODIFIED_BY" => $USER->GetID())); while ($arTracking = $dbTracking->GetNext()) { if (strlen($arTracking["WORKFLOW_ID"]) > 0) { $arTracking["STATE"] = CBPStateService::GetWorkflowState($arTracking["WORKFLOW_ID"]); $arTracking["STATE"]["Url"] = CBPDocument::GetDocumentAdminPage($arTracking["STATE"]["DOCUMENT_ID"]); } $arResult["TRACKING"][] = $arTracking; } } $this->IncludeComponentTemplate();
public function OnAfterIBlockElementDelete($arFields) { CBPDocument::OnDocumentDelete(array("bizproc", "CBPVirtualDocument", $arFields["ID"]), $arErrorsTmp); }