1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
addressbook.php
См. документацию.
1<?php
2
4
10
16{
17 private function editContact($contactData): ItemCollection
18 {
19 $id = $contactData['ID'];
20 $userID = MailContactTable::getRow(
21 [
22 'filter' => ['ID' => $id],
23 'select' => ['USER_ID'],
24 ]
25 )['USER_ID'];
26
27 $currentUserId = $this->getCurrentUser()?->getId();
28
29 if (is_null($currentUserId) || !((int)$this->getCurrentUser()?->getId() === (int)$userID &&
30 $contactData['NAME'] <> "" &&
31 check_email($contactData['EMAIL'])))
32 {
34 }
35
36 MailContactTable::update(
37 $id,
38 [
39 'ICON' => [
40 'INITIALS' => $contactData['INITIALS'],
41 'COLOR' => $contactData['COLOR'],
42 ],
43 'NAME' => trim($contactData['NAME']),
44 'EMAIL' => $contactData['EMAIL'],
45 ]
46 );
47
49 [
50 'email' => $contactData['EMAIL'],
51 'name' => $contactData['NAME'],
52 ],
53 ]);
54 }
55
56 private function isUserAdmin()
57 {
58 global $USER;
59 if (!(is_object($USER) && $USER->IsAuthorized()))
60 {
61 return false;
62 }
63
64 return $USER->isAdmin() || $USER->canDoOperation('bitrix24_config');
65 }
66
73 public function removeContactsAction($idSet)
74 {
75 $currentUserId = $this->getCurrentUser()?->getId();
76
77 if (!Loader::includeModule('mail') || is_null($currentUserId))
78 {
79 return false;
80 }
81
82 foreach ($idSet as $id)
83 {
84 $contactToDelete = MailContactTable::getRow(
85 [
86 'filter' => [
87 '=ID' => $id,
88 '=USER_ID' => $currentUserId,
89 ],
90 ]
91 );
92
93 if (is_null($contactToDelete))
94 {
95 return false;
96 }
97
98 MailContactTable::delete($id);
99 }
100
101 return true;
102 }
103
108 public function getContactIdByEmailAction(string $email): int
109 {
110 $currentUserId = $this->getCurrentUser()?->getId();
111
112 if (is_null($currentUserId) || !Loader::includeModule('mail'))
113 {
114 return 0;
115 }
116
117 return MailContactTable::getContactByEmail($email, $currentUserId)['ID'];
118 }
119
125 public function saveContactAction($contactData): ItemCollection
126 {
127 $selectedRecipientsForDialog = Message::getSelectedRecipientsForDialog();
128
129 if (!Loader::includeModule('mail'))
130 {
131 return $selectedRecipientsForDialog;
132 }
133
134 $contactData['EMAIL'] = mb_strtolower($contactData['EMAIL']);
135
136 if(!check_email($contactData['EMAIL']))
137 {
138 return $selectedRecipientsForDialog;
139 }
140
141 if ($contactData['ID'] !== 'new')
142 {
143 return $this->editContact($contactData);
144 }
145 else
146 {
147 $currentUserId = $this->getCurrentUser()?->getId();
148
149 if (is_null($currentUserId))
150 {
151 return $selectedRecipientsForDialog;
152 }
153
154 $contactsData[] = [
155 'USER_ID' => $currentUserId,
156 'NAME' => $contactData['NAME'],
157 'ICON' => [
158 'INITIALS' => $contactData['INITIALS'],
159 'COLOR' => $contactData['COLOR'],
160 ],
161 'EMAIL' => $contactData['EMAIL'],
162 'ADDED_FROM' => 'MANUAL',
163 ];
164
165 $result = MailContactTable::addContactsBatch($contactsData);
166
167 if (!$result->isSuccess())
168 {
169 $this->addErrors($result->getErrors());
170
171 return $selectedRecipientsForDialog;
172 }
173 }
174
176 [
177 'email' => $contactData['EMAIL'],
178 'name' => $contactData['NAME'],
179 ],
180 ]);
181 }
182}
removeContactsAction($idSet)
Определения addressbook.php:73
saveContactAction($contactData)
Определения addressbook.php:125
getContactIdByEmailAction(string $email)
Определения addressbook.php:108
static getSelectedRecipientsForDialog($recipients=[], $updateData=false)
Определения message.php:80
Определения loader.php:13
$result
Определения get_property_values.php:14
global $USER
Определения csv_new_run.php:40
check_email($email, $strict=false, $domainCheck=false)
Определения tools.php:4571
$email
Определения payment.php:49