Browse Source

Added Feature - Premade Ban Reasons (might need some visual tinkering)

PupperWoff 7 years ago
committed by -
parent
commit
13ac9172e7
  1. 22
      inc/config.php
  2. 5
      inc/mod/pages.php
  3. 12
      js/mod/mod_snippets.js
  4. 9
      stylesheets/style.css
  5. 3
      templates/header.html
  6. 34
      templates/mod/ban_form.html
  7. 30
      templates/mod/warning_form.html

22
inc/config.php

@ -649,7 +649,7 @@
/*
* ====================
* Ban settings
* Ban and warning settings
* ====================
*/
@ -682,6 +682,24 @@
// a link to an email address or IRC chat room to appeal the ban.
$config['warning_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' => ''),
);
// Pre-configured warning reasons that pre-fill the warning form when clicked.
// To disable, set $config['warning_reasons'] = false;
$config['warning_reasons'][] = "Low-quality posting";
$config['warning_reasons'][] = "Off-topic";
$config['warning_reasons'][] = "Check the catalog before posting: A thread of this type has already been posted";
/*
@ -1824,8 +1842,6 @@
// Please set this setting in your board/config.php, not globally.
$config['nntpchan']['group'] = false; // eg. 'overchan.test'
/*
* ====================
* Other/uncategorized

5
inc/mod/pages.php

@ -1822,6 +1822,7 @@ function mod_ban_post($board, $delete, $post, $token = false) {
$thread = $_post['thread'];
$ip = $_post['ip'];
if (isset($_POST['new_ban'], $_POST['reason'], $_POST['length'], $_POST['board'])) {
require_once 'inc/mod/ban.php';
@ -1899,7 +1900,7 @@ function mod_ban_post($board, $delete, $post, $token = false) {
header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']);
}
$args = array(
'ip' => $ip,
'hide_ip' => !hasPermission($config['mod']['show_ip'], $board),
@ -1907,6 +1908,7 @@ function mod_ban_post($board, $delete, $post, $token = false) {
'board' => $board,
'delete' => (bool)$delete,
'boards' => listBoards(),
'reasons' => $config['ban_reasons'],
'token' => $security_token
);
@ -1971,6 +1973,7 @@ function mod_warning_post($board, $post, $token = false) {
'post' => $post,
'board' => $board,
'boards' => listBoards(),
'reasons' => $config['warning_reasons'],
'token' => $security_token
);

12
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);
});
}

9
stylesheets/style.css

@ -1227,3 +1227,12 @@ 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);
}

3
templates/header.html

@ -16,6 +16,9 @@
{% if not config.additional_javascript_compile %}
{% for javascript in config.additional_javascript %}<script type="text/javascript" src="{{ config.additional_javascript_url }}{{ javascript }}"></script>{% endfor %}
{% endif %}
{% if mod %}
<script type="text/javascript" src="/js/mod/mod_snippets.js"></script>
{% endif %}
{% endif %}
{% if config.recaptcha %}<script src="//www.google.com/recaptcha/api.js"></script>
<style type="text/css">{% verbatim %}

34
templates/mod/ban_form.html

@ -4,7 +4,17 @@
{% set action = '?/ban' %}
{% endif %}
<form action="{{ action }}" method="post">
{% if reasons %}
<script type="text/javascript">
$(document).ready(function(){
{% for key, reason in reasons %}
var data_{{ key }} = '{"reason":"{{ reason.reason|escape('js') }}","message":"{{ reason.reason|escape('js') }}","length":"{{ reason.length|escape('js') }}"}';
$('#reason-selector-id-{{ key }}').click(function() { populateFormJQuery('#ban-form-id', $.parseJSON(data_{{ key }})); });
{% endfor %}
});
</script>
{% endif %}
<form action="{{ action }}" method="post" id="ban-form-id">
<input type="hidden" name="token" value="{{ token }}">
{% if redirect %}
<input type="hidden" name="redirect" value="{{ redirect|e }}">
@ -38,7 +48,7 @@
{% if post and board and not delete %}
<tr>
<th>
<label for="reason">{% trans 'Message' %}</label>
<label for="message">{% trans 'Message' %}</label>
</th>
<td>
<input type="checkbox" id="public_message" name="public_message"{% if config.mod.check_ban_message %} checked{% endif %}>
@ -58,7 +68,7 @@
<label for="length">{% trans 'Length' %}</label>
</th>
<td>
<input type="text" name="length" id="length" size="20" maxlength="40">
<input type="text" name="length" id="length" size="20" maxlength="40">
<span class="unimportant">(eg. "2d1h30m" or "2 days")</span></td>
</tr>
<tr>
@ -89,4 +99,20 @@
</tr>
</table>
</form>
{% if reasons %}
<center>
<h3>Predefined Reasons:</h3>
<table class="ban-reason-table">
<tr id="reason-selector-heading">
<th><b>Length</b></th>
<th><b>Reason</b></th>
</tr>
{% for key, reason in reasons %}
<tr id="reason-selector-id-{{ key }}">
<td>{% if not reason.length %}forever{% else %}{{ reason.length|e }}{% endif %}</td>
<td>{{ reason.reason|e }}</td>
</tr>
{% endfor %}
</table>
</center>
{% endif %}

30
templates/mod/warning_form.html

@ -4,7 +4,17 @@
{% set action = '?/warning' %}
{% endif %}
<form action="{{ action }}" method="post">
{% if reasons %}
<script type="text/javascript">
$(document).ready(function(){
{% for key, reason in reasons %}
var data_{{ key }} = '{"reason":"{{ reason|escape('js') }}","message":"{{ reason|escape('js') }}"}';
$('#reason-selector-id-{{ key }}').click(function() { populateFormJQuery('#warning-form-id', $.parseJSON(data_{{ key }})); });
{% endfor %}
});
</script>
{% endif %}
<form action="{{ action }}" method="post" id="warning-form-id">
<input type="hidden" name="token" value="{{ token }}">
{% if redirect %}
<input type="hidden" name="redirect" value="{{ redirect|e }}">
@ -38,7 +48,7 @@
{% if post and board %}
<tr>
<th>
<label for="reason">{% trans 'Message' %}</label>
<label for="message">{% trans 'Message' %}</label>
</th>
<td>
<input type="checkbox" id="public_message" name="public_message"{% if config.mod.check_warning_message %} checked{% endif %}>
@ -59,4 +69,18 @@
</tr>
</table>
</form>
{% if reasons %}
<center>
<h3>Predefined Reasons:</h3>
<table class="warning-reason-table">
<tr id="reason-selector-heading">
<th><b>Reason</b></th>
</tr>
{% for key, reason in reasons %}
<tr id="reason-selector-id-{{ key }}">
<td>{{ reason|e }}</td>
</tr>
{% endfor %}
</table>
</center>
{% endif %}

Loading…
Cancel
Save