<?php

/**
 * This file is part of JohnCMS Content Management System.
 *
 * @copyright JohnCMS Community
 * @license   https://opensource.org/licenses/GPL-3.0 GPL-3.0
 * @link      https://johncms.com JohnCMS Project
 */

/**
 * @var $item
 */
?>

<div class="user-row <?= (isset($item['active']) && $item['active'] ? 'bg-yellow-light' : '') ?>">
    <div class="d-flex align-items-start">
        <div class="user-avatar me-2 me-md-4">
            <div class="avatar-image rounded-circle overflow-hidden">
                <img src="<?= $this->avatar($item['id']) ?>" class="img-fluid" alt=".">
            </div>
            <div class="user-status <?= $item['user_is_online'] ? 'online' : 'offline' ?> shadow"></div>
        </div>
        <div class="overflow-auto flex-grow-1">
            <div class="user-name">
                <?php if (! empty($item['user_profile_link'])): ?>
                    <a href="<?= $item['user_profile_link'] ?>" class="user-login me-2"><?= $item['name'] ?></a>
                <?php else: ?>
                    <a class="user-login me-2"><?= $item['name'] ?></a>
                <?php endif; ?>
            </div>
            <?php if (! empty($item['buttons'])): ?>
                <div class="mt-3">
                    <?php foreach ($item['buttons'] as $button): ?>
                        <a href="<?= $button['url'] ?>"><?= $button['name'] ?></a>
                    <?php endforeach; ?>
                </div>
            <?php endif; ?>
        </div>
    </div>
    <?php if ($user->rights >= 3): ?>
        <div class="post-footer d-flex justify-content-between border-top pt-2 mt-2">
            <div class="post-user-info d-flex overflow-hidden small align-items-center">
                <?php if ($user->rights): ?>
                    <div class="user-ip me-2">
                        <a href="<?= $item['search_ip_url'] ?>"><?= $item['ip'] ?></a>
                        <?php if (! empty($item['ip_via_proxy'])): ?>
                            / <a href="<?= $item['search_ip_via_proxy_url'] ?>"><?= $item['ip_via_proxy'] ?></a>
                        <?php endif; ?>
                    </div>
                    <div class="useragent">
                        <span>User-Agent:</span>
                        <span><?= $item['browser'] ?></span>
                    </div>
                <?php endif; ?>
            </div>
        </div>
    <?php endif; ?>
</div>
