1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
WorkflowAccessService.php
См. документацию.
1<?php
2
3namespace Bitrix\Bizproc\Api\Service;
4
5use Bitrix\Bizproc\Api\Request\WorkflowAccessService\CanViewFacesRequest;
6use Bitrix\Bizproc\Api\Request\WorkflowAccessService\CanViewTimelineRequest;
7use Bitrix\Bizproc\Api\Request\WorkflowAccessService\CheckStartWorkflowRequest;
8use Bitrix\Bizproc\Api\Response\Error;
9use Bitrix\Bizproc\Api\Response\WorkflowAccessService\CanViewFacesResponse;
10use Bitrix\Bizproc\Api\Response\WorkflowAccessService\CanViewTimelineResponse;
11use Bitrix\Bizproc\Api\Response\WorkflowAccessService\CheckAccessResponse;
12use Bitrix\Bizproc\Workflow\Entity\WorkflowUserTable;
13use Bitrix\Main\Localization\Loc;
14
16{
18 {
19 $hasAccess =
20 \CBPDocument::canUserOperateDocument(
22 $request->userId,
23 $request->complexDocumentId,
24 $request->parameters,
25 )
26 ;
27
29 if (!$hasAccess)
30 {
31 $response->addError(new Error(Loc::getMessage(
32 'BIZPROC_LIB_API_WORKFLOW_ACCESS_SERVICE_START_WORKFLOW_RIGHTS_ERROR'
33 )));
34 }
35
36 return $response;
37 }
38
40 {
41 $workflowUser =
42 WorkflowUserTable::query()
43 ->setSelect(['*'])
44 ->setFilter([
45 '=WORKFLOW_ID' => $request->workflowId,
46 '=USER_ID' => $request->userId,
47 ])
48 ->setLimit(1)
49 ->exec()
50 ->fetchObject()
51 ;
52
53 if (!$workflowUser && !$this->canViewWorkflow($request->workflowId, $request->userId))
54 {
55 return CanViewTimelineResponse::createError(static::getViewAccessDeniedError());
56 }
57
58 return new CanViewTimelineResponse();
59 }
60
61 private function canViewWorkflow($workflowId, $userId): bool
62 {
63 $documentId = \CBPStateService::getStateDocumentId($workflowId);
64
65 return (
66 $documentId
67 && \CBPDocument::canUserOperateDocument(
69 $userId,
70 $documentId,
71 [
72 'WorkflowId' => $workflowId,
73 ]
74 )
75 );
76 }
77
78 public function canCreateWorkflow(array $complexDocumentType, int $userId, array $parameters = []): bool
79 {
80 return \CBPDocument::CanUserOperateDocumentType(
82 $userId,
83 $complexDocumentType,
84 $parameters
85 );
86 }
87
88 public static function getViewAccessDeniedError(): \Bitrix\Bizproc\Error
89 {
90 return new \Bitrix\Bizproc\Error(Loc::getMessage(
91 'BIZPROC_LIB_API_WORKFLOW_ACCESS_SERVICE_VIEW_TIMELINE_RIGHTS_ERROR_MSGVER_1'
92 ));
93 }
94
96 {
97 if (empty($request->workflowId) || $request->userId <= 0)
98 {
99 return CanViewFacesResponse::createError(self::getViewAccessDeniedError());
100 }
101
102 // admin can view all bp content
103 if ($request->currentUserId > 0 && (new \CBPWorkflowTemplateUser($request->currentUserId))->isAdmin())
104 {
105 return CanViewFacesResponse::createOk();
106 }
107
108 $canViewResponse = $this->canViewTimeline(
110 $request->workflowId,
111 $request->userId
112 )
113 );
114 if (!$canViewResponse->isSuccess())
115 {
116 return CanViewFacesResponse::createError(self::getViewAccessDeniedError());
117 }
118
119 if (
120 $request->currentUserId > 0
121 && $request->currentUserId !== $request->userId
122 && !\CBPHelper::checkUserSubordination($request->currentUserId, $request->userId)
123 )
124 {
125 return CanViewFacesResponse::createError(self::getViewAccessDeniedError());
126 }
127
128 return CanViewFacesResponse::createOk();
129 }
130}
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
Определения catalog_reindex.php:36
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
canViewFaces(CanViewFacesRequest $request)
Определения WorkflowAccessService.php:95
canViewTimeline(CanViewTimelineRequest $request)
Определения WorkflowAccessService.php:39
canCreateWorkflow(array $complexDocumentType, int $userId, array $parameters=[])
Определения WorkflowAccessService.php:78
checkStartWorkflow(CheckStartWorkflowRequest $request)
Определения WorkflowAccessService.php:17
Определения error.php:15
const ViewWorkflow
Определения constants.php:211
const CreateWorkflow
Определения constants.php:213
const StartWorkflow
Определения constants.php:212
static getStateDocumentId($workflowId)
Определения stateservice.php:75
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$response
Определения result.php:21