image = $image; $this->locked = $locked; } } class PostLock extends Extension { /** @var PostLockTheme */ protected Themelet $theme; public function onImageAddition(ImageAdditionEvent $event): void { if (!empty($event->metadata['locked'])) { send_event(new LockSetEvent($event->image, $event->metadata['locked'])); } } public function onImageInfoSet(ImageInfoSetEvent $event): void { global $page, $user; if ($event->image->is_locked() && !$user->can(Permissions::EDIT_IMAGE_LOCK)) { throw new PermissionDenied("Error: This image is locked and cannot be edited."); } if ($user->can(Permissions::EDIT_IMAGE_LOCK)) { $locked = isset($event->params['locked']) && $event->params['locked'] == "on"; send_event(new LockSetEvent($event->image, $locked)); } } public function onLockSet(LockSetEvent $event): void { global $user; if ($user->can(Permissions::EDIT_IMAGE_LOCK)) { $event->image->set_locked($event->locked); } } public function onImageInfoBoxBuilding(ImageInfoBoxBuildingEvent $event): void { $event->add_part($this->theme->get_lock_editor_html($event->image), 42); } }