From 98e7359c6e4b873b3433f4d84e5649253ccdd8d5 Mon Sep 17 00:00:00 2001 From: "green-ponies (jgen)" Date: Wed, 8 Feb 2012 16:32:41 -0500 Subject: [PATCH] Show a link for the Next image in a pool. --- contrib/pools/main.php | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/contrib/pools/main.php b/contrib/pools/main.php index 6986867e..900c3435 100644 --- a/contrib/pools/main.php +++ b/contrib/pools/main.php @@ -100,7 +100,7 @@ class Pools extends SimpleExtension { $this->list_pools($page, int_escape($event->get_arg(1))); break; - case "new": // Show form + case "new": // Show form for new pools if(!$user->is_anonymous()){ $this->theme->new_pool_composer($page); } else { @@ -237,6 +237,11 @@ class Pools extends SimpleExtension { $pools = $this->get_pool($poolID['pool_id']); foreach ($pools as $pool){ $linksPools[] = "".html_escape($pool['title']).""; + // TODO: make a config for this + $next_image_in_pool = get_next_post($pool['id'], $imageID); + if (!empty($next_image_in_pool)) { + $linksPools[] = 'Next'; + } } } $this->theme->pool_info($linksPools); @@ -475,6 +480,30 @@ class Pools extends SimpleExtension { return ($result != 0); } + /** + * Gets the next successive image from a pool, given a pool ID and an image ID. + */ + private function get_next_post(/*int*/ $poolID, /*int*/ $imageID) { + global $database; + + $poolID = int_escape($poolID); + $pool = $this->get_pool($poolID); + + $result = $database->get_one(" + SELECT image_id + FROM pool_images + WHERE pool_id=:pid + AND image_order > (SELECT image_order FROM pool_images WHERE pool_id=:pid AND image_id =:iid LIMIT 1 ) + ORDER BY image_order ASC LIMIT 1", + array("pid"=>$poolID, "iid"=>$imageID) ); + + if (empty($result)) { + // assume that we are at the end of the pool + return null; + } else { + return $result; + } + } /** * Retrieve all the images in a pool, given a pool ID.