Файл: pages/konts.php
Строк: 40
<?php
add_body_class('mail-contacts');
only_reg();
$set['title'] = __('Сообщения');
get_header();
$k_post = db::count("SELECT COUNT(*) FROM `mail_contacts` WHERE user_id = '" . $user['id'] . "'");
$k_page = k_page( $k_post, $set['p_str'] );
$page = page( $k_page );
$start = $set['p_str'] * $page - $set['p_str'];
$q = db::query("SELECT * FROM `mail_contacts` WHERE `user_id` = '" . $user['id'] . "' ORDER BY `time_update` DESC LIMIT $start, $set[p_str]");
if ($k_post == 0) {
echo '<div class="empty">' . __('Список контактов пуст') . '</div>';
}
$content = '';
while($post = $q->fetch_assoc()) {
$ank = get_user($post['contact_id']);
$last = db::fetch("SELECT * FROM mail WHERE (contact_id = '" . $ank['id'] . "' AND user_id = '" . $user['id'] . "') OR (contact_id = '" . $user['id'] . "' AND user_id = '" . $ank['id'] . "') ORDER BY id DESC LIMIT 1");
$msg = use_filters('ds_contact_msg', (isset($last['id']) ? '<div class="ds-contact-text ' . ($last['read'] == 1 ? 'read' : 'no-read') . '">' . ($last['user_id'] == $user['id'] ? '<span class="contact_main_message">' . __('Вы') . ':</span>' : '') . $last['msg'] . '</div>' : ''), $last, $ank);
$classes = array();
if ($last['user_id'] == $user['id']) {
$classes[] = 'post-main';
} else {
$classes[] = 'post-contact';
}
if ($last['time'] > mktime(0,0,0)) {
$datetime = '<span class="ds-post-date" title="' . ds_date('d F Y H:i:s', $last['time']) . '">' . ds_date('H:i', $last['time']) . '</span>';
} else {
$datetime = '<span class="ds-post-date" title="' . ds_date('d F Y H:i:s', $last['time']) . '">' . ds_date('d.m.Y', $last['time']) . '</span>';
}
$header = array(
'image' => '<a href="' . get_mail_url($post['contact_id']) . '">' . get_avatar($post['contact_id']) . '</a>',
'content' => array(
'post_title' => '<a href="' . get_mail_url($post['contact_id']) . '">' . get_user_nick($post['contact_id']) . '</a>',
'post_content' => $msg,
'post_date' => $datetime,
),
'action' => array(),
);
echo get_template_post(array(
'href' => get_mail_url($post['contact_id']),
'header' => $header,
'post_classes' => $classes,
'post_attr' => array(
'data-user' => $post['contact_id'],
'data-last_id' => (isset($last['id']) ? $last['id'] : 0),
),
));
}
if ( $k_page > 1 )
str( "?", $k_page, $page );
get_footer();