From 7a5f87572c81153b9b8621924a5ca187412952f1 Mon Sep 17 00:00:00 2001 From: Shish Date: Fri, 27 Jan 2012 16:27:02 +0000 Subject: [PATCH] an image already knows what its own details are, it doesn't need to be passed them... --- core/imageboard.pack.php | 14 ++++++++------ ext/tag_edit/main.php | 9 +++++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php index 55842143..42e28637 100644 --- a/core/imageboard.pack.php +++ b/core/imageboard.pack.php @@ -363,10 +363,10 @@ class Image { /** * Set the image's source URL */ - public function set_source($source, $old_source) { + public function set_source($source) { global $database; if(empty($source)) $source = null; - if($old_source != $source){ + if($source != $this->source) { $database->execute("UPDATE images SET source=:source WHERE id=:id", array("source"=>$source, "id"=>$this->id)); log_info("core-image", "Source for Image #{$this->id} set to: ".$source); } @@ -376,13 +376,13 @@ class Image { public function is_locked() { return ($this->locked === true || $this->locked == "Y" || $this->locked == "t"); } - public function set_locked($tf, $old_sln) { + public function set_locked($tf) { global $database; $ln = $tf ? "Y" : "N"; $sln = $database->engine->scoreql_to_sql("SCORE_BOOL_$ln"); $sln = str_replace("'", "", $sln); $sln = str_replace('"', "", $sln); - if($old_sln != $sln){ + if($sln != $this->locked) { $database->execute("UPDATE images SET locked=:yn WHERE id=:id", array("yn"=>$sln, "id"=>$this->id)); log_info("core-image", "Setting Image #{$this->id} lock to: $ln"); } @@ -404,14 +404,16 @@ class Image { /** * Set the tags for this image */ - public function set_tags($tags, $old_tags) { + public function set_tags($tags) { global $database; + $tags = Tag::resolve_list($tags); assert(is_array($tags)); assert(count($tags) > 0); $new_tags = implode(" ", $tags); - if($old_tags != $new_tags){ + + if($new_tags != $this->get_tag_list()) { // delete old $this->delete_tags_from_image(); // insert each new tags diff --git a/ext/tag_edit/main.php b/ext/tag_edit/main.php index afdfdbe1..d6fa8ba3 100644 --- a/ext/tag_edit/main.php +++ b/ext/tag_edit/main.php @@ -85,25 +85,26 @@ class TagEdit implements Extension { $this->theme->display_error($page, "Error", "Anonymous tag editing is disabled"); } if($user->is_admin()) { - send_event(new LockSetEvent($event->image, $_POST['tag_edit__locked']=="on")); + $locked = isset($_POST['tag_edit__locked']) && $_POST['tag_edit__locked']=="on"; + send_event(new LockSetEvent($event->image, $locked)); } } if($event instanceof TagSetEvent) { if($user->is_admin() || !$event->image->is_locked()) { - $event->image->set_tags($event->tags, $event->image->get_tag_list()); + $event->image->set_tags($event->tags); } } if($event instanceof SourceSetEvent) { if($user->is_admin() || !$event->image->is_locked()) { - $event->image->set_source($event->source, $event->image->source); + $event->image->set_source($event->source); } } if($event instanceof LockSetEvent) { if($user->is_admin()) { - $event->image->set_locked($event->locked, $event->image->locked); + $event->image->set_locked($event->locked); } }