Example #1
0
        }
    } else {
        $oid = $_SESSION['random']['last'];
    }
}
// if random
if ($type == 'song') {
    /* Base Checks passed create the song object */
    $media = new Song($oid);
    $media->format();
} elseif ($type == 'song_preview') {
    $media = new Song_Preview($oid);
    $media->format();
} elseif ($type == 'podcast_episode') {
    $media = new Podcast_Episode($oid);
    $media->format();
} else {
    $type = 'video';
    $media = new Video($oid);
    if (isset($_REQUEST['subtitle'])) {
        $subtitle = $media->get_subtitle_file($_REQUEST['subtitle']);
    }
    $media->format();
}
if (!User::stream_control(array(array('object_type' => $type, 'object_id' => $media->id)))) {
    debug_event('UI::access_denied', 'Stream control failed for user ' . $GLOBALS['user']->username . ' on ' . $media->get_stream_name(), 3);
    UI::access_denied();
    exit;
}
if ($media->catalog) {
    // Build up the catalog for our current object
Example #2
0
 public static function _musicChilds($prmPath, $prmQuery, $start, $count)
 {
     $mediaItems = array();
     $maxCount = 0;
     $queryData = array();
     parse_str($prmQuery, $queryData);
     $parent = 'amp://music' . $prmPath;
     $pathreq = explode('/', $prmPath);
     if ($pathreq[0] == '' && count($pathreq) > 0) {
         array_shift($pathreq);
     }
     switch ($pathreq[0]) {
         case 'artists':
             switch (count($pathreq)) {
                 case 1:
                     // Get artists list
                     //$artists = Catalog::get_artists();
                     //list($maxCount, $artists) = self::_slice($artists, $start, $count);
                     $artists = Catalog::get_artists(null, $count, $start);
                     list($maxCount, $artists) = array(999999, $artists);
                     foreach ($artists as $artist) {
                         $artist->format();
                         $mediaItems[] = self::_itemArtist($artist, $parent);
                     }
                     break;
                 case 2:
                     // Get artist's albums list
                     $artist = new Artist($pathreq[1]);
                     if ($artist->id) {
                         $album_ids = $artist->get_albums();
                         list($maxCount, $album_ids) = self::_slice($album_ids, $start, $count);
                         foreach ($album_ids as $album_id) {
                             $album = new Album($album_id);
                             $album->format();
                             $mediaItems[] = self::_itemAlbum($album, $parent);
                         }
                     }
                     break;
             }
             break;
         case 'albums':
             switch (count($pathreq)) {
                 case 1:
                     // Get albums list
                     //!!$album_ids = Catalog::get_albums();
                     //!!list($maxCount, $album_ids) = self::_slice($album_ids, $start, $count);
                     $album_ids = Catalog::get_albums($count, $start);
                     list($maxCount, $album_ids) = array(999999, $album_ids);
                     foreach ($album_ids as $album_id) {
                         $album = new Album($album_id);
                         $album->format();
                         $mediaItems[] = self::_itemAlbum($album, $parent);
                     }
                     break;
                 case 2:
                     // Get album's songs list
                     $album = new Album($pathreq[1]);
                     if ($album->id) {
                         $song_ids = $album->get_songs();
                         list($maxCount, $song_ids) = self::_slice($song_ids, $start, $count);
                         foreach ($song_ids as $song_id) {
                             $song = new Song($song_id);
                             $song->format();
                             $mediaItems[] = self::_itemSong($song, $parent);
                         }
                     }
                     break;
             }
             break;
         case 'songs':
             switch (count($pathreq)) {
                 case 1:
                     // Get songs list
                     $catalogs = Catalog::get_catalogs();
                     foreach ($catalogs as $catalog_id) {
                         $catalog = Catalog::create_from_id($catalog_id);
                         $songs = $catalog->get_songs();
                         list($maxCount, $songs) = self::_slice($songs, $start, $count);
                         foreach ($songs as $song) {
                             $song->format();
                             $mediaItems[] = self::_itemSong($song, $parent);
                         }
                     }
                     break;
             }
             break;
         case 'playlists':
             switch (count($pathreq)) {
                 case 1:
                     // Get playlists list
                     $pl_ids = Playlist::get_playlists();
                     list($maxCount, $pl_ids) = self::_slice($pl_ids, $start, $count);
                     foreach ($pl_ids as $pl_id) {
                         $playlist = new Playlist($pl_id);
                         $playlist->format();
                         $mediaItems[] = self::_itemPlaylist($playlist, $parent);
                     }
                     break;
                 case 2:
                     // Get playlist's songs list
                     $playlist = new Playlist($pathreq[1]);
                     if ($playlist->id) {
                         $items = $playlist->get_items();
                         list($maxCount, $items) = self::_slice($items, $start, $count);
                         foreach ($items as $item) {
                             if ($item['object_type'] == 'song') {
                                 $song = new Song($item['object_id']);
                                 $song->format();
                                 $mediaItems[] = self::_itemSong($song, $parent);
                             }
                         }
                     }
                     break;
             }
             break;
         case 'smartplaylists':
             switch (count($pathreq)) {
                 case 1:
                     // Get playlists list
                     $pl_ids = Search::get_searches();
                     list($maxCount, $pl_ids) = self::_slice($pl_ids, $start, $count);
                     foreach ($pl_ids as $pl_id) {
                         $playlist = new Search($pl_id, 'song');
                         $playlist->format();
                         $mediaItems[] = self::_itemPlaylist($playlist, $parent);
                     }
                     break;
                 case 2:
                     // Get playlist's songs list
                     $playlist = new Search($pathreq[1], 'song');
                     if ($playlist->id) {
                         $items = $playlist->get_items();
                         list($maxCount, $items) = self::_slice($items, $start, $count);
                         foreach ($items as $item) {
                             if ($item['object_type'] == 'song') {
                                 $song = new Song($item['object_id']);
                                 $song->format();
                                 $mediaItems[] = self::_itemSong($song, $parent);
                             }
                         }
                     }
                     break;
             }
             break;
         case 'live_streams':
             switch (count($pathreq)) {
                 case 1:
                     // Get radios list
                     $radios = Live_Stream::get_all_radios();
                     list($maxCount, $radios) = self::_slice($radios, $start, $count);
                     foreach ($radios as $radio_id) {
                         $radio = new Live_Stream($radio_id);
                         $radio->format();
                         $mediaItems[] = self::_itemLiveStream($radio, $parent);
                     }
                     break;
             }
             break;
         case 'podcasts':
             switch (count($pathreq)) {
                 case 1:
                     // Get podcasts list
                     $podcasts = Catalog::get_podcasts();
                     list($maxCount, $podcasts) = self::_slice($podcasts, $start, $count);
                     foreach ($podcasts as $podcast) {
                         $podcast->format();
                         $mediaItems[] = self::_itemPodcast($podcast, $parent);
                     }
                     break;
                 case 2:
                     // Get podcast episodes list
                     $podcast = new Podcast($pathreq[1]);
                     if ($podcast->id) {
                         $episodes = $podcast->get_episodes();
                         list($maxCount, $episodes) = self::_slice($episodes, $start, $count);
                         foreach ($episodes as $episode_id) {
                             $episode = new Podcast_Episode($episode_id);
                             $episode->format();
                             $mediaItems[] = self::_itemPodcastEpisode($episode, $parent);
                         }
                     }
                     break;
             }
             break;
         default:
             $mediaItems[] = self::_musicMetadata('artists');
             $mediaItems[] = self::_musicMetadata('albums');
             $mediaItems[] = self::_musicMetadata('songs');
             $mediaItems[] = self::_musicMetadata('playlists');
             $mediaItems[] = self::_musicMetadata('smartplaylists');
             if (AmpConfig::get('live_stream')) {
                 $mediaItems[] = self::_musicMetadata('live_streams');
             }
             if (AmpConfig::get('podcast')) {
                 $mediaItems[] = self::_musicMetadata('podcasts');
             }
             break;
     }
     if ($maxCount == 0) {
         $maxCount = count($mediaItems);
     }
     return array($maxCount, $mediaItems);
 }
Example #3
0
    case 'delete':
        if (AmpConfig::get('demo_mode')) {
            break;
        }
        $episode_id = scrub_in($_REQUEST['podcast_episode_id']);
        show_confirmation(T_('Podcast Episode Deletion'), T_('Are you sure you want to permanently delete this episode?'), AmpConfig::get('web_path') . "/podcast_episode.php?action=confirm_delete&podcast_episode_id=" . $episode_id, 1, 'delete_podcast_episode');
        break;
    case 'confirm_delete':
        if (AmpConfig::get('demo_mode')) {
            break;
        }
        $episode = new Podcast_Episode($_REQUEST['podcast_episode_id']);
        if (!Catalog::can_remove($episode)) {
            debug_event('video', 'Unauthorized to remove the episode `.' . $episode->id . '`.', 1);
            UI::access_denied();
            exit;
        }
        if ($episode->remove()) {
            show_confirmation(T_('Podcast Episode Deletion'), T_('Episode has been deleted.'), AmpConfig::get('web_path'));
        } else {
            show_confirmation(T_('Podcast Episode Deletion'), T_('Cannot delete this episode.'), AmpConfig::get('web_path'));
        }
        break;
    case 'show':
    default:
        $episode = new Podcast_Episode($_REQUEST['podcast_episode']);
        $episode->format();
        require_once AmpConfig::get('prefix') . UI::find_template('show_podcast_episode.inc.php');
        break;
}
UI::show_footer();
echo T_('Actions');
?>
</th>
        </tr>
    </thead>
    <tbody>
        <?php 
if (AmpConfig::get('ratings')) {
    Rating::build_cache('podcast_episode', $object_ids);
}
if (AmpConfig::get('userflags')) {
    Userflag::build_cache('podcast_episode', $object_ids);
}
foreach ($object_ids as $episode_id) {
    $libitem = new Podcast_Episode($episode_id);
    $libitem->format();
    ?>
        <tr id="podcast_episode_<?php 
    echo $libitem->id;
    ?>
" class="<?php 
    echo UI::flip_class();
    ?>
">
            <?php 
    require AmpConfig::get('prefix') . UI::find_template('show_podcast_episode_row.inc.php');
    ?>
        </tr>
        <?php 
}
?>