From e712b12ad90b43830f06e25a38261a68deb353f5 Mon Sep 17 00:00:00 2001 From: PupperWoff Date: Tue, 6 Jun 2017 23:12:15 +0200 Subject: [PATCH] Added Feature - Warn and Delete [W&D] function --- inc/config.php | 1 + inc/mod/pages.php | 14 +++++++++++++- mod.php | 6 +++--- templates/mod/warning_form.html | 4 +--- templates/post/post_controls.html | 3 +++ 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/inc/config.php b/inc/config.php index 533c0702..c82be167 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1452,6 +1452,7 @@ // Mod links (full HTML). $config['mod']['link_delete'] = '[D]'; $config['mod']['link_warning'] = '[W]'; + $config['mod']['link_warningdelete'] = '[W&D]'; $config['mod']['link_ban'] = '[B]'; $config['mod']['link_bandelete'] = '[B&D]'; $config['mod']['link_deletefile'] = '[F]'; diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 67f20b1e..209d8b86 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -1960,7 +1960,7 @@ function mod_ban_post($board, $delete, $post, $token = false) { mod_page(_('New ban'), 'mod/ban_form.html', $args); } -function mod_warning_post($board, $post, $token = false) { +function mod_warning_post($board, $delete, $post, $token = false) { global $config, $mod; if (!openBoard($board)) @@ -2002,6 +2002,17 @@ function mod_warning_post($board, $post, $token = false) { modLog("Attached a public warning message to post #{$post}: " . utf8tohtml($_POST['message'])); buildThread($thread ? $thread : $post); buildIndex(); + } elseif (isset($_POST['delete']) && (int) $_POST['delete']) { + if (!hasPermission($config['mod']['delete'], $board)) + error($config['error']['noaccess']); + + // Delete post + deletePost($post); + modLog("Deleted post #{$post}"); + // Rebuild board + buildIndex(); + // Rebuild themes + rebuildThemes('post-delete', $board); } if(isset($_POST['thread'])) { // Redirect to thread @@ -2018,6 +2029,7 @@ function mod_warning_post($board, $post, $token = false) { 'post' => $post, 'board' => $board, 'boards' => listBoards(), + 'delete' => (bool)$delete, 'reasons' => $config['warning_reasons'], 'token' => $security_token ); diff --git a/mod.php b/mod.php index cf006544..a305beb4 100644 --- a/mod.php +++ b/mod.php @@ -62,7 +62,7 @@ $pages = array( '/IP/([\w.:]+)' => 'secure_POST ip', // view ip address '/IP/([\w.:]+)/remove_note/(\d+)' => 'secure ip_remove_note', // remove note from ip address '/IP/([\w.:-]+)/remove_telegram/(\d+)' => 'secure ip_remove_telegram', // remove telegram from ip address - + '/ban' => 'secure_POST ban', // new ban '/bans' => 'secure_POST bans', // ban list '/bans.json' => 'secure bans_json', // ban list JSON @@ -71,14 +71,14 @@ $pages = array( '/recent/(\d+)' => 'recent_posts', // view recent posts '/recent/(\d+)/([\w,]+?)' => 'recent_posts', // view recent posts '/recent/(\d+)/([\w,]+?)/(json)?' => 'recent_posts', // view recent posts JSON - + '/search' => 'search_redirect', // search '/search/(posts|IP_notes|bans|log)/(.+)/(\d+)' => 'search', // search '/search/(posts|IP_notes|bans|log)/(.+)' => 'search', // search '/(\%b)/archive/' => 'secure_POST view_archive', // view archive '/(\%b)/featured/' => 'secure_POST view_archive_featured', // view featured Archive - '/(\%b)/warning/(\d+)' => 'secure_POST warning_post', // issue warning for post + '/(\%b)/warning(&delete)?/(\d+)' => 'secure_POST warning_post', // issue warning for post '/(\%b)/ban(&delete)?/(\d+)' => 'secure_POST ban_post', // ban poster '/(\%b)/move/(\d+)' => 'secure_POST move', // move thread '/(\%b)/move_reply/(\d+)' => 'secure_POST move_reply', // move reply diff --git a/templates/mod/warning_form.html b/templates/mod/warning_form.html index 5cc90cad..df834663 100644 --- a/templates/mod/warning_form.html +++ b/templates/mod/warning_form.html @@ -22,9 +22,7 @@ $(document).ready(function(){ {% if post and board %} {% endif %} - - - {% if post and board %} + {% if post and board and not delete %}
@@ -45,7 +43,7 @@ $(document).ready(function(){
diff --git a/templates/post/post_controls.html b/templates/post/post_controls.html index 88b25024..9ee3bd75 100644 --- a/templates/post/post_controls.html +++ b/templates/post/post_controls.html @@ -13,6 +13,9 @@ {% if mod|hasPermission(config.mod.warning, board.uri) %} {{ config.mod.link_warning }}  {% endif %} +{% if mod|hasPermission(config.mod.warning, board.uri) and mod|hasPermission(config.mod.delete, board.uri) %} + {{ config.mod.link_warningdelete }}  +{% endif %} {% if mod|hasPermission(config.mod.ban, board.uri) %} {{ config.mod.link_ban }}  {% endif %}