- Модуль: im
- Путь к файлу: ~/bitrix/modules/im/classes/general/im_message_param.php
- Класс: CIMMessageParam
- Вызов: CIMMessageParam::Get
static function Get($messageId, $paramName = false, $withDefault = false)
{
$arResult = array();
if (is_array($messageId))
{
if (!empty($messageId))
{
foreach ($messageId as $key => $value)
{
$messageId[$key] = intval($value);
$arResult[$messageId[$key]] = Array();
}
}
else
{
return $arResult;
}
}
else
{
$messageId = intval($messageId);
if ($messageId <= 0)
{
return false;
}
$arResult[$messageId] = Array();
}
$filter = array(
'=MESSAGE_ID' => $messageId,
);
if ($paramName && $paramName <> '')
{
$filter['=PARAM_NAME'] = $paramName;
}
$messageParameters = IMModelMessageParamTable::getList(array(
'select' => array('ID', 'MESSAGE_ID', 'PARAM_NAME', 'PARAM_VALUE', 'PARAM_JSON'),
'filter' => $filter,
));
while($ar = $messageParameters->fetch())
{
if (in_array($ar["PARAM_NAME"], Array('KEYBOARD', 'MENU', 'ATTACH', 'NAME', 'IMOL_VOTE_TEXT', 'IMOL_VOTE_LIKE', 'IMOL_VOTE_DISLIKE', 'IMOL_COMMENT_HEAD')))
{
$ar['PARAM_VALUE'] = BitrixImText::decodeEmoji($ar['PARAM_VALUE']);
}
if ($ar["PARAM_JSON"] <> '')
{
try
{
$value = BitrixMainWebJson::decode($ar["PARAM_JSON"]);
}
catch (BitrixMainSystemException $e)
{
}
}
else
{
$value = $ar["PARAM_VALUE"];
}
if (in_array($ar["PARAM_NAME"], Array('KEYBOARD', 'MENU')))
{
$arResult[$ar["MESSAGE_ID"]][$ar["PARAM_NAME"]] = $value;
}
else
{
$arResult[$ar["MESSAGE_ID"]][$ar["PARAM_NAME"]][] = $value;
}
}
if (is_array($messageId))
{
foreach ($messageId as $key)
{
$arResult[$key] = self::PrepareValues($arResult[$key], $withDefault);
}
}
else
{
$arResult = self::PrepareValues($arResult[$messageId], $withDefault);
}
if ($paramName)
{
$arResult = isset($arResult[$paramName])? $arResult[$paramName]: null;
}
return $arResult;
}