<?php
  
$sql = "SELECT `PHOTOS`.`ID`,`PHOTOS`.`ID_DIR` FROM `PHOTOS` LEFT JOIN `PHOTOS_DIR` ON (`PHOTOS_DIR`.`ID` = `PHOTOS`.`ID_DIR` OR `PHOTOS_DIR`.`ID_DIR` = `PHOTOS`.`ID_DIR`) WHERE `PRIVATE` = '0' GROUP BY `PHOTOS`.`ID`";
  
$count = DB::GET_STRING_ALL($sql);

$photo_i = 0;

WHILE ($count->FETCH()){ $photo_i++; }
  
$data = DB::GET_STRING_ALL($sql." ORDER BY `PHOTOS`.`TIME` DESC LIMIT 15");
  
ECHO "<div class='list-body'>";
  
ECHO "<div class='list-menu list-menu-title'>".ICONS('photo', 15, 'fa-fw')." ".LG('Фото пользователей')." <a href='/modules/?path=photos' style='float: right;'>".LG('Все')." ".ICONS('chevron-right', 15, 'fa-fw')."</a></div>";

IF ($photo_i == 0){
  
  ECHO "<div class='list-menu'>".LG('Пока нет фото').". "; 
  
  IF (ISSET($user)){
    
    ECHO "<a href='/modules/?path=photos&section=users&id=".$user['ID']."'>".LG('Желаете добавить фото первым?')."</a>";
    
  }
  
  ECHO "</div>";
  
}ELSE{
  
  ECHO "<div class='menu-list-optimize'>";
  
  WHILE ($list = $data->FETCH()){
    
    ECHO "<a href='/modules/?path=photos&section=show&photo_id=".$list['ID']."'>";
    
    ECHO " <img src='/photo/150x150/".$list['ID_DIR']."/".$list['ID']."/' style='border-radius: 4px; max-width: 75px; margin: 1px;'> ";
    
    ECHO "</a>";
  
  }
  
  IF ($photo_i > 5){  
    
    ECHO " <a class='menu-list-all' href='/modules/?path=photos'><b>".LG('ВСЕ')."</b> ".ICONS('chevron-right', 15, 'fa-fw')."</a> ";
  
  }
  
  ECHO "</div>";
  
}

ECHO "</div>";
  
?>