<?
/*
* Заголовок обсуждения
*/

if ($type == 'notes' && $post['avtor'] != $user['id'])
{
	$name = __('Дневник друга');
}
else if ($type == 'notes' && $post['avtor'] == $user['id'])
{
	$name = __('Ваш дневник');
}

/*
* Выводим на экран
*/
if ($type == 'notes')
{
	  $diary = mysql_fetch_assoc(mysql_query("
                  SELECT n.*, 
                    (SELECT COUNT(*) FROM notes_komm AS k WHERE k.id_notes = n.id) AS comments,
                    (SELECT COUNT(*) FROM notes_count AS c WHERE c.id_notes = n.id) AS view,
                    (SELECT COUNT(*) FROM notes_like AS l WHERE l.id_notes = n.id AND l.like = '1') AS 'like',
                    (SELECT COUNT(*) FROM notes_like AS l WHERE l.id_notes = n.id AND l.like = '0') AS 'dlike'
                  FROM notes AS n WHERE n.id = " . $post['id_sim']));
    
    if (isset($diary['id'])) {
        ?>
        <div class="list-post">
        <?
          if ($diary['attachments']) {  
              $attach = unserialize($diary['attachments']);
          } else {
              $attach = array();
          }
          ?>
          <div class="list-post-item">
            <div class="list-post-header">
              <?= ($avtor['id'] != $user['id'] ? '<a href="user.settings.php?id=' . $avtor['id'] . '">[!]</a>' : '')?> 
              <?= $name?>
              <a href="/plugins/diary?f=diary&amp;s=n&amp;id=<?= $diary['id']?>"><?= Diary::get_name($diary['name'], $diary['msg'])?></a>
              <?
              if ($post['count'] > 0) {
          			?><b><font color='red'>+<?= $post['count']?></font></b><?
          		}
          		?>
              <?= $s1 . vremja($post['time']) . $s2?>
            </div>
            
            <div class="list-post-item-text">
              <?= Diary::get_name(null, $diary['msg'], 220)?>..
            </div>
            
            <? if (isset($attach['photo'])) { ?>
              <div class="attach">
                <? foreach($attach['photo'] AS $file) { ?>
                  <img src="/user/attachments/download/photo/<?= $file['fileSize']?>_50/<?= $file['fileId']?>/<?= $file['fileNameSend']?>" />
                <? 
                break;
                } ?>
              </div>      
            <? } ?>
            
            <div class="list-post-item-panel">
              <div class="list-post-info">
                <span class="pull-left">
                  <img src="/style/icons/views_num_gray.png" /> <?= $diary['view']?> 
                  <img src="/style/icons/comm_num_gray.png" /> <?= $diary['comments']?> 
                </span>
                <span class="pull-right">
                  <img src="/style/icons/vote_up.png" /> <?= $diary['like']?> 
                  <img src="/style/icons/vote_down.png" /> <?= $diary['dlike']?> 
                </span>
              </div>
              
              <a href="/plugins/diary?f=diary&amp;s=u&amp;r=user&amp;u=<?= $diary['id_user']?>&amp;id=<?= $diary['id']?>&amp;zsort=<?= $user['sort']?>#page-up">
                <i class="icpb icpb-comments"></i> <?= __('Обсудить')?>
              </a>  
            </div>
          </div>
        </div>
        <?
    }
}
?>