2namespace Bitrix\Calendar\Controller;
4use Bitrix\Calendar\Access\ActionDictionary;
5use Bitrix\Calendar\Access\Model\TypeModel;
6use Bitrix\Calendar\Access\SyncAccessController;
7use Bitrix\Calendar\Access\TypeAccessController;
8use Bitrix\Calendar\Controller\Filter\RestrictExternalUser;
9use Bitrix\Calendar\Core\Role\Helper;
10use Bitrix\Calendar\Core\Role\User;
11use Bitrix\Calendar\Internals\Counter\CounterService;
12use Bitrix\Calendar\Internals\Counter\Event\EventDictionary;
13use Bitrix\Calendar\Internals\SectionTable;
14use Bitrix\Calendar\Sync\Google;
15use Bitrix\Calendar\Sync\ICloud;
16use Bitrix\Calendar\Util;
18use Bitrix\Main\HttpApplication;
19use Bitrix\Main\HttpResponse;
20use Bitrix\Main\Loader;
21use Bitrix\Main\LoaderException;
22use Bitrix\Main\Localization\Loc;
23use Bitrix\Calendar\Sync;
24use Bitrix\Main\Engine\ActionFilter;
25use Bitrix\Calendar\Core\Oauth;
27Loc::loadMessages(__FILE__);
34 'handleMobileAuth' => [
36 ActionFilter\Authentication::class,
37 ActionFilter\Csrf::class,
53 $params[
'userId'] = \CCalendar::getCurUserId();
55 return \CCalendarSync::GetSyncInfo(
$params);
60 $userId = \CCalendar::GetUserId();
65 ActionDictionary::ACTION_SYNC_DELETE,
73 \CCalendar::setOwnerId(
$userId);
74 \CCalendar::RemoveConnection([
'id' => (
int)$connectionId,
'del_calendars' => $removeCalendars ===
'Y']);
75 CounterService::addEvent(EventDictionary::SYNC_CHANGED, [
'user_ids' => [
$userId]]);
86 $params[
'user_id'] = \CCalendar::getCurUserId();
94 if ($parameter ===
'')
96 $this->
addError(
new Error(Loc::getMessage(
'EC_CALDAV_URL_ERROR'),
'incorrect_parameters'));
101 if (Loader::IncludeModule(
'dav'))
107 \CDavGroupdavClientCalendar::DataSync(
"user",
$params[
'user_id']);
114 CounterService::addEvent(EventDictionary::SYNC_CHANGED, [
'user_ids' => [
$params[
'user_id']]]);
131 'message' =>
'Could not finish sync.',
134 if (!\CCalendar::isGoogleApiEnabled())
136 $this->
addError(
new Error(Loc::getMessage(
'EC_SYNCAJAX_GOOGLE_API_REQUIRED'),
'google_api_required'));
140 if (!Loader::includeModule(
'dav'))
142 $this->
addError(
new Error(Loc::getMessage(
'EC_SYNCAJAX_DAV_REQUIRED'),
'dav_required'));
159 if (!Loader::includeModule(
'dav'))
163 'message' =>
'Module dav is required',
166 if (!Loader::includeModule(
'socialservices'))
170 'message' =>
'Module socialservices is required',
174 $owner = Helper::getRole(\CCalendar::GetUserId(), User::TYPE);
191 $appleId = trim($appleId);
192 $appPassword = trim($appPassword);
194 if (!Loader::includeModule(
'dav'))
196 $this->
addError(
new Error(Loc::getMessage(
'EC_SYNCAJAX_DAV_REQUIRED')));
200 'message' => Loc::getMessage(
'EC_SYNCAJAX_DAV_REQUIRED'),
203 $typeModel = TypeModel::createFromXmlId(User::TYPE);
205 if (!
$accessController->check(ActionDictionary::ACTION_TYPE_EDIT, $typeModel, []))
211 'message' =>
'Access Denied',
214 if (!preg_match(
"/[a-z]{4}-[a-z]{4}-[a-z]{4}-[a-z]{4}/", $appPassword))
219 'status' =>
'incorrect_app_pass',
220 'message' =>
'Incorrect app password'
227 $this->
addError(
new Error(Loc::getMessage(
'EC_SYNCALAX_ICLOUD_WRONG_AUTH')));
231 'message' => Loc::getMessage(
'EC_SYNCALAX_ICLOUD_WRONG_AUTH'),
236 'status' =>
'success',
237 'connectionId' => $connectionId
243 if (!Loader::includeModule(
'dav'))
245 $this->
addError(
new Error(Loc::getMessage(
'EC_SYNCAJAX_DAV_REQUIRED')));
249 'message' => Loc::getMessage(
'EC_SYNCAJAX_DAV_REQUIRED'),
268 $params[
'userId'] = \CCalendar::getCurUserId();
269 $requestUid =
$request->getPost(
'requestUid');
270 if (!empty($requestUid))
279 return \CCalendarSync::GetSyncInfo(
$params);
292 if (!Loader::includeModule(
'dav'))
297 return \CCalendarSync::deactivateConnection($connectionId);
307 return \CCalendarSect::getAllSectionsForVendor($connectionId, [
Sync\
Icloud\Helper::ACCOUNT_TYPE]);
312 return \CCalendarSect::getAllSectionsForVendor($connectionId, [
Sync\
Office365\Helper::ACCOUNT_TYPE]);
317 return \CCalendarSect::getAllSectionsForVendor($connectionId,
Sync\
Google\Dictionary::ACCESS_ROLE_TO_EXTERNAL_TYPE);
323 (
int)\CCalendar::GetUserId(),
330 $userId = \CCalendar::getCurUserId();
331 \CUserOptions::DeleteOption(
'calendar',
'last_sync_iphone',
false,
$userId);
332 \CUserOptions::DeleteOption(
'calendar',
'last_sync_mac',
false,
$userId);
337 CUserOptions::SetOption(
'calendar',
'showGoogleApplicationRefused',
'N');
343 $section = SectionTable::query()
344 ->setSelect([
'XML_ID',
'CAL_TYPE',
'NAME',
'OWNER_ID'])
346 ->exec()->fetchObject()
351 $result = \CCalendarSect::GetOutlookLink([
352 'ID' => $section->getId(),
353 'XML_ID' => $section->getXmlId(),
354 'TYPE' => $section->getCalType(),
355 'NAME' => $section->getName(),
356 'PREFIX' => \CCalendar::GetOwnerName($section->getCalType(), $section->getOwnerId()),
357 'LINK_URL' => \CCalendar::GetOuterUrl()
368 if (Loader::includeModule(
'intranet') && !\
Bitrix\Intranet\Util::isIntranetUser())
375 $oauthEntity = Oauth\Factory::getInstance()->getByName($serviceName);
376 if ($oauthEntity &&
$url = $oauthEntity->getUrl())
391 $httpResponse->addHeader(
'Location',
'bitrix24://');
393 if (empty($serviceName) || empty($hitHash))
395 return $httpResponse;
398 if (!
$GLOBALS[
'USER']->LoginHitByHash($hitHash,
false,
true))
400 return $httpResponse;
403 HttpApplication::getInstance()->getSession()->set(
'MOBILE_OAUTH',
true);
405 $oauthEntity = Oauth\Factory::getInstance()->getByName($serviceName);
406 if ($oauthEntity &&
$url = $oauthEntity->getUrl())
411 return $httpResponse;
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
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 clearFinishedSyncNotificationAgent(int $userId, string $vendorName)
static setRequestUid(string $requestUid='')
static UpdateUserConnections()
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
static can($userId, string $action, $itemId=null, $params=null)
$GLOBALS['____1690880296']
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']