diff --git a/core/permissions.php b/core/permissions.php index 23a4491c..aedf3a5c 100644 --- a/core/permissions.php +++ b/core/permissions.php @@ -118,4 +118,5 @@ abstract class Permissions public const BULK_IMPORT = "bulk_import"; public const BULK_EXPORT = "bulk_export"; public const BULK_DOWNLOAD = "bulk_download"; + public const BULK_PARENT_CHILD = "bulk_parent_child"; } diff --git a/core/userclass.php b/core/userclass.php index fc04b60b..5e66256c 100644 --- a/core/userclass.php +++ b/core/userclass.php @@ -223,6 +223,7 @@ new UserClass("admin", "base", [ Permissions::BULK_IMPORT =>true, Permissions::BULK_EXPORT =>true, Permissions::BULK_DOWNLOAD => true, + Permissions::BULK_PARENT_CHILD => true, Permissions::SET_PRIVATE_IMAGE => true, Permissions::SET_OTHERS_PRIVATE_IMAGES => true, diff --git a/ext/bulk_parent_child/info.php b/ext/bulk_parent_child/info.php new file mode 100644 index 00000000..4f30a9d8 --- /dev/null +++ b/ext/bulk_parent_child/info.php @@ -0,0 +1,17 @@ +""]; + public string $license = self::LICENSE_WTFPL; + public string $description = "Allows bulk setting of parent-child relationships, in order of manual selection"; + public array $dependencies = [BulkActionsInfo::KEY]; +} diff --git a/ext/bulk_parent_child/main.php b/ext/bulk_parent_child/main.php new file mode 100644 index 00000000..296c9af8 --- /dev/null +++ b/ext/bulk_parent_child/main.php @@ -0,0 +1,41 @@ +can(Permissions::BULK_PARENT_CHILD)) { + $event->add_action(BulkParentChild::PARENT_CHILD_ACTION_NAME, "Set Parent Child"); + } + } + + public function onBulkAction(BulkActionEvent $event) + { + global $user, $page, $config; + if ($user->can(Permissions::BULK_PARENT_CHILD)&& + ($event->action == BulkParentChild::PARENT_CHILD_ACTION_NAME)) { + $prev_id = null; + foreach ($event->items as $image) { + if ($prev_id != null) { + send_event(new ImageRelationshipSetEvent($image->id, $prev_id)); + } + $prev_id = $image->id; + } + } + } +}