diff --git a/contrib/rating/main.php b/contrib/rating/main.php index e03cb2a4..e5b6edf3 100644 --- a/contrib/rating/main.php +++ b/contrib/rating/main.php @@ -15,11 +15,12 @@ class Ratings extends Extension { if(is_a($event, 'InitExtEvent')) { global $config; - if($config->get_int("ext_ratings_version") < 1) { + if($config->get_int("ext_ratings_version") < 2) { $this->install(); } } + # TODO: ImageEditorBuildingEvent if(is_a($event, 'PageRequestEvent') && $event->page_name == "rating" && $event->get_arg(0) == "set" && $event->user->is_admin() && isset($_POST['rating']) && isset($_POST['image_id'])) { @@ -31,7 +32,7 @@ class Ratings extends Extension { if(is_a($event, 'DisplayingImageEvent')) { global $user; if($user->is_admin()) { - $this->theme->display_rater($event->page, $event->image->id); + $this->theme->display_rater($event->page, $event->image->id, $event->image->rating); } } } @@ -39,10 +40,16 @@ class Ratings extends Extension { private function install() { global $database; global $config; - $database->Execute("ALTER TABLE images - ADD COLUMN rating ENUM('s', 'q', 'e') NOT NULL DEFAULT 'q' - )"); - $config->set_int("ext_ratings_version", 1); + + if($config->get_int("ext_ratings_version") < 1) { + $database->Execute("ALTER TABLE images ADD COLUMN rating ENUM('s', 'q', 'e') NOT NULL DEFAULT 'q'"); + $config->set_int("ext_ratings_version", 1); + } + + if($config->get_int("ext_ratings_version") < 2) { + $database->Execute("CREATE INDEX images__rating ON images(rating)"); + $config->set_int("ext_ratings_version", 2); + } } private function set_rating($image_id, $rating) { diff --git a/contrib/rating/theme.php b/contrib/rating/theme.php index dc12c658..67b1863b 100644 --- a/contrib/rating/theme.php +++ b/contrib/rating/theme.php @@ -1,18 +1,21 @@ - - - + + + "; - $page->add_block(new Block(null, $html, "main", 45)); + $page->add_block(new Block(null, $html, "main", 7)); } }