docs + added pool:lastcreated metatag which uses the ID of the last pool created by the user

This commit is contained in:
Daku 2014-05-30 16:04:12 +01:00
parent df6b9245ec
commit 183a2c7ae6
2 changed files with 24 additions and 3 deletions

View File

@ -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

View File

@ -23,7 +23,14 @@
* </ul>
* <li>Pools
* <ul>
* <li>pool=(PoolID, PoolTitle) -- add post to pool (if exists)
* <li>pool=(PoolID, PoolTitle, lastcreated) -- add post to pool (if exists)
* <li>pool=(PoolID, PoolTitle, lastcreated):(PoolOrder) -- add post to pool (if exists) with set pool order
* <ul>
* <li>pool=50 -- add post to pool with ID of 50
* <li>pool=10:25 -- add post to pool with ID of 10 and with order 25
* <li>pool=This_is_a_Pool -- add post to pool with a title of "This is a Pool"
* <li>pool=lastcreated -- add post to the last pool the user created
* </ul>
* </ul>
* <li>Post Relationships
* <ul>