mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-22 04:58:01 +01:00
Let admins download all items in playlists
This commit is contained in:
parent
e625c7ddea
commit
25e023ccb7
2 changed files with 5 additions and 4 deletions
|
@ -63,7 +63,7 @@ class PlaylistsController extends Controller
|
|||
public function getDownload($id, $extension)
|
||||
{
|
||||
$playlist = Playlist::with('tracks', 'tracks.trackFiles', 'user', 'tracks.album')->find($id);
|
||||
if (!$playlist || (!$playlist->is_public && !Auth::check()) || (!$playlist->is_public && ($playlist->user_id !== Auth::user()->id))) {
|
||||
if (!$playlist || (!$playlist->is_public && !Auth::check()) || !$playlist->canView(Auth::user()) || (!$playlist->is_public && ($playlist->user_id !== Auth::user()->id))) {
|
||||
App::abort(404);
|
||||
}
|
||||
|
||||
|
@ -88,6 +88,6 @@ class PlaylistsController extends Controller
|
|||
|
||||
ResourceLogItem::logItem('playlist', $id, ResourceLogItem::DOWNLOAD, $format['index']);
|
||||
$downloader = new PlaylistDownloader($playlist, $formatName);
|
||||
$downloader->download();
|
||||
$downloader->download(Auth::user());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ namespace Poniverse\Ponyfm;
|
|||
|
||||
use Poniverse\Ponyfm\Models\Playlist;
|
||||
use Poniverse\Ponyfm\Models\Track;
|
||||
use Poniverse\Ponyfm\Models\User;
|
||||
use ZipStream;
|
||||
|
||||
class PlaylistDownloader
|
||||
|
@ -42,7 +43,7 @@ class PlaylistDownloader
|
|||
$this->_format = $format;
|
||||
}
|
||||
|
||||
public function download()
|
||||
public function download(User $user)
|
||||
{
|
||||
// Check whether the format is lossless yet not all master files are lossless
|
||||
$isLosslessFormatWithLossyTracks = in_array($this->_format, Track::$LosslessFormats)
|
||||
|
@ -71,7 +72,7 @@ class PlaylistDownloader
|
|||
$m3u = '';
|
||||
$index = 1;
|
||||
foreach ($this->_playlist->tracks as $track) {
|
||||
if (!$track->is_downloadable) {
|
||||
if (!$track->is_downloadable && !$user->hasRole('admin')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue