<?php

/*
-------------------------
Удаление текущего аватара
-------------------------
*/
  
IF (GET('get') == 'avatar_delete'){
  
  IF (ISSET($par['ID']) && $par['ADMINISTRATION'] == 1 || MANAGEMENT == 1 || ACCESS('communities', NULL, 1)){
    
    CSRF::GET_CHECK_VALID(GET('get'));
    
    DB::GET_SET("UPDATE `COMMUNITIES` SET `AVATAR` = '0' WHERE `ID` = '".$comm['ID']."' LIMIT 1");
    
    @UNLINK(ROOT.'/files/upload/communities/avatar/'.$comm['AVATAR'].'.jpg');
    @UNLINK(ROOT.'/files/upload/communities/avatar/80x80/'.$comm['AVATAR'].'.jpg');
    
    REDIRECT('/modules/?path=communities&section=show&id='.$comm['ID']);
    
  }
  
}

/*
------------
Вывод автара
------------
*/
  
ECHO "<div style='position: absolute; bottom: 5px; left: 25px;'>";

ECHO "<span style='position: relative;'>";

ECHO "<span id='avatar_upgrade'>";

$style = "max-width: 85px; border-radius: 100%; border: 4px white solid;";

IF (IS_FILE(ROOT.'/files/upload/communities/avatar/100x100/'.$comm['AVATAR'].'.jpg')){
  
  ECHO "<img src='/files/upload/communities/avatar/100x100/".$comm['AVATAR'].".jpg' style='".$style."'>";
  
}ELSE{
  
  ECHO "<img src='/files/upload/communities/avatar/no_photo.jpg' style='".$style." witdth: 85px; height: 85px;'>";
  
}

ECHO "</span>";

IF (ISSET($par['ID']) && $par['ADMINISTRATION'] == 1 || MANAGEMENT == 1 || ACCESS('communities', NULL, 1)){
  
  ?><a id="upload" action="/system/AJAX/php/avatar_comm.php?id=<?=$comm['ID']?>" class="btn-avatar" style="top: -15px;" onclick="modal_open('#avatar')" load="none"><?=ICONS('camera', 13, 'fa-fw')?></a><?
    
  /*
  -----------------------
  Выгрузка новой аватарки
  -----------------------
  */
  
  ECHO "<div class='overlay'>";
  
  ECHO "<div class='modal' id='avatar'>";
  
  ECHO "<div class='modal-title'>";
  ECHO "<b>".LG('Новый аватар')."</b>";
  ?><a onclick="modal_close('#avatar')" load="none" class="btn-modal-close"><?=ICONS('times', 20, 'fa-fw')?></a><?
  ECHO "</div>";
  
  ECHO "<div class='modal-optimize'>";
  
  ECHO "<div class='list-menu'>";
  
  ECHO "<div id='upload2'></div>";

  ECHO "</div>";
  
  ECHO "</div>";
  
  ECHO "</div>";
  
  ECHO "</div>";
  
}

ECHO "</span>";

ECHO "</div>";  
  
?>