boolinate approval

This commit is contained in:
Shish 2020-10-26 23:53:33 +00:00
parent 607803c04f
commit 0cf35db00c

View file

@ -127,7 +127,7 @@ class Approval extends Extension
$matches = [];
if (is_null($event->term) && $this->no_approval_query($event->context)) {
$event->add_querylet(new Querylet($database->scoreql_to_sql("approved = SCORE_BOOL_Y ")));
$event->add_querylet(new Querylet("approved = :true", ["true"=>true]));
}
if (is_null($event->term)) {
@ -135,9 +135,9 @@ class Approval extends Extension
}
if (preg_match(self::SEARCH_REGEXP, strtolower($event->term), $matches)) {
if ($user->can(Permissions::APPROVE_IMAGE) && $matches[1] == "no") {
$event->add_querylet(new Querylet($database->scoreql_to_sql("approved = SCORE_BOOL_N ")));
$event->add_querylet(new Querylet("approved != :true", ["true"=>true]));
} else {
$event->add_querylet(new Querylet($database->scoreql_to_sql("approved = SCORE_BOOL_Y ")));
$event->add_querylet(new Querylet("approved = :true", ["true"=>true]));
}
}
}
@ -261,15 +261,15 @@ class Approval extends Extension
global $database;
if ($this->get_version(ApprovalConfig::VERSION) < 1) {
$database->execute($database->scoreql_to_sql(
"ALTER TABLE images ADD COLUMN approved SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N"
));
$database->execute(
"ALTER TABLE images ADD COLUMN approved_by_id INTEGER NULL"
);
$database->execute("ALTER TABLE images ADD COLUMN approved BOOLEAN NOT NULL DEFAULT FALSE");
$database->execute("ALTER TABLE images ADD COLUMN approved_by_id INTEGER NULL");
$database->execute("CREATE INDEX images_approved_idx ON images(approved)");
$this->set_version(ApprovalConfig::VERSION, 1);
$this->set_version(ApprovalConfig::VERSION, 2);
}
if ($this->get_version(ApprovalConfig::VERSION) < 2) {
$database->standardise_boolean("images", "approved");
$this->set_version(ApprovalConfig::VERSION, 2);
}
}
}