Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
stssync.php
1<?php
3
4use Bitrix\Intranet\OutlookApplication;
11
13{
14 const SERVICE_PATH = '/stssync/';
15
16 public static function getUrl($type, $servicePath, $linkUrl, $prefix, $name, $guid)
17 {
18 \CJSCore::Init(array('stssync'));
19
20 $port = Context::getCurrent()->getRequest()->isHttps() ? 443 : 80;
21
22 if(Loader::includeModule('ldap'))
23 {
24 $port = \CLdapUtil::getTargetPort();
25 }
26
27 return 'BX.StsSync.sync(\''.$type.'\', \''.static::SERVICE_PATH.$servicePath.'\', \''.\CUtil::jsEscape($linkUrl).'\', \''.\CUtil::jsEscape($prefix).'\', \''.\CUtil::jsEscape($name).'\', \''.$guid.'\', '.intval($port).')';
28 }
29
30 public static function checkAuth($userId, $ap)
31 {
32 global $USER;
33
34 if(Loader::includeModule('intranet'))
35 {
36 $appPassword = ApplicationPasswordTable::findPassword($userId, $ap);
37 if($appPassword !== false)
38 {
39 if($appPassword["APPLICATION_ID"] === OutlookApplication::ID)
40 {
41 $appManager = ApplicationManager::getInstance();
42 if($appManager->checkScope($appPassword["APPLICATION_ID"]) === true)
43 {
44 ApplicationPasswordTable::update($appPassword["ID"], array(
45 'DATE_LOGIN' => new DateTime(),
46 'LAST_IP' => Context::getCurrent()->getRequest()->getRemoteAddress(),
47 ));
48
49 setSessionExpired(true);
50 return $USER->Authorize($userId);
51 }
52 }
53 }
54 }
55
56 return false;
57 }
58
59 public static function getAuth($type = '')
60 {
61 if(Loader::includeModule('intranet'))
62 {
63 return \Bitrix\Intranet\OutlookApplication::generateAppPassword($type);
64 }
65 else
66 {
67 return false;
68 }
69 }
70}
static getCurrent()
Definition context.php:241
static getUrl($type, $servicePath, $linkUrl, $prefix, $name, $guid)
Definition stssync.php:16