From ffb215eb476d1344ffd904626288c2553f95355d Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Mon, 10 Oct 2011 22:37:39 +1100 Subject: added "bumplocking" feature --- inc/config.php | 9 ++++++++- inc/display.php | 9 ++++++++- inc/functions.php | 23 ++++++++++++++++++++--- 3 files changed, 36 insertions(+), 5 deletions(-) (limited to 'inc') diff --git a/inc/config.php b/inc/config.php index 2a511c04..fc5b1b56 100644 --- a/inc/config.php +++ b/inc/config.php @@ -630,6 +630,7 @@ // These can be URLs OR base64 (data URI scheme) //$config['image_sticky'] = $config['dir']['static'] . 'sticky.gif'; //$config['image_locked'] = $config['dir']['static'] . 'locked.gif'; + //$config['image_bumplocked'] = $config['dir']['static'] . 'sage.gif'; //$config['image_deleted'] = $config['dir']['static'] . 'deleted.'; //$config['image_zip'] = $config['dir']['static'] . 'zip.'; @@ -675,6 +676,8 @@ $config['mod']['link_desticky'] = '[-Sticky]'; $config['mod']['link_lock'] = '[Lock]'; $config['mod']['link_unlock'] = '[-Lock]'; + $config['mod']['link_bumplock'] = '[Sage]'; + $config['mod']['link_bumpunlock'] = '[-Sage]'; // Moderator capcodes $config['capcode'] = ' ## %s'; @@ -770,7 +773,11 @@ $config['mod']['lock'] = MOD; // Post in a locked thread $config['mod']['postinlocked'] = MOD; - // Post bypass unoriginal content check + // Prevent a thread from being bumped + $config['mod']['bumplock'] = MOD; + // View whether a thread has been bumplocked ("-1" to allow non-mods to see too) + $config['mod']['view_bumplock'] = MOD; + // Post bypass unoriginal content check on robot-enabled boards $config['mod']['postunoriginal'] = ADMIN; // Bypass flood check $config['mod']['flood'] = ADMIN; diff --git a/inc/display.php b/inc/display.php index 4377ea3c..655aaf22 100644 --- a/inc/display.php +++ b/inc/display.php @@ -276,7 +276,7 @@ }; class Thread { - public function __construct($id, $subject, $email, $name, $trip, $capcode, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $sticky, $locked, $embed, $root=null, $mod=false, $hr=true) { + public function __construct($id, $subject, $email, $name, $trip, $capcode, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $sticky, $locked, $bumplocked, $embed, $root=null, $mod=false, $hr=true) { global $config; if(!isset($root)) $root = &$config['root']; @@ -302,6 +302,7 @@ $this->ip = $ip; $this->sticky = $sticky; $this->locked = $locked; + $this->bumplocked = $bumplocked; $this->embed = $embed; $this->root = $root; $this->mod = $mod; @@ -357,6 +358,12 @@ else $built .= ' ' . $config['mod']['link_sticky'] . ''; + if(hasPermission($config['mod']['bumplock'], $board['uri'], $this->mod)) + if($this->bumplocked) + $built .= ' ' . $config['mod']['link_bumpunlock'] . ''; + else + $built .= ' ' . $config['mod']['link_bumplock'] . ''; + // Lock if(hasPermission($config['mod']['lock'], $board['uri'], $this->mod)) if($this->locked) diff --git a/inc/functions.php b/inc/functions.php index 464d22da..8b90a22f 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -62,6 +62,8 @@ $config['image_sticky'] = $config['dir']['static'] . 'sticky.gif'; if(!isset($config['image_locked'])) $config['image_locked'] = $config['dir']['static'] . 'locked.gif'; + if(!isset($config['image_bumplocked'])) + $config['image_bumplocked'] = $config['dir']['static'] . 'sage.gif'; if(!isset($config['image_deleted'])) $config['image_deleted'] = $config['dir']['static'] . 'deleted.png'; if(!isset($config['image_zip'])) @@ -543,6 +545,21 @@ return (bool) $post['locked']; } + function threadSageLocked($id) { + global $board; + + $query = prepare(sprintf("SELECT `sage` FROM `posts_%s` WHERE `id` = :id AND `thread` IS NULL LIMIT 1", $board['uri'])); + $query->bindValue(':id', $id, PDO::PARAM_INT); + $query->execute() or error(db_error()); + + if(!$post = $query->fetch()) { + // Non-existant, so it can't be locked... + return false; + } + + return (bool) $post['sage']; + } + function threadExists($id) { global $board; @@ -557,7 +574,7 @@ function post($post, $OP) { global $pdo, $board; - $query = prepare(sprintf("INSERT INTO `posts_%s` VALUES ( NULL, :thread, :subject, :email, :name, :trip, :capcode, :body, :time, :time, :thumb, :thumbwidth, :thumbheight, :file, :width, :height, :filesize, :filename, :filehash, :password, :ip, :sticky, :locked, :embed)", $board['uri'])); + $query = prepare(sprintf("INSERT INTO `posts_%s` VALUES ( NULL, :thread, :subject, :email, :name, :trip, :capcode, :body, :time, :time, :thumb, :thumbwidth, :thumbheight, :file, :width, :height, :filesize, :filename, :filehash, :password, :ip, :sticky, :locked, 0, :embed)", $board['uri'])); // Basic stuff $query->bindValue(':subject', $post['subject']); @@ -754,7 +771,7 @@ } } - $thread = new Thread($th['id'], $th['subject'], $th['email'], $th['name'], $th['trip'], $th['capcode'], $th['body'], $th['time'], $th['thumb'], $th['thumbwidth'], $th['thumbheight'], $th['file'], $th['filewidth'], $th['fileheight'], $th['filesize'], $th['filename'], $th['ip'], $th['sticky'], $th['locked'], $th['embed'], $mod ? '?/' : $config['root'], $mod); + $thread = new Thread($th['id'], $th['subject'], $th['email'], $th['name'], $th['trip'], $th['capcode'], $th['body'], $th['time'], $th['thumb'], $th['thumbwidth'], $th['thumbheight'], $th['file'], $th['filewidth'], $th['fileheight'], $th['filesize'], $th['filename'], $th['ip'], $th['sticky'], $th['locked'], $th['sage'], $th['embed'], $mod ? '?/' : $config['root'], $mod); $posts = prepare(sprintf("SELECT * FROM `posts_%s` WHERE `thread` = :id ORDER BY `id` DESC LIMIT :limit", $board['uri'])); $posts->bindValue(':id', $th['id']); @@ -1372,7 +1389,7 @@ while($post = $query->fetch()) { if(!isset($thread)) { - $thread = new Thread($post['id'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['sticky'], $post['locked'], $post['embed'], $mod ? '?/' : $config['root'], $mod); + $thread = new Thread($post['id'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['sticky'], $post['locked'], $post['sage'], $post['embed'], $mod ? '?/' : $config['root'], $mod); } else { $thread->add(new Post($post['id'], $thread->id, $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['embed'], $mod ? '?/' : $config['root'], $mod)); } -- cgit v1.3