1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
AccessRights.php
См. документацию.
1<?php
2
4
19use Bitrix\Socialnetwork\Collab\Controller\Trait\GetCollabIdBySourceTrait;
23
25{
26 use GetCollabIdBySourceTrait;
27
30
31 protected int $userId;
32
33 public function getAutoWiredParameters(): array
34 {
35 return [
36 new Parameter(
37 CollabUpdateDto::class,
38 function (): CollabUpdateDto {
39 $request = $this->getRequest();
40 $requestData = $request->getPostList()->toArray();
41 $requestData['id'] = $this->resolveCollabId($request, 'id');
42
43 return CollabUpdateDto::createFromRequest($requestData);
44 }
45 ),
47 CollabGetDto::class,
48 function (): CollabGetDto {
49 $request = $this->getRequest();
50 $requestData = $request->getPostList()->toArray();
51 $requestData['id'] = $this->resolveCollabId($request, 'id');
52
53 return CollabGetDto::createFromRequest($requestData);
54 }
55 ),
56 ];
57 }
58
59 public function configureActions(): array
60 {
61 return [
62 'saveRights' => [
63 '+prefilters' => [
65 ],
66 ],
67 'getAddForm' => [
68 '+prefilters' => [
70 ],
71 ],
72 'getEditForm' => [
73 '+prefilters' => [
75 ],
76 ],
77 ];
78 }
79
84 {
85 try
86 {
87 $command = CollabUpdateCommand::createFromArray($dto)->setInitiatorId($this->userId);
88 }
89 catch (ArgumentException $e)
90 {
91 $this->addError(Error::createFromThrowable($e));
92
93 return null;
94 }
95
96 $result = (new AccessDecorator($this->service))->update($command);
97 if (!$result->isSuccess())
98 {
99 $this->addErrors($result->getErrors());
100
101 return null;
102 }
103
104 return $this->forward(Collab::class, 'get');
105 }
106
110 public function getAddFormAction(): ?array
111 {
112 if (!CollabAccessController::can($this->userId, CollabDictionary::CREATE))
113 {
114 $this->addError(new Error('Access denied'));
115
116 return null;
117 }
118
119 $featureProvider = FeatureProvider::getInstance();
120
121 return [
122 'ownerId' => $this->userId,
123 'permissionsLabels' => $featureProvider->getPermissionLabels(),
124 'rightsPermissionsLabels' => $featureProvider->getRightsPermissionLabels(),
125 'optionsLabels' => $featureProvider->getOptionLabels(),
126 'permissions' => $featureProvider->getAllDefaultPermissions(),
127 'isAllowedInviteCollabers' => $featureProvider->isAllowedInviteCollabers(),
128 ];
129 }
130
134 public function getEditFormAction(CollabGetDto $dto): ?array
135 {
136 if (!CollabAccessController::can($this->userId, CollabDictionary::UPDATE, $dto->id))
137 {
138 $this->addError(new Error('Access denied'));
139
140 return null;
141 }
142
143 $collab = $this->forward(Collab::class, 'get');
144 if ($collab === null)
145 {
146 return null;
147 }
148
149 $data = $collab->toJson();
150 $data['rightsPermissionsLabels'] = FeatureProvider::getInstance()->getRightsPermissionLabels();
151 $data['permissionsLabels'] = FeatureProvider::getInstance()->getPermissionLabels();
152 $data['optionsLabels'] = FeatureProvider::getInstance()->getOptionLabels();
153 $data['isAllowedInviteCollabers'] = FeatureProvider::getInstance()->isAllowedInviteCollabers();
154
155 return $data;
156 }
157
158 protected function init(): void
159 {
160 parent::init();
161
162 $this->service = ServiceLocator::getInstance()->get('socialnetwork.collab.service');
163 $this->registry = GroupRegistry::getInstance();
164
165 $this->userId = (int)CurrentUser::get()->getId();
166 }
167}
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
Определения catalog_reindex.php:36
Определения error.php:15
saveRightsAction(CollabUpdateDto $dto)
Определения AccessRights.php:83
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14