51 $userId = \CCalendar::GetUserId();
52 $connection = $this->mapperFactory->getConnection()->getById($connectionId);
57 'status' => self::STATUS_ERROR,
58 'message' =>
'Connection not found',
62 if ($connection->getOwner()->getId() !== $userId)
65 'status' => self::STATUS_ERROR,
66 'message' =>
'Access Denied',
70 $result = Managers\DataSyncManager::createInstance()->dataSync($userId);
74 'status' => self::STATUS_ERROR,
75 'message' =>
'Error while trying to import events',
80 'process_sync_connection',
83 'vendorName' => $this->helper::ACCOUNT_TYPE,
84 'stage' =>
'import_finished',
85 'accountName' => $connection->getServer()->getUserName(),
90 if (!$result->isSuccess())
93 'status' => self::STATUS_ERROR,
94 'message' =>
'Error while trying to export events',
99 'process_sync_connection',
102 'vendorName' => $this->helper::ACCOUNT_TYPE,
103 'stage' =>
'export_finished',
104 'accountName' => $connection->getServer()->getUserName(),
108 NotificationManager::addFinishedSyncNotificationAgent(
110 $this->helper::ACCOUNT_TYPE
114 'status' => self::STATUS_SUCCESS
129 'ENTITY_ID' => \CCalendar::GetCurUserId(),
130 'ENTITY_TYPE' => Core\Role\User::TYPE,
131 'SERVER_HOST' => $this->helper::SERVER_PATH,
132 'SERVER_USERNAME' => $appleId,
133 'SERVER_PASSWORD' => $appPassword,
134 'NAME' => str_replace(
'#NAME#', $appleId, $this->helper::CONNECTION_NAME)
138 $calendarPath = $this->getSyncService()->getCalendarServerPath($params);
141 $this->error =
'Error while trying to get calendars path';
145 $owner = Core\Role\Helper::getRole(\CCalendar::GetUserId(), Core\
Role\User::TYPE);
148 foreach ($connections as $con)
150 $existPath = $con->getServerScheme()
152 . $con->getServerHost()
154 . $con->getServerPort()
155 . $con->getServerPath()
157 if ($existPath === $calendarPath)
166 if ($connection->isDeleted())
168 $connection->setDeleted(
false);
169 $connection->getServer()->setPassword($appPassword);
172 $connectionManager->update($connection);
173 return $connection->getId();