Merge pull request #921 from luanalatte/approval-bypass

Approval bypass
This commit is contained in:
Shish 2023-06-25 19:54:07 +01:00 committed by GitHub
commit a03840c60e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 0 deletions

View file

@ -120,6 +120,7 @@ abstract class Permissions
public const CRON_ADMIN = "cron_admin";
public const APPROVE_IMAGE = "approve_image";
public const APPROVE_COMMENT = "approve_comment";
public const BYPASS_IMAGE_APPROVAL = "bypass_image_approval";
public const SET_PRIVATE_IMAGE = "set_private_image";
public const SET_OTHERS_PRIVATE_IMAGES = "set_others_private_images";

View file

@ -217,6 +217,7 @@ new UserClass("admin", "base", [
Permissions::APPROVE_IMAGE => true,
Permissions::APPROVE_COMMENT => true,
Permissions::BYPASS_IMAGE_APPROVAL => true,
Permissions::CRON_RUN =>true,

View file

@ -26,6 +26,15 @@ class Approval extends Extension
Image::$bool_props[] = "approved";
}
public function onImageAddition(ImageAdditionEvent $event)
{
global $user, $config;
if ($config->get_bool(ApprovalConfig::IMAGES) && $user->can(Permissions::BYPASS_IMAGE_APPROVAL)) {
self::approve_image($event->image->id);
}
}
public function onPageRequest(PageRequestEvent $event)
{
global $page, $user;