Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
activity.php
1<?php
2
4
8
9class Activity extends Base
10{
11 public function requestAction(array $documentType, string $activity, array $params)
12 {
13 try
14 {
15 $documentType = \CBPHelper::ParseDocumentId($documentType);
16 $activity = (new Bizproc\Validator(['activity' => $activity]))
17 ->validateString('activity')
18 ->getPureValues()['activity'];
19
20 $dirtyParams = $params;
21 $pureParams = (new Bizproc\Validator($params))
22 //->validateRequire('lists_document_type')
23 //->validateString('lists_document_type')
24 ->validateRequire('form_name')
25 ->validateString('form_name')
26 ->validateEnum('public_mode', ['Y', ''])
27 ->setDefault('public_mode', '')
28 ->getPureValues();
29
30 $params = array_merge($dirtyParams, $pureParams);
31 }
32 catch (\Throwable $e)
33 {
34 $this->addError(new Error($e->getMessage(), $e->getCode()));
35 return null;
36 }
37 $user = $this->getCurrentUser();
38
39 if (
40 !\CBPDocument::CanUserOperateDocumentType(
41 \CBPCanUserOperateOperation::CreateWorkflow,
42 $user->getId(),
43 $documentType
44 )
45 )
46 {
47 $this->addError(new Error(Loc::getMessage('BIZPROC_ACCESS_DENIED')));
48 return null;
49 }
50
51 $runtime = \CBPRuntime::GetRuntime();
52 $runtime->StartRuntime();
53
54 $activityDescription = $runtime->GetActivityDescription($activity);
55 if (!$activityDescription)
56 {
57 $this->addError(new Error("Bad activity type!" . htmlspecialcharsbx($activity)));
58 return null;
59 }
60
61 $runtime->IncludeActivityFile($activity);
62
63 return \CBPActivity::CallStaticMethod(
64 $activity,
65 "getAjaxResponse",
66 [$params]
67 );
68 }
69}
static addError($error)
Definition base.php:278
requestAction(array $documentType, string $activity, array $params)
Definition activity.php:11
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29