Approval bypass

This commit is contained in:
Luana 2023-06-14 04:48:38 -03:00
parent 133616e508
commit 6cbc12e427
4 changed files with 13 additions and 0 deletions

View file

@ -110,6 +110,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

@ -9,6 +9,7 @@ abstract class ApprovalConfig
public const VERSION = "ext_approval_version";
public const IMAGES = "approve_images";
public const COMMENTS = "approve_comments";
public const BYPASS = "approval_bypass";
}
class Approval extends Extension
@ -22,10 +23,19 @@ class Approval extends Extension
$config->set_default_bool(ApprovalConfig::IMAGES, false);
$config->set_default_bool(ApprovalConfig::COMMENTS, false);
$config->set_default_bool(ApprovalConfig::BYPASS, false);
Image::$bool_props[] = "approved";
}
public function onImageAddition(ImageAdditionEvent $event) {
global $user, $config;
if ($config->get_bool(ApprovalConfig::IMAGES) && $config->get_bool(ApprovalConfig::BYPASS) && $user->can(Permissions::BYPASS_IMAGE_APPROVAL)) {
self::approve_image($event->image->id);
}
}
public function onPageRequest(PageRequestEvent $event)
{
global $page, $user;

View file

@ -47,6 +47,7 @@ class ApprovalTheme extends Themelet
{
$sb = $event->panel->create_new_block("Approval");
$sb->add_bool_option(ApprovalConfig::IMAGES, "Posts: ");
$sb->add_bool_option(ApprovalConfig::BYPASS, "<br>Enable Bypass (if user has permission): ");
}
public function display_admin_form()