View file user/notification/index.php

File size: 4.02Kb
<?
include_once $_SERVER['DOCUMENT_ROOT'] . '/sys/inc/home.php';
include_once H.'sys/inc/start.php';
include_once H.'sys/inc/compress.php';
include_once H.'sys/inc/sess.php';
include_once H.'sys/inc/settings.php';
include_once H.'sys/inc/db_connect.php';
include_once H.'sys/inc/ipua.php';
include_once H.'sys/inc/fnc.php';
include_once H.'sys/inc/user.php';
only_reg();

// Размер подарков при выводе в браузер
$width = ($webbrowser == 'web' ? '100' : '70'); 

if (isset($_GET['delete']) && $_GET['delete'] == 'all') {
  if (isset($user)) {
  	query("DELETE FROM `notification` WHERE `id_user` = '$user[id]'");
  	$_SESSION['message'] = 'Уведомления очищены';
  	header('Location: ?');
  	exit;
  }
}

if (isset($_GET['del']))  {
  if (isset($user)) {
    $id = (int) $_GET['del'];
  	if (mysql_result(query("SELECT COUNT(*) FROM `notification`  WHERE `id_user` = '$user[id]' AND `id` = '$id'"),0) == 1) {
    	query("DELETE FROM `notification` WHERE `id_user` = '$user[id]' AND `id` = '$id' LIMIT 1");
    	$_SESSION['message'] = 'Уведомление удалено';
    	header('Location: ?page=' . $id);
    	exit;
  	}
  }
}

$set['title'] = __('Уведомления');
include_once H.'sys/inc/thead.php';
title();
aut();

$k_notif = mysql_result(query("SELECT COUNT(`read`) FROM `notification` WHERE `id_user` = '$user[id]' AND `read` = '0'"), 0); 

if ($k_notif > 0)$k_notif = '<font color=red>(' . $k_notif . ')</font>';
else $k_notif = null;

$discuss = mysql_result(query("SELECT COUNT(`count`) FROM `discussions` WHERE `id_user` = '$user[id]' AND `count` > '0' "), 0); 

if ($discuss > 0)$discuss = '<font color=red>(' . $discuss . ')</font>';
else $discuss = null;

$lenta = mysql_result(query("SELECT COUNT(`read`) FROM `tape` WHERE `id_user` = '$user[id]' AND `read` = '0' "), 0); 

if ($lenta > 0)$lenta = '<font color=red>(' . $lenta . ')</font>';
else $lenta = null;

?>
<div id='comments' class='menus'>
  <div class='webmenu'>
    <a href='/user/tape/'><?= __('Лента') . $lenta?></a>
  </div>

  <div class='webmenu'>
    <a href='/user/discussions/' ><?= __('Обсуждения') . $discuss?></a>
  </div>

  <div class='webmenu'>
    <a href='/user/notification/' class='activ'><?= __('Уведомления') . $k_notif?></a>
  </div>
</div>
<?
$k_post = mysql_result(query("SELECT COUNT(*) FROM `notification`  WHERE `id_user` = '$user[id]'"), 0);
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];

$q = query("SELECT * FROM `notification` WHERE `id_user` = '$user[id]' ORDER BY `time` DESC LIMIT $start, $set[p_str]");

if ($k_post == 0) {
	?><div class='mess'><?= __('Нет новых уведомлений')?></div><?
}

while ($post = mysql_fetch_assoc($q)) {
	$num++;
	
	?><div class="<?= ($num % 2 ? 'nav2' : 'nav1')?>"><?

	$type = $post['type'];
	$avtor = user::get_user($post['avtor'], 1);
  
  if (is_file('inc/' . $type . '.php')) {
    require 'inc/' . $type . '.php';
  } else {
    echo __('К сожалению плагин уведомления не найден, пожалуйста сообщите об этом администрации.');
    ?>
    <br />Error: <?= $type?> 
    <?
  }

  if ($post['read'] == 0) {
    query("UPDATE `notification` SET `read` = '1' WHERE `id` = '$post[id]' LIMIT 1");
  }
  ?>
  <span class="<?= ($post['read'] == 0 ? 'off' : 'time')?>"><?= vremja($post['time'])?></span> 
  <div class="right"><a href="?del=<?= $post['id']?>&amp;page=<?= $page?>" title="<?= __('Удалить это уведомление')?>"><img src="/style/icons/delete.gif" alt="*" /></a></div>
  </div>
  <?
}

if ($k_page > 1) { 
  str('?', $k_page, $page); 
}
?>
<div class="foot">
<img src='/style/icons/str2.gif' alt='*'> <?= user::nick($user['id'], 1)?> | <b><?= __('Уведомления')?></b> | <a href="settings.php"><?= __('Настройки')?></a>
</div>
<?
include_once H.'sys/inc/tfoot.php';
?>