option for add_post & remove_post to log history
(for use with TagTermParse) also make navbox show on pool history page
This commit is contained in:
parent
6a1a57b1a2
commit
2ffb9e9b8a
@ -319,29 +319,22 @@ class Pools extends Extension {
|
||||
$matches = array();
|
||||
|
||||
if(preg_match("/^pool[=|:](.*)$/i", $event->term, $matches)) {
|
||||
$this->add_post_from_tag($matches[1], $event->id);
|
||||
$poolTag = (string) str_replace("_", " ", $matches[1]);
|
||||
|
||||
if(ctype_digit($poolTag)){ //Assume tag is poolID
|
||||
if($this->get_single_pool($poolTag)){
|
||||
$this->add_post($poolTag, $event->id, true);
|
||||
}
|
||||
}else{ //Assume tag is poolTitle
|
||||
if($pool = $this->get_single_pool_from_title($poolTag)){
|
||||
$this->add_post($pool['id'], $event->id, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($matches)) $event->metatag = true;
|
||||
}
|
||||
|
||||
public function add_post_from_tag(/*str*/ $poolTag, /*int*/ $imageID){
|
||||
$poolTag = str_replace("_", " ", $poolTag);
|
||||
//First check if pool tag is a title
|
||||
if(ctype_digit($poolTag)){
|
||||
//If string only contains numeric characters, assume it is $poolID
|
||||
if($this->get_single_pool($poolTag)){ //Make sure pool exists
|
||||
$this->add_post($poolTag, $imageID);
|
||||
}
|
||||
}else{
|
||||
//If string doesn't contain only numeric characters, check to see if tag is title.
|
||||
$pool = $this->get_single_pool_from_title($poolTag);
|
||||
if($pool){
|
||||
$this->add_post($pool['id'], $imageID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------- */
|
||||
/* -------------- Private Functions -------------- */
|
||||
/* ------------------------------------------------- */
|
||||
@ -842,9 +835,9 @@ class Pools extends Extension {
|
||||
|
||||
/*
|
||||
* HERE WE ADD A SIMPLE POST FROM POOL
|
||||
* USED WITH FOREACH IN revert_history()
|
||||
* USED WITH FOREACH IN revert_history() & onTagTermParse()
|
||||
*/
|
||||
private function add_post(/*int*/ $poolID, /*int*/ $imageID) {
|
||||
private function add_post(/*int*/ $poolID, /*int*/ $imageID, $history=false) {
|
||||
global $database;
|
||||
|
||||
if(!$this->check_post($poolID, $imageID)) {
|
||||
@ -855,19 +848,29 @@ class Pools extends Extension {
|
||||
}
|
||||
|
||||
$database->execute("UPDATE pools SET posts=(SELECT COUNT(*) FROM pool_images WHERE pool_id=:pid) WHERE id=:pid", array("pid"=>$poolID));
|
||||
|
||||
if($history){
|
||||
$count = $database->get_one("SELECT COUNT(*) FROM pool_images WHERE pool_id=:pid", array("pid"=>$poolID));
|
||||
$this->add_history($poolID, 1, $imageID, $count);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* HERE WE REMOVE A SIMPLE POST FROM POOL
|
||||
* USED WITH FOREACH IN revert_history()
|
||||
* USED WITH FOREACH IN revert_history() & onTagTermParse()
|
||||
*/
|
||||
private function delete_post(/*int*/ $poolID, /*int*/ $imageID) {
|
||||
private function delete_post(/*int*/ $poolID, /*int*/ $imageID, $history=false) {
|
||||
global $database;
|
||||
|
||||
$database->execute("DELETE FROM pool_images WHERE pool_id = :pid AND image_id = :iid", array("pid"=>$poolID, "iid"=>$imageID));
|
||||
$database->execute("UPDATE pools SET posts=(SELECT COUNT(*) FROM pool_images WHERE pool_id=:pid) WHERE id=:pid", array("pid"=>$poolID));
|
||||
|
||||
if($history){
|
||||
$count = $database->get_one("SELECT COUNT(*) FROM pool_images WHERE pool_id=:pid", array("pid"=>$poolID));
|
||||
$this->add_history($poolID, 0, $imageID, $count);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -412,8 +412,15 @@ class PoolsTheme extends Themelet {
|
||||
|
||||
$html .= "</tbody></table>";
|
||||
|
||||
$nav_html = '
|
||||
<a href="'.make_link().'">Index</a>
|
||||
<br><a href="'.make_link("pool/new").'">Create Pool</a>
|
||||
<br><a href="'.make_link("pool/updated").'">Pool Changes</a>
|
||||
';
|
||||
|
||||
$page->set_title("Recent Changes");
|
||||
$page->set_heading("Recent Changes");
|
||||
$page->add_block(new Block("Navigation", $nav_html, "left", 10));
|
||||
$page->add_block(new Block("Recent Changes", $html, "main", 10));
|
||||
|
||||
$this->display_paginator($page, "pool/updated", null, $pageNumber, $totalPages);
|
||||
|
Loading…
x
Reference in New Issue
Block a user