misuzu/templates/user/macros.twig

463 lines
20 KiB
Twig
Raw Permalink Normal View History

2022-09-13 13:14:49 +00:00
{% macro user_card(user, current_user) %}
{% if user.getId is defined %}
{% from _self import user_card_new %}
{{ user_card_new(user, current_user) }}
{% else %}
{% from _self import user_card_old %}
{{ user_card_old(user) }}
{% endif %}
{% endmacro %}
{% macro user_card_new(user, current_user) %}
{% from 'macros.twig' import avatar %}
<div class="usercard" style="--accent-colour: {{ user.colour }}">
<div class="usercard__background"></div>
<div class="usercard__header">
<a class="usercard__header__link" href="{{ url('user-profile', {'user': user.id}) }}"></a>
<div class="usercard__header__container">
<div class="usercard__header__avatar">
{{ avatar(user.id, 60, user.username) }}
</div>
<div class="usercard__header__details">
<div class="usercard__header__username">
{{ user.username }}
</div>
{% if user.hasTitle %}
<div class="usercard__header__title">
{{ user.title }}
</div>
{% endif %}
{% if user.hasCountry %}
<div class="usercard__header__country">
<div class="flag flag--{{ user.country|lower }}"></div>
<div class="usercard__header__country__name">
{{ user.countryName }}
</div>
</div>
{% endif %}
</div>
</div>
</div>
<div class="usercard__container">
<div class="usercard__stats">
{% if user.forumTopicCount > 0 %}
<a class="usercard__stat" href="{{ url('user-profile-forum-topics', {'user': user.id}) }}">
<div class="usercard__stat__name">
Topics
</div>
<div class="usercard__stat__value">
{{ user.forumTopicCount|number_format }}
</div>
</a>
{% endif %}
{% if user.forumPostCount > 0 %}
<a class="usercard__stat" href="{{ url('user-profile-forum-posts', {'user': user.id}) }}">
<div class="usercard__stat__name">
Posts
</div>
<div class="usercard__stat__value">
{{ user.forumPostCount|number_format }}
</div>
</a>
{% endif %}
</div>
<div class="usercard__dates">
<div class="usercard__date" title="{{ user.createdTime|date('r') }}">
2023-07-18 23:12:47 +00:00
Joined <time datetime="{{ user.createdTime|date('c') }}">{{ user.createdTime|time_format }}</time>
2022-09-13 13:14:49 +00:00
</div>
{% if user.hasBeenActive %}
<div class="usercard__date" title="{{ user.activeTime|date('r') }}">
2023-07-18 23:12:47 +00:00
Last seen <time datetime="{{ user.activeTime|date('c') }}">{{ user.activeTime|time_format }}</time>
2022-09-13 13:14:49 +00:00
</div>
{% else %}
<div class="usercard__date">
Never logged in
</div>
{% endif %}
</div>
<div class="usercard__actions">
<a class="usercard__action" href="{{ url('user-profile', {'user': user.id}) }}" title="View Profile">
<i class="fas fa-user"></i>
</a>
</div>
</div>
</div>
{% endmacro %}
{% macro user_card_old(user) %}
{% from 'macros.twig' import avatar %}
<div class="usercard"{% if user.user_colour is defined %} style="{{ user.user_colour|html_colour('--accent-colour') }}"{% endif %}>
<div class="usercard__background"></div>
<div class="usercard__header">
<a class="usercard__header__link" href="{{ url('user-profile', {'user': user.user_id}) }}"></a>
<div class="usercard__header__container">
<div class="usercard__header__avatar">
{{ avatar(user.user_id, 60, user.username) }}
</div>
<div class="usercard__header__details">
<div class="usercard__header__username"{% if user.user_colour is defined %} style="{{ user.user_colour|html_colour }}"{% endif %}>
{{ user.username }}
</div>
{% if user.user_title is defined and user.user_title is not empty %}
<div class="usercard__header__title">
{{ user.user_title }}
</div>
{% endif %}
{% if user.user_country|default('XX') != 'XX' %}
<div class="usercard__header__country">
<div class="flag flag--{{ user.user_country|lower }}"></div>
<div class="usercard__header__country__name">
{{ user.user_country|country_name }}
</div>
</div>
{% endif %}
</div>
</div>
</div>
<div class="usercard__container">
<div class="usercard__stats">
{% if user.user_count_topics|default(0) > 0 %}
<a class="usercard__stat" href="{{ url('user-profile-forum-topics', {'user': user.user_id}) }}">
<div class="usercard__stat__name">
Topics
</div>
<div class="usercard__stat__value">
{{ user.user_count_topics|number_format }}
</div>
</a>
{% endif %}
{% if user.user_count_posts|default(0) > 0 %}
<a class="usercard__stat" href="{{ url('user-profile-forum-posts', {'user': user.user_id}) }}">
<div class="usercard__stat__name">
Posts
</div>
<div class="usercard__stat__value">
{{ user.user_count_posts|number_format }}
</div>
</a>
{% endif %}
</div>
<div class="usercard__dates">
{% if user.user_created is defined %}
<div class="usercard__date" title="{{ user.user_created|date('r') }}">
2023-07-18 23:12:47 +00:00
Joined <time datetime="{{ user.user_created|date('c') }}">{{ user.user_created|time_format }}</time>
2022-09-13 13:14:49 +00:00
</div>
{% endif %}
{% if user.user_active is defined %}
{% if user.user_active is null %}
<div class="usercard__date">
Never logged in
</div>
{% else %}
<div class="usercard__date" title="{{ user.user_active|date('r') }}">
2023-07-18 23:12:47 +00:00
Last seen <time datetime="{{ user.user_active|date('c') }}">{{ user.user_active|time_format }}</time>
2022-09-13 13:14:49 +00:00
</div>
{% endif %}
{% endif %}
</div>
<div class="usercard__actions">
<a class="usercard__action" href="{{ url('user-profile', {'user': user.user_id}) }}" title="View Profile">
<i class="fas fa-user"></i>
</a>
</div>
</div>
</div>
{% endmacro %}
{% macro user_session(session, is_current_session) %}
{% from '_layout/input.twig' import input_hidden, input_csrf, input_checkbox_raw %}
<div class="settings__session{% if is_current_session %} settings__session--current{% endif %}" id="session-{{ session.id }}">
<div class="settings__session__container">
<div class="settings__session__important">
<div class="flag flag--{{ session.country|lower }} settings__session__flag" title="{{ session.countryName }}">{{ session.country }}</div>
<div class="settings__session__description">
{{ session.userAgentInfo.toString }}
</div>
<form class="settings__session__actions" method="post" action="{{ url('settings-sessions') }}">
{{ input_csrf() }}
{{ input_hidden('session[]', session.id) }}
<button class="settings__session__action" title="{{ is_current_session ? 'Logout' : 'End Session' }}">
{% if is_current_session %}
<i class="fas fa-sign-out-alt"></i>
{% else %}
<i class="fas fa-times-circle"></i>
{% endif %}
</button>
</form>
</div>
<div class="settings__session__details">
<div class="settings__session__detail">
<div class="settings__session__detail__title">
Created from IP
</div>
<div class="settings__session__detail__value">
{{ session.initialRemoteAddress }}
</div>
</div>
{% if session.hasLastRemoteAddress %}
<div class="settings__session__detail">
<div class="settings__session__detail__title">
Last used from IP
</div>
<div class="settings__session__detail__value">
{{ session.lastRemoteAddress }}
</div>
</div>
{% endif %}
<div class="settings__session__detail" title="{{ session.createdTime|date('r') }}">
<div class="settings__session__detail__title">
Created
</div>
<time class="settings__session__detail__value" datetime="{{ session.createdTime|date('c') }}">
2023-07-18 23:12:47 +00:00
{{ session.createdTime|time_format }}
2022-09-13 13:14:49 +00:00
</time>
</div>
<div class="settings__session__detail" title="{{ session.expiresTime|date('r') }}">
<div class="settings__session__detail__title">
Expires{% if not session.shouldBumpExpire %} (static){% endif %}
</div>
<time class="settings__session__detail__value" datetime="{{ session.expiresTime|date('c') }}">
2023-07-18 23:12:47 +00:00
{{ session.expiresTime|time_format }}
2022-09-13 13:14:49 +00:00
</time>
</div>
{% if session.hasActiveTime %}
<div class="settings__session__detail" title="{{ session.activeTime|date('r') }}">
<div class="settings__session__detail__title">
Last Active
</div>
<time class="settings__session__detail__value" datetime="{{ session.activeTime|date('c') }}">
2023-07-18 23:12:47 +00:00
{{ session.activeTime|time_format }}
2022-09-13 13:14:49 +00:00
</time>
</div>
{% endif %}
<div class="settings__session__detail">
<div class="settings__session__detail__title">
User Agent
</div>
<div class="settings__session__detail__value">
{{ session.userAgent is empty ? 'None' : session.userAgent }}
</div>
</div>
</div>
</div>
</div>
{% endmacro %}
{% macro user_login_attempt(attempt) %}
<div class="settings__login-attempt{% if not attempt.success %} settings__login-attempt--failed{% endif %}">
<div class="settings__login-attempt__container">
<div class="settings__login-attempt__important">
<div class="flag flag--{{ attempt.country|lower }} settings__login-attempt__flag" title="{{ attempt.countryName }}">{{ attempt.country }}</div>
<div class="settings__login-attempt__description">
{{ attempt.userAgentInfo.toString }}
</div>
</div>
<div class="settings__login-attempt__details">
<div class="settings__login-attempt__detail">
<div class="settings__login-attempt__detail__title">
IP Address
</div>
<div class="settings__login-attempt__detail__value">
{{ attempt.remoteAddress }}
</div>
</div>
<div class="settings__login-attempt__detail">
<div class="settings__login-attempt__detail__title">
Succeeded
</div>
<div class="settings__login-attempt__detail__value">
{{ attempt.success ? 'Yes' : 'No' }}
</div>
</div>
<div class="settings__login-attempt__detail" title="{{ attempt.createdTime|date('r') }}">
<div class="settings__login-attempt__detail__title">
Attempted
</div>
<time class="settings__login-attempt__detail__value" datetime="{{ attempt.createdTime|date('c') }}">
2023-07-18 23:12:47 +00:00
{{ attempt.createdTime|time_format }}
2022-09-13 13:14:49 +00:00
</time>
</div>
<div class="settings__login-attempt__detail">
<div class="settings__login-attempt__detail__title">
User Agent
</div>
<div class="settings__login-attempt__detail__value">
{{ attempt.userAgent is empty ? 'None' : attempt.userAgent }}
</div>
</div>
</div>
</div>
</div>
{% endmacro %}
{% macro user_account_log(data, users) %}
2022-09-13 13:14:49 +00:00
{% from 'macros.twig' import avatar %}
<div class="settings__account-log">
{% if data.hasUserId and users[data.userId] is defined %}
{% set user = users[data.userId] %}
<a href="{{ url('user-profile', {'user': user.id}) }}" class="settings__account-log__user" style="--user-colour: {{ user.colour }}">
<div class="settings__account-log__user__avatar">{{ avatar(user.id, 20, user.username) }}</div>
<div class="settings__account-log__user__name">{{ user.username }}</div>
2022-09-13 13:14:49 +00:00
</a>
{% endif %}
<div class="settings__account-log__container">
<div class="settings__account-log__important">
<div class="flag flag--{{ data.countryCode|lower }} settings__login-attempt__flag" title="{{ data.countryCode|country_name }}">{{ data.countryCode }}</div>
2022-09-13 13:14:49 +00:00
<div class="settings__login-attempt__description">
{{ data.formatted }}
2022-09-13 13:14:49 +00:00
</div>
</div>
<div class="settings__account-log__details">
<div class="settings__account-log__detail">
<div class="settings__account-log__detail__title">
IP Address
</div>
<div class="settings__account-log__detail__value">
{{ data.remoteAddress }}
</div>
</div>
<div class="settings__account-log__detail" title="{{ data.createdTime|date('r') }}">
<div class="settings__account-log__detail__title">
Date
</div>
<time class="settings__account-log__detail__value" datetime="{{ data.createdTime|date('c') }}">
2023-07-18 23:12:47 +00:00
{{ data.createdTime|time_format }}
2022-09-13 13:14:49 +00:00
</time>
</div>
</div>
</div>
</div>
{% endmacro %}
{% macro user_profile_warning(warning, show_private_note, show_user_info, delete_csrf) %}
{% from 'macros.twig' import avatar %}
{% if warning.isSilence %}
{% set warning_text = 'Silence' %}
{% set warning_class = 'silence' %}
{% elseif warning.isBan %}
{% set warning_text = 'Ban' %}
{% set warning_class = 'ban' %}
{% elseif warning.isWarning %}
{% set warning_text = 'Warning' %}
{% set warning_class = 'warning' %}
{% else %}
{% set warning_text = 'Note' %}
{% set warning_class = 'note' %}
{% endif %}
<div class="profile__warning profile__warning--{{ warning_class }}{% if show_user_info or delete_csrf %} profile__warning--extendo{% endif %}">
<div class="profile__warning__background"></div>
{% if show_user_info or delete_csrf %}
<div class="profile__warning__tools">
{% if show_user_info %}
<div class="profile__warning__user">
<div class="profile__warning__user__avatar">
{{ avatar(warning.user.id, 20, warning.user.username) }}
</div>
<a class="profile__warning__user__username" href="{{ url('user-profile', {'user': warning.user.id}) }}">
{{ warning.user.username }}
</a>
<div class="profile__warning__user__ip">
{{ warning.userRemoteAddress }}
</div>
</div>
<div class="profile__warning__user">
<div class="profile__warning__user__avatar">
{{ avatar(warning.issuer.id, 20, warning.issuer.username) }}
</div>
<a class="profile__warning__user__username" href="{{ url('user-profile', {'user': warning.issuer.id}) }}">
{{ warning.issuer.username }}
</a>
<div class="profile__warning__user__ip">
{{ warning.issuerRemoteAddress }}
</div>
</div>
{% endif %}
{% if delete_csrf %}
<div class="profile__warning__options">
<a href="{{ url('manage-users-warning-delete', {'warning': warning.id}) }}" class="profile__warning__option"><i class="far fa-trash-alt"></i> Delete</a>
</div>
{% endif %}
</div>
{% endif %}
<div class="profile__warning__content">
<div class="profile__warning__type">
{{ warning_text }}
</div>
<time datetime="{{ warning.createdTime|date('c') }}" title="{{ warning.createdTime|date('r') }}" class="profile__warning__created">
2023-07-18 23:12:47 +00:00
{{ warning.createdTime|time_format }}
2022-09-13 13:14:49 +00:00
</time>
{% if warning.isPermanent %}
<div class="profile__warning__duration">
<b>PERMANENT</b>
</div>
{% elseif warning.hasDuration %}
<div class="profile__warning__duration">
{{ warning.durationString }}
</div>
{% else %}
<div class="profile__warning__duration"></div>
{% endif %}
<div class="profile__warning__note">
{{ warning.publicNote }}
{% if show_private_note and warning.hasPrivateNote %}
<div class="profile__warning__private">
{{ warning.privateNote|nl2br }}
</div>
{% endif %}
</div>
</div>
</div>
{% endmacro %}