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

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

//Удаление раздела
IF (GET('get') == "delete_ok"){  
  
  IF (ACCESS('forum_section', NULL, 1) || MANAGEMENT == 1){
    
    REQUIRE (ROOT.'/modules/forum/plugins/section_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 "".TEXT_ABSOLUTE($section['NAME'])."";
ECHO "</div>";

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

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

IF (ACCESS('forum_section', NULL, 1) || MANAGEMENT == 1){
  
  ECHO "<div class='list'>";
  
  ECHO "<a href='/modules/?path=forum&section=subsection&id=".$section['ID']."&get=add' class='btn'>".ICONS('plus', 15, 'fa-fw')." ".LG('Добавить подраздел')."</a>";
  
  ECHO "<a href='/modules/?path=forum&section=subsection&id=".$section['ID']."&get=edit' class='btn'>".ICONS('pencil', 15, 'fa-fw')." ".LG('Редактировать раздел')."</a>";
  
  ECHO "<a href='/modules/?path=forum&section=subsection&id=".$section['ID']."&get=delete' class='btn'>".ICONS('times', 15, 'fa-fw')." ".LG('Удалить раздел')."</a>";
  
  ECHO "</div>";
  
}
  
$column = DB::GET_COLUMN("SELECT COUNT(*) FROM `FORUM_SUB_SECTION` WHERE `SECTION_ID` = '".$section['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_SUB_SECTION` WHERE `SECTION_ID` = '".$section['ID']."' ORDER BY `ID` DESC LIMIT ".$limit.", ".$page_settings."");

WHILE ($list = $data->FETCH()){
  
  $thems = DB::GET_COLUMN("SELECT COUNT(*) FROM `FORUM_THEM` WHERE `SUB_SECTION_ID` = '".$list['ID']."'");
  $comments = DB::GET_COLUMN("SELECT COUNT(*) FROM `FORUM_THEM_COMMENTS` WHERE `SUB_SECTION_ID` = '".$list['ID']."'");
  
  ECHO "<a href='/modules/?path=forum&section=subsection_themes&id=".$list['ID']."'><div class='list-menu hover'><b>".TEXT_ABSOLUTE($list['NAME'])."</b> <span class='count'>".$thems."/".$comments."</span><br />";
  ECHO "<font color='#7B8285'><small>".TEXT($list['MESSAGE'])."</small></font></div></a>";

}

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

}

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

ECHO "<div class='list'>";
ECHO "<a href='/modules/?path=forum'>".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 "".TEXT_ABSOLUTE($section['NAME'])."";
ECHO "</div>";
  
?>