Location: PHPKode > projects > Axis Groupware > musiclib/listen.php
<?php
$phpgw_info["flags"] = array ("currentapp" => "musiclib",
							 "enable_nextmatchs_class" => True,
 							 "noheader" => True );

include ("../header.inc.php"); #PHP Groupware header

require ('inc/config.inc.php');
require ('inc/functions.inc.php');

$artist = urldecode($artist);
$album  = urldecode($album);

switch ($mode) 
{
	case 'random':
		switch ($type) 
		{
			case 'album':
				$where = "WHERE repository=1";
				break;
			case 'misc':
				$where = "WHERE repository=2";
				break;
			case 'playlist':
				$where = "WHERE owner=".$GLOBALS['phpgw_info']['user']['account_id'];
		}

		$where .= " AND random_play=1";
		
		if ($GLOBALS['phpgw_info']['server']['db_type'] == 'pgsql') 
		{
			$random = "RANDOM()";
		} 
		else 
		{
			$random = "RAND()";
		}
		
		if ($type == 'playlist') 
		{
			$query = construct_random_playlist_song_select($where." ORDER BY ".$random." LIMIT ".$musiclib['config']['random_playlist_size']);
		} 
		else 
		{
			$query = construct_song_select($where." ORDER BY ".$random." LIMIT ".$musiclib['config']['random_playlist_size']);
		}

		break;
	case 'misc':

		$query = "SELECT * FROM ".$musiclib['tables']['songs']." WHERE id=".$id;
	
		break;
	case 'song':

		$query = construct_song_select("WHERE ".$musiclib['tables']['songs'].".id=".$id);
		
		break;
	case 'album':
		$query = construct_song_select("WHERE album_id='".$id."' ORDER BY track");
		times_played($mode,$id);

		break;
	case 'playlist':

		$query = construct_playlist_song_select($id);
		
		break;
	default:
		echo "mode not defined. exiting.";
		exit;
}

generate_playlist($mode,$query);

?>
Return current item: Axis Groupware