Example #1
0
 /**
  * get_from_session
  * This returns a playlist object based on the session that is passed to
  * us.  This is used by the load_playlist on user for the most part.
  */
 public static function get_from_session($session_id)
 {
     $session_id = Dba::escape($session_id);
     $sql = "SELECT `id` FROM `tmp_playlist` WHERE `session`='{$session_id}'";
     $db_results = Dba::read($sql);
     $results = Dba::fetch_row($db_results);
     if (!$results['0']) {
         $results['0'] = Tmp_Playlist::create(array('session_id' => $session_id, 'type' => 'user', 'object_type' => 'song'));
     }
     $playlist = new Tmp_Playlist($results['0']);
     return $playlist;
 }
Example #2
0
/**
 * action switch
 */
switch ($_REQUEST['action']) {
    case 'basket':
        // Pull in our items (multiple types)
        $media_ids = $GLOBALS['user']->playlist->get_items();
        // Check to see if 'clear' was passed if it was then we need to reset the basket
        if ($_REQUEST['playlist_method'] == 'clear' || AmpConfig::get('playlist_method') == 'clear') {
            $GLOBALS['user']->playlist->clear();
        }
        break;
        /* This is run if we need to gather info based on a tmp playlist */
    /* This is run if we need to gather info based on a tmp playlist */
    case 'tmp_playlist':
        $tmp_playlist = new Tmp_Playlist($_REQUEST['tmpplaylist_id']);
        $media_ids = $tmp_playlist->get_items();
        break;
    case 'play_favorite':
        $data = $GLOBALS['user']->get_favorites($_REQUEST['type']);
        $media_ids = array();
        switch ($_REQUEST['type']) {
            case 'artist':
            case 'album':
                foreach ($data as $value) {
                    $songs = $value->get_songs();
                    $media_ids = array_merge($media_ids, $songs);
                }
                break;
            case 'song':
                foreach ($data as $value) {
Example #3
0
    ?>
</i>
    <?php 
}
?>
    </dd>
</dl><br />
<?php 
UI::show_box_bottom();
UI::show_box_top(T_('Active Playlist'));
?>
<table cellspacing="0">
    <tr>
        <td valign="top">
            <?php 
$tmp_playlist = new Tmp_Playlist(Tmp_Playlist::get_from_userid($client->id));
$object_ids = $tmp_playlist->get_items();
foreach ($object_ids as $object_data) {
    $type = array_shift($object_data);
    $object = new $type(array_shift($object_data));
    $object->format();
    echo $object->f_link;
    ?>
                <br />
            <?php 
}
?>
        </td>
    </tr>
</table><br />
<?php 
Example #4
0
 /**
  * load_playlist
  * This is called once per page load it makes sure that this session
  * has a tmp_playlist, creating it if it doesn't, then sets $this->playlist
  * as a tmp_playlist object that can be fiddled with later on
  */
 public function load_playlist()
 {
     $session_id = session_id();
     $this->playlist = Tmp_Playlist::get_from_session($session_id);
 }
Example #5
0
 /**
  * gc
  *
  * This is a wrapper function for all of the different cleaning
  * functions, it runs them in an order that resembles correctness.
  */
 public static function gc()
 {
     debug_event('catalog', 'Database cleanup started', 5);
     Song::gc();
     Album::gc();
     Artist::gc();
     Art::gc();
     Stats::gc();
     Rating::gc();
     Userflag::gc();
     Playlist::gc();
     Tmp_Playlist::gc();
     Shoutbox::gc();
     Tag::gc();
     debug_event('catalog', 'Database cleanup ended', 5);
 }
Example #6
0
 /**
  * gc
  *
  * This is a wrapper function for all of the different cleaning
  * functions, it runs them in an order that resembles correctness.
  */
 public static function gc()
 {
     debug_event('catalog', 'Database cleanup started', 5);
     Song::gc();
     Album::gc();
     Artist::gc();
     Video::gc();
     Art::gc();
     Stats::gc();
     Rating::gc();
     Userflag::gc();
     Useractivity::gc();
     Playlist::gc();
     Tmp_Playlist::gc();
     Shoutbox::gc();
     Tag::gc();
     // TODO: use InnoDB with foreign keys and on delete cascade to get rid of garbage collection
     \Lib\Metadata\Repository\Metadata::gc();
     \Lib\Metadata\Repository\MetadataField::gc();
     debug_event('catalog', 'Database cleanup ended', 5);
 }
Example #7
0
 /**
  * get_voters
  * This returns the users that voted for the specified object
  * This is an array of user ids
  */
 public function get_voters($object_id)
 {
     if (parent::is_cached('democratic_voters', $object_id)) {
         return parent::get_from_cache('democratic_voters', $object_id);
     }
     $sql = "SELECT `user` FROM `user_vote` WHERE `object_id` = ?";
     $db_results = Dba::read($sql, array($object_id));
     $voters = array();
     while ($results = Dba::fetch_assoc($db_results)) {
         $voters[] = $results['user'];
     }
     parent::add_to_cache('democratic_vote', $object_id, $voters);
     return $voters;
 }
Example #8
0
 /**
  * get_voters
  * This returns the users that voted for the specified object
  * This is an array of user ids
  */
 public function get_voters($object_id)
 {
     return parent::get_from_cache('democratic_voters', $object_id);
 }
Example #9
0
 /**
  * gc
  *
  * This function is randomly called and it cleans up the spoo
  */
 public static function gc()
 {
     $sql = 'DELETE FROM `session` WHERE `expire` < ?';
     Dba::write($sql, array(time()));
     // Also clean up things that use sessions as keys
     Query::gc();
     Tmp_Playlist::gc();
     Stream_Playlist::gc();
     Song_Preview::gc();
     return true;
 }