<?php

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

$data = DB::GET_STRING_ALL("SELECT * FROM `FORUM_SUB_SECTION` WHERE `SECTION_ID` = '".$section['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 `SECTION_ID` = '".$section['ID']."'");

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

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

}

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

?>