only show some admin actions on some pages

This commit is contained in:
Shish 2021-04-25 11:20:55 +01:00
parent faf35cc884
commit f5a69e8fa9
5 changed files with 18 additions and 14 deletions

View file

@ -70,7 +70,7 @@ class Featured extends Extension
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event)
{ {
global $user; global $user;
if ($user->can(Permissions::EDIT_FEATURE)) { if ($user->can(Permissions::EDIT_FEATURE) && $event->context == "view") {
$event->add_part($this->theme->get_buttons_html($event->image->id)); $event->add_part($this->theme->get_buttons_html($event->image->id));
} }
} }

View file

@ -57,6 +57,7 @@ class PixelFileHandler extends DataHandlerExtension
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event)
{ {
if ($event->context == "view") {
$event->add_part(" $event->add_part("
<form> <form>
<select class='shm-zoomer'> <select class='shm-zoomer'>
@ -69,3 +70,4 @@ class PixelFileHandler extends DataHandlerExtension
", 20); ", 20);
} }
} }
}

View file

@ -16,7 +16,7 @@ class ReportImageTheme extends Themelet
$reporter_name = html_escape($report['reporter_name']); $reporter_name = html_escape($report['reporter_name']);
$userlink = "<a href='".make_link("user/$reporter_name")."'>$reporter_name</a>"; $userlink = "<a href='".make_link("user/$reporter_name")."'>$reporter_name</a>";
$iabbe = new ImageAdminBlockBuildingEvent($image, $user); $iabbe = new ImageAdminBlockBuildingEvent($image, $user, "report");
send_event($iabbe); send_event($iabbe);
ksort($iabbe->parts); ksort($iabbe->parts);
$actions = join("<br>", $iabbe->parts); $actions = join("<br>", $iabbe->parts);

View file

@ -6,12 +6,14 @@ class ImageAdminBlockBuildingEvent extends Event
public array $parts = []; public array $parts = [];
public Image $image; public Image $image;
public User $user; public User $user;
public string $context;
public function __construct(Image $image, User $user) public function __construct(Image $image, User $user, string $context)
{ {
parent::__construct(); parent::__construct();
$this->image = $image; $this->image = $image;
$this->user = $user; $this->user = $user;
$this->context = $context;
} }
public function add_part(string $html, int $position=50) public function add_part(string $html, int $position=50)

View file

@ -102,7 +102,7 @@ class ViewImage extends Extension
ksort($iibbe->parts); ksort($iibbe->parts);
$this->theme->display_page($image, $iibbe->parts); $this->theme->display_page($image, $iibbe->parts);
$iabbe = new ImageAdminBlockBuildingEvent($image, $user); $iabbe = new ImageAdminBlockBuildingEvent($image, $user, "view");
send_event($iabbe); send_event($iabbe);
ksort($iabbe->parts); ksort($iabbe->parts);
$this->theme->display_admin_block($page, $iabbe->parts); $this->theme->display_admin_block($page, $iabbe->parts);