From fcb7944a35680e964b6eb947c9e5f0efbbed90f7 Mon Sep 17 00:00:00 2001 From: discomrade Date: Sun, 22 May 2022 19:42:57 -0200 Subject: [PATCH] Added Feature - Premade Ban Reasons see https://git.leftypol.org/leftypol/leftypol_vichan/commit/13ac9172e7467519a4dfcab8c6919e05fcc05438 --- inc/config.php | 13 +++++++++++++ inc/mod/pages.php | 1 + js/mod/mod_snippets.js | 12 ++++++++++++ stylesheets/style.css | 10 ++++++++++ templates/header.html | 3 +++ templates/mod/ban_form.html | 31 +++++++++++++++++++++++++++++-- 6 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 js/mod/mod_snippets.js diff --git a/inc/config.php b/inc/config.php index 1b80cd22..b69806cb 100644 --- a/inc/config.php +++ b/inc/config.php @@ -669,6 +669,19 @@ // a link to an email address or IRC chat room to appeal the ban. $config['ban_page_extra'] = ''; + // Pre-configured ban reasons that pre-fill the ban form when clicked. + // To disable, set $config['ban_reasons'] = false; + $config['ban_reasons'] = array( + array( 'reason' => 'Low-quality posting', + 'length' => '1d'), + array( 'reason' => 'Off-topic', + 'length' => '1d'), + array( 'reason' => 'Ban evasion', + 'length' => '30d'), + array( 'reason' => 'Illegal content', + 'length' => ''), + ); + // Allow users to appeal bans through Tinyboard. $config['ban_appeals'] = false; diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 1b68fb2c..c2927de0 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -1872,6 +1872,7 @@ function mod_ban_post($board, $delete, $post, $token = false) { 'board' => $board, 'delete' => (bool)$delete, 'boards' => listBoards(), + 'reasons' => $config['ban_reasons'], 'token' => $security_token ); diff --git a/js/mod/mod_snippets.js b/js/mod/mod_snippets.js new file mode 100644 index 00000000..8e9ab800 --- /dev/null +++ b/js/mod/mod_snippets.js @@ -0,0 +1,12 @@ +/* + * mod_snippets.js + * + * Javascript snippets to be loaded when in mod mode + * + */ + +function populateFormJQuery(frm, data) { + $.each(data, function(key, value){ + $('[name='+key+']', frm).val(value); + }); +} \ No newline at end of file diff --git a/stylesheets/style.css b/stylesheets/style.css index 1803bb9a..60c826c7 100644 --- a/stylesheets/style.css +++ b/stylesheets/style.css @@ -1958,6 +1958,16 @@ div.mix { display: inline-block; } + +.ban-reason-table .warning-reason-table tr td:first-child { + text-align: right; + padding-right: 10px; +} +.ban-reason-table .warning-reason-table tr:hover td { + cursor: pointer; + background-color: rgba(100%,100%,100%,0.2); +} + footer { margin-bottom: 50px; } diff --git a/templates/header.html b/templates/header.html index 0a7aa95f..68c0b8af 100644 --- a/templates/header.html +++ b/templates/header.html @@ -24,6 +24,9 @@ {% for javascript in config.additional_javascript_defer %}{% endfor %} {% endif %} {% endif %} + {% if mod %} + + {% endif %} {% endif %} {% if config.recaptcha %} diff --git a/templates/mod/ban_form.html b/templates/mod/ban_form.html index 1f940ff8..100c497f 100644 --- a/templates/mod/ban_form.html +++ b/templates/mod/ban_form.html @@ -4,7 +4,17 @@ {% set action = '?/ban' %} {% endif %} -
+{% if reasons %} + +{% endif %} + {% if redirect %} @@ -41,7 +51,7 @@ {% if post and board and not delete %} - + @@ -93,3 +103,20 @@
+{% if reasons %} +
+

Predefined Reasons:

+ + + + + + {% for key, reason in reasons %} + + + + + {% endfor %} +
LengthReason
{% if not reason.length %}forever{% else %}{{ reason.length|e }}{% endif %}{{ reason.reason|e }}
+
+{% endif %} \ No newline at end of file