<?php
  
/*
---------------
Темы субраздела
---------------
*/
  
$subsection = DB::GET_STRING("SELECT * FROM `FORUM_SUB_SECTION` WHERE `ID` = '".INTVAL(GET('id'))."' LIMIT 1");
$section = DB::GET_STRING("SELECT * FROM `FORUM_SECTION` WHERE `ID` = '".$subsection['SECTION_ID']."' LIMIT 1");
  
IF (!ISSET($subsection['ID'])){
  
  ERROR('Неверная директива', 'session');
  REDIRECT('/index');
  
}

//Редактирование подраздела
IF (GET('get') == "edit"){  
  
  IF (ACCESS('forum_section', NULL, 1) || MANAGEMENT == 1){
    
    REQUIRE (ROOT.'/modules/forum/plugins/subsection_edit.php');
    
  }
  
}

//Удаление подраздела
IF (GET('get') == "delete_ok"){  
  
  IF (ACCESS('forum_section', NULL, 1) || MANAGEMENT == 1){
    
    REQUIRE (ROOT.'/modules/forum/plugins/subsection_delete.php');
    
  }
  
}

//Навигация
ECHO "<div class='navigation'>";
ECHO "<a href='/'>".ICONS('home', 25, 'fa-fw')."</a>";
ECHO "".ICONS('angle-right', 20, 'fa-fw')."";
ECHO "<a href='/modules/?path=forum'>".LG('Форум')."</a>";
ECHO "".ICONS('angle-right', 20, 'fa-fw')."";
ECHO "<a href='/modules/?path=forum&section=subsection&id=".$section['ID']."'>".TEXT_ABSOLUTE($section['NAME'])."</a>";
ECHO "".ICONS('angle-right', 20, 'fa-fw')."";
ECHO "".TEXT_ABSOLUTE($subsection['NAME'])."";
ECHO "</div>";

//Удаление раздела
IF (GET('get') == "delete"){  
  
  IF (ACCESS('forum_section', NULL, 1) || MANAGEMENT == 1){
    
    ECHO "<div class='list'>";
    ECHO "".LG('Вы действительно хотите удалить подраздел')." <b>".TEXT_ABSOLUTE($subsection['NAME'])."</b>?<br /><br />";
    ECHO "<a href='/modules/?path=forum&section=subsection_themes&id=".$subsection['ID']."&get=delete_ok' class='btn'>".ICONS('trash', 15, 'fa-fw')." ".LG('Удалить')."</a>";
    ECHO "<a href='/modules/?path=forum&section=subsection_themes&id=".$subsection['ID']."' class='btn-o'>".ICONS('times', 15, 'fa-fw')." ".LG('Отмена')."</a>";
    ECHO "</div>";
    
  }
  
}

IF (ISSET($user)){
  
  //Добавление темы
  IF (GET('them') == "add"){  
    
    REQUIRE (ROOT.'/modules/forum/plugins/them_add.php');
    
  }
  
  ECHO "<div class='list'>";
  
  ECHO "<a href='/modules/?path=forum&section=subsection_themes&id=".$subsection['ID']."&them=add' class='btn'>".ICONS('plus', 15, 'fa-fw')." ".LG('Создать тему')."</a>";
  
  IF (ACCESS('forum_section', NULL, 1) || MANAGEMENT == 1){
    
    ECHO "<a href='/modules/?path=forum&section=subsection_themes&id=".$subsection['ID']."&get=edit' class='btn'>".ICONS('pencil', 15, 'fa-fw')." ".LG('Редактировать подраздел')."</a>";
    
    ECHO "<a href='/modules/?path=forum&section=subsection_themes&id=".$subsection['ID']."&get=delete' class='btn'>".ICONS('times', 15, 'fa-fw')." ".LG('Удалить подраздел')."</a>";
    
  }
  
  ECHO "</div>";
  
}
  
$column = DB::GET_COLUMN("SELECT COUNT(*) FROM `FORUM_THEM` WHERE `SUB_SECTION_ID` = '".$subsection['ID']."'");
$spage = SPAGE($column, $page_settings);
$page = PAGE($spage);
$limit = $page_settings * $page - $page_settings;
  
IF ($column == 0){ 
  
  HTML::EMPTY();

}ELSE{
  
  ECHO "<div class='list-body'>"; 

}

$data = DB::GET_STRING_ALL("SELECT * FROM `FORUM_THEM` WHERE `SUB_SECTION_ID` = '".$subsection['ID']."' ORDER BY `TIME` DESC LIMIT ".$limit.", ".$page_settings."");

WHILE ($list = $data->FETCH()){
  
  REQUIRE (ROOT.'/modules/forum/plugins/them_list.php');

}

IF ($column > 0){
  
  ECHO "</div>";

}

IF ($spage > 1){ ECHO STR_PAGE('/modules/?path=forum&section=subsection_themes&id='.$subsection['ID'].'&', $spage, $page); }

ECHO "<div class='list'>";
ECHO "<a href='/modules/?path=forum&section=subsection&id=".$section['ID']."'>".ICONS('arrow-left', 15, 'fa-fw')." ".LG('Назад')."</a>";
ECHO "</div>";

//Навигация
ECHO "<div class='navigation'>";
ECHO "<a href='/'>".ICONS('home', 25, 'fa-fw')."</a>";
ECHO "".ICONS('angle-right', 20, 'fa-fw')."";
ECHO "<a href='/modules/?path=forum'>".LG('Форум')."</a>";
ECHO "".ICONS('angle-right', 20, 'fa-fw')."";
ECHO "<a href='/modules/?path=forum&section=subsection&id=".$section['ID']."'>".TEXT_ABSOLUTE($section['NAME'])."</a>";
ECHO "".ICONS('angle-right', 20, 'fa-fw')."";
ECHO "".TEXT_ABSOLUTE($subsection['NAME'])."";
ECHO "</div>";
  
?>