<?php

$subsection = DB::GET_STRING("SELECT * FROM `FORUM_SUB_SECTION` WHERE `ID` = '".INTVAL(GET('id'))."' LIMIT 1");
  
IF (!ISSET($subsection['ID'])){
  
  ERROR('Неверная директива', 'session');
  REDIRECT('/index');
  
}

$data = DB::GET_STRING_ALL("SELECT * FROM `FORUM_SUB_SECTION` WHERE `ID` = '".$subsection['ID']."'");
WHILE ($list = $data->FETCH()){
  
  $them = DB::GET_STRING("SELECT * FROM `FORUM_THEM` WHERE `SUB_SECTION_ID` = '".$list['ID']."' LIMIT 1");
  
  DB::GET_SET("DELETE FROM `FORUM_THEM` WHERE `ID` = '".$them['ID']."'");
  DB::GET_SET("DELETE FROM `FORUM_THEM_COMMENTS` WHERE `THEM_ID` = '".$them['ID']."'");
  
}

DB::GET_SET("DELETE FROM `FORUM_SUB_SECTION` WHERE `ID` = '".$subsection['ID']."'");

IF (ACCESS('forum_section', NULL, 1) || MANAGEMENT == 1){
  
  LOGS('Форум - удаление подраздела', $user['ID']);

}

SUCCESS('Подраздел успешно удален', 'session');
REDIRECT('/modules/?path=forum');

?>