- Модуль: im
- Путь к файлу: ~/bitrix/modules/im/lib/textareaicon.php
- Класс: BitrixImTextareaIcon
- Вызов: TextareaIcon::update
static function update(array $icon, array $updateFields)
{
$iconId = intval($icon['ICON_ID']);
$userId = intval($icon['USER_ID']);
$moduleId = isset($icon['MODULE_ID'])? $icon['MODULE_ID']: '';
$appId = isset($icon['APP_ID'])? $icon['APP_ID']: '';
if (intval($iconId) <= 0)
return false;
$commands = self::getListCache();
if (!isset($commands[$iconId]))
return false;
if (strlen($moduleId) > 0 && $commands[$iconId]['MODULE_ID'] != $moduleId)
return false;
if (strlen($appId) > 0 && $commands[$iconId]['APP_ID'] != $appId)
return false;
if (isset($updateFields['LANG']) && $commands[$iconId]['MODULE_ID'] == 'rest')
{
$orm = BitrixImModelTextareaIconLangTable::getList(Array(
'filter' => Array('=ICON_ID' => $iconId)
));
while ($row = $orm->fetch())
{
BitrixImModelTextareaIconLangTable::delete($row['ID']);
}
foreach ($updateFields['LANG'] as $lang)
{
if (!isset($lang['LANGUAGE_ID']) || empty($lang['LANGUAGE_ID']))
continue;
if (!isset($lang['TITLE']) && empty($lang['TITLE']))
continue;
try
{
BitrixImModelTextareaIconLangTable::add(array(
'ICON_ID' => $iconId,
'LANGUAGE_ID' => strtolower($lang['LANGUAGE_ID']),
'TITLE' => $lang['TITLE'],
'DESCRIPTION' => $lang['DESCRIPTION'],
'COPYRIGHT' => $lang['COPYRIGHT']
));
}
catch(Exception $e)
{
}
}
}
$update = Array();
if (isset($updateFields['CONTEXT']) && !empty($updateFields['CONTEXT']))
{
$update['CONTEXT'] = ToLower($updateFields['CONTEXT']);
}
if (isset($updateFields['HASH']) && !empty($updateFields['HASH']))
{
$update['HASH'] = $updateFields['HASH'];
}
if (isset($updateFields['HIDDEN']))
{
$update['HIDDEN'] = $updateFields['HIDDEN'] == 'Y'? 'Y': 'N';
}
if (isset($updateFields['IFRAME']) && !empty($updateFields['IFRAME']))
{
$check = parse_url($updateFields['IFRAME']);
if (!isset($check['scheme']) && !isset($check['host']))
{
if (strpos($updateFields['IFRAME'], '/desktop_app/iframe/') !== 0)
{
return false;
}
}
else if (!in_array($check['scheme'], Array('http', 'https')) || empty($check['host']))
{
return false;
}
$update['IFRAME'] = $updateFields['IFRAME'].(isset($check['query'])? '&': '?');
}
else if (isset($updateFields['JS']) && !empty($updateFields['JS']))
{
$update['JS'] = $updateFields['JS'];
}
if (isset($updateFields['IFRAME_WIDTH']))
{
$update['IFRAME_WIDTH'] = intval($updateFields['IFRAME_WIDTH']) > 250? intval($updateFields['IFRAME_WIDTH']): 350;
}
if (isset($updateFields['IFRAME_HEIGHT']))
{
$update['IFRAME_HEIGHT'] = intval($updateFields['IFRAME_HEIGHT']) > 50? intval($updateFields['IFRAME_HEIGHT']): 150;
}
if (isset($updateFields['ICON_FILE_ID']))
{
$update['ICON_FILE_ID'] = intval($updateFields['ICON_FILE_ID']);
}
if (isset($updateFields['CLASS']) && !empty($updateFields['CLASS']))
{
$update['CLASS'] = $updateFields['CLASS'];
}
if (isset($updateFields['METHOD_LANG_GET']))
{
$update['METHOD_LANG_GET'] = $updateFields['METHOD_LANG_GET'];
}
if (isset($updateFields['EXTRANET_SUPPORT']))
{
$update['EXTRANET_SUPPORT'] = $updateFields['EXTRANET_SUPPORT'] == 'Y'? 'Y': 'N';
}
if (!empty($update))
{
BitrixImModelTextareaIconTable::update($iconId, $update);
$cache = BitrixMainDataCache::createInstance();
$cache->cleanDir(self::CACHE_PATH);
}
if (BitrixMainLoader::includeModule('pull'))
{
if ($update['HASH'] || $update['CONTEXT'] || $update['IFRAME'] || $update['JS'] || $update['IFRAME_WIDTH'] || $update['IFRAME_HEIGHT'])
{
CPullStack::AddShared(Array(
'module_id' => 'im',
'command' => 'updateTextareaIcon',
'params' => Array(
'iconId' => $iconId,
'userId' => $userId,
'hash' => $update['HASH'],
'context' => $update['CONTEXT'],
'js' => $update['JS'],
'iframe' => $update['IFRAME'],
'iframeWidth' => $update['IFRAME_WIDTH'],
'iframeHeight' => $update['IFRAME_HEIGHT'],
)
));
}
else
{
CPullStack::AddShared(Array(
'module_id' => 'im',
'command' => 'deleteTextareaIcon',
'params' => Array(
'iconId' => $iconId
)
));
}
}
return true;
}