Ejemplo n.º 1
0
 private static function _updatePlaylist($id, $name, $songsIdToAdd = array(), $songIndexToRemove = array(), $public = true)
 {
     $playlist = new Playlist($id);
     $newdata = array();
     $newdata['name'] = !empty($name) ? $name : $playlist->name;
     $newdata['pl_type'] = $public ? "public" : "private";
     $playlist->update($newdata);
     if ($songsIdToAdd) {
         if (!is_array($songsIdToAdd)) {
             $songsIdToAdd = array($songsIdToAdd);
         }
         if (count($songsIdToAdd) > 0) {
             for ($i = 0; $i < count($songsIdToAdd); ++$i) {
                 $songsIdToAdd[$i] = Subsonic_XML_Data::getAmpacheId($songsIdToAdd[$i]);
             }
             $playlist->add_songs($songsIdToAdd);
         }
     }
     if ($songIndexToRemove) {
         if (!is_array($songIndexToRemove)) {
             $songIndexToRemove = array($songIndexToRemove);
         }
         if (count($songIndexToRemove) > 0) {
             foreach ($songIndexToRemove as $track) {
                 $playlist->delete_track_number($track);
             }
             $playlist->regenerate_track_numbers();
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * playlist_remove_song
  * This remove a song from a playlist
  */
 public static function playlist_remove_song($input)
 {
     ob_end_clean();
     $playlist = new Playlist($input['filter']);
     $track = new Playlist($input['track']);
     if (!$playlist->has_access()) {
         echo XML_Data::error('401', T_('Access denied to this playlist.'));
     } else {
         $playlist->delete_track_number($track);
         echo XML_Data::single_string('success');
     }
 }