11use Bitrix\Calendar\Sync\ICloud;
30 'handleMobileAuth' => [
32 ActionFilter\Authentication::class,
33 ActionFilter\Csrf::class,
43 $params[
'type'] =
$request->getPost(
'type');
44 $params[
'userId'] = \CCalendar::getCurUserId();
46 return \CCalendarSync::GetSyncInfo($params);
51 \CCalendar::setOwnerId(\CCalendar::getCurUserId());
52 \CCalendar::RemoveConnection([
'id' => (
int)$connectionId,
'del_calendars' => $removeCalendars ===
'Y']);
63 $params[
'user_id'] = \CCalendar::getCurUserId();
64 $params[
'user_name'] =
$request[
'userName'];
66 $params[
'link'] =
$request[
'server'];
69 foreach ($params as $parameter)
71 if ($parameter ===
'')
78 if (Loader::IncludeModule(
'dav'))
80 $res = \CCalendar::AddConnection($params);
84 \CDavGroupdavClientCalendar::DataSync(
"user", $params[
'user_id']);
106 'message' =>
'Could not finish sync.',
109 if (!\CCalendar::isGoogleApiEnabled())
115 if (!Loader::includeModule(
'dav'))
134 if (!Loader::includeModule(
'dav'))
138 'message' =>
'Module dav is required',
141 if (!Loader::includeModule(
'socialservices'))
145 'message' =>
'Module socialservices is required',
149 $owner = Helper::getRole(\CCalendar::GetUserId(), User::TYPE);
151 return (
new Sync\
Office365\StartSyncController($owner))->synchronize();
166 $appleId = trim($appleId);
167 $appPassword = trim($appPassword);
169 if (!Loader::includeModule(
'dav'))
178 $typeModel = TypeModel::createFromXmlId(User::TYPE);
180 if (!$accessController->check(ActionDictionary::ACTION_TYPE_EDIT, $typeModel, []))
186 'message' =>
'Access Denied',
189 if (!preg_match(
"/[a-z]{4}-[a-z]{4}-[a-z]{4}-[a-z]{4}/", $appPassword))
194 'status' =>
'incorrect_app_pass',
195 'message' =>
'Incorrect app password'
211 'status' =>
'success',
212 'connectionId' => $connectionId
218 if (!Loader::includeModule(
'dav'))
230 if ($result[
'status'] ===
'error' && $result[
'message'])
242 $params[
'type'] =
$request->getPost(
'type');
243 $params[
'userId'] = \CCalendar::getCurUserId();
244 $requestUid =
$request->getPost(
'requestUid');
245 if (!empty($requestUid))
250 \CCalendarSync::UpdateUserConnections();
254 return \CCalendarSync::GetSyncInfo($params);
260 $type = in_array($type, [
'slider',
'banner'],
true)
264 if (\
Bitrix\Main\Loader::includeModule(
"mobile"))
266 return [
'link' => \Bitrix\Mobile\Deeplink::getAuthLink(
"calendar_sync_".$type)];
281 if (!Loader::includeModule(
'dav'))
286 return \CCalendarSync::deactivateConnection($connectionId);
296 return \CCalendarSect::getAllSectionsForVendor($connectionId, [Sync\Icloud\Helper::ACCOUNT_TYPE]);
301 return \CCalendarSect::getAllSectionsForVendor($connectionId, [Sync\
Office365\Helper::ACCOUNT_TYPE]);
306 return \CCalendarSect::getAllSectionsForVendor($connectionId, Sync\
Google\Dictionary::ACCESS_ROLE_TO_EXTERNAL_TYPE);
311 \Bitrix\Calendar\Sync\Managers\NotificationManager::clearFinishedSyncNotificationAgent(
312 (
int)\CCalendar::GetUserId(),
319 $userId = \CCalendar::getCurUserId();
320 \CUserOptions::DeleteOption(
'calendar',
'last_sync_iphone',
false, $userId);
321 \CUserOptions::DeleteOption(
'calendar',
'last_sync_mac',
false, $userId);
326 CUserOptions::SetOption(
'calendar',
'showGoogleApplicationRefused',
'N');
332 $section = SectionTable::query()
333 ->setSelect([
'XML_ID',
'CAL_TYPE',
'NAME',
'OWNER_ID'])
335 ->exec()->fetchObject()
340 $result = \CCalendarSect::GetOutlookLink([
341 'ID' => $section->getId(),
342 'XML_ID' => $section->getXmlId(),
343 'TYPE' => $section->getCalType(),
344 'NAME' => $section->getName(),
345 'PREFIX' => \CCalendar::GetOwnerName($section->getCalType(), $section->getOwnerId()),
346 'LINK_URL' => \CCalendar::GetOuterUrl()
350 return [
'result' => $result];
357 if (Loader::includeModule(
'intranet') && !\
Bitrix\Intranet\Util::isIntranetUser())
364 $oauthEntity = Oauth\Factory::getInstance()->getByName($serviceName);
365 if ($oauthEntity && $url = $oauthEntity->getUrl())
367 $result[
'connectionLink'] = $url;
380 $httpResponse->addHeader(
'Location',
'bitrix24://');
382 if (empty($serviceName) || empty($hitHash))
384 return $httpResponse;
387 if (!
$GLOBALS[
'USER']->LoginHitByHash($hitHash,
false,
true))
389 return $httpResponse;
392 HttpApplication::getInstance()->getSession()->set(
'MOBILE_OAUTH',
true);
394 $oauthEntity = Oauth\Factory::getInstance()->getByName($serviceName);
395 if ($oauthEntity && $url = $oauthEntity->getUrl())
397 return $this->
redirectTo($url)->setSkipSecurity(
true);
400 return $httpResponse;
createGoogleConnectionAction()
clearSuccessfulConnectionNotifierAction(string $accountType)
removeConnectionAction($connectionId, $removeCalendars)
createIcloudConnectionAction(?string $appleId, ?string $appPassword)
disableShowGoogleApplicationRefusedAction()
handleMobileAuthAction(string $serviceName, string $hitHash)
getAllSectionsForOffice365Action(int $connectionId)
getAllSectionsForGoogleAction(int $connectionId)
getAllSectionsForIcloudAction(int $connectionId)
getOauthConnectionLinkAction(string $serviceName)
createOffice365ConnectionAction()
getOutlookLinkAction(int $id)
disableIphoneOrMacConnectionAction()
deactivateConnectionAction(int $connectionId, $removeCalendars='N')
syncIcloudConnectionAction($connectionId)
static setRequestUid(string $requestUid='')
static loadMessages($file)
static getMessage($code, $replace=null, $language=null)
$GLOBALS['____1444769544']