From 337caa23a8fb6e2359da3d1bc1cee03c3941914b Mon Sep 17 00:00:00 2001 From: Josef Citrine Date: Mon, 21 Nov 2016 11:41:16 +0000 Subject: [PATCH] Admins can see all playlists --- app/Commands/EditPlaylistCommand.php | 2 +- app/Models/Playlist.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Commands/EditPlaylistCommand.php b/app/Commands/EditPlaylistCommand.php index abe13e25..877b88c6 100644 --- a/app/Commands/EditPlaylistCommand.php +++ b/app/Commands/EditPlaylistCommand.php @@ -45,7 +45,7 @@ class EditPlaylistCommand extends CommandBase { $user = Auth::user(); - return $this->_playlist && $user != null && $this->_playlist->user_id == $user->id; + return $this->_playlist && $user != null && ($this->_playlist->user_id == $user->id || $user->hasRole('admin')); } /** diff --git a/app/Models/Playlist.php b/app/Models/Playlist.php index a60d24c4..4ca4f004 100644 --- a/app/Models/Playlist.php +++ b/app/Models/Playlist.php @@ -134,7 +134,7 @@ class Playlist extends Model implements Searchable, Commentable, Favouritable if (in_array($name, Track::$LosslessFormats) && !$playlist->hasLosslessTracksOnly() && !$playlist->hasLosslessTracks()) { continue; } - + $formats[] = [ 'name' => $name, 'extension' => $format['extension'], @@ -284,7 +284,7 @@ class Playlist extends Model implements Searchable, Commentable, Favouritable public function canView($user) { - return $this->is_public || ($user != null && $user->id == $this->user_id); + return $this->is_public || ($user != null && $user->id == $this->user_id) || ($user != null && $user->hasRole('admin')); } public function getUrlAttribute()