cavepaintings/ext/bulk_parent_child/main.php

42 lines
1.0 KiB
PHP

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