Пример #1
0
Файл: Queue.php Проект: 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;
     }
 }