Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
icalutil.php
1<?php
2
3
5
6
12
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}
static getIndexUsersById(array $usersId)
Definition icalutil.php:79
static getUsersByCode(array $attendeesCodeList=null)
Definition icalutil.php:106
static getUserIdByEmail(array $userInfo)
Definition icalutil.php:43
static prepareAttendeesToCancel($attendees)
Definition icalutil.php:62
static processDestinationUserEmail($params, &$errorText)
Definition icalutil.php:37