3namespace Bitrix\Calendar\Sync\Factories;
5use Bitrix\Calendar\Core\Base\Collection;
6use Bitrix\Calendar\Core\Base\Map;
7use Bitrix\Calendar\Core\Event\Event;
8use Bitrix\Calendar\Core\Section\Section;
9use Bitrix\Calendar\Core\Section\SectionMap;
10use Bitrix\Calendar\Internals\EO_SectionConnection;
11use Bitrix\Calendar\Internals\EventConnectionTable;
12use Bitrix\Calendar\Internals\SectionConnectionTable;
13use Bitrix\Calendar\Sync\Builders\BuilderEventConnectionFromDM;
14use Bitrix\Calendar\Sync\Connection\Connection;
15use Bitrix\Calendar\Sync\Connection\Server;
16use Bitrix\Calendar\Sync;
17use Bitrix\Calendar\Sync\Util\Context;
18use Bitrix\Dav\Internals\DavConnectionTable;
19use Bitrix\Main\ArgumentException;
20use Bitrix\Main\Loader;
21use Bitrix\Main\ObjectException;
22use Bitrix\Main\ObjectPropertyException;
23use Bitrix\Main\ORM\Query\Query;
24use Bitrix\Main\SystemException;
38 if (!Loader::includeModule(
'dav'))
40 return new self($collection);
43 $links = SectionConnectionTable::query()
48 ->addFilter(
'=SECTION_ID', $section->getId())
49 ->addFilter(
'=CONNECTION.IS_DELETED',
'N')
52 if ($availableService)
54 $links->addFilter(
'ACCOUNT_TYPE', $availableService);
57 $queryResult = $links->exec();
59 while ($link = $queryResult->fetchObject())
73 return new self($collection);
82 public static function createByEvent(
Event $event,
array $availableService =
null)
85 $links = self::getLinks(
$event->getSection(), $availableService);
86 $eventLinks = self::getEventLinksByConnectionId(
$event);
89 while ($link = $links->fetchObject())
104 return new self($collection);
121 if (!Loader::includeModule(
'dav'))
123 return new self($collection);
126 if (!$availableService)
128 $availableService = [
135 $sectionConnection = DavConnectionTable::query()
138 ->where(
'ENTITY_TYPE',
'user')
139 ->where(
'IS_DELETED',
'N')
140 ->whereIn(
'ACCOUNT_TYPE', $availableService)
145 while ($connectionDM = $sectionConnection->fetchObject())
156 return new self($collection);
173 if (!Loader::includeModule(
'dav'))
175 return new self($collection);
178 $links = SectionConnectionTable::query()
183 ->where(
'SECTION_ID', $section->getId())
184 ->where(
'CONNECTION.IS_DELETED',
'N')
185 ->whereIn(
'CONNECTION.ACCOUNT_TYPE', [
193 while ($link = $links->fetchObject())
197 'section_sync_data' => $link,
207 return new self(array_filter($collection));
219 private static function prepareContextForSection(
229 $sectionConnectionsMap->add($sectionConnection, $section->getId());
232 $sectionsMap->add($section, $section->getId());
235 'sections' => $sectionsMap,
236 'sectionConnections' => $sectionConnectionsMap,
237 'connections' => $connectionsMap
253 return new self([$factory]);
264 private static function getLinks(
266 ?
array $availableService
269 Loader::includeModule(
'dav');
270 $links = SectionConnectionTable::query()
275 ->addFilter(
'SECTION_ID', $section->getId())
276 ->addFilter(
'=CONNECTION.IS_DELETED',
'N')
279 if ($availableService)
281 $links->addFilter(
'ACCOUNT_TYPE', $availableService);
300 private static function getEventLinksByConnectionId(Event
$event): Map
302 $links = EventConnectionTable::query()
304 ->addFilter(
'EVENT_ID',
$event->getId())
308 $map =
new Sync\Connection\EventConnectionMap();
310 while ($link = $links->fetchObject())
312 $map->add((
new BuilderEventConnectionFromDM($link))->build(), $link->getConnectionId());
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
static createBySectionId(Section $section, array $availableService=null)
static createByUserId(int $userId, array $availableService=[])
static createBySection(Section $section)
static createByConnection(Connection $connection)
static create(string $accountType, Sync\Connection\Connection $connection, Sync\Util\Context $context)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)