<?php
  /**************************************************************************\
  * phpGroupWare - phpgw_dj                                                  *
  * http://www.phpgroupware.org                                              *
  * Written by: Miles Lott <milosch@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: delete.php,v 1.5 2001/09/15 12:02:51 milosch Exp $ */

	$confirm = $HTTP_POST_VARS['confirm'];
	if ($confirm)
	{
		$GLOBALS['phpgw_info']['flags'] = array(
			'noheader' => True,
			'nonavbar' => True
		);
	}

	$GLOBALS['phpgw_info']['flags']['currentapp'] = 'dj';
	include('../header.inc.php');

	$song_id = $HTTP_POST_VARS['song_id'] ? $HTTP_POST_VARS['song_id'] : $HTTP_GET_VARS['song_id'];

	if (!$song_id)
	{
		Header('Location: ' . $GLOBALS['phpgw']->link('/dj/index.php'));
	}

	if($confirm)
	{
		$accountid = $GLOBALS['phpgw_info']['user']['account_id'];

		$GLOBALS['phpgw']->db->query("DELETE FROM phpgw_dj_songlist WHERE song_id='$song_id'");
		Header('Location: ' . $GLOBALS['phpgw']->link('/dj/index.php'));
	}
	else
	{
		$GLOBALS['phpgw']->template->set_file(array('delete' => 'delete.tpl'));

		$GLOBALS['phpgw']->template->set_var('deleteheader',lang('Are you sure you want to delete this song ?'));
		$nolinkf = $GLOBALS['phpgw']->link('/dj/index.php');
		$nolink = "<a href=\"$nolinkf\">" . lang('No') . "</a>";
		$GLOBALS['phpgw']->template->set_var('nolink',$nolink);
		$GLOBALS['phpgw']->template->set_var('font',$font);

		$yeslinkf = $GLOBALS['phpgw']->link('/dj/delete.php',"song_id=$song_id&confirm=True");

		$yeslinkf = '<FORM method="POST" name="yesbutton" action="' . $GLOBALS['phpgw']->link('/dj/delete.php')."\">"
			. "<input type=hidden name=song_id value=$song_id>"
			. "<input type=hidden name=confirm value=True>"
			. "<input type=submit name=yesbutton value=Yes>"
			. "</FORM><SCRIPT>document.yesbutton.yesbutton.focus()</SCRIPT>";
		$yeslink = "<a href=\"$yeslinkf\">" . lang('Yes') ."</a>";
		$yeslink = $yeslinkf;

		$GLOBALS['phpgw']->template->set_var('yeslink',$yeslink);
		$GLOBALS['phpgw']->template->pparse('out','delete');
	}

	$GLOBALS['phpgw']->common->phpgw_footer();
?>
