only show some admin actions on some pages
This commit is contained in:
		
							parent
							
								
									faf35cc884
								
							
						
					
					
						commit
						f5a69e8fa9
					
				| @ -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)); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -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'> | ||||||
| @ -68,4 +69,5 @@ class PixelFileHandler extends DataHandlerExtension | |||||||
|                 </form> |                 </form> | ||||||
|             ", 20);
 |             ", 20);
 | ||||||
|         } |         } | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -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); | ||||||
|  | |||||||
| @ -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) | ||||||
|  | |||||||
| @ -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); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user