From 1c78a04edd7116cac972da0a727c0358c274b01a Mon Sep 17 00:00:00 2001 From: ctrlcctrlv Date: Thu, 8 Aug 2013 19:41:21 +0000 Subject: [PATCH] Spoil files moderator action --- inc/config.php | 1 + inc/display.php | 8 ++++++++ inc/mod/pages.php | 27 +++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/inc/config.php b/inc/config.php index 8ca769bb..ea0300e0 100644 --- a/inc/config.php +++ b/inc/config.php @@ -954,6 +954,7 @@ $config['mod']['link_ban'] = '[B]'; $config['mod']['link_bandelete'] = '[B&D]'; $config['mod']['link_deletefile'] = '[F]'; + $config['mod']['link_spoilerimage'] = '[S]'; $config['mod']['link_deletebyip'] = '[D+]'; $config['mod']['link_deletebyip_global'] = '[D++]'; $config['mod']['link_sticky'] = '[Sticky]'; diff --git a/inc/display.php b/inc/display.php index 99228fc3..77df971a 100644 --- a/inc/display.php +++ b/inc/display.php @@ -345,6 +345,10 @@ class Post { if (!empty($this->file) && hasPermission($config['mod']['deletefile'], $board['uri'], $this->mod)) $built .= ' ' . secure_link_confirm($config['mod']['link_deletefile'], _('Delete file'), _('Are you sure you want to delete this file?'), $board['dir'] . 'deletefile/' . $this->id); + // Spoiler file (keep post) + if (!empty($this->file) && $this->file != "deleted" && $this->file != null && $this->thumb != 'spoiler' && hasPermission($config['mod']['spoilerimage'], $board['uri'], $this->mod) && $config['spoiler_images']) + $built .= ' ' . secure_link_confirm($config['mod']['link_spoilerimage'], 'Spoiler File', 'Are you sure you want to spoiler this file?', $board['uri'] . '/spoiler/' . $this->id); + // Edit post if (hasPermission($config['mod']['editpost'], $board['uri'], $this->mod)) $built .= ' ' . $config['mod']['link_editpost'] . ''; @@ -445,6 +449,10 @@ class Thread { // Delete file (keep post) if (!empty($this->file) && $this->file != 'deleted' && hasPermission($config['mod']['deletefile'], $board['uri'], $this->mod)) $built .= ' ' . secure_link_confirm($config['mod']['link_deletefile'], _('Delete file'), _('Are you sure you want to delete this file?'), $board['dir'] . 'deletefile/' . $this->id); + + // Spoiler file (keep post) + if (!empty($this->file) && $this->file != "deleted" && $this->file != null && $this->thumb != 'spoiler' && hasPermission($config['mod']['spoilerimage'], $board['uri'], $this->mod) && $config['spoiler_images']) + $built .= ' ' . secure_link_confirm($config['mod']['link_spoilerimage'], 'Spoiler File', 'Are you sure you want to spoiler this file?', $board['uri'] . '/spoiler/' . $this->id); // Sticky if (hasPermission($config['mod']['sticky'], $board['uri'], $this->mod)) diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 10205a11..23b90aba 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -1361,6 +1361,33 @@ function mod_deletefile($board, $post) { header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']); } +function mod_spoiler_image($board, $post) { + global $config, $mod; + + if (!openBoard($board)) + error($config['error']['noboard']); + + if (!hasPermission($config['mod']['spoilerimage'], $board)) + error($config['error']['noaccess']); + + // Delete file + $query = prepare(sprintf("UPDATE `posts_%s` SET `thumb` = :thumb, `thumbwidth` = :thumbwidth, `thumbheight` = :thumbheight WHERE `id` = :id", $board)); + $query->bindValue(':thumb', "spoiler"); + $query->bindValue(':thumbwidth', 128, PDO::PARAM_INT); + $query->bindValue(':thumbheight', 128, PDO::PARAM_INT); + $query->bindValue(':id', $post, PDO::PARAM_INT); + $query->execute() or error(db_error($query)); + + // Record the action + modLog("Spoilered file from post #{$post}"); + + // Rebuild board + buildIndex(); + + // Redirect + header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']); +} + function mod_deletebyip($boardName, $post, $global = false) { global $config, $mod, $board;