<?php

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

$data = DB::GET_STRING_ALL("SELECT * FROM `COMMUNITIES_FORUM_THEM` WHERE `SECTION_ID` = '".$section['ID']."'");
WHILE ($list = $data->FETCH()){
  
  DB::GET_SET("DELETE FROM `FORUM_THEM_COMMENTS` WHERE `THEM_ID` = '".$list['ID']."'");
  DB::GET_SET("DELETE FROM `FORUM_THEM` WHERE `ID` = '".$list['ID']."'");
  
}

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

SUCCESS('Раздел успешно удален', 'session');
REDIRECT('/modules/?path=communities&section=forum_section&id='.$section['COMMUNITY_ID']);

?>