Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
google.php
1<?php
2
4
8
9class Google extends Base
10{
14 protected function __construct($userId)
15 {
16 if (\CSocServGoogleProxyOAuth::isProxyAuth())
17 {
18 $this->oauthClient = new \CSocServGoogleProxyOAuth($userId);
19 }
20 else
21 {
22 $this->oauthClient = new \CSocServGoogleOAuth($userId);
23 }
24
25 $this->oauthClient->getEntityOAuth()->addScope([
26 'https://www.googleapis.com/auth/calendar',
27 'https://www.googleapis.com/auth/calendar.readonly'
28 ]);
29
30 }
31
35 protected function checkService(): bool
36 {
37 return \CCalendar::IsCalDAVEnabled() && \CCalendar::isGoogleApiEnabled();
38 }
39
43 public static function getServiceName(): string
44 {
45 return 'google';
46 }
47
56 public function getUrl(): string
57 {
59 $helper = ServiceLocator::getInstance()->get('calendar.service.google.helper');
60 $isMobile = HttpApplication::getInstance()->getSession()->get('MOBILE_OAUTH');
61 $mode = $isMobile ? 'bx_mobile' : 'opener';
62 $backUrl = $isMobile ? null : '#googleAuthSuccess';
63
64 return $this->oauthClient->getUrl(
65 $mode,
66 null,
67 [
68 'BACKURL' => $backUrl,
69 'APIKEY' => $helper->getApiKey()
70 ]
71 );
72 }
73}