- Модуль: intranet
- Путь к файлу: ~/bitrix/modules/intranet/lib/contactcenter.php
- Класс: BitrixIntranetContactCenter
- Вызов: ContactCenter::getConnectorListItem
private function getConnectorListItem(string $connectorCode, array $configList, array $statusList): array
{
if (!Loader::includeModule("imconnector") || !Loader::includeModule("imopenlines"))
{
return [];
}
$connectorCode = htmlspecialcharsbx(CUtil::JSescape($connectorCode));
$sliderWidth = 700;
$openLineSliderPath = Common::getContactCenterPublicFolder() . "connector/?ID={$connectorCode}&LINE=#LINE#&action-line=create";
$infoConnectors = ImConnectorInfoConnectors::getInfoConnectorsList();
if (count($configList) > 0)
{
foreach ($configList as &$configItem)
{
//getting status if connector is connected for the open line
$status = $statusList[$connectorCode][$configItem["ID"]] ?? null;
if (!empty($status) && ($status instanceof ImConnectorStatus) && $status->isStatus())
{
$configItem["STATUS"] = 1;
}
else
{
$configItem["STATUS"] = 0;
}
//getting connected channel name
$channelInfo = $infoConnectors[$configItem["ID"]];
try
{
$channelData = JSON::decode($channelInfo['DATA']);
if (isset($channelData[$connectorCode]['name']) && is_string($channelData[$connectorCode]['name']))
{
$channelName = trim($channelData[$connectorCode]['name']);
}
else
{
$channelName = '';
}
}
catch (BitrixMainArgumentException $exception)
{
$channelName = '';
}
$configItem["NAME"] = htmlspecialcharsbx($configItem["NAME"]);
if (!empty($channelName))
{
$channelName = htmlspecialcharsbx($channelName);
$configItem["NAME"] .= " ({$channelName})";
}
elseif ($configItem["STATUS"] === 1)
{
$connectedMessage = Loc::getMessage("CONTACT_CENTER_IMOPENLINES_CONNECTED_CONNECTOR");
$configItem["NAME"] .= " ({$connectedMessage})";
}
$itemPath = str_replace('#LINE#', $configItem["ID"], $openLineSliderPath);
$configItem["ONCLICK"] = "BX.SidePanel.Instance.open('$itemPath', {width: $sliderWidth})";
}
unset($configItem);
//configured open lines are higher than not configured
usort($configList, static function($first, $second){
return ($second['STATUS'] - $first['STATUS']);
});
//delimiter between configured open lines and not configured
foreach ($configList as $key => $configItem)
{
if ($configItem['STATUS'] === 0)
{
$configList[$key]['DELIMITER_BEFORE'] = true;
break;
}
}
$userPermissions = Permissions::createWithCurrentUser();
if ($userPermissions->canPerform(Permissions::ENTITY_LINES, Permissions::ACTION_MODIFY))
{
$configList[] = [
'NAME' => Loc::getMessage("CONTACT_CENTER_IMOPENLINES_CREATE_OPEN_LINE"),
'ID' => 0,
'DELIMITER_BEFORE' => true,
'ONCLICK' => "new BX.Imopenlines.CreateLine({path:'{$openLineSliderPath}', sliderWidth:{$sliderWidth}});",
];
}
}
return $configList;
}