Example #1
0
File: Queue.php Project: nbar1/gs
 /**
  * Add Song To Queue
  *
  * @param Song $song Song to be added
  * @param User $user User that added song
  * @return string Message sent to user
  */
 public function addSongToQueue(Song $song, User $user)
 {
     if ($this->isSongInQueue($song->getToken())) {
         return json_encode(array('msg' => 'song already queued'));
     }
     if ($user->getAvailablePromotions() < 1) {
         $song->setPriority('low');
     }
     $promoted_user = $song->getPriority() === 'high' ? $user->getId() : null;
     $data = array($song->getToken(), $song->getPriority(), $this->getNextQueuePosition(), $user->getId(), $promoted_user);
     if ($this->getDao()->addSongToQueue($data)) {
         if (!$song->hasMetadata()) {
             $song->storeMetadata();
         }
         return true;
     } else {
         return false;
     }
 }
Example #2
0
File: Search.php Project: nbar1/gs
 /**
  * Return artist search
  *
  * @param string $artist_id Search query
  * @return array
  */
 public function doArtistSearch($artist_id, User $user)
 {
     try {
         $results_songs = $this->getArtistSongs($artist_id);
         return array('userPromotions' => $user->getAvailablePromotions(), 'type' => 'artist', 'artist' => $artist_id, 'songs' => $results_songs);
     } catch (Exception $e) {
         return false;
     }
 }