WIP: Draft: Resolve "Add option to link post in ban form in the IP page" #95
2 changed files with 85 additions and 35 deletions
|
|
@ -1716,11 +1716,13 @@ function mod_move(Context $ctx, $originBoard, $postID) {
|
|||
function mod_merge(Context $ctx, $originBoard, $postID) {
|
||||
global $board, $config, $pdo;
|
||||
|
||||
if (!openBoard($originBoard))
|
||||
if (!openBoard($originBoard)) {
|
||||
error($config['error']['noboard']);
|
||||
}
|
||||
|
||||
if (!hasPermission($config['mod']['merge'], $originBoard))
|
||||
if (!hasPermission($config['mod']['merge'], $originBoard)) {
|
||||
error($config['error']['noaccess']);
|
||||
}
|
||||
|
||||
$query = prepare(sprintf('SELECT * FROM ``posts_%s`` WHERE `id` = :id AND `thread` IS NULL', $originBoard));
|
||||
$query->bindValue(':id', (int)$postID, \PDO::PARAM_INT);
|
||||
|
|
@ -1729,32 +1731,29 @@ function mod_merge(Context $ctx, $originBoard, $postID) {
|
|||
error($config['error']['404']);
|
||||
}
|
||||
$sourceOp = "";
|
||||
if ($post['thread']){
|
||||
if ($post['thread']) {
|
||||
$sourceOp = $post['thread'];
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$sourceOp = $post['id'];
|
||||
}
|
||||
$newpost = "";
|
||||
$newpost = "";
|
||||
$boards = listBoards();
|
||||
|
||||
if (isset($_POST['board'])) {
|
||||
$targetBoard = $_POST['board'];
|
||||
$shadow = isset($_POST['shadow']);
|
||||
$targetOp = "";
|
||||
$targetOp = "";
|
||||
|
||||
if ($_POST['target_thread']) {
|
||||
$query = prepare(sprintf('SELECT * FROM ``posts_%s`` WHERE `id` = :id', $targetBoard));
|
||||
$query->bindValue(':id', $_POST['target_thread']);
|
||||
$query->execute() or error(db_error($query)); // If it fails, thread probably does not exist
|
||||
if (!$newpost = $query->fetch(PDO::FETCH_ASSOC)){
|
||||
error($config['error']['404']);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if ($newpost['thread']){
|
||||
$targetOp = $newpost['thread'];
|
||||
}
|
||||
else{
|
||||
} else{
|
||||
$targetOp = $newpost['id'];
|
||||
}
|
||||
}
|
||||
|
|
@ -1771,8 +1770,6 @@ function mod_merge(Context $ctx, $originBoard, $postID) {
|
|||
file_unlink($board['dir'] . $config['dir']['res'] . link_for($post) );
|
||||
file_unlink($board['dir'] . $config['dir']['res'] . link_for($post, true) ); // noko50
|
||||
file_unlink($board['dir'] . $config['dir']['res'] . sprintf('%d.json', $post['id']));
|
||||
//deletePost($postID);
|
||||
//modLog("Deleted post #{$postID}");
|
||||
buildIndex();
|
||||
|
||||
// build new thread
|
||||
|
|
@ -1784,22 +1781,24 @@ function mod_merge(Context $ctx, $originBoard, $postID) {
|
|||
|
||||
// redirect
|
||||
header('Location: ?/' . sprintf($config['board_path'], $board['uri']) . $config['dir']['res'] . link_for($newpost) . '#' . $targetOp, true, $config['redirect_http']);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Move thread to new board without shadow thread and then update the thread id for all posts in that thread to new op
|
||||
// indicate that the post is a thread
|
||||
if (count($boards) <= 1)
|
||||
if (count($boards) <= 1) {
|
||||
error(_('Impossible to merge thread to different board; there is only one board.'));
|
||||
}
|
||||
$post['op'] = true;
|
||||
|
||||
if ($post['files']) {
|
||||
$post['files'] = json_decode($post['files'], TRUE);
|
||||
$post['has_file'] = true;
|
||||
foreach ($post['files'] as $i => &$file) {
|
||||
if ($file['file'] !== 'deleted')
|
||||
if ($file['file'] !== 'deleted') {
|
||||
$file['file_path'] = sprintf($config['board_path'], $board['uri']) . $config['dir']['img'] . $file['file'];
|
||||
if (isset($file['thumb']) && !in_array($file['thumb'], array('spoiler', 'deleted', 'file')))
|
||||
}
|
||||
if (isset($file['thumb']) && !in_array($file['thumb'], array('spoiler', 'deleted', 'file'))) {
|
||||
$file['thumb_path'] = sprintf($config['board_path'], $board['uri']) . $config['dir']['thumb'] . $file['thumb'];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$post['has_file'] = false;
|
||||
|
|
@ -1808,8 +1807,9 @@ function mod_merge(Context $ctx, $originBoard, $postID) {
|
|||
// allow thread to keep its same traits (stickied, locked, etc.)
|
||||
$post['mod'] = true;
|
||||
|
||||
if (!openBoard($targetBoard))
|
||||
if (!openBoard($targetBoard)) {
|
||||
error($config['error']['noboard']);
|
||||
}
|
||||
|
||||
// create the new thread
|
||||
$newID = post($post);
|
||||
|
|
@ -1823,10 +1823,12 @@ function mod_merge(Context $ctx, $originBoard, $postID) {
|
|||
if ($post['has_file']) {
|
||||
// copy image
|
||||
foreach ($post['files'] as $i => &$file) {
|
||||
if ($file['file'] !== 'deleted')
|
||||
if ($file['file'] !== 'deleted') {
|
||||
clone_wrapped_with_exist_check($clone, $file['file_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['img'] . $file['file']);
|
||||
if (isset($file['thumb']) && !in_array($file['thumb'], array('spoiler', 'deleted', 'file')))
|
||||
}
|
||||
if (isset($file['thumb']) && !in_array($file['thumb'], array('spoiler', 'deleted', 'file'))) {
|
||||
clone_wrapped_with_exist_check($clone, $file['thumb_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['thumb'] . $file['thumb']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1847,10 +1849,12 @@ function mod_merge(Context $ctx, $originBoard, $postID) {
|
|||
$post['files'] = json_decode($post['files'], TRUE);
|
||||
$post['has_file'] = true;
|
||||
foreach ($post['files'] as $i => &$file) {
|
||||
if ($file['file'] !== 'deleted')
|
||||
if ($file['file'] !== 'deleted') {
|
||||
$file['file_path'] = sprintf($config['board_path'], $board['uri']) . $config['dir']['img'] . $file['file'];
|
||||
if (isset($file['thumb']) && !in_array($file['thumb'], array('spoiler', 'deleted', 'file')))
|
||||
}
|
||||
if (isset($file['thumb']) && !in_array($file['thumb'], array('spoiler', 'deleted', 'file'))) {
|
||||
$file['thumb_path'] = sprintf($config['board_path'], $board['uri']) . $config['dir']['thumb'] . $file['thumb'];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$post['has_file'] = false;
|
||||
|
|
@ -1889,10 +1893,12 @@ function mod_merge(Context $ctx, $originBoard, $postID) {
|
|||
if ($post['has_file']) {
|
||||
// copy image
|
||||
foreach ($post['files'] as $i => &$file) {
|
||||
if ($file['file'] !== 'deleted')
|
||||
if ($file['file'] !== 'deleted') {
|
||||
clone_wrapped_with_exist_check($clone, $file['file_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['img'] . $file['file']);
|
||||
if (isset($file['thumb']) && !in_array($file['thumb'], array('spoiler', 'deleted', 'file')))
|
||||
}
|
||||
if (isset($file['thumb']) && !in_array($file['thumb'], array('spoiler', 'deleted', 'file'))) {
|
||||
clone_wrapped_with_exist_check($clone, $file['thumb_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['thumb'] . $file['thumb']);
|
||||
}
|
||||
}
|
||||
}
|
||||
// insert reply
|
||||
|
|
@ -1921,8 +1927,6 @@ function mod_merge(Context $ctx, $originBoard, $postID) {
|
|||
// trigger themes
|
||||
rebuildThemes('post', $targetBoard);
|
||||
|
||||
$newboard = $board;
|
||||
|
||||
// return to original board
|
||||
openBoard($originBoard);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,11 +6,29 @@
|
|||
|
||||
{% if reasons %}
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
document.addEventListener("DOMContentLoaded", 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 %}
|
||||
|
||||
const context_post = document.getElementById('context-post');
|
||||
context_post.disabled = document.getElementById('context-board-no').checked;
|
||||
document.getElementById('context-board-no').addEventListener('change', function(e) {
|
||||
context_post.disabled = e.currentTarget.checked;
|
||||
});
|
||||
|
||||
const boards = [
|
||||
{% for b in boards %}
|
||||
'{{ b.uri }}',
|
||||
{% endfor %}
|
||||
];
|
||||
|
||||
boards.forEach(b => {
|
||||
document.getElementById(`context-board-${b}`).addEventListener('change', function(e) {
|
||||
context_post.disabled = false;
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endif %}
|
||||
|
|
@ -25,9 +43,8 @@ $(document).ready(function(){
|
|||
{% if thread %}
|
||||
<input type="hidden" name="thread" value="{{ thread }}">
|
||||
{% endif %}
|
||||
|
||||
|
||||
<table>
|
||||
|
||||
<tr>
|
||||
<th>
|
||||
<label for="ip">{% trans 'IP' %} <span class="unimportant">{% trans '(or subnet)' %}</span></label>
|
||||
|
|
@ -54,8 +71,8 @@ $(document).ready(function(){
|
|||
<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 %}>
|
||||
<input type="text" name="message" id="message" size="35" maxlength="200" value="{{ config.mod.default_ban_message|e }}">
|
||||
<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 }}">
|
||||
<span class="unimportant">({% trans 'public; attached to post' %})</span>
|
||||
<script type="text/javascript">
|
||||
document.getElementById('message').disabled = !document.getElementById('public_message').checked;
|
||||
|
|
@ -71,7 +88,7 @@ $(document).ready(function(){
|
|||
<label for="length">{% trans 'Length' %}</label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="text" name="length" id="length" size="20" maxlength="43" value="1h">
|
||||
<input type="text" name="length" id="length" size="20" maxlength="43" value="1h">
|
||||
<span class="unimportant">(eg. "2d1h30m" or "2 days", empty is permaban)</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
@ -84,7 +101,7 @@ $(document).ready(function(){
|
|||
<em>{% trans 'all boards' %}</em>
|
||||
</label>
|
||||
</li>
|
||||
|
||||
|
||||
{% for b in boards %}
|
||||
<li>
|
||||
<input type="radio" name="board" value="{{ b.uri }}" id="ban-board-{{ b.uri }}"{% if board == b.uri %} checked{% endif %}>
|
||||
|
|
@ -96,6 +113,35 @@ $(document).ready(function(){
|
|||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{% trans 'Context post' %}</th>
|
||||
<td>
|
||||
<input type="text" name="context-post" id="context-post"/>
|
||||
<span class="unimportant">Specify the post you want the user to see as context</span></td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{% trans 'Context board' %}</th>
|
||||
<td>
|
||||
<ul style="list-style:none;padding:2px 5px">
|
||||
<li>
|
||||
<input type="radio" name="context-board" value="*" id="context-board-no"{% if not board %} checked{% endif %}>
|
||||
<label style="display:inline" for="context-board-no">
|
||||
<em>{% trans 'no context' %}</em>
|
||||
</label>
|
||||
</li>
|
||||
|
||||
{% for b in boards %}
|
||||
<li>
|
||||
<input type="radio" name="context-board" value="{{ b.uri }}" id="context-board-{{ b.uri }}"{% if board == b.uri %} checked{% endif %}>
|
||||
<label style="display:inline" for="ban-board-{{ b.uri }}">
|
||||
{{ config.board_abbreviation|sprintf(b.uri) }} - {{ b.title|e }}
|
||||
</label>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><input name="new_ban" type="submit" value="{% trans 'New Ban' %}"></td>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue