Merge pull request #55 from Poniverse/scrutinizer-patch-1

Scrutinizer Auto-Fixes
This commit is contained in:
Peter Deltchev 2016-01-17 17:24:46 -08:00
commit 23ae7ffa72
9 changed files with 122 additions and 116 deletions

View file

@ -43,25 +43,25 @@ class AlbumDownloader
function download() function download()
{ {
$zip = new ZipStream($this->_album->user->display_name . ' - ' . $this->_album->title . '.zip'); $zip = new ZipStream($this->_album->user->display_name.' - '.$this->_album->title.'.zip');
$zip->setComment( $zip->setComment(
'Album: ' . $this->_album->title . "\r\n" . 'Album: '.$this->_album->title."\r\n".
'Artist: ' . $this->_album->user->display_name . "\r\n" . 'Artist: '.$this->_album->user->display_name."\r\n".
'URL: ' . $this->_album->url . "\r\n" . "\r\n" . 'URL: '.$this->_album->url."\r\n"."\r\n".
'Downloaded on ' . date('l, F jS, Y, \a\t h:i:s A') . '.' 'Downloaded on '.date('l, F jS, Y, \a\t h:i:s A').'.'
); );
$directory = $this->_album->user->display_name . '/' . $this->_album->title . '/'; $directory = $this->_album->user->display_name.'/'.$this->_album->title.'/';
$notes = $notes =
'Album: ' . $this->_album->title . "\r\n" . 'Album: '.$this->_album->title."\r\n".
'Artist: ' . $this->_album->user->display_name . "\r\n" . 'Artist: '.$this->_album->user->display_name."\r\n".
'URL: ' . $this->_album->url . "\r\n" . 'URL: '.$this->_album->url."\r\n".
"\r\n" . "\r\n".
$this->_album->description . "\r\n" . $this->_album->description."\r\n".
"\r\n" . "\r\n".
"\r\n" . "\r\n".
'Tracks' . "\r\n" . 'Tracks'."\r\n".
"\r\n"; "\r\n";
foreach ($this->_album->tracks as $track) { foreach ($this->_album->tracks as $track) {
@ -70,14 +70,14 @@ class AlbumDownloader
} }
$zip->addLargeFile($track->getFileFor($this->_format), $zip->addLargeFile($track->getFileFor($this->_format),
$directory . $track->getDownloadFilenameFor($this->_format)); $directory.$track->getDownloadFilenameFor($this->_format));
$notes .= $notes .=
$track->track_number . '. ' . $track->title . "\r\n" . $track->track_number.'. '.$track->title."\r\n".
$track->description . "\r\n" . $track->description."\r\n".
"\r\n"; "\r\n";
} }
$zip->addFile($notes, $directory . 'Album Notes.txt'); $zip->addFile($notes, $directory.'Album Notes.txt');
$zip->finalize(); $zip->finalize();
} }
} }

View file

@ -80,7 +80,7 @@ class AuthController extends Controller
$setData = [ $setData = [
'access_token' => $code['result']['access_token'], 'access_token' => $code['result']['access_token'],
'expires' => date('Y-m-d H:i:s', strtotime("+" . $code['result']['expires_in'] . " Seconds", time())), 'expires' => date('Y-m-d H:i:s', strtotime("+".$code['result']['expires_in']." Seconds", time())),
'type' => $code['result']['token_type'], 'type' => $code['result']['token_type'],
]; ];

View file

@ -22,7 +22,6 @@ namespace Poniverse\Ponyfm\Http\Middleware;
use Closure; use Closure;
use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Auth\Guard;
use Response;
class DisabledAccountCheck class DisabledAccountCheck
{ {
@ -59,7 +58,7 @@ class DisabledAccountCheck
if ($this->auth->check() if ($this->auth->check()
&& $this->auth->user()->disabled_at !== null && $this->auth->user()->disabled_at !== null
&& !($request->getMethod() === 'POST' && $request->getRequestUri() == '/auth/logout') && !($request->getMethod() === 'POST' && $request->getRequestUri() == '/auth/logout')
){ ) {
$this->auth->logout(); $this->auth->logout();
// return Response::view('home.account-disabled', ['username' => $this->auth->user()->username], 403); // return Response::view('home.account-disabled', ['username' => $this->auth->user()->username], 403);
} }

View file

@ -20,7 +20,6 @@
namespace Poniverse\Ponyfm\Http\Middleware; namespace Poniverse\Ponyfm\Http\Middleware;
use App;
use Closure; use Closure;
use Cache; use Cache;
use Config; use Config;
@ -58,7 +57,7 @@ class Profiler
$response = $this->processResponse($profiler, $response); $response = $this->processResponse($profiler, $response);
Log::listen(function ($level, $message, $context) use ($profiler, $request) { Log::listen(function($level, $message, $context) use ($profiler, $request) {
$profiler->log($level, $message, $context); $profiler->log($level, $message, $context);
}); });
@ -74,7 +73,7 @@ class Profiler
protected function processResponse(ProfileRequest $profiler, Response $response) { protected function processResponse(ProfileRequest $profiler, Response $response) {
$profiler->recordQueries(); $profiler->recordQueries();
Cache::put('profiler-request-' . $profiler->getId(), $profiler->toString(), 2); Cache::put('profiler-request-'.$profiler->getId(), $profiler->toString(), 2);
return $response->header('X-Request-Id', $profiler->getId()); return $response->header('X-Request-Id', $profiler->getId());
} }
} }

View file

@ -24,7 +24,6 @@ use Exception;
use Helpers; use Helpers;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Auth; use Auth;
use Cache; use Cache;
use Poniverse\Ponyfm\Contracts\Searchable; use Poniverse\Ponyfm\Contracts\Searchable;
@ -80,7 +79,7 @@ class Album extends Model implements Searchable
{ {
if (Auth::check()) { if (Auth::check()) {
$query->with([ $query->with([
'users' => function ($query) { 'users' => function($query) {
$query->whereUserId(Auth::user()->id); $query->whereUserId(Auth::user()->id);
} }
]); ]);
@ -164,8 +163,8 @@ class Album extends Model implements Searchable
$data['is_downloadable'] = $is_downloadable; $data['is_downloadable'] = $is_downloadable;
$data['share'] = [ $data['share'] = [
'url' => action('AlbumsController@getShortlink', ['id' => $album->id]), 'url' => action('AlbumsController@getShortlink', ['id' => $album->id]),
'tumblrUrl' => 'http://www.tumblr.com/share/link?url=' . urlencode($album->url) . '&name=' . urlencode($album->title) . '&description=' . urlencode($album->description), 'tumblrUrl' => 'http://www.tumblr.com/share/link?url='.urlencode($album->url).'&name='.urlencode($album->title).'&description='.urlencode($album->description),
'twitterUrl' => 'https://platform.twitter.com/widgets/tweet_button.html?text=' . $album->title . ' by ' . $album->user->display_name . ' on Pony.fm' 'twitterUrl' => 'https://platform.twitter.com/widgets/tweet_button.html?text='.$album->title.' by '.$album->user->display_name.' on Pony.fm'
]; ];
return $data; return $data;
@ -185,24 +184,24 @@ class Album extends Model implements Searchable
$userRow = $album->users[0]; $userRow = $album->users[0];
$userData = [ $userData = [
'stats' => [ 'stats' => [
'views' => (int)$userRow->view_count, 'views' => (int) $userRow->view_count,
'downloads' => (int)$userRow->download_count, 'downloads' => (int) $userRow->download_count,
], ],
'is_favourited' => (bool)$userRow->is_favourited 'is_favourited' => (bool) $userRow->is_favourited
]; ];
} }
return [ return [
'id' => (int)$album->id, 'id' => (int) $album->id,
'track_count' => (int)$album->track_count, 'track_count' => (int) $album->track_count,
'title' => $album->title, 'title' => $album->title,
'slug' => $album->slug, 'slug' => $album->slug,
'created_at' => $album->created_at->format('c'), 'created_at' => $album->created_at->format('c'),
'stats' => [ 'stats' => [
'views' => (int)$album->view_count, 'views' => (int) $album->view_count,
'downloads' => (int)$album->download_count, 'downloads' => (int) $album->download_count,
'comments' => (int)$album->comment_count, 'comments' => (int) $album->comment_count,
'favourites' => (int)$album->favourite_count 'favourites' => (int) $album->favourite_count
], ],
'covers' => [ 'covers' => [
'small' => $album->getCoverUrl(Image::SMALL), 'small' => $album->getCoverUrl(Image::SMALL),
@ -211,7 +210,7 @@ class Album extends Model implements Searchable
], ],
'url' => $album->url, 'url' => $album->url,
'user' => [ 'user' => [
'id' => (int)$album->user->id, 'id' => (int) $album->user->id,
'name' => $album->user->display_name, 'name' => $album->user->display_name,
'url' => $album->user->url, 'url' => $album->user->url,
], ],
@ -245,7 +244,7 @@ class Album extends Model implements Searchable
return 0; return 0;
} }
return Cache::remember($this->getCacheKey('filesize-' . $format), 1440, function () use ($tracks, $format) { return Cache::remember($this->getCacheKey('filesize-'.$format), 1440, function() use ($tracks, $format) {
$size = 0; $size = 0;
foreach ($tracks as $track) { foreach ($tracks as $track) {
@ -277,9 +276,9 @@ class Album extends Model implements Searchable
public function getDirectory() public function getDirectory()
{ {
$dir = (string)(floor($this->id / 100) * 100); $dir = (string) (floor($this->id / 100) * 100);
return \Config::get('ponyfm.files_directory') . '/tracks/' . $dir; return \Config::get('ponyfm.files_directory').'/tracks/'.$dir;
} }
public function getDates() public function getDates()
@ -384,13 +383,13 @@ class Album extends Model implements Searchable
} }
foreach (Track::$Formats as $name => $format) { foreach (Track::$Formats as $name => $format) {
Cache::forget($this->getCacheKey('filesize' . $name)); Cache::forget($this->getCacheKey('filesize'.$name));
} }
} }
public function getCacheKey($key) public function getCacheKey($key)
{ {
return 'album-' . $this->id . '-' . $key; return 'album-'.$this->id.'-'.$key;
} }
/** /**

View file

@ -24,7 +24,6 @@ use Auth;
use Cache; use Cache;
use Config; use Config;
use DB; use DB;
use Elasticsearch;
use Poniverse\Ponyfm\Contracts\Searchable; use Poniverse\Ponyfm\Contracts\Searchable;
use Poniverse\Ponyfm\Exceptions\TrackFileNotFoundException; use Poniverse\Ponyfm\Exceptions\TrackFileNotFoundException;
use Poniverse\Ponyfm\Traits\IndexedInElasticsearchTrait; use Poniverse\Ponyfm\Traits\IndexedInElasticsearchTrait;
@ -211,7 +210,7 @@ class Track extends Model implements Searchable
{ {
if (Auth::check()) { if (Auth::check()) {
$query->with([ $query->with([
'users' => function ($query) { 'users' => function($query) {
$query->whereUserId(Auth::user()->id); $query->whereUserId(Auth::user()->id);
} }
]); ]);
@ -238,7 +237,7 @@ class Track extends Model implements Searchable
public function scopeWithComments($query) public function scopeWithComments($query)
{ {
$query->with([ $query->with([
'comments' => function ($query) { 'comments' => function($query) {
$query->with('user'); $query->with('user');
} }
]); ]);
@ -254,10 +253,13 @@ class Track extends Model implements Searchable
$query->join('mlpma_tracks', 'tracks.id', '=', 'mlpma_tracks.track_id'); $query->join('mlpma_tracks', 'tracks.id', '=', 'mlpma_tracks.track_id');
} }
/**
* @param integer $count
*/
public static function popular($count, $allowExplicit = false) public static function popular($count, $allowExplicit = false)
{ {
$trackIds = Cache::remember('popular_tracks' . $count . '-' . ($allowExplicit ? 'explicit' : 'safe'), 5, $trackIds = Cache::remember('popular_tracks'.$count.'-'.($allowExplicit ? 'explicit' : 'safe'), 5,
function () use ($allowExplicit, $count) { function() use ($allowExplicit, $count) {
$query = static $query = static
::published() ::published()
->listed() ->listed()
@ -342,12 +344,12 @@ class Track extends Model implements Searchable
$returnValue['share'] = [ $returnValue['share'] = [
'url' => action('TracksController@getShortlink', ['id' => $track->id]), 'url' => action('TracksController@getShortlink', ['id' => $track->id]),
'html' => '<iframe src="' . action('TracksController@getEmbed', ['id' => $track->id]) . '" width="100%" height="150" allowTransparency="true" frameborder="0" seamless allowfullscreen></iframe>', 'html' => '<iframe src="'.action('TracksController@getEmbed', ['id' => $track->id]).'" width="100%" height="150" allowTransparency="true" frameborder="0" seamless allowfullscreen></iframe>',
'bbcode' => '[url=' . $track->url . '][img]' . $track->getCoverUrl() . '[/img][/url]', 'bbcode' => '[url='.$track->url.'][img]'.$track->getCoverUrl().'[/img][/url]',
'twitterUrl' => 'https://platform.twitter.com/widgets/tweet_button.html?text=' . $track->title . ' by ' . $track->user->display_name . ' on Pony.fm' 'twitterUrl' => 'https://platform.twitter.com/widgets/tweet_button.html?text='.$track->title.' by '.$track->user->display_name.' on Pony.fm'
]; ];
$returnValue['share']['tumblrUrl'] = 'http://www.tumblr.com/share/video?embed=' . urlencode($returnValue['share']['html']) . '&caption=' . urlencode($track->title); $returnValue['share']['tumblrUrl'] = 'http://www.tumblr.com/share/video?embed='.urlencode($returnValue['share']['html']).'&caption='.urlencode($track->title);
$returnValue['formats'] = $formats; $returnValue['formats'] = $formats;
@ -369,28 +371,28 @@ class Track extends Model implements Searchable
$userRow = $track->users[0]; $userRow = $track->users[0];
$userData = [ $userData = [
'stats' => [ 'stats' => [
'views' => (int)$userRow->view_count, 'views' => (int) $userRow->view_count,
'plays' => (int)$userRow->play_count, 'plays' => (int) $userRow->play_count,
'downloads' => $userRow->download_count, 'downloads' => $userRow->download_count,
], ],
'is_favourited' => (bool)$userRow->is_favourited 'is_favourited' => (bool) $userRow->is_favourited
]; ];
} }
return [ return [
'id' => (int)$track->id, 'id' => (int) $track->id,
'title' => $track->title, 'title' => $track->title,
'user' => [ 'user' => [
'id' => (int)$track->user->id, 'id' => (int) $track->user->id,
'name' => $track->user->display_name, 'name' => $track->user->display_name,
'url' => $track->user->url 'url' => $track->user->url
], ],
'stats' => [ 'stats' => [
'views' => (int)$track->view_count, 'views' => (int) $track->view_count,
'plays' => (int)$track->play_count, 'plays' => (int) $track->play_count,
'downloads' => (int)$track->download_count, 'downloads' => (int) $track->download_count,
'comments' => (int)$track->comment_count, 'comments' => (int) $track->comment_count,
'favourites' => (int)$track->favourite_count 'favourites' => (int) $track->favourite_count
], ],
'url' => $track->url, 'url' => $track->url,
'slug' => $track->slug, 'slug' => $track->slug,
@ -403,7 +405,7 @@ class Track extends Model implements Searchable
'genre' => $track->genre != null 'genre' => $track->genre != null
? ?
[ [
'id' => (int)$track->genre->id, 'id' => (int) $track->genre->id,
'slug' => $track->genre->slug, 'slug' => $track->genre->slug,
'name' => $track->genre->name 'name' => $track->genre->name
] : null, ] : null,
@ -442,7 +444,7 @@ class Track extends Model implements Searchable
$returnValue['released_at'] = $track->released_at; $returnValue['released_at'] = $track->released_at;
$returnValue['lyrics'] = $track->lyrics; $returnValue['lyrics'] = $track->lyrics;
$returnValue['description'] = $track->description; $returnValue['description'] = $track->description;
$returnValue['is_downloadable'] = !$track->isPublished() ? true : (bool)$track->is_downloadable; $returnValue['is_downloadable'] = !$track->isPublished() ? true : (bool) $track->is_downloadable;
$returnValue['license_id'] = $track->license_id != null ? $track->license_id : 3; $returnValue['license_id'] = $track->license_id != null ? $track->license_id : 3;
return $returnValue; return $returnValue;
@ -528,7 +530,7 @@ class Track extends Model implements Searchable
public function setTitleAttribute($value) public function setTitleAttribute($value)
{ {
$this->setTitleAttributeSlug($value);; $this->setTitleAttributeSlug($value); ;
$this->updateHash(); $this->updateHash();
} }
@ -567,7 +569,7 @@ class Track extends Model implements Searchable
public function getDownloadDirectoryAttribute() public function getDownloadDirectoryAttribute()
{ {
if ($this->album) { if ($this->album) {
return $this->user->display_name . '/' . $this->album->title; return $this->user->display_name.'/'.$this->album->title;
} }
return $this->user->display_name; return $this->user->display_name;
@ -626,9 +628,9 @@ class Track extends Model implements Searchable
public function getDirectory() public function getDirectory()
{ {
$dir = (string)(floor($this->id / 100) * 100); $dir = (string) (floor($this->id / 100) * 100);
return \Config::get('ponyfm.files_directory') . '/tracks/' . $dir; return \Config::get('ponyfm.files_directory').'/tracks/'.$dir;
} }
public function getDates() public function getDates()
@ -658,6 +660,9 @@ class Track extends Model implements Searchable
return "{$this->title}.{$format['extension']}"; return "{$this->title}.{$format['extension']}";
} }
/**
* @return string
*/
public function getFileFor($format) public function getFileFor($format)
{ {
if (!isset(self::$Formats[$format])) { if (!isset(self::$Formats[$format])) {
@ -677,7 +682,7 @@ class Track extends Model implements Searchable
* @return string * @return string
*/ */
public function getTemporarySourceFile() { public function getTemporarySourceFile() {
return Config::get('ponyfm.files_directory') . '/queued-tracks/' . $this->id; return Config::get('ponyfm.files_directory').'/queued-tracks/'.$this->id;
} }
@ -696,9 +701,9 @@ class Track extends Model implements Searchable
/** /**
* @return string one of the Track::STATUS_* values, indicating whether this track is currently being processed * @return string one of the Track::STATUS_* values, indicating whether this track is currently being processed
*/ */
public function getStatusAttribute(){ public function getStatusAttribute() {
return $this->trackFiles->reduce(function($carry, $trackFile){ return $this->trackFiles->reduce(function($carry, $trackFile) {
if((int) $trackFile->status === TrackFile::STATUS_PROCESSING_ERROR) { if ((int) $trackFile->status === TrackFile::STATUS_PROCESSING_ERROR) {
return static::STATUS_ERROR; return static::STATUS_ERROR;
} elseif ( } elseif (
@ -721,7 +726,7 @@ class Track extends Model implements Searchable
public function updateHash() public function updateHash()
{ {
$this->hash = md5(Helpers::sanitizeInputForHashing($this->user->display_name) . ' - ' . Helpers::sanitizeInputForHashing($this->title)); $this->hash = md5(Helpers::sanitizeInputForHashing($this->user->display_name).' - '.Helpers::sanitizeInputForHashing($this->title));
} }
public function updateTags($trackFileFormat = 'all') public function updateTags($trackFileFormat = 'all')
@ -750,22 +755,22 @@ class Track extends Model implements Searchable
/** @noinspection PhpUnusedPrivateMethodInspection */ /** @noinspection PhpUnusedPrivateMethodInspection */
private function updateTagsWithAtomicParsley($format) private function updateTagsWithAtomicParsley($format)
{ {
$command = 'AtomicParsley "' . $this->getFileFor($format) . '" '; $command = 'AtomicParsley "'.$this->getFileFor($format).'" ';
$command .= '--title ' . escapeshellarg($this->title) . ' '; $command .= '--title '.escapeshellarg($this->title).' ';
$command .= '--artist ' . escapeshellarg($this->user->display_name) . ' '; $command .= '--artist '.escapeshellarg($this->user->display_name).' ';
$command .= '--year "' . $this->year . '" '; $command .= '--year "'.$this->year.'" ';
$command .= '--genre ' . escapeshellarg($this->genre != null ? $this->genre->name : '') . ' '; $command .= '--genre '.escapeshellarg($this->genre != null ? $this->genre->name : '').' ';
$command .= '--copyright ' . escapeshellarg('© ' . $this->year . ' ' . $this->user->display_name) . ' '; $command .= '--copyright '.escapeshellarg('© '.$this->year.' '.$this->user->display_name).' ';
$command .= '--comment "' . 'Downloaded from: https://pony.fm/' . '" '; $command .= '--comment "'.'Downloaded from: https://pony.fm/'.'" ';
$command .= '--encodingTool "' . 'Pony.fm - https://pony.fm/' . '" '; $command .= '--encodingTool "'.'Pony.fm - https://pony.fm/'.'" ';
if ($this->album_id !== null) { if ($this->album_id !== null) {
$command .= '--album ' . escapeshellarg($this->album->title) . ' '; $command .= '--album '.escapeshellarg($this->album->title).' ';
$command .= '--tracknum ' . $this->track_number . ' '; $command .= '--tracknum '.$this->track_number.' ';
} }
if ($this->cover !== null) { if ($this->cover !== null) {
$command .= '--artwork ' . $this->cover->getFile(Image::ORIGINAL) . ' '; $command .= '--artwork '.$this->cover->getFile(Image::ORIGINAL).' ';
} }
$command .= '--overWrite'; $command .= '--overWrite';
@ -776,8 +781,8 @@ class Track extends Model implements Searchable
/** @noinspection PhpUnusedPrivateMethodInspection */ /** @noinspection PhpUnusedPrivateMethodInspection */
private function updateTagsWithGetId3($format) private function updateTagsWithGetId3($format)
{ {
require_once(app_path() . '/Library/getid3/getid3/getid3.php'); require_once(app_path().'/Library/getid3/getid3/getid3.php');
require_once(app_path() . '/Library/getid3/getid3/write.php'); require_once(app_path().'/Library/getid3/getid3/write.php');
$tagWriter = new getid3_writetags; $tagWriter = new getid3_writetags;
$tagWriter->overwrite_tags = true; $tagWriter->overwrite_tags = true;
@ -787,10 +792,10 @@ class Track extends Model implements Searchable
$tagWriter->tag_data = [ $tagWriter->tag_data = [
'title' => [$this->title], 'title' => [$this->title],
'artist' => [$this->user->display_name], 'artist' => [$this->user->display_name],
'year' => ['' . $this->year], 'year' => [''.$this->year],
'genre' => [$this->genre != null ? $this->genre->name : ''], 'genre' => [$this->genre != null ? $this->genre->name : ''],
'comment' => ['Downloaded from: https://pony.fm/'], 'comment' => ['Downloaded from: https://pony.fm/'],
'copyright' => ['© ' . $this->year . ' ' . $this->user->display_name], 'copyright' => ['© '.$this->year.' '.$this->user->display_name],
'publisher' => ['Pony.fm - https://pony.fm/'], 'publisher' => ['Pony.fm - https://pony.fm/'],
'encoded_by' => ['https://pony.fm/'], 'encoded_by' => ['https://pony.fm/'],
// 'url_artist' => [$this->user->url], // 'url_artist' => [$this->user->url],
@ -818,18 +823,18 @@ class Track extends Model implements Searchable
if ($tagWriter->WriteTags()) { if ($tagWriter->WriteTags()) {
if (!empty($tagWriter->warnings)) { if (!empty($tagWriter->warnings)) {
Log::warning('Track #' . $this->id . ': There were some warnings:<br />' . implode('<br /><br />', Log::warning('Track #'.$this->id.': There were some warnings:<br />'.implode('<br /><br />',
$tagWriter->warnings)); $tagWriter->warnings));
} }
} else { } else {
Log::error('Track #' . $this->id . ': Failed to write tags!<br />' . implode('<br /><br />', Log::error('Track #'.$this->id.': Failed to write tags!<br />'.implode('<br /><br />',
$tagWriter->errors)); $tagWriter->errors));
} }
} }
private function getCacheKey($key) private function getCacheKey($key)
{ {
return 'track-' . $this->id . '-' . $key; return 'track-'.$this->id.'-'.$key;
} }

View file

@ -88,7 +88,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
{ {
if (Auth::check()) { if (Auth::check()) {
$query->with([ $query->with([
'users' => function ($query) { 'users' => function($query) {
$query->whereUserId(Auth::user()->id); $query->whereUserId(Auth::user()->id);
} }
]); ]);
@ -151,7 +151,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
public function getIsArchivedAttribute() public function getIsArchivedAttribute()
{ {
return (bool)$this->attributes['is_archived']; return (bool) $this->attributes['is_archived'];
} }
public function getUrlAttribute() public function getUrlAttribute()
@ -161,7 +161,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
public function getMessageUrlAttribute() public function getMessageUrlAttribute()
{ {
return 'http://mlpforums.com/index.php?app=members&module=messaging&section=send&do=form&fromMemberID=' . $this->id; return 'http://mlpforums.com/index.php?app=members&module=messaging&section=send&do=form&fromMemberID='.$this->id;
} }
public function getAuthIdentifier() public function getAuthIdentifier()
@ -192,7 +192,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
} }
if ($this->email == "redacted@example.net") { if ($this->email == "redacted@example.net") {
return Gravatar::getUrl($this->id . "", Image::$ImageTypes[$type]['width'], "identicon"); return Gravatar::getUrl($this->id."", Image::$ImageTypes[$type]['width'], "identicon");
} }
$email = $this->gravatar; $email = $this->gravatar;
@ -238,7 +238,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
/** /**
* Returns true if this user has the given role. * Returns true if this user has the given role.
* *
* @param $roleName * @param string $roleName
* @return bool * @return bool
*/ */
public function hasRole($roleName) public function hasRole($roleName)

View file

@ -43,23 +43,23 @@ class PlaylistDownloader
function download() function download()
{ {
$zip = new ZipStream($this->_playlist->user->display_name . ' - ' . $this->_playlist->title . '.zip'); $zip = new ZipStream($this->_playlist->user->display_name.' - '.$this->_playlist->title.'.zip');
$zip->setComment( $zip->setComment(
'Playlist: ' . $this->_playlist->title . "\r\n" . 'Playlist: '.$this->_playlist->title."\r\n".
'Curator: ' . $this->_playlist->user->display_name . "\r\n" . 'Curator: '.$this->_playlist->user->display_name."\r\n".
'URL: ' . $this->_playlist->url . "\r\n" . "\r\n" . 'URL: '.$this->_playlist->url."\r\n"."\r\n".
'Downloaded on ' . date('l, F jS, Y, \a\t h:i:s A') . '.' 'Downloaded on '.date('l, F jS, Y, \a\t h:i:s A').'.'
); );
$notes = $notes =
'Playlist: ' . $this->_playlist->title . "\r\n" . 'Playlist: '.$this->_playlist->title."\r\n".
'Curator: ' . $this->_playlist->user->display_name . "\r\n" . 'Curator: '.$this->_playlist->user->display_name."\r\n".
'URL: ' . $this->_playlist->url . "\r\n" . 'URL: '.$this->_playlist->url."\r\n".
"\r\n" . "\r\n".
$this->_playlist->description . "\r\n" . $this->_playlist->description."\r\n".
"\r\n" . "\r\n".
"\r\n" . "\r\n".
'Tracks' . "\r\n" . 'Tracks'."\r\n".
"\r\n"; "\r\n";
$m3u = ''; $m3u = '';
@ -69,22 +69,22 @@ class PlaylistDownloader
continue; continue;
} }
$trackTarget = $track->downloadDirectory . '/' . $track->getDownloadFilenameFor($this->_format); $trackTarget = $track->downloadDirectory.'/'.$track->getDownloadFilenameFor($this->_format);
$zip->addLargeFile($track->getFileFor($this->_format), $trackTarget); $zip->addLargeFile($track->getFileFor($this->_format), $trackTarget);
$notes .= $notes .=
$index . '. ' . $track->title . "\r\n" . $index.'. '.$track->title."\r\n".
$track->description . "\r\n" . $track->description."\r\n".
"\r\n"; "\r\n";
$m3u .= '#EXTINF:' . $track->duration . ',' . $track->title . "\r\n"; $m3u .= '#EXTINF:'.$track->duration.','.$track->title."\r\n";
$m3u .= '../' . $trackTarget . "\r\n"; $m3u .= '../'.$trackTarget."\r\n";
$index++; $index++;
} }
$playlistDir = 'Pony.fm Playlists/'; $playlistDir = 'Pony.fm Playlists/';
$zip->addFile($notes, $playlistDir . $this->_playlist->title . '.txt'); $zip->addFile($notes, $playlistDir.$this->_playlist->title.'.txt');
$zip->addFile($m3u, $playlistDir . $this->_playlist->title . '.m3u'); $zip->addFile($m3u, $playlistDir.$this->_playlist->title.'.m3u');
$zip->finalize(); $zip->finalize();
} }
} }

View file

@ -87,6 +87,10 @@ class ProfileRequest
} }
} }
/**
* @param string $level
* @param string $message
*/
public function log($level, $message, $context) public function log($level, $message, $context)
{ {
$this->_data['log'][] = [ $this->_data['log'][] = [