コード例 #1
0
ファイル: ajax.php プロジェクト: webgksupport/alpina
 protected function getTemplatesIdList()
 {
     if (!Loader::includeModule('bizproc') || empty($this->iblockTypeId) || empty($this->iblockId)) {
         return array();
     }
     $documentType = BizprocDocument::generateDocumentComplexType($this->iblockTypeId, $this->iblockId);
     $templates = array_merge(\CBPWorkflowTemplateLoader::SearchTemplatesByDocumentType($documentType, CBPDocumentEventType::Create), \CBPWorkflowTemplateLoader::SearchTemplatesByDocumentType($documentType, CBPDocumentEventType::Edit));
     $templateData = array();
     foreach ($templates as $template) {
         $templateData[$template['ID']]['ID'] = $template['ID'];
         $templateData[$template['ID']]['NAME'] = $template['NAME'];
     }
     return $templateData;
 }
コード例 #2
0
ファイル: ajax.php プロジェクト: mrdeadmouse/u136006
 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());
 }
コード例 #3
0
ファイル: component.php プロジェクト: mrdeadmouse/u136006
                     } else {
                         if (!array_key_exists($bpTemplateId, $arDocumentStates)) {
                             continue;
                         }
                         $bpId = $arBizProcWorkflowId[$bpTemplateId];
                     }
                     $arErrorTmp = array();
                     CBPDocument::SendExternalEvent($bpId, $bpEvent, array("Groups" => $arCurrentUserGroups, "User" => $GLOBALS["USER"]->GetID()), $arErrorTmp);
                     foreach ($arErrorsTmp as $e) {
                         $strWarning .= $e["message"] . "<br />";
                     }
                 }
             }
         }
         $arDocumentStates = null;
         CBPDocument::AddDocumentToHistory(BizprocDocument::getDocumentComplexId($arParams["IBLOCK_TYPE_ID"], $arResult["ELEMENT_ID"]), $arElement["NAME"], $GLOBALS["USER"]->GetID());
     }
 }
 if (!$strError) {
     //Successfull update
     //And go to proper page
     if (isset($_POST["save"])) {
         LocalRedirect($arResult["~LIST_SECTION_URL"]);
     } elseif ($lists_perm < CListPermissions::CAN_READ && !CIBlockElementRights::UserHasRightTo($arResult["IBLOCK_ID"], $arResult["ELEMENT_ID"], "element_read")) {
         LocalRedirect($arResult["~LIST_SECTION_URL"]);
     } else {
         $url = CHTTP::urlAddParams(str_replace(array("#list_id#", "#section_id#", "#element_id#", "#group_id#"), array($arResult["IBLOCK_ID"], intval($_POST["IBLOCK_SECTION_ID"]), $arResult["ELEMENT_ID"], $arParams["SOCNET_GROUP_ID"]), $arParams["~LIST_ELEMENT_URL"]), array($tab_name => $_POST[$tab_name]), array("skip_empty" => true, "encode" => true));
         if (isset($_GET["list_section_id"]) && strlen($_GET["list_section_id"]) == 0) {
             $url = CHTTP::urlAddParams($url, array("list_section_id" => ""));
         }
         LocalRedirect($url);
コード例 #4
0
ファイル: component.php プロジェクト: mrdeadmouse/u136006
 if ($arResult["PROCESSES"] && $arResult["USE_COMMENTS"]) {
     $documentState = CBPDocument::GetDocumentStates(BizprocDocument::generateDocumentComplexType($arIBlock["IBLOCK_TYPE_ID"], $arIBlock["ID"]), BizprocDocument::getDocumentComplexId($arIBlock["IBLOCK_TYPE_ID"], $data["ID"]));
     if (!empty($documentState)) {
         $documentState = current($documentState);
         $data["WORKFLOW_ID"] = $documentState["ID"];
     } else {
         $data["WORKFLOW_ID"] = '';
     }
 }
 $arUserGroupsForBPTmp = $arUserGroupsForBP;
 if ($USER->GetID() == $data["CREATED_BY"]) {
     $arUserGroupsForBPTmp[] = "Author";
 }
 $arBPStart = array();
 foreach ($arDocumentTemplates as $arWorkflowTemplate) {
     if (CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::StartWorkflow, $USER->GetID(), BizprocDocument::getDocumentComplexId($arParams["IBLOCK_TYPE_ID"], intval($data["~ID"])), array("IBlockId" => $arIBlock["ID"], "AllUserGroups" => $arUserGroupsForBPTmp, "DocumentStates" => $arDocumentStatesForBP, "WorkflowId" => $arWorkflowTemplate["ID"]))) {
         $backUrl = $APPLICATION->GetCurPageParam();
         $url = CHTTP::urlAddParams(str_replace(array("#list_id#", "#section_id#", "#element_id#", "#workflow_template_id#", "#group_id#"), array($arIBlock["ID"], intval($arResult["SECTION_ID"]), intval($data["~ID"]), $arWorkflowTemplate["ID"], $arParams["SOCNET_GROUP_ID"]), $arParams["BIZPROC_WORKFLOW_START_URL"]), array("workflow_template_id" => $arWorkflowTemplate["ID"], "back_url" => $backUrl));
         $url .= (strpos($url, "?") === false ? "?" : "&") . bitrix_sessid_get();
         $arBPStart[] = array("TEXT" => $arWorkflowTemplate["NAME"], "ONCLICK" => "jsUtils.Redirect(arguments, '" . CUtil::JSEscape($url) . "')");
     }
 }
 $url = str_replace(array("#list_id#", "#section_id#", "#element_id#", "#group_id#"), array($arIBlock["ID"], intval($arResult["SECTION_ID"]), intval($data["~ID"]), $arParams["SOCNET_GROUP_ID"]), $arParams["LIST_ELEMENT_URL"]);
 if ($arResult["ANY_SECTION"]) {
     $url = CHTTP::urlAddParams($url, array("list_section_id" => ""));
 }
 $aActions = array();
 if (!$arResult["IS_SOCNET_GROUP_CLOSED"] && ($lists_perm >= CListPermissions::CAN_WRITE || CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $data["~ID"], "element_edit"))) {
     $aActions[] = array("ICONCLASS" => "edit", "TEXT" => GetMessage("CC_BLL_ELEMENT_ACTION_MENU_EDIT"), "ONCLICK" => "jsUtils.Redirect(arguments, '" . CUtil::JSEscape($url) . "')", "DEFAULT" => true);
     $arResult["ELEMENTS_CAN_MOVE"][] = $data["ID"];
 } else {
コード例 #5
0
ファイル: class.php プロジェクト: Satariall/izurit
 public function executeComponent()
 {
     if (!empty($this->arParams['ERROR'])) {
         ShowError(array_shift($this->arParams['ERROR']));
         return;
     }
     $this->arResult['USER_ID'] = $this->arParams['USER_ID'];
     $this->arResult['GRID_ID'] = 'lists_processes';
     $selectFields = array('ID', 'IBLOCK_TYPE_ID', 'IBLOCK_ID', 'NAME');
     $gridOptions = new CGridOptions($this->arResult['GRID_ID']);
     $gridColumns = $gridOptions->getVisibleColumns();
     $gridSort = $gridOptions->getSorting(array('sort' => array('ID' => 'desc')));
     $this->arResult['HEADERS'] = array(array("id" => "ID", "name" => "ID", "default" => false, "sort" => "ID"), array('id' => 'DOCUMENT_NAME', 'name' => Loc::getMessage('CC_BLL_DOCUMENT_NAME'), 'default' => true, 'sort' => 'DOCUMENT_NAME'), array('id' => 'COMMENTS', 'name' => Loc::getMessage('CC_BLL_COMMENTS'), 'default' => true, 'sort' => '', 'hideName' => true, 'iconCls' => 'bp-comments-icon'), array('id' => 'WORKFLOW_PROGRESS', 'name' => Loc::getMessage('CC_BLL_WORKFLOW_PROGRESS'), 'default' => true, 'sort' => ''), array('id' => 'WORKFLOW_STATE', 'name' => Loc::getMessage('CC_BLL_WORKFLOW_STATE'), 'default' => false, 'sort' => ''));
     $this->arResult['FILTER'] = array(array("id" => "NAME", "name" => GetMessage("BPATL_NAME"), "type" => "string"), array('id' => 'TIMESTAMP_X', 'name' => Loc::getMessage('CC_BLL_MODIFIED'), 'type' => 'date'), array('id' => 'DATE_CREATE', 'name' => Loc::getMessage('CC_BLL_CREATED'), 'type' => 'date', 'default' => true));
     $gridFilter = $gridOptions->getFilter($this->arResult['FILTER']);
     foreach ($gridFilter as $key => $value) {
         if (substr($key, -5) == "_from") {
             $op = ">=";
             $newKey = substr($key, 0, -5);
         } elseif (substr($key, -3) == "_to") {
             $op = "<=";
             $newKey = substr($key, 0, -3);
             if (in_array($newKey, array("TIMESTAMP_X", 'DATE_CREATE'))) {
                 if (!preg_match("/\\d\\d:\\d\\d:\\d\\d\$/", $value)) {
                     $value .= " 23:59:59";
                 }
             }
         } else {
             $op = "";
             $newKey = $key;
         }
         $filter[$op . $newKey] = $value;
     }
     $this->arResult['SORT'] = $gridSort['sort'];
     $useComments = (bool) CModule::includeModule("forum");
     $workflows = array();
     $this->arResult['DATA'] = array();
     $this->arResult["COMMENTS_COUNT"] = array();
     $filter['CREATED_BY'] = $this->arParams['USER_ID'];
     $iblockTypeId = COption::GetOptionString("lists", "livefeed_iblock_type_id");
     $filter['IBLOCK_TYPE'] = $iblockTypeId;
     $filter['CHECK_PERMISSIONS'] = $this->arParams['LIST_PERM'] >= CListPermissions::CAN_READ ? "N" : "Y";
     $elementObject = CIBlockElement::getList($gridSort['sort'], $filter, false, $gridOptions->getNavParams(), $selectFields);
     $documentState = true;
     $path = rtrim(SITE_DIR, '/');
     while ($element = $elementObject->fetch()) {
         $documentState = CBPDocument::GetDocumentStates(BizprocDocument::generateDocumentComplexType($iblockTypeId, $element['IBLOCK_ID']), BizprocDocument::getDocumentComplexId($iblockTypeId, $element['ID']));
         $this->arResult['DATA'][$element['ID']]['ID'] = $element['ID'];
         $this->arResult['DATA'][$element['ID']]['DOCUMENT_NAME'] = $element['NAME'];
         $this->arResult['DATA'][$element['ID']]['DOCUMENT_URL'] = $path . COption::GetOptionString('lists', 'livefeed_url') . '?livefeed=y&list_id=' . $element["IBLOCK_ID"] . '&element_id=' . $element['ID'];
         if (!empty($documentState)) {
             $this->arResult['DATA'][$element['ID']]['DOCUMENT_STATE'] = true;
             $documentState = current($documentState);
             $this->arResult['DATA'][$element['ID']]['WORKFLOW_ID'] = $documentState['ID'];
             $this->arResult['DATA'][$element['ID']]["WORKFLOW_NAME"] = $documentState["TEMPLATE_NAME"];
             $this->arResult['DATA'][$element['ID']]["WORKFLOW_STATE"] = $documentState["STATE_TITLE"];
             $this->arResult['DATA'][$element['ID']]["WORKFLOW_STARTED"] = FormatDateFromDB($documentState["STARTED_FORMATTED"]);
             $this->arResult['DATA'][$element['ID']]["WORKFLOW_STARTED_BY"] = "";
             if (intval($documentState["STARTED_BY"]) > 0) {
                 $dbUserTmp = CUser::getByID($documentState["STARTED_BY"]);
                 $arUserTmp = $dbUserTmp->fetch();
                 $this->arResult['DATA'][$element['ID']]["WORKFLOW_STARTED_BY"] = CUser::FormatName($this->arParams["NAME_TEMPLATE"], $arUserTmp, true);
                 $this->arResult['DATA'][$element['ID']]["WORKFLOW_STARTED_BY"] .= " [" . $documentState["STARTED_BY"] . "]";
             }
             $this->arResult['DATA'][$element['ID']]['MODULE_ID'] = $documentState["DOCUMENT_ID"][0];
             $this->arResult['DATA'][$element['ID']]['ENTITY'] = $documentState["DOCUMENT_ID"][1];
             $this->arResult['DATA'][$element['ID']]['DOCUMENT_ID'] = $documentState["DOCUMENT_ID"][2];
         } else {
             $documentState = false;
             $this->arResult['DATA'][$element['ID']]['DOCUMENT_STATE'] = false;
         }
     }
     foreach ($this->arResult['DATA'] as $data) {
         if ($documentState) {
             if ($useComments) {
                 $workflows[] = 'WF_' . $data['WORKFLOW_ID'];
             }
         }
         $actions = array();
         if (strlen($data["DOCUMENT_URL"]) > 0) {
             $actions[] = array('ICONCLASS' => '', 'DEFAULT' => false, 'TEXT' => Loc::getMessage('CC_BLL_C_DOCUMENT'), 'ONCLICK' => 'window.open("' . $data["DOCUMENT_URL"] . '");');
         }
         $this->arResult['RECORDS'][] = array('data' => $data, 'actions' => $actions);
     }
     if ($useComments && $documentState) {
         $workflows = array_unique($workflows);
         if ($workflows) {
             $iterator = CForumTopic::getList(array(), array("@XML_ID" => $workflows));
             while ($row = $iterator->fetch()) {
                 $this->arResult["COMMENTS_COUNT"][$row['XML_ID']] = $row['POSTS'];
             }
         }
     }
     $this->arResult['COUNTERS'] = array('all' => 0);
     $this->arResult["ROWS_COUNT"] = $elementObject->selectedRowsCount();
     $this->arResult["NAV_RESULT"] = $elementObject;
     if ($this->arParams['SET_TITLE'] == 'Y') {
         $this->getApplication()->setTitle(Loc::getMessage('CC_BLL_TITLE'));
     }
     $this->includeComponentTemplate();
 }
コード例 #6
0
ファイル: lists.php プロジェクト: DarneoStudio/bitrix
 /**
  * @param string $workflowId
  * @param string $iblockType
  * @param int $elementId
  * @param int $iblockId
  * @param string $action Action stop or delete
  * @return string error
  */
 public static function completeWorkflow($workflowId, $iblockType, $elementId, $iblockId, $action)
 {
     if (!Loader::includeModule('bizproc')) {
         return Loc::getMessage('LISTS_MODULE_BIZPROC_NOT_INSTALLED');
     }
     global $USER;
     $userId = $USER->getID();
     $documentType = BizprocDocument::generateDocumentComplexType($iblockType, $iblockId);
     $documentId = BizprocDocument::getDocumentComplexId($iblockType, $elementId);
     $documentStates = CBPDocument::getDocumentStates($documentType, $documentId);
     $permission = CBPDocument::canUserOperateDocument($action == 'stop' ? CBPCanUserOperateOperation::StartWorkflow : CBPCanUserOperateOperation::CreateWorkflow, $userId, $documentId, array("DocumentStates" => $documentStates));
     if (!$permission) {
         return Loc::getMessage('LISTS_ACCESS_DENIED');
     }
     $stringError = '';
     if ($action == 'stop') {
         $errors = array();
         CBPDocument::terminateWorkflow($workflowId, $documentId, $errors);
         if (!empty($errors)) {
             $stringError = '';
             foreach ($errors as $error) {
                 $stringError .= $error['message'];
             }
             $listError[] = array('id' => 'stopBizproc', 'text' => $stringError);
         }
     } else {
         $errors = array();
         if (isset($documentStates[$workflowId]['WORKFLOW_STATUS']) && $documentStates[$workflowId]['WORKFLOW_STATUS'] !== null) {
             CBPDocument::terminateWorkflow($workflowId, $documentId, $errors);
         }
         if (!empty($errors)) {
             $stringError = '';
             foreach ($errors as $error) {
                 $stringError .= $error['message'];
             }
             $listError[] = array('id' => 'stopBizproc', 'text' => $stringError);
         } else {
             CBPTaskService::deleteByWorkflow($workflowId);
             CBPTrackingService::deleteByWorkflow($workflowId);
             CBPStateService::deleteWorkflow($workflowId);
         }
     }
     if (empty($listError) && Loader::includeModule('socialnetwork') && $iblockType == COption::getOptionString("lists", "livefeed_iblock_type_id")) {
         $sourceId = CBPStateService::getWorkflowIntegerId($workflowId);
         $resultQuery = CSocNetLog::getList(array(), array('EVENT_ID' => 'lists_new_element', 'SOURCE_ID' => $sourceId), false, false, array('ID'));
         while ($log = $resultQuery->fetch()) {
             CSocNetLog::delete($log['ID']);
         }
     }
     if (!empty($listError)) {
         $errorObject = new CAdminException($listError);
         $stringError = $errorObject->getString();
     }
     return $stringError;
 }
コード例 #7
0
ファイル: template.php プロジェクト: mrdeadmouse/u136006
                    foreach ($arTasks as $arTask) {
                        $back_url = CHTTP::urlAddParams($APPLICATION->GetCurPageParam("", array("lists_element_edit_active_tab")), array("lists_element_edit_active_tab" => "tab_bp"));
                        $url = CHTTP::urlAddParams(str_replace(array("#list_id#", "#section_id#", "#element_id#", "#task_id#", "#group_id#"), array($arResult["IBLOCK_ID"], intval($arResult["SECTION_ID"]), $arResult["ELEMENT_ID"], $arTask["ID"], $arParams["SOCNET_GROUP_ID"]), $arParams["~BIZPROC_TASK_URL"]), array("back_url" => $back_url), array("skip_empty" => true, "encode" => true));
                        $html .= '<a href="' . htmlspecialcharsbx($url) . '" title="' . strip_tags($arTask["DESCRIPTION"]) . '">' . $arTask["NAME"] . '</a><br />';
                    }
                    $arTab2Fields[] = array("id" => "BIZPROC_TASKS" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_TASKS"), "type" => "label", "value" => $html);
                }
            }
        }
    }
    if (!$bizProcIndex) {
        $arTab2Fields[] = array("id" => "BIZPROC_NO", "name" => GetMessage("CT_BLEE_BIZPROC_NA_LABEL"), "type" => "label", "value" => GetMessage("CT_BLEE_BIZPROC_NA"));
    }
    $custom_html .= '<input type="hidden" name="bizproc_index" value="' . $bizProcIndex . '">';
    if ($arResult["ELEMENT_ID"]) {
        $bStartWorkflowPermission = CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::StartWorkflow, $USER->GetID(), BizprocDocument::getDocumentComplexId($arParams["IBLOCK_TYPE_ID"], $arResult["ELEMENT_ID"]), array("AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates, "WorkflowId" => $arDocumentState["TEMPLATE_ID"]));
        if ($bStartWorkflowPermission) {
            $arTab2Fields[] = array("id" => "BIZPROC_NEW", "name" => GetMessage("CT_BLEE_BIZPROC_NEW"), "type" => "section");
            $back_url = CHTTP::urlAddParams($APPLICATION->GetCurPageParam("", array("lists_element_edit_active_tab")), array("lists_element_edit_active_tab" => "tab_bp"));
            $url = CHTTP::urlAddParams(str_replace(array("#list_id#", "#section_id#", "#element_id#", "#group_id#"), array($arResult["IBLOCK_ID"], intval($arResult["SECTION_ID"]), $arResult["ELEMENT_ID"], $arParams["SOCNET_GROUP_ID"]), $arParams["~BIZPROC_WORKFLOW_START_URL"]), array("back_url" => $back_url, "sessid" => bitrix_sessid()), array("skip_empty" => true, "encode" => true));
            $arTab2Fields[] = array("id" => "BIZPROC_NEW_START", "name" => GetMessage("CT_BLEE_BIZPROC_START"), "type" => "custom", "colspan" => true, "value" => '<a href="' . htmlspecialcharsbx($url) . '">' . GetMessage("CT_BLEE_BIZPROC_START") . '</a>');
        }
    }
    $arTabs[] = array("id" => "tab_bp", "name" => GetMessage("CT_BLEE_BIZPROC_TAB"), "icon" => "", "fields" => $arTab2Fields);
}
if (isset($arResult["RIGHTS"])) {
    ob_start();
    IBlockShowRights('element', $arResult["IBLOCK_ID"], $arResult["ELEMENT_ID"], "", "RIGHTS", $arResult["TASKS"], $arResult["RIGHTS"], true, $arResult["ELEMENT_ID"] <= 0, $arResult["SELECTED"], $arResult["HIGHLIGHT"]);
    $rights_html = ob_get_contents();
    ob_end_clean();
    $rights_fields = array(array("id" => "RIGHTS", "name" => GetMessage("CT_BLEE_ACCESS_RIGHTS"), "type" => "custom", "colspan" => true, "value" => $rights_html));
コード例 #8
0
ファイル: lists.php プロジェクト: mrdeadmouse/u136006
 function OnAfterIBlockDelete($iblock_id)
 {
     BizprocDocument::deleteDataIblock($iblock_id);
 }
コード例 #9
0
ファイル: class.php プロジェクト: mrdeadmouse/u136006
 protected function getArrayBizproc($data = array())
 {
     $currentUserId = $GLOBALS["USER"]->GetID();
     $html = "";
     if ($this->arResult["IBLOCK"]["BIZPROC"] == "Y" && CModule::IncludeModule('bizproc')) {
         $this->arResult["ELEMENTS_HEADERS"]["BIZPROC"] = array("name" => Loc::getMessage("CC_BLL_COLUMN_BIZPROC"), "default" => true, "sort" => false);
         $arDocumentStates = CBPDocument::GetDocumentStates(BizprocDocument::generateDocumentComplexType($this->arParams["IBLOCK_TYPE_ID"], $this->arResult["IBLOCK_ID"]), BizprocDocument::getDocumentComplexId($this->arParams["IBLOCK_TYPE_ID"], $data["ID"]));
         $userGroups = $GLOBALS["USER"]->GetUserGroupArray();
         if ($data["~CREATED_BY"] == $currentUserId) {
             $userGroups[] = "Author";
         }
         $ii = 0;
         foreach ($arDocumentStates as $workflowId => $workflowState) {
             if (strlen($workflowState["TEMPLATE_NAME"]) > 0) {
                 $html .= "" . $workflowState["TEMPLATE_NAME"] . ":\r\n";
             } else {
                 $html .= "" . ++$ii . ":\r\n";
             }
             $html .= "" . (strlen($workflowState["STATE_TITLE"]) > 0 ? $workflowState["STATE_TITLE"] : $workflowState["STATE_NAME"]) . "\r\n";
         }
     }
     return $html;
 }
コード例 #10
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
$file = trim(preg_replace("'[\\\\/]+'", "/", dirname(__FILE__) . "/lang/" . LANGUAGE_ID . "/result_modifier.php"));
__IncludeLang($file);
$arArrays = array();
$arElements = array();
$arSections = array();
$CURRENT_USER_ID = $GLOBALS["USER"]->GetID();
$CURRENT_USER_GROUPS = $GLOBALS["USER"]->GetUserGroupArray();
foreach ($arResult["ELEMENTS_ROWS"] as $i => $arRow) {
    if ($arResult["BIZPROC"] == "Y") {
        $arDocumentStates = CBPDocument::GetDocumentStates(BizprocDocument::generateDocumentComplexType($arParams["IBLOCK_TYPE_ID"], $arResult["IBLOCK_ID"]), BizprocDocument::getDocumentComplexId($arParams["IBLOCK_TYPE_ID"], $arRow["data"]["ID"]));
        $USER_GROUPS = $CURRENT_USER_GROUPS;
        if ($arRow["data"]["~CREATED_BY"] == $CURRENT_USER_ID) {
            $USER_GROUPS[] = "Author";
        }
        $ii = 0;
        $html = "";
        $proccesses = false;
        if ($arResult["PROCESSES"] && $arResult["USE_COMMENTS"]) {
            $proccesses = true;
            $workflows = array();
        }
        foreach ($arDocumentStates as $kk => $vv) {
            if ($vv["ID"] && $proccesses && !empty($arRow["data"]["WORKFLOW_ID"])) {
                $workflows[] = 'WF_' . $vv["ID"];
            }
            $canViewWorkflow = CIBlockDocument::CanUserOperateDocument(CBPCanUserOperateOperation::ViewWorkflow, $CURRENT_USER_ID, $arRow["data"]["ID"], array("IBlockPermission" => $arResult["IBLOCK_PERM"], "AllUserGroups" => $USER_GROUPS, "DocumentStates" => $arDocumentStates, "WorkflowId" => $kk));