forked from Cavemanon/cavepaintings
tags/source/rating/locked should only update/log if different than current
This commit is contained in:
@ -64,7 +64,7 @@ class Ratings implements Extension {
|
||||
}
|
||||
|
||||
if($event instanceof RatingSetEvent) {
|
||||
$this->set_rating($event->image->id, $event->rating);
|
||||
$this->set_rating($event->image->id, $event->rating, $event->image->rating);
|
||||
}
|
||||
|
||||
if($event instanceof ImageInfoBoxBuildingEvent) {
|
||||
@ -205,10 +205,12 @@ class Ratings implements Extension {
|
||||
}
|
||||
}
|
||||
|
||||
private function set_rating($image_id, $rating) {
|
||||
private function set_rating($image_id, $rating, $old_rating) {
|
||||
global $database;
|
||||
$database->Execute("UPDATE images SET rating=? WHERE id=?", array($rating, $image_id));
|
||||
log_info("core-image", "Rating for Image #{$image_id} set to: ".$this->theme->rating_to_name($rating));
|
||||
if($old_rating != $rating){
|
||||
$database->Execute("UPDATE images SET rating=? WHERE id=?", array($rating, $image_id));
|
||||
log_info("core-image", "Rating for Image #{$image_id} set to: ".$this->theme->rating_to_name($rating));
|
||||
}
|
||||
}
|
||||
}
|
||||
add_event_listener(new Ratings());
|
||||
|
Reference in New Issue
Block a user