diff --git a/core/permissions.php b/core/permissions.php index fe26d0a7..23a4491c 100644 --- a/core/permissions.php +++ b/core/permissions.php @@ -72,9 +72,13 @@ abstract class Permissions public const SEND_PM = "send_pm"; public const READ_PM = "read_pm"; public const VIEW_OTHER_PMS = "view_other_pms"; + public const EDIT_FEATURE = "edit_feature"; + + public const CREATE_VOTE = "create_vote"; public const BULK_EDIT_VOTE = "bulk_edit_vote"; public const EDIT_OTHER_VOTE = "edit_other_vote"; + public const VIEW_SYSINTO = "view_sysinfo"; public const HELLBANNED = "hellbanned"; diff --git a/core/userclass.php b/core/userclass.php index 7e72b333..d3fbc7e9 100644 --- a/core/userclass.php +++ b/core/userclass.php @@ -108,6 +108,7 @@ new UserClass("user", "base", [ Permissions::CREATE_IMAGE_REPORT => true, Permissions::EDIT_IMAGE_RATING => true, Permissions::EDIT_FAVOURITES => true, + Permissions::CREATE_VOTE => true, Permissions::SEND_PM => true, Permissions::READ_PM => true, Permissions::SET_PRIVATE_IMAGE => true, diff --git a/ext/numeric_score/main.php b/ext/numeric_score/main.php index b5a65cd0..0fff5e68 100644 --- a/ext/numeric_score/main.php +++ b/ext/numeric_score/main.php @@ -75,7 +75,7 @@ class NumericScoreVote public static function create_vote(int $post_id, int $score): bool { global $user; - if (!$user->is_anonymous()) { + if ($user->can(Permissions::CREATE_VOTE)) { assert($score == 0 || $score == -1 || $score == 1); send_event(new NumericScoreSetEvent($post_id, $user, $score)); return true; @@ -107,7 +107,7 @@ class NumericScore extends Extension public function onDisplayingImage(DisplayingImageEvent $event) { global $user; - if (!$user->is_anonymous()) { + if ($user->can(Permissions::CREATE_VOTE)) { $this->theme->get_voter($event->image); } } @@ -150,7 +150,7 @@ class NumericScore extends Extension } die($html); } elseif ($event->page_matches("numeric_score_vote") && $user->check_auth_token()) { - if (!$user->is_anonymous()) { + if ($user->can(Permissions::CREATE_VOTE)) { $image_id = int_escape($_POST['image_id']); $score = int_escape($_POST['vote']); if (($score == -1 || $score == 0 || $score == 1) && $image_id>0) { @@ -366,7 +366,7 @@ class NumericScore extends Extension if (preg_match("/^vote[=|:](up|down|remove)$/", $event->term, $matches)) { global $user; $score = ($matches[1] == "up" ? 1 : ($matches[1] == "down" ? -1 : 0)); - if (!$user->is_anonymous()) { + if ($user->can(Permissions::CREATE_VOTE)) { send_event(new NumericScoreSetEvent($event->image_id, $user, $score)); } }