diff --git a/app/controllers/Api/Web/ArtistsController.php b/app/controllers/Api/Web/ArtistsController.php index 3dfaee41..b485db0c 100644 --- a/app/controllers/Api/Web/ArtistsController.php +++ b/app/controllers/Api/Web/ArtistsController.php @@ -57,7 +57,7 @@ if (!$user) App::abort(404); - $query = Track::summary()->with('genre', 'cover', 'user')->userDetails()->whereUserId($user->id)->whereNotNull('published_at'); + $query = Track::summary()->published()->listed()->explicitFilter()->with('genre', 'cover', 'user')->userDetails()->whereUserId($user->id)->whereNotNull('published_at'); $tracks = []; $singles = []; @@ -88,7 +88,7 @@ if (!$user) App::abort(404); - $trackQuery = Track::summary()->with('genre', 'cover', 'user')->userDetails()->whereUserId($user->id)->whereNotNull('published_at')->orderBy('created_at', 'desc')->take(20); + $trackQuery = Track::summary()->published()->explicitFilter()->listed()->with('genre', 'cover', 'user')->userDetails()->whereUserId($user->id)->whereNotNull('published_at')->orderBy('created_at', 'desc')->take(20); $latestTracks = []; foreach ($trackQuery->get() as $track) { diff --git a/app/controllers/Api/Web/DashboardController.php b/app/controllers/Api/Web/DashboardController.php index 5fe6ee1e..e664dccb 100644 --- a/app/controllers/Api/Web/DashboardController.php +++ b/app/controllers/Api/Web/DashboardController.php @@ -18,6 +18,7 @@ $recentQuery = Track::summary() ->with(['genre', 'user', 'cover', 'user.avatar']) ->whereIsLatest(true) + ->listed() ->userDetails() ->explicitFilter() ->published() diff --git a/app/controllers/Api/Web/TracksController.php b/app/controllers/Api/Web/TracksController.php index 61b3180b..000cbf84 100644 --- a/app/controllers/Api/Web/TracksController.php +++ b/app/controllers/Api/Web/TracksController.php @@ -52,6 +52,7 @@ $query = Track::summary() ->userDetails() + ->listed() ->explicitFilter() ->published() ->with('user', 'genre', 'cover', 'album', 'album.user'); diff --git a/app/database/migrations/2013_09_24_055911_track_is_listed.php b/app/database/migrations/2013_09_24_055911_track_is_listed.php new file mode 100644 index 00000000..184e8b8d --- /dev/null +++ b/app/database/migrations/2013_09_24_055911_track_is_listed.php @@ -0,0 +1,23 @@ +boolean('is_listed')->notNullable()->indexed(); + }); + + DB::update(' + UPDATE + tracks + SET + is_listed = true'); + } + + public function down() { + Schema::table('tracks', function($table) { + $table->dropColumn('is_listed'); + }); + } +} \ No newline at end of file diff --git a/app/models/Commands/EditTrackCommand.php b/app/models/Commands/EditTrackCommand.php index 468fba6f..6976e206 100644 --- a/app/models/Commands/EditTrackCommand.php +++ b/app/models/Commands/EditTrackCommand.php @@ -70,6 +70,7 @@ $track->track_type_id = $this->_input['track_type_id']; $track->is_explicit = $this->_input['is_explicit'] == 'true'; $track->is_downloadable = $this->_input['is_downloadable'] == 'true'; + $track->is_listed = $this->_input['is_listed'] == 'true'; $track->is_vocal = $isVocal; if (isset($this->_input['album_id']) && strlen(trim($this->_input['album_id']))) { diff --git a/app/models/Commands/UploadTrackCommand.php b/app/models/Commands/UploadTrackCommand.php index 8beb8af4..ab6f5248 100644 --- a/app/models/Commands/UploadTrackCommand.php +++ b/app/models/Commands/UploadTrackCommand.php @@ -40,6 +40,7 @@ $track->user_id = $user->id; $track->title = pathinfo($trackFile->getClientOriginalName(), PATHINFO_FILENAME); $track->duration = $audio->getDuration(); + $track->is_listed = true; $track->save(); diff --git a/app/models/Entities/Track.php b/app/models/Entities/Track.php index f5161b6b..c2e3aca7 100644 --- a/app/models/Entities/Track.php +++ b/app/models/Entities/Track.php @@ -47,6 +47,10 @@ $query->whereNotNull('published_at'); } + public function scopeListed($query) { + $query->whereIsListed(true); + } + public function scopeExplicitFilter($query) { if (!Auth::check() || !Auth::user()->can_see_explicit_content) $query->whereIsExplicit(false); @@ -60,6 +64,7 @@ $trackIds = Cache::remember('popular_tracks' . $count . '-' . ($allowExplicit ? 'explicit' : 'safe'), 5, function() use ($allowExplicit, $count) { $query = static ::published() + ->listed() ->join(DB::raw(' ( SELECT `track_id`, `created_at` FROM `resource_log_items` @@ -249,7 +254,8 @@ 'duration' => $track->duration, 'genre_id' => $track->genre_id, 'track_type_id' => $track->track_type_id, - 'cover_url' => $track->getCoverUrl(Image::SMALL) + 'cover_url' => $track->getCoverUrl(Image::SMALL), + 'is_listed' => !!$track->is_listed ]; } diff --git a/app/models/Entities/User.php b/app/models/Entities/User.php index 7cdfcb75..eb9941b5 100644 --- a/app/models/Entities/User.php +++ b/app/models/Entities/User.php @@ -57,7 +57,7 @@ return $this->email; } - public function setDisplayName($value) { + public function setDisplayNameAttribute($value) { $this->attributes['display_name'] = $value; $this->attributes['slug'] = Str::slug($value); } diff --git a/public/scripts/app/controllers/account-track.coffee b/public/scripts/app/controllers/account-track.coffee index ee52ae76..946aadfb 100644 --- a/public/scripts/app/controllers/account-track.coffee +++ b/public/scripts/app/controllers/account-track.coffee @@ -122,6 +122,7 @@ angular.module('ponyfm').controller "account-track", [ cover: track.cover_url album_id: track.album_id is_published: track.is_published + is_listed: track.is_listed $scope.selectedAlbum = if track.album_id then albumsDb[track.album_id] else null $scope.selectedSongs = {} diff --git a/public/templates/account/track.html b/public/templates/account/track.html index e76cca88..92bc1c01 100644 --- a/public/templates/account/track.html +++ b/public/templates/account/track.html @@ -91,12 +91,15 @@
-
+
-
+
+
+ +