forked from Public/pics
Download: allow limiting by user uploaded as well
This commit is contained in:
@@ -21,22 +21,30 @@ class Download
|
||||
$tag = (int)$_GET['tag'];
|
||||
$album = Tag::fromId($tag);
|
||||
|
||||
if (isset($_GET['by']) && ($user = Member::fromSlug($_GET['by'])) !== false)
|
||||
$id_user_uploaded = $user->getUserId();
|
||||
else
|
||||
$id_user_uploaded = null;
|
||||
|
||||
if (isset($_SESSION['current_export']))
|
||||
throw new UserFacingException('You can only export one album at the same time. Please wait until the other download finishes, or try again later.');
|
||||
|
||||
// So far so good?
|
||||
$this->exportAlbum($album);
|
||||
$this->exportAlbum($album, $id_user_uploaded);
|
||||
exit;
|
||||
}
|
||||
|
||||
private function exportAlbum(Tag $album)
|
||||
private function exportAlbum(Tag $album, $id_user_uploaded)
|
||||
{
|
||||
$files = [];
|
||||
|
||||
$album_ids = array_merge([$album->id_tag], $this->getChildAlbumIds($album->id_tag));
|
||||
foreach ($album_ids as $album_id)
|
||||
{
|
||||
$iterator = AssetIterator::getByOptions(['id_tag' => $album_id]);
|
||||
$iterator = AssetIterator::getByOptions([
|
||||
'id_tag' => $album_id,
|
||||
'id_user_uploaded' => $id_user_uploaded,
|
||||
]);
|
||||
while ($asset = $iterator->next())
|
||||
$files[] = join(DIRECTORY_SEPARATOR, [$asset->getSubdir(), $asset->getFilename()]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user