- Модуль: pull
- Путь к файлу: ~/bitrix/modules/pull/classes/general/pull_channel.php
- Класс: CPullChannel
- Вызов: CPullChannel::DeleteByUser
static function DeleteByUser($userId, $channelId = null, $channelType = self::TYPE_PRIVATE)
{
global $DB, $CACHE_MANAGER;
$userId = intval($userId);
if ($userId == 0 && $channelType == self::TYPE_PRIVATE)
{
$channelType = self::TYPE_SHARED;
}
if (is_null($channelId))
{
$strSql = "SELECT CHANNEL_ID, CHANNEL_TYPE FROM b_pull_channel WHERE USER_ID = ".$userId." AND CHANNEL_TYPE = '".$DB->ForSQL($channelType)."'";
$res = $DB->Query($strSql);
if ($arRes = $res->Fetch())
{
$channelId = $arRes['CHANNEL_ID'];
$channelType = $arRes['CHANNEL_TYPE'];
}
}
if ($channelType == '')
$channelTypeSql = "(CHANNEL_TYPE = '' OR CHANNEL_TYPE IS NULL)";
else
$channelTypeSql = "CHANNEL_TYPE = '".$DB->ForSQL($channelType)."'";
$strSql = "DELETE FROM b_pull_channel WHERE USER_ID = ".$userId." AND ".$channelTypeSql;
$DB->Query($strSql, false, "File: ".__FILE__."
Line: ".__LINE__);
$CACHE_MANAGER->Clean("b_pchc_".$userId."_".$channelType, self::CACHE_TABLE);
$params = Array(
'action' => $channelType != self::TYPE_PRIVATE? 'reconnect': 'get_config',
'channel' => Array(
'id' => self::SignChannel($channelId),
'type' => $channelType,
),
);
if ($channelType != self::TYPE_PRIVATE)
{
$result = self::GetShared(false);
if (!$result)
{
return true;
}
$params['new_channel'] = Array(
'id' => self::SignChannel($result['CHANNEL_ID']),
'start' => $result['CHANNEL_DT'],
'end' => date('c', $result['CHANNEL_DT']+ self::CHANNEL_TTL),
'type' => $channelType,
);
}
$arMessage = Array(
'module_id' => 'pull',
'command' => 'channel_expire',
'params' => $params
);
CPullStack::AddByChannel($channelId, $arMessage);
return true;
}