<?php

/*
----------------------------------------
Удаление комментариев и лайков к новости
----------------------------------------
*/

DB::GET_SET("DELETE FROM `NEWS_LIKES` WHERE `NEWS_ID` = '".$news['ID']."'");

DB::GET_SET("DELETE FROM `NEWS_EYE` WHERE `NEWS_ID` = '".$news['ID']."'");

$data = DB::GET_STRING_ALL("SELECT `ID` FROM `NEWS_COMMENTS` WHERE `NEWS_ID` = '".$news['ID']."'");

WHILE ($list = $data->FETCH()){
  
  DB::GET_SET("DELETE FROM `NEWS_COMMENTS_LIKES` WHERE `COMMENT_ID` = '".$list['ID']."'");
  
  DB::GET_SET("DELETE FROM `ATTACHMENTS` WHERE `ID_POST` = '".$list['ID']."' AND `TYPE_POST` = 'news_comments'");
  
  DB::GET_SET("DELETE FROM `NEWS_COMMENTS` WHERE `ID` = '".$list['ID']."' LIMIT 1");
  
}

/*
----------------------
Удаление самой новости
----------------------
*/

DB::GET_SET("DELETE FROM `ATTACHMENTS` WHERE `ID_POST` = '".$list['ID']."' AND `NEWS` = '1'");
  
DB::GET_SET("DELETE FROM `NEWS` WHERE `ID` = '".$news['ID']."' AND `USER_ID` = '".$account['ID']."'");

SUCCESS('Запись успешно удалена', 'session');
REDIRECT('/modules/?path=news&section=users&id='.$account['ID'].'');

?>