1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
rest.php
См. документацию.
1<?php
2
3if (!CModule::IncludeModule('rest'))
4 return;
5
7{
8
9 public static function OnRestServiceBuildDescription()
10 {
11 return array(
12 'mailservice' => array(
13 'mailservice.fields' => array('CMailRestService', 'mailserviceFields'),
14 'mailservice.list' => array('CMailRestService', 'mailserviceList'),
15 'mailservice.get' => array('CMailRestService', 'mailserviceGet'),
16 'mailservice.add' => array('CMailRestService', 'mailserviceAdd'),
17 'mailservice.update' => array('CMailRestService', 'mailserviceUpdate'),
18 'mailservice.delete' => array('CMailRestService', 'mailserviceDelete'),
19 ),
20 );
21 }
22
23 public static function mailserviceFields($arParams)
24 {
25 IncludeModuleLangFile(__FILE__);
26
27 return array(
28 'ID' => 'ID',
29 'SITE_ID' => GetMessage('MAIL_MAILSERVICE_SITE_ID'),
30 'ACTIVE' => GetMessage('MAIL_MAILSERVICE_ACTIVE'),
31 //'SERVICE_TYPE' => GetMessage('MAIL_MAILSERVICE_TYPE'),
32 'NAME' => GetMessage('MAIL_MAILSERVICE_NAME'),
33 'SERVER' => GetMessage('MAIL_MAILSERVICE_SERVER'),
34 'PORT' => GetMessage('MAIL_MAILSERVICE_PORT'),
35 'ENCRYPTION' => GetMessage('MAIL_MAILSERVICE_ENCRYPTION'),
36 'LINK' => GetMessage('MAIL_MAILSERVICE_LINK'),
37 'ICON' => GetMessage('MAIL_MAILSERVICE_ICON'),
38 //'TOKEN' => GetMessage('MAIL_MAILSERVICE_TOKEN'),
39 'SORT' => GetMessage('MAIL_MAILSERVICE_SORT'),
40 );
41 }
42
43 public static function mailserviceList($arParams)
44 {
45 IncludeModuleLangFile(__FILE__);
46
47 $result = Bitrix\Mail\MailServicesTable::getList(array(
48 'filter' => array('ACTIVE' => 'Y', '=SITE_ID' => SITE_ID),
49 'order' => array('SORT' => 'ASC', 'NAME' => 'ASC')
50 ));
51
52 $data = array();
53 while ($row = $result->fetch())
54 {
55 unset($row['SERVICE_TYPE'], $row['TOKEN'], $row['FLAGS']);
56 $row['ICON'] = Bitrix\Mail\MailServicesTable::getIconSrc($row['NAME'], $row['ICON']);
57
58 $data[] = $row;
59 }
60
61 if (empty($data))
62 throw new Exception(GetMessage('MAIL_MAILSERVICE_LIST_EMPTY'));
63
64 return $data;
65 }
66
67 public static function mailserviceGet($arParams)
68 {
69 IncludeModuleLangFile(__FILE__);
70
71 if (empty($arParams['ID']))
72 throw new Exception(GetMessage('MAIL_MAILSERVICE_EMPTY_ID'));
73
74 $result = Bitrix\Mail\MailServicesTable::getList(array(
75 'filter' => array('=ID' => $arParams['ID'], '=SITE_ID' => SITE_ID)
76 ));
77
78 if ($data = $result->fetch())
79 {
80 unset($data['SERVICE_TYPE'], $data['TOKEN'], $data['FLAGS']);
82 }
83
84 if (empty($data))
85 throw new Exception(GetMessage('MAIL_MAILSERVICE_EMPTY'));
86
87 return $data;
88 }
89
90 public static function mailserviceAdd($arParams)
91 {
92 global $USER;
93
94 if (!$USER->CanDoOperation('bitrix24_config'))
95 throw new Exception(GetMessage('ACCESS_DENIED'));
96
98 'SITE_ID' => SITE_ID,
99 'ACTIVE' => $arParams['ACTIVE'] ?: 'Y',
100 'SERVICE_TYPE' => 'imap',
101 'NAME' => $arParams['NAME'],
102 'SERVER' => $arParams['SERVER'],
103 'PORT' => $arParams['PORT'],
104 'ENCRYPTION' => $arParams['ENCRYPTION'],
105 'LINK' => $arParams['LINK'],
106 'ICON' => CRestUtil::saveFile($arParams['ICON']) ?: $arParams['ICON'],
107 //'TOKEN' => $arParams['TOKEN'],
108 'SORT' => $arParams['SORT'] ?: 100
109 );
110
112
113 if (!$result->isSuccess())
114 throw new Exception(join('; ', $result->getErrorMessages()));
115
116 return $result->getId();
117 }
118
119 public static function mailserviceUpdate($arParams)
120 {
121 global $USER;
122
123 IncludeModuleLangFile(__FILE__);
124
125 if (!$USER->CanDoOperation('bitrix24_config'))
126 throw new Exception(GetMessage('ACCESS_DENIED'));
127
128 if (empty($arParams['ID']))
129 throw new Exception(GetMessage('MAIL_MAILSERVICE_EMPTY_ID'));
130
131 $result = Bitrix\Mail\MailServicesTable::getList(array(
132 'filter' => array('=ID' => $arParams['ID'], '=SITE_ID' => SITE_ID)
133 ));
134
135 if (!$result->fetch())
136 throw new Exception(GetMessage('MAIL_MAILSERVICE_EMPTY'));
137
139 'ACTIVE' => $arParams['ACTIVE'],
140 'NAME' => $arParams['NAME'],
141 'SERVER' => $arParams['SERVER'],
142 'PORT' => $arParams['PORT'],
143 'ENCRYPTION' => $arParams['ENCRYPTION'],
144 'LINK' => $arParams['LINK'],
145 'ICON' => CRestUtil::saveFile($arParams['ICON']) ?: $arParams['ICON'],
146 //'TOKEN' => $arParams['TOKEN'],
147 'SORT' => $arParams['SORT']
148 );
149
150 foreach ($arFields as $name => $value)
151 {
152 if (empty($value))
153 unset($arFields[$name]);
154 }
155
157
158 if (!$result->isSuccess())
159 throw new Exception(join('; ', $result->getErrorMessages()));
160
161 return true;
162 }
163
164 public static function mailserviceDelete($arParams)
165 {
166 global $USER;
167
168 IncludeModuleLangFile(__FILE__);
169
170 if (!$USER->CanDoOperation('bitrix24_config'))
171 throw new Exception(GetMessage('ACCESS_DENIED'));
172
173 if (empty($arParams['ID']))
174 throw new Exception(GetMessage('MAIL_MAILSERVICE_EMPTY_ID'));
175
176 $result = Bitrix\Mail\MailServicesTable::getList(array(
177 'filter' => array('=ID' => $arParams['ID'], '=SITE_ID' => SITE_ID)
178 ));
179
180 if (!$result->fetch())
181 throw new Exception(GetMessage('MAIL_MAILSERVICE_EMPTY'));
182
184
185 if (!$result->isSuccess())
186 throw new Exception(join('; ', $result->getErrorMessages()));
187
188 return true;
189 }
190
191}
$arParams
Определения access_dialog.php:21
static delete($primary)
Определения mailservices.php:235
static add(array $data)
Определения mailservices.php:74
static getIconSrc($serviceName, $iconId=null)
Определения mailservices.php:185
static update($primary, array $data)
Определения mailservices.php:90
Определения rest.php:7
static mailserviceAdd($arParams)
Определения rest.php:90
static mailserviceDelete($arParams)
Определения rest.php:164
static OnRestServiceBuildDescription()
Определения rest.php:9
static mailserviceList($arParams)
Определения rest.php:43
static mailserviceGet($arParams)
Определения rest.php:67
static mailserviceUpdate($arParams)
Определения rest.php:119
static mailserviceFields($arParams)
Определения rest.php:23
Определения rest.php:896
$arFields
Определения dblapprove.php:5
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
global $USER
Определения csv_new_run.php:40
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
GetMessage($name, $aReplace=null)
Определения tools.php:3397
$name
Определения menu_edit.php:35
const SITE_ID
Определения sonet_set_content_view.php:12