/**
  * 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;
 }
Beispiel #2
0
 /**
  * create
  * This is the democratic play create function it inserts this into the democratic table
  */
 public static function create($data)
 {
     // Clean up the input
     $name = Dba::escape($data['name']);
     $base = Dba::escape($data['democratic']);
     $cool = Dba::escape($data['cooldown']);
     $level = Dba::escape($data['level']);
     $default = Dba::escape($data['make_default']);
     $user = Dba::escape($GLOBALS['user']->id);
     $sql = "INSERT INTO `democratic` (`name`,`base_playlist`,`cooldown`,`level`,`user`,`primary`) " . "VALUES ('{$name}','{$base}','{$cool}','{$level}','{$user}','{$default}')";
     $db_results = Dba::write($sql);
     if ($db_results) {
         $insert_id = Dba::insert_id();
         parent::create(array('session_id' => $insert_id, 'type' => 'vote', 'object_type' => 'song'));
     }
     return $db_results;
 }