1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-12 01:50:48 +01:00

Added Feature - Premade Ban Reasons

see 13ac9172e7
This commit is contained in:
discomrade 2022-05-22 19:42:57 -02:00 committed by Zankaria
parent 3ac86a074a
commit 43973862dd
6 changed files with 81 additions and 7 deletions

View File

@ -690,6 +690,27 @@
// a link to an email address or IRC chat room to appeal the ban. // a link to an email address or IRC chat room to appeal the ban.
$config['ban_page_extra'] = ''; $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. // Allow users to appeal bans through vichan.
$config['ban_appeals'] = false; $config['ban_appeals'] = false;

View File

@ -1586,6 +1586,7 @@ function mod_ban_post($board, $delete, $post, $token = false) {
'board' => $board, 'board' => $board,
'delete' => (bool)$delete, 'delete' => (bool)$delete,
'boards' => listBoards(), 'boards' => listBoards(),
'reasons' => $config['premade_ban_reasons'],
'token' => $security_token 'token' => $security_token
); );

12
js/mod/mod_snippets.js Normal file
View File

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

View File

@ -1225,3 +1225,13 @@ table.fileboard .intro a {
div.mix { div.mix {
display: inline-block; 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);
}

View File

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

View File

@ -6,7 +6,17 @@
{% set action = '?/ban' %} {% set action = '?/ban' %}
{% endif %} {% 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 }}"> <input type="hidden" name="token" value="{{ token }}">
{% if redirect %} {% if redirect %}
<input type="hidden" name="redirect" value="{{ redirect|e }}"> <input type="hidden" name="redirect" value="{{ redirect|e }}">
@ -14,7 +24,7 @@
{% if post and board %} {% if post and board %}
<input type="hidden" name="delete" value="{% if delete %}1{% else %}0{% endif %}"> <input type="hidden" name="delete" value="{% if delete %}1{% else %}0{% endif %}">
{% endif %} {% endif %}
<table> <table>
{% if not edit_ban %} {% if not edit_ban %}
<tr> <tr>
@ -41,11 +51,11 @@
{% if post and board and not delete %} {% if post and board and not delete %}
<tr> <tr>
<th> <th>
<label for="reason">{% trans 'Message' %}</label> <label for="message">{% trans 'Message' %}</label>
</th> </th>
<td> <td>
<input type="checkbox" id="public_message" name="public_message"{% if config.mod.check_ban_message %} checked{% endif %}> <input type="checkbox" id="public_message" name="public_message"{% if config.mod.check_ban_message %} checked{% endif %}>
<input type="text" name="message" id="message" size="35" maxlength="200" value="{{ config.mod.default_ban_message|e }}"> <input type="text" name="message" id="message" size="35" maxlength="200" value="{{ config.mod.default_ban_message|e }}">
<span class="unimportant">({% trans 'public; attached to post' %})</span> <span class="unimportant">({% trans 'public; attached to post' %})</span>
<script type="text/javascript"> <script type="text/javascript">
document.getElementById('message').disabled = !document.getElementById('public_message').checked; document.getElementById('message').disabled = !document.getElementById('public_message').checked;
@ -61,7 +71,7 @@
<label for="length">{% trans 'Length' %}</label> <label for="length">{% trans 'Length' %}</label>
</th> </th>
<td> <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> <span class="unimportant">(eg. "2d1h30m" or "2 days")</span></td>
</tr> </tr>
<tr> <tr>
@ -74,7 +84,7 @@
<em>{% trans 'all boards' %}</em> <em>{% trans 'all boards' %}</em>
</label> </label>
</li> </li>
{% for board in boards %} {% for board in boards %}
<li> <li>
<input type="radio" name="board" value="{{ board.uri }}" id="ban-board-{{ board.uri }}" {% if edit_ban and current_board == board.uri %}checked{% endif %}> <input type="radio" name="board" value="{{ board.uri }}" id="ban-board-{{ board.uri }}" {% if edit_ban and current_board == board.uri %}checked{% endif %}>
@ -93,3 +103,20 @@
</table> </table>
</form> </form>
{% if reasons %}
<div style="text-align: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>
</div>
{% endif %}