From 43973862dd3c5a3121bdb78cba1dd751e2eac52e 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 | 21 +++++++++++++++++++ inc/mod/pages.php | 1 + js/mod/mod_snippets.js | 12 +++++++++++ stylesheets/style.css | 10 +++++++++ templates/header.html | 3 +++ templates/mod/ban_form.html | 41 ++++++++++++++++++++++++++++++------- 6 files changed, 81 insertions(+), 7 deletions(-) create mode 100644 js/mod/mod_snippets.js diff --git a/inc/config.php b/inc/config.php index 7a2f603d..b28f87f1 100644 --- a/inc/config.php +++ b/inc/config.php @@ -690,6 +690,27 @@ // 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. + // $config['premade_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' => '' + // ) + //); + $config['premade_ban_reasons'] = false; + // Allow users to appeal bans through vichan. $config['ban_appeals'] = false; diff --git a/inc/mod/pages.php b/inc/mod/pages.php index f5ea284c..1e803424 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -1586,6 +1586,7 @@ function mod_ban_post($board, $delete, $post, $token = false) { 'board' => $board, 'delete' => (bool)$delete, 'boards' => listBoards(), + 'reasons' => $config['premade_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..6c61ad6a --- /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); + }); +} diff --git a/stylesheets/style.css b/stylesheets/style.css index 4f81b1a5..6d1d1829 100644 --- a/stylesheets/style.css +++ b/stylesheets/style.css @@ -1225,3 +1225,13 @@ table.fileboard .intro a { 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); +} diff --git a/templates/header.html b/templates/header.html index be20fed1..d35fabb9 100644 --- a/templates/header.html +++ b/templates/header.html @@ -16,6 +16,9 @@ {% if not config.additional_javascript_compile %} {% for javascript in config.additional_javascript %}{% endfor %} {% endif %} + {% if mod %} + + {% endif %} {% endif %} {% if config.recaptcha %}