1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
task.php
См. документацию.
1<?php
2
3namespace Bitrix\Bizproc\Controller;
4
5use Bitrix\Bizproc;
6use Bitrix\Main\Error;
7use Bitrix\Main\Localization\Loc;
8use Bitrix\Main\Engine\Response\HtmlContent;
9
10class Task extends Base
11{
12 public function delegateAction(array $taskIds, int $toUserId, int $fromUserId): ?array
13 {
14 if (!$taskIds)
15 {
16 $this->addError(new Error(Loc::getMessage('BIZPROC_CONTROLLER_TASK_DELEGATE_EMPTY_TASK_IDS')));
17
18 return null;
19 }
20 if ($toUserId <= 0 || $fromUserId <= 0)
21 {
22 $this->addError(new Error(Loc::getMessage('BIZPROC_CONTROLLER_TASK_DELEGATE_INCORRECT_USER_ID')));
23
24 return null;
25 }
26
27 $currentUserId = $this->getCurrentUser()->getId();
28
29 $taskService = new Bizproc\Api\Service\TaskService(
30 new Bizproc\Api\Service\TaskAccessService($currentUserId)
31 );
32
33 $tasksRequest = new Bizproc\Api\Request\TaskService\DelegateTasksRequest($taskIds, $fromUserId, $toUserId, $currentUserId);
34 $delegateTaskResult = $taskService->delegateTasks($tasksRequest);
35
36 if (!$delegateTaskResult->isSuccess())
37 {
38 $this->addErrors($delegateTaskResult->getErrors());
39
40 return null;
41 }
42
43 return [
44 'message' => $delegateTaskResult->getSuccessDelegateTaskMessage(),
45 ];
46 }
47
51 private function getListAction(?int $targetUserId = null): ?array
52 {
53 $currentUserId = $this->getCurrentUser()->getId();
54 if (!$targetUserId)
55 {
56 $targetUserId = $currentUserId;
57 }
58
59 // todo: check that $targetUserId > 0
60
61 $taskService = new Bizproc\Api\Service\TaskService(
62 new Bizproc\Api\Service\TaskAccessService($currentUserId)
63 );
64
66 additionalSelectFields: ['NAME', 'DESCRIPTION'],
67 filter: [
68 'USER_ID' => $targetUserId,
69 ],
70 );
71 $getTasksResult = $taskService->getTasks($tasksRequest);
72 if (!$getTasksResult->isSuccess())
73 {
74 $this->addErrors($getTasksResult->getErrors());
75
76 return null;
77 }
78
79 return [
80 'tasks' => $getTasksResult->getTasks(),
81 ];
82 }
83
84 public function doAction(int $taskId, ?array $taskRequest = null): ?bool
85 {
86 $currentUserId = $this->getCurrentUser()->getId();
87
88 $taskService = new Bizproc\Api\Service\TaskService(
89 new Bizproc\Api\Service\TaskAccessService($currentUserId)
90 );
91
92 if ($taskRequest === null)
93 {
94 $taskRequest = $this->request->getPostList()->toArray() + $this->request->getFileList()->toArray();
95 }
96
98 taskId: $taskId,
99 userId: $currentUserId,
100 taskRequest: $taskRequest,
101 );
102
103 $getTasksResult = $taskService->doTask($request);
104 if (!$getTasksResult->isSuccess())
105 {
106 $this->addErrors($getTasksResult->getErrors());
107
108 return null;
109 }
110
111 return true;
112 }
113
114 public function getUserTaskByWorkflowIdAction(string $workflowId): ?HtmlContent
115 {
116 $currentUserId = $this->getCurrentUser()->getId();
117
118 $taskService = new Bizproc\Api\Service\TaskService(
119 new Bizproc\Api\Service\TaskAccessService($currentUserId)
120 );
121
123 workflowId: $workflowId,
124 userId: $currentUserId,
125 );
126
127 $userTaskResult = $taskService->getUserTaskByWorkflowId($request);
128 if ($userTaskResult->isSuccess())
129 {
130 return new HtmlContent(
131 content: $userTaskResult->getContent(),
132 additionalResponseParams: $userTaskResult->getTask(),
133 );
134
135 }
136
137 $this->addErrors($userTaskResult->getErrors());
138
139 return null;
140 }
141
147 public function doInlineTasksAction(array $taskIds, int $newStatus): ?bool
148 {
149 $currentUserId = $this->getCurrentUser()->getId();
150
151 $preparedTaskIds = [];
152 foreach ($taskIds as $id)
153 {
154 if (is_numeric($id))
155 {
156 $preparedTaskIds[] = (int)$id;
157 }
158 }
159
161 taskIds: $preparedTaskIds,
162 userId: $currentUserId,
163 newTaskStatusId: $newStatus,
164 );
165
167 new Bizproc\Api\Service\TaskAccessService($request->userId),
168 );
169
170 $response = $service->doInlineTasks($request);
171
172 if (!$response->isSuccess())
173 {
174 $this->addErrors($response->getErrors());
175 return null;
176 }
177
178 return true;
179 }
180}
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
Определения catalog_reindex.php:36
static addError($error)
Определения base.php:278
static addErrors(array $errors)
Определения base.php:287
doInlineTasksAction(array $taskIds, int $newStatus)
Определения task.php:147
delegateAction(array $taskIds, int $toUserId, int $fromUserId)
Определения task.php:12
doAction(int $taskId, ?array $taskRequest=null)
Определения task.php:84
getUserTaskByWorkflowIdAction(string $workflowId)
Определения task.php:114
Определения error.php:15
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
Определения BaseTask.php:3
$service
Определения payment.php:18
$response
Определения result.php:21