Changes to bulk actions, passing full ID arrays instead of chunked image arrays

Changed the bulk actions to have a separate identifier from the button name
This commit is contained in:
Matthew Barbour
2019-06-12 17:44:25 -05:00
parent 97f60b3ea5
commit b27904a7e0
6 changed files with 184 additions and 105 deletions

View File

@ -170,7 +170,7 @@ class Ratings extends Extension
global $user;
if ($user->is_admin()) {
$event->add_action("Set Rating","",$this->theme->get_selection_rater_html("bulk_rating"));
$event->add_action("bulk_rate","Set Rating","",$this->theme->get_selection_rater_html("bulk_rating"));
}
}
@ -180,16 +180,23 @@ class Ratings extends Extension
global $user;
switch($event->action) {
case "Set Rating":
case "bulk_rate":
if (!isset($_POST['bulk_rating'])) {
return;
}
if ($user->is_admin()) {
$rating = $_POST['bulk_rating'];
foreach ($event->items as $image) {
$total = 0;
foreach ($event->items as $id) {
$image = Image::by_id($id);
if($image==null) {
continue;
}
send_event(new RatingSetEvent($image, $rating));
$event->running_total++;
$total++;
}
flash_message("Rating set for $total items");
}
break;
}