<?php
  
$account = DB::GET_STRING("SELECT * FROM `USERS` WHERE `ID` = '".INTVAL(GET('id'))."' LIMIT 1");

IF (!$account['ID']){
  
  ERROR('Такого пользователя не существует', 'session');
  REDIRECT('/modules/?path=blogs');

}

/*
---------------
Добавить запись
---------------
*/

IF (GET('get') == 'add' && $account['ID'] == $user['ID']){
  
  REQUIRE (ROOT.'/modules/blogs/plugins/add.php');
  
}

/*
--------------
Список записей
--------------
*/
  
//Навигация
ECHO "<div class='navigation'>";
ECHO "<a href='/'>".ICONS('home', 25, 'fa-fw')."</a>";
ECHO "".ICONS('angle-right', 20, 'fa-fw')."";
ECHO "<a href='/id".$account['ID']."'>".$account['LOGIN']."</a>";
ECHO "".ICONS('angle-right', 20, 'fa-fw')."";
ECHO "".LG('Блог')." ".$account['LOGIN']."";
ECHO "</div>";

IF ($account['ID'] == $user['ID']){
  
  ECHO "<div class='list'>";
  ECHO "<a href='/modules/?path=blogs&section=users&id=".$account['ID']."&get=add' class='btn'>".ICONS('pencil', 15, 'fa-fw')."".LG('Создать запись')."</a>";
  ECHO "</div>";
  
}

$column = DB::GET_COLUMN("SELECT COUNT(*) FROM `BLOGS` WHERE `USER_ID` = '".$account['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 `BLOGS` WHERE `USER_ID` = '".$account['ID']."' ORDER BY `TIME` DESC LIMIT ".$limit.", ".$page_settings."");
WHILE ($list = $data->FETCH())
{
  
  REQUIRE (ROOT.'/modules/blogs/plugins/blogs_list.php');

}

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

IF ($spage > 1){ ECHO STR_PAGE('/modules/?path=blogs&section=users&id='.$account['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='/id".$account['ID']."'>".$account['LOGIN']."</a>";
ECHO "".ICONS('angle-right', 20, 'fa-fw')."";
ECHO "".LG('Блог')." ".$account['LOGIN']."";
ECHO "</div>"; 
  
?>