Skip to content

Commit

Permalink
Improve modlog (#828)
Browse files Browse the repository at this point in the history
  • Loading branch information
BentiGorlich authored Jun 14, 2024
1 parent 2e9b04c commit 8afe388
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 14 deletions.
4 changes: 4 additions & 0 deletions src/Controller/User/ThemeSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class ThemeSettingsController extends AbstractController
public const KBIN_SUBSCRIPTIONS_SIDEBARS_SAME_SIDE = 'kbin_subscriptions_sidebars_same_side';
public const KBIN_SUBSCRIPTIONS_LARGE_PANEL = 'kbin_subscriptions_large_panel';
public const KBIN_SUBSCRIPTIONS_SHOW_MAGAZINE_ICON = 'kbin_subscriptions_show_magazine_icon';
public const MBIN_MODERATION_LOG_SHOW_USER_AVATARS = 'mbin_moderation_log_show_user_avatars';
public const MBIN_MODERATION_LOG_SHOW_MAGAZINE_ICONS = 'mbin_moderation_log_show_magazine_icons';

public const CLASSIC = 'classic';
public const CHAT = 'chat';
Expand Down Expand Up @@ -96,6 +98,8 @@ class ThemeSettingsController extends AbstractController
self::KBIN_SUBSCRIPTIONS_SIDEBARS_SAME_SIDE,
self::KBIN_SUBSCRIPTIONS_LARGE_PANEL,
self::KBIN_SUBSCRIPTIONS_SHOW_MAGAZINE_ICON,
self::MBIN_MODERATION_LOG_SHOW_USER_AVATARS,
self::MBIN_MODERATION_LOG_SHOW_MAGAZINE_ICONS,
];

public const VALUES = [
Expand Down
5 changes: 5 additions & 0 deletions templates/layout/_options_appearance.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@
{{ component('settings_row_enum', {label: 'comment_reply_position'|trans, help: 'comment_reply_position_help'|trans, settingsKey: 'KBIN_COMMENTS_REPLY_POSITION', values: [ {name: 'position_top'|trans , value: 'TOP'}, {name: 'position_bottom'|trans , value: 'BOTTOM' } ], defaultValue: 'TOP' } ) }}
{{ component('settings_row_switch', {label: 'show_avatars_on_comments'|trans, help: 'show_avatars_on_comments_help'|trans, settingsKey: 'KBIN_COMMENTS_SHOW_USER_AVATAR', defaultValue: true}) }}
</div>
<strong>{{ 'mod_log'|trans }}</strong>
<div class="settings-section">
{{ component('settings_row_switch', {label: 'show_users_avatars'|trans, settingsKey: 'MBIN_MODERATION_LOG_SHOW_USER_AVATARS', defaultValue: false}) }}
{{ component('settings_row_switch', {label: 'show_magazines_icons'|trans, settingsKey: 'MBIN_MODERATION_LOG_SHOW_MAGAZINE_ICONS', defaultValue: false}) }}
</div>
</div>
30 changes: 18 additions & 12 deletions templates/modlog/_blocks.html.twig
Original file line number Diff line number Diff line change
@@ -1,58 +1,64 @@
{% block log_entry_deleted %}
{{ component('user_inline', {user: log.user, showAvatar: false}) }} {{ 'removed_thread_by'|trans|lower }} {{ component('user_inline', {user: log.entry.user, showAvatar: false}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.entry.magazine, showIcon: false }) }}{% endif %} -
{{ component('user_inline', {user: log.user, showAvatar: showAvatars}) }} {{ 'removed_thread_by'|trans|lower }} {{ component('user_inline', {user: log.entry.user}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.entry.magazine, showAvatar: showIcons }) }}{% endif %} -
<a href="{{ entry_url(log.entry) }}">{{ log.entry.shortTitle(300) }}</a>
{% endblock %}

{% block log_entry_restored %}
{{ component('user_inline', {user: log.user, showAvatar: false}) }} {{ 'restored_thread_by'|trans|lower }} {{ component('user_inline', {user: log.entry.user, showAvatar: false}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.entry.magazine, showIcon: false }) }}{% endif %} -
{{ component('user_inline', {user: log.user, showAvatar: showAvatars}) }} {{ 'restored_thread_by'|trans|lower }} {{ component('user_inline', {user: log.entry.user}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.entry.magazine, showAvatar: showIcons }) }}{% endif %} -
<a href="{{ entry_url(log.entry) }}">{{ log.entry.shortTitle(300) }}</a>
{% endblock %}

{% block log_entry_comment_deleted %}
{{ component('user_inline', {user: log.user, showAvatar: false}) }} {{ 'removed_comment_by'|trans|lower }} {{ component('user_inline', {user: log.comment.user, showAvatar: false}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.comment.magazine, showIcon: false }) }}{% endif %} -
{{ component('user_inline', {user: log.user, showAvatar: showAvatars}) }} {{ 'removed_comment_by'|trans|lower }} {{ component('user_inline', {user: log.comment.user}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.comment.magazine, showAvatar: showIcons }) }}{% endif %} -
<a href="{{ entry_comment_view_url(log.comment) }}#{{ get_url_fragment(log.comment) }}">{{ log.comment.shortTitle(300) }}</a>
{% endblock %}

{% block log_entry_comment_restored %}
{{ component('user_inline', {user: log.user, showAvatar: false}) }} {{ 'restored_comment_by'|trans|lower }} {{ component('user_inline', {user: log.comment.user, showAvatar: false}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.comment.magazine, showIcon: false }) }}{% endif %} -
{{ component('user_inline', {user: log.user, showAvatar: showAvatars}) }} {{ 'restored_comment_by'|trans|lower }} {{ component('user_inline', {user: log.comment.user}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.comment.magazine, showAvatar: showIcons }) }}{% endif %} -
<a href="{{ entry_comment_view_url(log.comment) }}#{{ get_url_fragment(log.comment) }}">{{ log.comment.shortTitle(300) }}</a>
{% endblock %}

{% block log_post_deleted %}
{{ component('user_inline', {user: log.user, showAvatar: false}) }} {{ 'removed_post_by'|trans|lower }} {{ component('user_inline', {user: log.post.user, showAvatar: false}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.post.magazine, showIcon: false }) }}{% endif %} -
{{ component('user_inline', {user: log.user, showAvatar: showAvatars}) }} {{ 'removed_post_by'|trans|lower }} {{ component('user_inline', {user: log.post.user}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.post.magazine, showAvatar: showIcons }) }}{% endif %} -
<a href="{{ post_url(log.post) }}">{{ log.post.shortTitle(300) }}</a>
{% endblock %}

{% block log_post_restored %}
{{ component('user_inline', {user: log.user, showAvatar: false}) }} {{ 'restored_post_by'|trans|lower }} {{ component('user_inline', {user: log.post.user, showAvatar: false}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.post.magazine, showIcon: false }) }}{% endif %} -
{{ component('user_inline', {user: log.user, showAvatar: showAvatars}) }} {{ 'restored_post_by'|trans|lower }} {{ component('user_inline', {user: log.post.user}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.post.magazine, showAvatar: showIcons }) }}{% endif %} -
<a href="{{ post_url(log.post) }}">{{ log.post.shortTitle(300) }}</a>
{% endblock %}

{% block log_post_comment_deleted %}
{{ component('user_inline', {user: log.user, showAvatar: false}) }} {{ 'removed_comment_by'|trans|lower }} {{ component('user_inline', {user: log.comment.user, showAvatar: false}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.comment.magazine, showIcon: false }) }}{% endif %} -
{{ component('user_inline', {user: log.user, showAvatar: showAvatars}) }} {{ 'removed_comment_by'|trans|lower }} {{ component('user_inline', {user: log.comment.user}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.comment.magazine, showAvatar: showIcons }) }}{% endif %} -
<a href="{{ post_url(log.comment.post) }}#{{ get_url_fragment(log.comment) }}">{{ log.comment.shortTitle(300) }}</a>
{% endblock %}

{% block log_post_comment_restored %}
{{ component('user_inline', {user: log.user, showAvatar: false}) }} {{ 'restored_comment_by'|trans|lower }} {{ component('user_inline', {user: log.comment.user, showAvatar: false}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.comment.magazine, showIcon: false }) }}{% endif %} -
{{ component('user_inline', {user: log.user, showAvatar: showAvatars}) }} {{ 'restored_comment_by'|trans|lower }} {{ component('user_inline', {user: log.comment.user}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.comment.magazine, showAvatar: showIcons }) }}{% endif %} -
<a href="{{ post_url(log.comment.post) }}#{{ get_url_fragment(log.comment) }}">{{ log.comment.shortTitle(300) }}</a>
{% endblock %}

{% block log_ban %}
{{ component('user_inline', {user: log.user, showAvatar: false}) }} {% if log.meta is same as 'ban' %}{{ 'he_banned'|trans|lower }}{% else %}{{ 'he_unbanned'|trans|lower }}{% endif %} {{ component('user_inline', {user: log.ban.user, showAvatar: false}) }}
{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.ban.magazine, showIcon: false }) }}{% endif %}{% if log.ban.reason %} - {{ log.ban.reason }}{% endif %}
{{ component('user_inline', {user: log.user, showAvatar: showAvatars}) }} {% if log.meta is same as 'ban' %}{{ 'he_banned'|trans|lower }}{% else %}{{ 'he_unbanned'|trans|lower }}{% endif %} {{ component('user_inline', {user: log.ban.user}) }}
{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.ban.magazine, showAvatar: showIcons }) }}{% endif %}{% if log.ban.reason %} - {{ log.ban.reason }}{% endif %}
{% endblock %}

{% block log_moderator_add %}
{% if log.actingUser is not same as null %}
{{ component('user_inline', {user: log.actingUser}) }}
{% else %}
{{ 'someone'|trans }}
{% endif %}
{{ 'magazine_log_mod_added'|trans }}: {{ component('user_inline', {user: log.user}) }}
{{ 'magazine_log_mod_added'|trans -}}
{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.magazine, showAvatar: showIcons }) -}}{%- endif -%}: {{ component('user_inline', {user: log.user, showAvatar: showAvatars}) }}
{% endblock %}

{% block log_moderator_remove %}
{% if log.actingUser is not same as null %}
{{ component('user_inline', {user: log.actingUser}) }}
{% else %}
{{ 'someone'|trans }}
{% endif %}
{{ 'magazine_log_mod_removed'|trans }}: {{ component('user_inline', {user: log.user}) }}
{{ 'magazine_log_mod_removed'|trans -}}
{% if showMagazine %} {{ 'from'|trans|lower }} {{ component('magazine_inline', {magazine: log.magazine, showAvatar: showIcons }) -}}{%- endif -%}: {{ component('user_inline', {user: log.user, showAvatar: showAvatars}) }}
{% endblock %}
9 changes: 8 additions & 1 deletion templates/modlog/front.html.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{% extends 'base.html.twig' %}
{% set V_TRUE = constant('App\\Controller\\User\\ThemeSettingsController::TRUE') %}
{% set MBIN_MODERATION_LOG_SHOW_USER_AVATARS = constant('App\\Controller\\User\\ThemeSettingsController::MBIN_MODERATION_LOG_SHOW_USER_AVATARS') %}
{% set showAvatars = app.request.cookies.get(MBIN_MODERATION_LOG_SHOW_USER_AVATARS) is same as V_TRUE %}
{% set MBIN_MODERATION_LOG_SHOW_MAGAZINE_ICONS = constant('App\\Controller\\User\\ThemeSettingsController::MBIN_MODERATION_LOG_SHOW_MAGAZINE_ICONS') %}
{% set showIcons = app.request.cookies.get(MBIN_MODERATION_LOG_SHOW_MAGAZINE_ICONS) is same as V_TRUE %}
{% use 'modlog/_blocks.html.twig' %}

{%- block title -%}
Expand Down Expand Up @@ -27,7 +32,9 @@
<div>
{%- with {
log: log,
showMagazine: false,
showMagazine: true,
showAvatars: showAvatars,
showIcons: showIcons,
} only -%}
{{ block(log.type) }}
{%- endwith -%}
Expand Down
9 changes: 8 additions & 1 deletion templates/modlog/magazine.html.twig
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
{% extends 'base.html.twig' %}
{% set V_TRUE = constant('App\\Controller\\User\\ThemeSettingsController::TRUE') %}
{% set MBIN_MODERATION_LOG_SHOW_USER_AVATARS = constant('App\\Controller\\User\\ThemeSettingsController::MBIN_MODERATION_LOG_SHOW_USER_AVATARS') %}
{% set showAvatars = app.request.cookies.get(MBIN_MODERATION_LOG_SHOW_USER_AVATARS) is same as V_TRUE %}
{% set MBIN_MODERATION_LOG_SHOW_MAGAZINE_ICONS = constant('App\\Controller\\User\\ThemeSettingsController::MBIN_MODERATION_LOG_SHOW_MAGAZINE_ICONS') %}
{% set showIcons = app.request.cookies.get(MBIN_MODERATION_LOG_SHOW_MAGAZINE_ICONS) is same as V_TRUE %}
{% use 'modlog/_blocks.html.twig' %}

{%- block title -%}
{{- 'magazines'|trans }} - {{ parent() -}}
{%- endblock -%}

{% block mainClass %}page-magazines{% endblock %}
{% block mainClass %}page-magazines page-modlog{% endblock %}

{% block header_nav %}
{% endblock %}
Expand All @@ -24,6 +29,8 @@
{%- with {
log: log,
showMagazine: false,
showAvatars: showAvatars,
showIcons: showIcons,
} only -%}
{{ block(log.type) }}
{%- endwith -%}
Expand Down
2 changes: 2 additions & 0 deletions translations/messages.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ reset_password: Reset password
show_more: Show more
to: to
in: in
from: from
username: Username
email: Email
repeat_password: Repeat password
Expand Down Expand Up @@ -824,5 +825,6 @@ related_entry: Related
restrict_magazine_creation: Restrict local magazine creation to admins and global mods
sso_show_first: Show SSO first on login and registration pages
continue_with: Continue with
someone: Someone
magazine_log_mod_added: has added a moderator
magazine_log_mod_removed: has removed a moderator

0 comments on commit 8afe388

Please sign in to comment.