<?php
  
$par = DB::GET_STRING("SELECT `ADMINISTRATION`,`USER_ID`,`ID`,`ACT` FROM `COMMUNITIES_PAR` WHERE `COMMUNITY_ID` = '".$comm['ID']."' AND `USER_ID` = '".$user['ID']."' AND `ACT` = '1' LIMIT 1");

IF (!ISSET($comm['ID'])){
  
  ERROR('Неверная директива', 'session');
  REDIRECT('/modules/?path=communities');

}

//Навигация
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=communities'>".LG('Сообщества')."</a>";
ECHO "".ICONS('angle-right', 20, 'fa-fw')."";
ECHO "<a href='/modules/?path=communities&section=show&id=".$comm['ID']."'>".TEXT_ABSOLUTE($comm['NAME'])."</a>";
ECHO "".ICONS('angle-right', 20, 'fa-fw')."";
ECHO LG('Форум');
ECHO "</div>";

//Добавление раздела
IF (GET('get') == "add"){  
  
  IF (ISSET($par['ID']) && $par['ADMINISTRATION'] == 1 || MANAGEMENT == 1 || ACCESS('communities', NULL, 1)){
    
    REQUIRE (ROOT.'/modules/communities/plugins/forum_section_add.php');
    
  }
  
}

IF (ISSET($user)){ 
  
  ECHO "<div class='list'>";
  
  IF (ISSET($par['ID']) && $par['ADMINISTRATION'] == 1 || MANAGEMENT == 1 || ACCESS('communities', NULL, 1)){
    
    ECHO "<a href='/modules/?path=communities&section=forum_section&id=".$comm['ID']."&get=add' class='btn'>".ICONS('plus', 15, 'fa-fw')." ".LG('Добавить раздел')."</a>";
    
  }
  
  ECHO "<a href='/modules/?path=communities&section=forum_section&id=".$comm['ID']."&get=users' class='btn-o'>".ICONS('user', 15, 'fa-fw')." ".LG('Мои темы')."</a>";
  
  ECHO "</div>";
  
}

$column = DB::GET_COLUMN("SELECT COUNT(*) FROM `COMMUNITIES_FORUM_SECTION` WHERE `COMMUNITY_ID` = '".$comm['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 `COMMUNITIES_FORUM_SECTION` WHERE `COMMUNITY_ID` = '".$comm['ID']."' ORDER BY `ID` DESC LIMIT ".$limit.", ".$page_settings."");

WHILE ($list = $data->FETCH())
{
  
  $count = DB::GET_COLUMN("SELECT COUNT(*) FROM `COMMUNITIES_FORUM_THEM` WHERE `SECTION_ID` = '".$list['ID']."'");
  
  ECHO "<a href='/modules/?path=communities&section=forum_section_themes&id=".$list['ID']."'><div class='list-menu hover'><span class='icons'>".ICONS('angle-double-right', 23, 'fa-fw')."</span><b>".TEXT_ABSOLUTE($list['NAME'])."</b> <span class='count'>".$count."</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=communities&section=forum_section&id='.$comm['ID'].'&', $spage, $page); }

//Навигация
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=communities'>".LG('Сообщества')."</a>";
ECHO "".ICONS('angle-right', 20, 'fa-fw')."";
ECHO "<a href='/modules/?path=communities&section=show&id=".$comm['ID']."'>".TEXT_ABSOLUTE($comm['NAME'])."</a>";
ECHO "".ICONS('angle-right', 20, 'fa-fw')."";
ECHO LG('Форум');
ECHO "</div>";
  
?>