This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/ext/bulk_parent_child/main.php

42 lines
1.1 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace Shimmie2;
class BulkParentChildConfig
{
}
class BulkParentChildException extends BulkActionException
{
}
class BulkParentChild extends Extension
{
private const PARENT_CHILD_ACTION_NAME = "bulk_parent_child";
public function onBulkActionBlockBuilding(BulkActionBlockBuildingEvent $event): void
{
global $user;
if ($user->can(Permissions::BULK_PARENT_CHILD)) {
$event->add_action(BulkParentChild::PARENT_CHILD_ACTION_NAME, "Set Parent Child");
}
}
public function onBulkAction(BulkActionEvent $event): void
{
global $user, $page, $config;
2023-11-11 21:49:12 +00:00
if ($user->can(Permissions::BULK_PARENT_CHILD) &&
($event->action == BulkParentChild::PARENT_CHILD_ACTION_NAME)) {
2023-03-30 19:37:06 +00:00
$prev_id = null;
foreach ($event->items as $image) {
2023-06-27 16:45:35 +00:00
if ($prev_id !== null) {
2023-03-30 19:37:06 +00:00
send_event(new ImageRelationshipSetEvent($image->id, $prev_id));
}
$prev_id = $image->id;
}
}
}
}