Ansel_ActionHandler::download PHP Method

download() public static method

Check for download action.
public static download ( string $actionID )
$actionID string The action identifier.
    public static function download($actionID)
    {
        global $notification, $registry;
        if ($actionID == 'downloadzip') {
            $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;
                }
                $image_ids = $gallery->listImages();
            } else {
                $image_ids = array();
                foreach ($image_id as $image) {
                    $img = $ansel_storage->getImage($image);
                    $galleries[$img->gallery][] = $image;
                }
                foreach ($galleries as $gid => $images) {
                    $gallery = $ansel_storage->getGallery($gid);
                    if (!$registry->getAuth() || !$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ) | $gallery->hasPasswd() || !$gallery->isOldEnough()) {
                        continue;
                    }
                    $image_ids = array_merge($image_ids, $images);
                }
            }
            if (count($image_ids)) {
                Ansel::downloadImagesAsZip(null, $image_ids);
            } else {
                $notification->push(_("You must select images to download."), 'horde.error');
            }
            return true;
        }
        return false;
    }