/** * User profile */ private function user() { $playlists = $this->user->playlists(); $likedPlaylists = $this->user->likedPlaylists(); if (ADMIN || LOGGED == $this->user->id) { $unpubPlaylists = $this->user->unpubPlaylists(); } if (LOGGED) { $followDisplay = $this->user->id !== LOGGED; View::set('follow_display', $followDisplay); if ($followDisplay) { $followActive = UserRelation::filter('isActive', $this->user->id, LOGGED); View::set('follow_active', $followActive); } } View::set('playlists', $playlists); View::set('liked_playlists', $likedPlaylists); View::set('unpub_playlists', $unpubPlaylists); View::show('profile/profile'); }
private function playlist() { // Playlist Author $author = $this->playlist->user(); $author->playlists = $author->playlists(); View::set('author', $author->asArray()); // Tags $tags = $this->playlist->tags(); View::set('tags', $tags); // Similar playlists if ($tags) { $similarPlaylists = Playlist::filter('byTags', $tags)->select('p.*')->whereNotEqual('p.id', $this->playlist->id); $count = $similarPlaylists->countDistinct('p.id'); $similarPlaylists = $similarPlaylists->groupBy('p.id')->paginate($count); // View all link if ($similarPlaylists) { $similarPlaylists['href'] = implode('/', $tags); } View::set('similar_playlists', $similarPlaylists); } // Liked if (LOGGED) { $likeActive = PlaylistLike::filter('isActive', $this->playlist->id, LOGGED); View::set('like_active', $likeActive); $followDisplay = $this->playlist->user_id !== LOGGED; View::set('follow_display', $followDisplay); if ($followDisplay) { $followActive = UserRelation::filter('isActive', $this->playlist->user_id, LOGGED); View::set('follow_active', $followActive); } $reportActive = Report::filter('isActive', $this->playlist->id, 'playlist', LOGGED); View::set('report_active', $reportActive); } $edit = ADMIN || LOGGED === $this->playlist->user_id; View::set('edit', $edit); // View View::set('playlist', $this->playlist->asArray()); View::set('tracks', $this->playlist->tracks()); View::set('comments', $this->playlist->comments()); View::show('playlist/playlist'); }
/** * Follow another user * @return json success */ private function follow() { Base::requireLogged(); $ret = array('active' => 0); if (!Validate::id($_GET['id']) || $_GET['id'] === LOGGED) { return $ret; } $id = (int) $_GET['id']; // Insert into database $relation = UserRelation::filter('add', $id, LOGGED); // Get current status $ret['active'] = UserRelation::filter('isActive', $id, LOGGED); // Show status return $ret; }