• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/classes/general/im_notify.php
  • Класс: CIMNotify
  • Вызов: CIMNotify::DeleteWithCheck
public function DeleteWithCheck($id)
{
	global $DB;

	if (is_array($id) && count($id) === 1)
	{
		$id = $id[0];
	}

	if (is_array($id) && count($id) > 1)
	{
		$ids = array_map(static function($item) {
			return (int)$item;
		}, $id);

		$sqlWhere = "M.ID IN (" . implode(',', $ids) . ")";
	}
	else
	{
		$id = (int)$id;
		$sqlWhere = "M.ID = " . $id;
	}

	$strSql = "
		SELECT M.* FROM b_im_relation R, b_im_message M 
		WHERE ". $sqlWhere ." 
		AND R.USER_ID = ".$this->user_id." 
		AND R.MESSAGE_TYPE = '".IM_MESSAGE_SYSTEM."' 
		AND R.CHAT_ID = M.CHAT_ID
	";
	$dbRes = $DB->Query($strSql, false, "File: ".__FILE__."
Line: ".__LINE__); $notificationsToDelete = []; while ($arRes = $dbRes->Fetch()) { $notificationsToDelete[] = (int)$arRes['ID']; } if (count($notificationsToDelete) === 0) { return false; } if (count($notificationsToDelete) === 1) { self::Delete($notificationsToDelete[0]); } else { self::deleteList($notificationsToDelete); } return true; }