1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
sharinggroupajax.php
См. документацию.
1<?php
2
3namespace Bitrix\Calendar\Controller;
4
5use Bitrix\Calendar\Access\ActionDictionary;
6use Bitrix\Calendar\Access\SectionAccessController;
7use Bitrix\Calendar\Core\Event\Tools\Dictionary;
8use Bitrix\Calendar\Core\Mappers;
9use Bitrix\Calendar\Core\Section\Section;
10use Bitrix\Calendar\Sharing;
11use Bitrix\Main\Engine\AutoWire\ExactParameter;
12use Bitrix\Main\Engine\Controller;
13use Bitrix\Main\Engine\CurrentUser;
14use Bitrix\Main\Error;
15
16final class SharingGroupAjax extends Controller
17{
18 public function getAutoWiredParameters()
19 {
20 return [
22 Section::class,
23 'section',
24 function(string $className, CurrentUser $currentUser, ?int $groupId = null): ?Section
25 {
26 if (!$groupId)
27 {
28 $this->addError(new Error('access denied'));
29
30 return null;
31 }
32 $sections = (new Mappers\Section())->getMap([
33 'OWNER_ID' => $groupId,
34 'CAL_TYPE' => Dictionary::CALENDAR_TYPE['group'],
35 'ACTIVE' => 'Y',
36 ]);
37 if (!$sections->count())
38 {
39 $this->addError(new Error('access denied'));
40
41 return null;
42 }
43 $section = $sections->fetch();
44
45 $hasAccess = SectionAccessController::can(
46 $currentUser->getId(),
47 ActionDictionary::ACTION_SECTION_EDIT,
48 $section->getId()
49 );
50 if (!$hasAccess)
51 {
52 $this->addError(new Error('access denied'));
53
54 return null;
55 }
56
57 return $section;
58 },
59 ),
60 ];
61 }
62
63 public function enableSharingAction(CurrentUser $currentUser, ?Section $section): ?array
64 {
65 if ($this->getErrors())
66 {
67 return null;
68 }
69
70 $sharing = new Sharing\SharingGroup($section->getOwner()->getId(), $currentUser->getId());
71 $result = $sharing->enable();
72 if (!$result->isSuccess())
73 {
74 $this->addErrors($result->getErrors());
75
76 return null;
77 }
78
79 return $sharing->getLinkInfo();
80 }
81
82 public function disableSharingAction(CurrentUser $currentUser, ?Section $section): ?array
83 {
84 if ($this->getErrors())
85 {
86 return null;
87 }
88
89 $sharing = new Sharing\SharingGroup($section->getOwner()->getId(), $currentUser->getId());
90 $result = $sharing->disable();
91 if (!$result->isSuccess())
92 {
93 $this->addErrors($result->getErrors());
94
95 return null;
96 }
97
98 return [];
99 }
100
101 public function generateJointSharingLinkAction(CurrentUser $currentUser, array $memberIds, ?Section $section): ?array
102 {
103 if ($this->getErrors())
104 {
105 return null;
106 }
107
108 $sharing = new Sharing\SharingGroup($section->getOwner()->getId(), $currentUser->getId());
109 $result = $sharing->generateGroupJointLink($memberIds);
110 if (!$result->isSuccess())
111 {
112 $this->addErrors($result->getErrors());
113
114 return null;
115 }
116
117 return $result->getData();
118 }
119
120 public function enableAndGetSharingConfigAction(CurrentUser $currentUser, ?Section $section): ?array
121 {
122 if ($this->getErrors())
123 {
124 return null;
125 }
126
127 $sharing = new Sharing\SharingGroup($section->getOwner()->getId(), $currentUser->getId());
128 if (!$sharing->isEnabled())
129 {
130 $result = $sharing->enable();
131
132 if (!$result->isSuccess())
133 {
134 $this->addErrors($result->getErrors());
135
136 return null;
137 }
138 }
139
140 $portalCalendarConfig = \CCalendar::GetSettings();
141
142 return [
143 'link' => $sharing->getLinkInfo(),
144 'userCalendarSettings' => [
145 'week_holidays' => $portalCalendarConfig['week_holidays'],
146 'week_start' => $portalCalendarConfig['week_start'],
147 'work_time_start' => $portalCalendarConfig['work_time_start'],
148 'work_time_end' => $portalCalendarConfig['work_time_end'],
149 ],
150 'user' => (new Sharing\Sharing($currentUser->getId()))->getUserInfo(),
151 ];
152 }
153}
disableSharingAction(CurrentUser $currentUser, ?Section $section)
Определения sharinggroupajax.php:82
enableSharingAction(CurrentUser $currentUser, ?Section $section)
Определения sharinggroupajax.php:63
enableAndGetSharingConfigAction(CurrentUser $currentUser, ?Section $section)
Определения sharinggroupajax.php:120
generateJointSharingLinkAction(CurrentUser $currentUser, array $memberIds, ?Section $section)
Определения sharinggroupajax.php:101
addError(Error $error)
Определения controller.php:1070
addErrors(array $errors)
Определения controller.php:1083
Определения 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
$result
Определения get_property_values.php:14