Skip to content

Commit

Permalink
Bug: 14569 Honor selected images for download.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Feb 1, 2017
1 parent 65223dc commit 37c419a
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions ansel/lib/ActionHandler.php
Expand Up @@ -40,28 +40,17 @@ public static function download($actionID)
$gallery_id = Horde_Util::getFormData('gallery');
$image_id = Horde_Util::getFormData('image');
$ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage');
if (!is_array($image_id)) {
$image_id = array($image_id);
} else {
$image_id = array_keys($image_id);
}

// All from same gallery.
if ($gallery_id) {
$gallery = $ansel_storage->getGallery($gallery_id);
if (!$registry->getAuth() ||
!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ) ||
$gallery->hasPasswd() || !$gallery->isOldEnough()) {

$notification->push(
_("Access denied downloading photos from this gallery."),
'horde.error');
return true;
// Explicitly list images to include
if ($image_id) {
if (!is_array($image_id)) {
$image_id = array($image_id);
} else {
$image_id = array_keys($image_id);
}
$image_ids = $gallery->listImages();
} else {
$image_ids = array();
foreach ($image_id as $image) {

$img = $ansel_storage->getImage($image);
$galleries[$img->gallery][] = $image;
}
Expand All @@ -74,7 +63,21 @@ public static function download($actionID)
}
$image_ids = array_merge($image_ids, $images);
}
} else if ($gallery_id) {
// Or just download enitre gallery.
$gallery = $ansel_storage->getGallery($gallery_id);
if (!$registry->getAuth() ||
!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ) ||
$gallery->hasPasswd() || !$gallery->isOldEnough()) {

$notification->push(
_("Access denied downloading photos from this gallery."),
'horde.error');
return true;
}
$image_ids = $gallery->listImages();
}

if (count($image_ids)) {
Ansel::downloadImagesAsZip(null, $image_ids);
} else {
Expand Down

0 comments on commit 37c419a

Please sign in to comment.