View file siwap.ru/apps/mail/index.php

File size: 2.86Kb
<?php 
require_once $_SERVER['DOCUMENT_ROOT'].'/system/App.php';
$header = 'Диалоги';
require_once ROOT.'/system/header.php';

$user->access();
?>
<div class="col">
</div>

<div class="col-sm-8 col-md-6 col-lg-4 col-xl-4">
<nav aria-label="breadcrumb">
	<ol class="breadcrumb">
		<div class="b-item">
			<li class="breadcrumb-item">
				<a href="/">На главную</a>
			</li>
			<li class="breadcrumb-item active" aria-current="page">Диалоги</li>
		</div>
	</ol>
</nav>

<div class="mb-3">
<a href="/mail/new_chat" class="btn btn-theme-active btn-block">Создать беседу</a>
</div>

<div class="card">
<ul class="list-group list-group-flush">
<?php
$dialogsUser = $mail->DialogsFromUser();

if(empty($dialogsUser))
{
	echo '<li class="list-group-item text-center text-muted">Пока что пусто...</li>';
}
else
{
foreach($dialogsUser as $dialog)
{
	
	$MessageDialog = $mail->previewDialog($dialog['id']);
	$UsersDialog = $mail->UsersFromDialog($dialog['id']);
	$contactDialog = $mail->ContactFromDialog($dialog['id']);
	$contactInfo = $user->infoByID($contactDialog);
	$authorInfo = $user->infoByID($MessageDialog['user_id']);
	
	echo '<li class="list-group-item">';
	if(empty($dialog['contact_id']))
	{
		echo '<a href="/mail/chat'.$dialog['id'].'"><b class="text-secondary">'.$dialog['name'].'</b></a> <span class="badge badge-pill badge-theme float-right mt-1">'.$sys->time($dialog['last_time']).'</span><br />';
	}
	else
	{
		echo '<a href="/id'.$contactInfo['id'].'"><b class="text-secondary" >'.$contactInfo['login'].'</b></a> <span class="badge badge-pill badge-theme float-right mt-1">'.date('H:i', $dialog['last_time']).'</span><br />';
	}
	
	if(!empty($MessageDialog))
	{
		if($MessageDialog['user_id'] == $me['id'])
		{
			echo '<div class="media mt-2">
			<div class="media-left">
			<div class="media-avatar avatar-min" style="background-image: url('.$authorInfo['avatar'].');"></div>
			<img class="media-object d-none rounded-circle" src="'.$authorInfo['avatar'].'" alt="" style="width: 30px; height: 30px; margin-top: -1px; margin-right: 10px;">
			</div>
			<div class="media-body">
			<a href="/mail/id'.$dialog['id'].'" class="message-out '.($MessageDialog['read'] == 1 ? '.read' : '').' text-small">'.$MessageDialog['message'].'</a>
			</div>
			</div>';
		}
		else
		{
			echo '<a href="/mail/id'.$dialog['id'].'" class="text-small">'.$MessageDialog['message'].' <span class="badge badge-pill badge-info float-right" style="margin-top: 6px; font-size: smaller;">'.$mail->unreadMessages($dialog['id']).'</span></a>';
		}
	}
	else
	{
		echo '<a href="/mail/id'.$dialog['id'].'" class="message-out mt-2 text-center text-small">Перейти к диалогу</a>';
	}
	echo '</li>';
}
} 
?>
</ul>
</div>
</div>

<div class="col">
</div>
<?php
require ROOT.'/system/footer.php';
?>