diff --git a/ext/pools/main.php b/ext/pools/main.php index 08fef3fb..08105b61 100644 --- a/ext/pools/main.php +++ b/ext/pools/main.php @@ -325,17 +325,21 @@ class Pools extends Extension { public function onTagTermParse(TagTermParseEvent $event) { $matches = array(); - if(preg_match("/^pool[=|:]([^:]*):?([0-9]*)$/i", $event->term, $matches)) { + if(preg_match("/^pool[=|:]([^:]*|lastcreated):?([0-9]*)$/i", $event->term, $matches)) { global $user; $poolTag = (string) str_replace("_", " ", $matches[1]); $pool = null; - if(ctype_digit($poolTag)){ //If only digits, assume PoolID + if($poolTag == 'lastcreated'){ + $pool = $this->get_last_userpool($user->id); + } + elseif(ctype_digit($poolTag)){ //If only digits, assume PoolID $pool = $this->get_single_pool($poolTag); }else{ //assume PoolTitle $pool = $this->get_single_pool_from_title($poolTag); } + if($pool ? $this->have_permission($user, $pool) : FALSE){ $image_order = ($matches[2] ?: 0); $this->add_post($pool['id'], $event->id, true, $image_order); @@ -492,6 +496,16 @@ class Pools extends Extension { return $database->get_all("SELECT pool_id FROM pool_images WHERE image_id=:iid", array("iid"=>$imageID)); } + /** + * Retrieve information about the last pool the given userID created + * @param int $userID + * @return array + */ + private function get_last_userpool(/*int*/ $userID){ + global $database; + return $database->get_row("SELECT * FROM pools WHERE user_id=:uid ORDER BY id DESC", array("uid"=>$userID)); + } + /** * HERE WE GET THE IMAGES FROM THE TAG ON IMPORT * @param int $pool_id diff --git a/ext/tag_edit/main.php b/ext/tag_edit/main.php index af70092d..1dfa025e 100644 --- a/ext/tag_edit/main.php +++ b/ext/tag_edit/main.php @@ -23,7 +23,14 @@ * *