- Модуль: mail
- Путь к файлу: ~/bitrix/modules/mail/classes/general/rest.php
- Класс: CMailRestService
- Вызов: CMailRestService::mailserviceUpdate
static function mailserviceUpdate($arParams)
{
global $USER;
IncludeModuleLangFile(__FILE__);
if (!$USER->CanDoOperation('bitrix24_config'))
throw new Exception(GetMessage('ACCESS_DENIED'));
if (empty($arParams['ID']))
throw new Exception(GetMessage('MAIL_MAILSERVICE_EMPTY_ID'));
$result = BitrixMailMailServicesTable::getList(array(
'filter' => array('=ID' => $arParams['ID'], '=SITE_ID' => SITE_ID)
));
if (!$result->fetch())
throw new Exception(GetMessage('MAIL_MAILSERVICE_EMPTY'));
$arFields = array(
'ACTIVE' => $arParams['ACTIVE'],
'NAME' => $arParams['NAME'],
'SERVER' => $arParams['SERVER'],
'PORT' => $arParams['PORT'],
'ENCRYPTION' => $arParams['ENCRYPTION'],
'LINK' => $arParams['LINK'],
'ICON' => CRestUtil::saveFile($arParams['ICON']) ?: $arParams['ICON'],
//'TOKEN' => $arParams['TOKEN'],
'SORT' => $arParams['SORT']
);
foreach ($arFields as $name => $value)
{
if (empty($value))
unset($arFields[$name]);
}
$result = BitrixMailMailServicesTable::update($arParams['ID'], $arFields);
if (!$result->isSuccess())
throw new Exception(join('; ', $result->getErrorMessages()));
return true;
}