当前位置: 首页>>代码示例>>PHP>>正文


PHP CBPDocument::startWorkflow方法代码示例

本文整理汇总了PHP中CBPDocument::startWorkflow方法的典型用法代码示例。如果您正苦于以下问题:PHP CBPDocument::startWorkflow方法的具体用法?PHP CBPDocument::startWorkflow怎么用?PHP CBPDocument::startWorkflow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CBPDocument的用法示例。


在下文中一共展示了CBPDocument::startWorkflow方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getData

 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()) {
//.........这里部分代码省略.........
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:101,代码来源:class.php

示例2: startAutoBizProc

 public static function startAutoBizProc($storageId, $fileId, $autoExecute, $workflowParameters)
 {
     $documentData = array('DISK' => array('DOCUMENT_TYPE' => \Bitrix\Disk\BizProcDocument::generateDocumentComplexType($storageId), 'DOCUMENT_ID' => \Bitrix\Disk\BizProcDocument::getDocumentComplexId($fileId)), 'WEBDAV' => array('DOCUMENT_TYPE' => \Bitrix\Disk\BizProcDocumentCompatible::generateDocumentComplexType($storageId), 'DOCUMENT_ID' => \Bitrix\Disk\BizProcDocumentCompatible::getDocumentComplexId($fileId)));
     $error = array();
     foreach ($documentData as $nameModule => $data) {
         $workflowTemplateObject = \CBPWorkflowTemplateLoader::getList(array(), array("DOCUMENT_TYPE" => $data["DOCUMENT_TYPE"], "AUTO_EXECUTE" => $autoExecute, "ACTIVE" => "Y"), false, false, array("ID", "PARAMETERS"));
         while ($workflowTemplate = $workflowTemplateObject->getNext()) {
             if (!empty($workflowTemplate)) {
                 $workflowParameter = array();
                 foreach ($workflowParameters as $idParameter => $valueParameter) {
                     $search = $workflowTemplate['ID'];
                     $res = strpos($idParameter, $search);
                     if ($res === 7) {
                         $parameterKey = end(explode('_', $idParameter));
                         $workflowParameter[$parameterKey] = $valueParameter;
                     }
                 }
                 $workflowParametersCheck = \CBPWorkflowTemplateLoader::checkWorkflowParameters($workflowTemplate["PARAMETERS"], $workflowParameter, $data["DOCUMENT_TYPE"], $error);
                 \CBPDocument::startWorkflow($workflowTemplate['ID'], $data["DOCUMENT_ID"], $workflowParametersCheck, $error);
             }
         }
     }
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:23,代码来源:bizprocdocument.php


注:本文中的CBPDocument::startWorkflow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。