16use Bitrix\Dav\Internals\DavConnectionTable;
17use Bitrix\Dav\Internals\EO_DavConnection_Collection;
33 'existed' =>
'existed',
34 'created' =>
'created',
35 'activated' =>
'activated',
39 private $mapperFactory;
43 $this->mapperFactory = ServiceLocator::getInstance()->get(
'calendar.service.mappers.factory');
61 foreach ($connectionData as
$con)
87 array $optionalFilter = []
88 ): ?EO_DavConnection_Collection
90 $statement = DavConnectionTable::query()
92 ->addFilter(
'=ENTITY_TYPE', $owner->
getType())
93 ->addFilter(
'=ENTITY_ID', $owner->
getId())
94 ->addFilter(
'=ACCOUNT_TYPE',
$type)
97 if (!empty($optionalFilter))
99 foreach ($optionalFilter as
$key => $value)
101 $statement->addFilter(
$key, $value);
105 return $statement->fetchCollection() ?:
null;
119 'ENTITY_TYPE' =>
$connection->getOwner()->getType(),
121 'ACCOUNT_TYPE' =>
$connection->getVendor()->getCode(),
124 'SERVER_SCHEME' =>
$connection->getServer()->getScheme(),
125 'SERVER_HOST' =>
$connection->getServer()->getHost(),
126 'SERVER_PORT' =>
$connection->getServer()->getPort(),
127 'SERVER_USERNAME' =>
$connection->getServer()->getUserName(),
128 'SERVER_PASSWORD' =>
$connection->getServer()->getPassword(),
129 'SERVER_PATH' =>
$connection->getServer()->getBasePath(),
130 'MODIFIED' => $lastModified,
131 'SYNCHRONIZED' => $lastModified,
133 'IS_DELETED' =>
$connection->isDeleted() ?
'Y' :
'N'
142 return (
new Result())->addError(
new Error($e->getMessage()));
160 if (!Loader::includeModule(
'dav'))
171 $resultData[
'status'] = self::INIT_STATUS[
'activated'];
175 $resultData[
'status'] = self::INIT_STATUS[
'existed'];
186 $resultData[
'status'] = self::INIT_STATUS[
'created'];
221 'ENTITY_TYPE' => $owner->
getType(),
222 'ENTITY_ID' => $owner->
getId(),
223 'ACCOUNT_TYPE' =>
$type,
225 'SERVER' => $serverPath,
227 if ($connectionId = CDavConnection::Add(
$fields))
229 return $this->mapperFactory->getConnection()->getById($connectionId);
232 throw new BaseException(
'Error of create new Dav connection');
247 $user = UserTable::query()
248 ->addFilter(
'=USER_ID', $owner->
getId())
249 ->addFilter(
'=EXTERNAL_AUTH_ID', $accountType)
250 ->setSelect([
'LOGIN'])
253 return $user[
'LOGIN'] ??
'';
258 if ($connections ===
null)
263 foreach ($connections as $connectionRow)
288 if (!Loader::includeModule(
'dav'))
293 $updateResult = DavConnectionTable::update(
$connection->getId(), [
295 'SYNC_TOKEN' =>
null,
297 if ($updateResult->isSuccess())
307 PushCommand::DeleteSyncConnection,
312 'type' => $accountType,
321 $result->addErrors($updateResult->getErrors());
341 $links = SectionConnectionTable::query()
347 while ($link = $links->fetchObject())
349 SectionConnectionTable::update($link->getId(), [
354 'ENTITY_TYPE' =>
'SECTION_CONNECTION',
355 'ENTITY_ID' => $link->getId(),
365 "UPDATE b_dav_connections as con SET con.IS_DELETED ='Y' WHERE con.ID = $id;",
369 "DELETE FROM b_calendar_section_connection WHERE CONNECTION_ID = $id;",
373 "DELETE FROM b_calendar_event_connection WHERE CONNECTION_ID = $id;",
377 $DB->Query(
"DELETE sect FROM b_calendar_section sect
378 LEFT JOIN b_calendar_section_connection link ON sect.ID = link.SECTION_ID
379 WHERE link.ID IS NULL
380 AND sect.EXTERNAL_TYPE = '{$connection->getVendor()->getCode()}'
381 AND sect.OWNER_ID = '{$connection->getOwner()->getId()}'
385 $DB->Query(
"DELETE event FROM b_calendar_event event
386 LEFT JOIN b_calendar_section sec ON event.SECTION_ID = sec.ID
388 AND event.OWNER_ID = '{$connection->getOwner()->getId()}'
392 $DB->Query(
"DELETE push FROM b_calendar_push push
393 LEFT JOIN b_calendar_section_connection as sc on push.ENTITY_ID=sc.ID and push.ENTITY_TYPE='SECTION_CONNECTION'
394 WHERE sc.ID IS NULL;",
const GOOGLE_ACCOUNT_TYPE_API
getConnection(Role $owner, string $accountType, array $optionalFilter=[])
unsubscribeConnection(Connection $connection)
deactivateConnection(Connection $connection)
disableConnection(Connection $connection)
update(Connection $connection)
initConnection(Role $owner, string $accountType, string $server)
getConnectionsData(Role $owner, array $type, array $optionalFilter=[])
getSocialUserLogin(Role $owner, string $accountType)
createConnection(Role $owner, string $type, string $name, string $serverPath)
deactivateConnections(?EO_DavConnection_Collection $connections)
static addPullEvent(PushCommand $command, int $userId, array $params=[])
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(empty($signedUserToken)) $key