41 if ($elementId < 0 || $userId <= 0)
51 $operation = \CBPCanUserOperateOperation::WriteDocument;
53 'AllUserGroups' => $userGroups,
59 ? \CBPDocument::canUserOperateDocument($operation, $userId, $complexDocumentId, $parameters)
60 : \CBPDocument::canUserOperateDocumentType($operation, $userId, $this->complexDocumentType, $parameters)
69 if ($currentUserId <= 0 || $elementId < 0 || $sectionId < 0)
79 $canStart = \CBPDocument::canUserOperateDocumentType(
80 \CBPCanUserOperateOperation::StartWorkflow,
82 $this->complexDocumentType,
83 [
'sectionId' => $sectionId,
'DocumentStates' => $documentStates]
92 $isConstantsTuned =
true;
95 $templates = array_merge(
96 \CBPWorkflowTemplateLoader::searchTemplatesByDocumentType(
97 $this->complexDocumentType, \CBPDocumentEventType::Create
99 \CBPWorkflowTemplateLoader::searchTemplatesByDocumentType(
100 $this->complexDocumentType, \CBPDocumentEventType::Edit
104 foreach ($templates as $template)
106 if (!\CBPWorkflowTemplateLoader::isConstantsTuned($template[
'ID']))
108 $isConstantsTuned =
false;
115 return $isConstantsTuned;
175 if ($request->elementId <= 0 || $request->currentUserId <= 0)
178 $response->addError(
new Error(
'incorrect input data'));
184 $documentStates = $this->
getDocumentStates($request->isNewElement ?
null : $complexDocumentId);
185 foreach ($documentStates as $state)
187 if (empty($state[
'ID']))
191 $startWorkflowParameters = [
192 \CBPDocument::PARAM_TAGRET_USER =>
'user_' . $request->currentUserId,
193 \CBPDocument::PARAM_MODIFIED_DOCUMENT_FIELDS => $request->changedFields,
196 $workflowIds[$state[
'TEMPLATE_ID']] = \CBPDocument::startWorkflow(
197 $state[
'TEMPLATE_ID'],
199 array_merge($request->parameters[$state[
'TEMPLATE_ID']] ?? [], $startWorkflowParameters),
203 if (!$errors && isset($request->timeToStart))
205 $metadata =
new EO_WorkflowMetadata();
206 $metadata->setWorkflowId($workflowIds[$state[
'TEMPLATE_ID']]);
207 $metadata->setStartDuration($request->timeToStart);
211 foreach ($errors as $error)
213 $response->addError(
new Error($error[
'message']));
219 return $response->setWorkflowIds($workflowIds);