Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
icalutil.php
1
<?php
2
3
4
namespace
Bitrix\Calendar\ICal\Basic
;
5
6
7
use
Bitrix\Calendar\Util
;
8
use
Bitrix\Main\Loader
;
9
use
Bitrix\Main\Type\Date
;
10
use
Bitrix\Main\Type\DateTime
;
11
use
Bitrix\Main\UserTable
;
12
13
class
ICalUtil
14
{
15
public
static
function
isMailUser
($userId): bool
16
{
17
$parameters = [
18
'filter'
=> [
19
'ID'
=> $userId,
20
],
21
'select'
=> [
22
'ID'
,
'EXTERNAL_AUTH_ID'
,
23
],
24
'limit'
=> 1,
25
];
26
27
$userDd = UserTable::getList($parameters);
28
29
if
($user = $userDd->fetch())
30
{
31
return
$user[
'EXTERNAL_AUTH_ID'
] ===
'email'
;
32
}
33
34
return
false
;
35
}
36
37
public
static
function
processDestinationUserEmail
($params, &$errorText)
38
{
39
$userId = static::getExternalUserByEmail($params, $errorText);
40
return
$userId ? [
'U'
.$userId] : [];
41
}
42
43
public
static
function
getUserIdByEmail
(array $userInfo): ?string
44
{
45
$parameters = [
46
'filter'
=> [
47
'EMAIL'
=> $userInfo[
'EMAIL'
],
48
],
49
'select'
=> [
'ID'
,],
50
'limit'
=> 1,
51
];
52
53
$userDd = UserTable::getList($parameters);
54
if
($user = $userDd->fetch())
55
{
56
return
$user[
'ID'
];
57
}
58
59
return
self::getExternalUserByEmail($userInfo, $errorCollection);
60
}
61
62
public
static
function
prepareAttendeesToCancel
($attendees)
63
{
64
foreach
($attendees as $attendee)
65
{
66
$usersId[] = $attendee[
'id'
];
67
}
68
69
return
!empty($usersId) ?
self::getIndexUsersById
($usersId) :
null
;
70
}
71
79
public
static
function
getIndexUsersById
(array $usersId): array
80
{
81
$users = [];
82
$usersDd = UserTable::getList([
83
'filter'
=> [
84
'ID'
=> $usersId,
85
],
86
'select'
=> [
87
'ID'
,
88
'NAME'
,
89
'LAST_NAME'
,
90
'EMAIL'
,
91
],
92
]);
93
94
while
($user = $usersDd->fetch())
95
{
96
$users[$user[
'ID'
]] = $user;
97
}
98
99
return
$users;
100
}
101
106
public
static
function
getUsersByCode
(array $attendeesCodeList =
null
): array
107
{
108
$userIdsList = [];
109
foreach
($attendeesCodeList as $code)
110
{
111
if
(mb_strpos($code,
'U'
) === 0)
112
{
113
$userIdsList[] = (int)mb_substr($code, 1);
114
}
115
}
116
117
return
self::getIndexUsersById
($userIdsList);
118
}
119
}
Bitrix\Calendar\ICal\Basic\ICalUtil
Definition
icalutil.php:14
Bitrix\Calendar\ICal\Basic\ICalUtil\getIndexUsersById
static getIndexUsersById(array $usersId)
Definition
icalutil.php:79
Bitrix\Calendar\ICal\Basic\ICalUtil\getUsersByCode
static getUsersByCode(array $attendeesCodeList=null)
Definition
icalutil.php:106
Bitrix\Calendar\ICal\Basic\ICalUtil\getUserIdByEmail
static getUserIdByEmail(array $userInfo)
Definition
icalutil.php:43
Bitrix\Calendar\ICal\Basic\ICalUtil\isMailUser
static isMailUser($userId)
Definition
icalutil.php:15
Bitrix\Calendar\ICal\Basic\ICalUtil\prepareAttendeesToCancel
static prepareAttendeesToCancel($attendees)
Definition
icalutil.php:62
Bitrix\Calendar\ICal\Basic\ICalUtil\processDestinationUserEmail
static processDestinationUserEmail($params, &$errorText)
Definition
icalutil.php:37
Bitrix\Calendar\Util
Definition
util.php:16
Bitrix\Main\Loader
Definition
loader.php:12
Bitrix\Main\Type\Date
Definition
date.php:9
Bitrix\Main\Type\DateTime
Definition
datetime.php:9
Bitrix\Main\UserTable
Definition
user.php:46
Bitrix\Calendar\ICal\Basic
Definition
attachmentmanager.php:4
modules
calendar
lib
ical
basic
icalutil.php
Создано системой
1.10.0