diff --git a/contrib/numeric_score/main.php b/contrib/numeric_score/main.php
index 1e2166fd..0fec3a5a 100644
--- a/contrib/numeric_score/main.php
+++ b/contrib/numeric_score/main.php
@@ -91,5 +91,5 @@ class NumericScore extends Extension {
array($image_id, $image_id));
}
}
-add_event_listener(new Score());
+add_event_listener(new NumericScore());
?>
diff --git a/contrib/numeric_score/theme.php b/contrib/numeric_score/theme.php
index 881bc002..0dda1680 100644
--- a/contrib/numeric_score/theme.php
+++ b/contrib/numeric_score/theme.php
@@ -10,12 +10,12 @@ class NumericScoreTheme extends Themelet {
";
diff --git a/contrib/text_score/main.php b/contrib/text_score/main.php
index 698dba15..8114ce49 100644
--- a/contrib/text_score/main.php
+++ b/contrib/text_score/main.php
@@ -1,59 +1,55 @@
* Link: http://trac.shishnet.org/shimmie2/
* License: GPLv2
* Description: Allow users to score images
*/
-class ScoreSetEvent extends Event {
+class TextScoreSetEvent extends Event {
var $image_id, $user, $score;
- public function ScoreSetEvent($image_id, $user, $score) {
+ public function TextScoreSetEvent($image_id, $user, $score) {
$this->image_id = $image_id;
$this->user = $user;
$this->score = $score;
}
}
-class Score extends Extension {
+class TextScore extends Extension {
var $theme;
public function receive_event($event) {
- if(is_null($this->theme)) $this->theme = get_theme_object("score", "ScoreTheme");
+ if(is_null($this->theme)) $this->theme = get_theme_object("text_score", "TextScoreTheme");
if(is_a($event, 'InitExtEvent')) {
global $config;
- if($config->get_int("ext_score_version", 0) < 2) {
+ if($config->get_int("ext_text_score_version", 0) < 1) {
$this->install();
}
-
- global $config;
- $config->set_default_string("ext_rating_anon_privs", 'sq');
- $config->set_default_string("ext_rating_user_privs", 'sq');
}
- if(is_a($event, 'PageRequestEvent') && $event->page_name == "score_text" &&
+ if(is_a($event, 'PageRequestEvent') && $event->page_name == "text_score" &&
$event->get_arg(0) == "vote" && $event->user->is_admin() &&
isset($_POST['score']) && isset($_POST['image_id'])) {
$i_score = int_escape($_POST['score']);
$i_image_id = int_escape($_POST['image_id']);
if($i_score >= -2 || $i_score <= 2) {
- send_event(new ScoreSetEvent($i_image_id, $event->user->id, $i_score));
+ send_event(new TextScoreSetEvent($i_image_id, $event->user->id, $i_score));
}
$event->page->set_mode("redirect");
$event->page->set_redirect(make_link("post/view/$i_image_id"));
}
- if(is_a($event, 'ScoreSetEvent')) {
+ if(is_a($event, 'TextScoreSetEvent')) {
$this->add_vote($event->image_id, $event->user->id, $event->score);
}
if(is_a($event, 'DisplayingImageEvent')) {
- $this->theme->display_scorer($event->page, $event->image->id, $event->image->vote_score);
+ $this->theme->display_scorer($event->page, $event->image->id, $event->image->text_score);
}
if(is_a($event, 'SetupBuildingEvent')) {
@@ -68,11 +64,11 @@ class Score extends Extension {
global $database;
global $config;
- if($config->get_int("ext_score_version") < 1) {
- $database->Execute("ALTER TABLE images ADD COLUMN score INTEGER NOT NULL DEFAULT 0");
- $database->Execute("CREATE INDEX images__score ON images(score)");
+ if($config->get_int("ext_text_score_version") < 1) {
+ $database->Execute("ALTER TABLE images ADD COLUMN text_score INTEGER NOT NULL DEFAULT 0");
+ $database->Execute("CREATE INDEX images__text_score ON images(numeric_score)");
$database->Execute("
- CREATE TABLE images_score_votes (
+ CREATE TABLE text_score_votes (
image_id INTEGER NOT NULL,
user_id INTEGER NOT NULL,
score INTEGER NOT NULL,
@@ -80,16 +76,7 @@ class Score extends Extension {
INDEX(image_id)
)
");
- $config->set_int("ext_score_version", 1);
- }
- if($config->get_int("ext_score_version") < 2) {
- $database->Execute("ALTER TABLE images CHANGE score vote_score INTEGER NOT NULL DEFAULT 0");
- $config->set_int("ext_score_version", 2);
- }
- if($config->get_int("ext_score_version") < 3) {
- $database->Execute("ALTER TABLE images CHANGE vote_score score_text INTEGER NOT NULL DEFAULT 0");
- $database->Execute("RENAME TABLE images_score_votes TO votes_text");
- $config->set_int("ext_score_version", 3);
+ $config->set_int("ext_text_score_version", 1);
}
}
@@ -97,12 +84,12 @@ class Score extends Extension {
global $database;
// TODO: update if already voted
$database->Execute(
- "INSERT INTO votes_text(image_id, user_id, score) VALUES(?, ?, ?)",
+ "INSERT INTO text_score_votes(image_id, user_id, score) VALUES(?, ?, ?)",
array($image_id, $user_id, $score));
$database->Execute(
- "UPDATE images SET score_text=(SELECT AVG(score) FROM votes_text WHERE image_id=?) WHERE id=?",
+ "UPDATE images SET text_score=(SELECT AVG(score) FROM text_score_votes WHERE image_id=?) WHERE id=?",
array($image_id, $image_id));
}
}
-add_event_listener(new Score());
+add_event_listener(new TextScore());
?>
diff --git a/contrib/text_score/theme.php b/contrib/text_score/theme.php
index 307c3275..0bcdde75 100644
--- a/contrib/text_score/theme.php
+++ b/contrib/text_score/theme.php
@@ -1,6 +1,6 @@