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)
{
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));
}
}

View file

@ -57,15 +57,17 @@ class PixelFileHandler extends DataHandlerExtension
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event)
{
$event->add_part("
<form>
<select class='shm-zoomer'>
<option value='full'>Full Size</option>
<option value='width'>Fit Width</option>
<option value='height'>Fit Height</option>
<option value='both'>Fit Both</option>
</select>
</form>
", 20);
if ($event->context == "view") {
$event->add_part("
<form>
<select class='shm-zoomer'>
<option value='full'>Full Size</option>
<option value='width'>Fit Width</option>
<option value='height'>Fit Height</option>
<option value='both'>Fit Both</option>
</select>
</form>
", 20);
}
}
}

View file

@ -16,7 +16,7 @@ class ReportImageTheme extends Themelet
$reporter_name = html_escape($report['reporter_name']);
$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);
ksort($iabbe->parts);
$actions = join("<br>", $iabbe->parts);

View file

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

View file

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