diff --git a/ext/bulk_actions/main.php b/ext/bulk_actions/main.php index 096cc00d..90a727d5 100644 --- a/ext/bulk_actions/main.php +++ b/ext/bulk_actions/main.php @@ -46,13 +46,19 @@ class BulkActionEvent extends Event { public string $action; public \Generator $items; + /** @var array */ + public array $params; public bool $redirect = true; - public function __construct(string $action, \Generator $items) + /** + * @param array $params + */ + public function __construct(string $action, \Generator $items, array $params) { parent::__construct(); $this->action = $action; $this->items = $items; + $this->params = $params; } } @@ -116,7 +122,7 @@ class BulkActions extends Extension $query = $input->getArgument('query'); $items = $this->yield_search_results($query); log_info("bulk_actions", "Performing $action on $query"); - send_event(new BulkActionEvent($action, $items)); + send_event(new BulkActionEvent($action, $items, [])); return Command::SUCCESS; }); } @@ -133,13 +139,13 @@ class BulkActions extends Extension } break; case "bulk_tag": - if (!isset($_POST['bulk_tags'])) { + if (!isset($event->params['bulk_tags'])) { return; } if ($user->can(Permissions::BULK_EDIT_IMAGE_TAG)) { - $tags = $_POST['bulk_tags']; + $tags = $event->params['bulk_tags']; $replace = false; - if (isset($_POST['bulk_tags_replace']) && $_POST['bulk_tags_replace'] == "true") { + if (isset($event->params['bulk_tags_replace']) && $event->params['bulk_tags_replace'] == "true") { $replace = true; } @@ -148,11 +154,11 @@ class BulkActions extends Extension } break; case "bulk_source": - if (!isset($_POST['bulk_source'])) { + if (!isset($event->params['bulk_source'])) { return; } if ($user->can(Permissions::BULK_EDIT_IMAGE_SOURCE)) { - $source = $_POST['bulk_source']; + $source = $event->params['bulk_source']; $i = $this->set_source($event->items, $source); $page->flash("Set source for $i items"); } @@ -186,7 +192,7 @@ class BulkActions extends Extension } shm_set_timeout(null); - $bae = send_event(new BulkActionEvent($action, $items)); + $bae = send_event(new BulkActionEvent($action, $items, $event->POST)); if ($bae->redirect) { $page->set_mode(PageMode::REDIRECT); diff --git a/ext/pools/main.php b/ext/pools/main.php index 5a1763b7..e1a4dde4 100644 --- a/ext/pools/main.php +++ b/ext/pools/main.php @@ -613,10 +613,7 @@ class Pools extends Extension switch ($event->action) { case "bulk_pool_add_existing": - if (!isset($_POST['bulk_pool_select'])) { - return; - } - $pool_id = intval($_POST['bulk_pool_select']); + $pool_id = intval($event->params['bulk_pool_select']); $pool = $this->get_single_pool($pool_id); if ($this->have_permission($user, $pool)) { @@ -626,10 +623,7 @@ class Pools extends Extension } break; case "bulk_pool_add_new": - if (!isset($_POST['bulk_pool_new'])) { - return; - } - $new_pool_title = $_POST['bulk_pool_new']; + $new_pool_title = $event->params['bulk_pool_new']; $pce = send_event(new PoolCreationEvent($new_pool_title)); send_event(new PoolAddPostsEvent($pce->new_id, iterator_map_to_array("Shimmie2\_image_to_id", $event->items))); break; diff --git a/ext/rating/main.php b/ext/rating/main.php index 56520960..c845b609 100644 --- a/ext/rating/main.php +++ b/ext/rating/main.php @@ -354,11 +354,11 @@ class Ratings extends Extension switch ($event->action) { case "bulk_rate": - if (!isset($_POST['rating'])) { + if (!isset($event->params['rating'])) { return; } if ($user->can(Permissions::BULK_EDIT_IMAGE_RATING)) { - $rating = $_POST['rating']; + $rating = $event->params['rating']; $total = 0; foreach ($event->items as $image) { send_event(new RatingSetEvent($image, $rating)); diff --git a/ext/transcode/main.php b/ext/transcode/main.php index 83f9dc68..7f12c62c 100644 --- a/ext/transcode/main.php +++ b/ext/transcode/main.php @@ -285,11 +285,11 @@ class TranscodeImage extends Extension switch ($event->action) { case self::ACTION_BULK_TRANSCODE: - if (!isset($_POST['transcode_mime'])) { + if (!isset($event->params['transcode_mime'])) { return; } if ($user->can(Permissions::EDIT_FILES)) { - $mime = $_POST['transcode_mime']; + $mime = $event->params['transcode_mime']; $total = 0; $size_difference = 0; foreach ($event->items as $image) { diff --git a/ext/transcode_video/main.php b/ext/transcode_video/main.php index 5d3bcf42..7edf5dfb 100644 --- a/ext/transcode_video/main.php +++ b/ext/transcode_video/main.php @@ -147,11 +147,11 @@ class TranscodeVideo extends Extension switch ($event->action) { case self::ACTION_BULK_TRANSCODE: - if (!isset($_POST['transcode_format'])) { + if (!isset($event->params['transcode_format'])) { return; } if ($user->can(Permissions::EDIT_FILES)) { - $format = $_POST['transcode_format']; + $format = $event->params['transcode_format']; $total = 0; foreach ($event->items as $image) { try {