<?php 

only_reg();
$type = $tools->keyGlobals('type', 'get', 'diary');
$delete_id = $tools->keyGlobals('delete_id', 'get', 0);
$diary = mysql_fetch_assoc(mysql_query("
                  SELECT n.*
                  FROM notes AS n WHERE n.id = " . (int) $maps['diary_id']));

if (!isset($diary['id']) || ($user['id'] != $diary['id_user'] && !user_access('notes_delete'))) {
    header('Location: ?f=diary&s=u&id=' . $diary['id'] . '&u=' . $maps['u']);
    exit;
}

if ($type == 'comment') {
    if ($delete_id) {
        $comment = mysql_fetch_assoc(mysql_query("
                            SELECT k.*
                            FROM notes_komm AS k WHERE k.id = '" . (int) $delete_id . "' AND id_notes = " . $diary['id']));
    } else {
        header('Location: ?f=diary&s=u&id=' . $diary['id'] . '&u=' . $maps['u']);
        exit;
    }
}

$diary_name = $classDiary->get_name($diary['name'], $diary['msg']);

$deleteType = array(
    'diary' => 'запись',
    'comment' => 'комментарий',
);

$_SESSION['sid'] = mt_rand(111, 999);
$set['title'] = __('Удалить ' . $deleteType[$type]);
require H.'sys/inc/thead.php';
title();
aut();
err();
?>
<ol class="breadcrumb">
  <li><a href="/index.php"><i class="ic ic-home"></i></a></li>
  <li><a href="?"><?= __('Дневники')?></a></li>
  <li><a href="?f=diary&amp;s=<?= $maps['s']?>&amp;q=<?= $maps['search']?>&amp;r=<?= $maps['r']?>&amp;u=<?= $maps['u']?>&amp;zsort=<?= $maps['zsort']?>&amp;id=<?= $diary['id']?>"><?= $diary_name?></a></li>
  <li><?= __('Удалить ' . $deleteType[$type])?></li>
</ol>

<div class="alert alert-warning">
Вы действительно хотетите удалить <?= $deleteType[$type]?>: 
&laquo;<?= ($type == 'diary' ? $diary_name : output_text($comment['msg']))?>&raquo;
</div>

<div class="list-form">   
  <form method="post" name="delete" action="?f=<?= $maps['f']?>&amp;s=<?= $maps['s']?>&amp;q=<?= $maps['search']?>&amp;r=<?= ($type == 'comment' ? 'diary' : 'index')?>&amp;zsort=<?= $maps['zsort']?>&amp;u=<?= $diary['id_user']?>&amp;id=<?= $diary['id']?>&amp;delete_id=<?= $delete_id?>&amp;type=<?= text($type)?>">
    <input name="type" value="<?= $type?>" type="hidden" /> 
    <input name="delete_id" value="<?= $delete_id?>" type="hidden" /> 
    <input name="delete" value="<?= __('Удалить')?>" type="submit" />  <a href="?f=diary&amp;s=<?= $maps['s']?>&amp;q=<?= $maps['search']?>&amp;r=<?= $maps['r']?>&amp;u=<?= $maps['u']?>&amp;zsort=<?= $maps['zsort']?>&amp;id=<?= $diary['id']?>"><?= __('Отмена')?></a>
  </form>
</div>
<?