<?php
  /**************************************************************************\
  * phpGroupWare - E-Mail                                                    *
  * http://www.phpgroupware.org                                              *
  * --------------------------------------------                             *
  *  This program is free software; you can redistribute it and/or modify it *
  *  under the terms of the GNU General Public License as published by the   *
  *  Free Software Foundation; either version 2 of the License, or (at your  *
  *  option) any later version.                                              *
  \**************************************************************************/

	/* $Id: hook_home.inc.php,v 1.4 2001/09/15 12:02:51 milosch Exp $ */

	$d1 = strtolower(substr(PHPGW_APP_INC,0,3));
	if($d1 == 'htt' || $d1 == 'ftp' )
	{
		echo "Failed attempt to break in via an old Security Hole!<br>\n";
		$GLOBALS['phpgw']->common->phpgw_exit();
	}
	unset($d1);

	$tmp_app_tpl = $GLOBALS['phpgw']->common->get_tpl_dir('dj');

	/* There is no prefs dialog for this yet */
	/* $GLOBALS['phpgw_info']['user']['preferences']['dj']['mainscreen_showrequest'] = 1; */
	if ($GLOBALS['phpgw_info']['user']['apps']['dj']
		&& $GLOBALS['phpgw_info']['user']['preferences']['dj']['mainscreen_showrequest'])
	{
		echo "\n<!-- DJ Request QUE -->\n";

		$p = CreateObject('phpgwapi.Template',$tmp_app_tpl);
		$p->set_file(array('request' => 'request_home.tpl'));
		$p->set_block('request','list','list');
		$p->set_block('request','row','row');

		$p->set_var('th_bg',$GLOBALS['phpgw_info']['theme']['th_bg']);
		$p->set_var('message',lang('DJ') . ' - ' . lang('The following songs are in the queue to be played'));
		$p->set_var('lang_title',lang('Title'));
		$p->set_var('lang_artist',lang('Artist'));
		$p->set_var('lang_year',lang('Year'));
		$p->set_var('lang_genre',lang('Genre'));
		$p->set_var('lang_time',lang('Time'));

		$db2 = $GLOBALS['phpgw']->db;
		$i = 0;
		$GLOBALS['phpgw']->db->query("SELECT * FROM phpgw_dj_que ORDER BY que_id ASC",__LINE__,__FILE__);
		while ($GLOBALS['phpgw']->db->next_record())
		{
			if ($i > $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'])
			{
				break;
			}
			$db2->query("SELECT * FROM phpgw_dj_songlist WHERE song_name='" . addslashes($GLOBALS['phpgw']->db->f('que_song')) . "'",__LINE__,__FILE__);
			$db2->next_record();
			$totaltime = $totaltime + $db2->f('song_length');

			$GLOBALS['phpgw']->nextmatchs->template_alternate_row_color($p);
			$p->set_var('row_title',trim($db2->f('song_title')));
			$p->set_var('row_artist',trim($db2->f('song_artist')));
			$p->set_var('row_year',trim($db2->f('song_year')));
			$p->set_var('row_genre',trim($db2->f('song_genre')));
			$p->set_var('row_time',date('i:s',$db2->f('song_length')));

			$p->parse('rows','row',True);
			$i++;
		}
		$p->set_var('lang_totaltime',lang('Total time'));
		$p->set_var('value_totaltime',date('i:s',$totaltime));
		$p->set_var('value_done','<a href="' . $GLOBALS['phpgw']->link('/dj/index.php','cat_id='.$cat_id) . '">' . lang('Done') . '</a>');

		$p->pfp('out','list');

		echo "\n<!-- DJ Request QUE -->\n";
	}
?>
