<?PHP
// +----------------------------------------------------------------------+
// | Der Dirigent 1.0                                                     |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003-2004 the dedi-group <dedi-group@der-dirigent.de>  |
// +----------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License                 |
// |                                                                      |
// | This program is subject to the GPL license, that is bundled with     |
// | this package in the file LICENSE.TXT.                                |
// | If you did not receive a copy of the GNU General Public License      |
// | along with this program write to the Free Software Foundation, Inc., |
// | 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA               |
// |                                                                      |
// | This program is distributed in the hope that it will be useful,      |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of       |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        |
// | GNU General Public License for more details.                         |
// |                                                                      |
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+

/******************************************************************************
 1. Benötigte Funktionen und Klassen includieren
******************************************************************************/

include('inc/fnc.group.php');

/******************************************************************************
 2. Eventuelle Actions/ Funktionen abarbeiten
******************************************************************************/

$perm->check('area_group_edit');
switch($action) {
	case 'save':
		$errno = group_save();
		if (!$errno) {
			header ('Status: 302 Moved Temporarily');
			header ('Location:'.$sess->url("main.php?area=group&order=$order&ascdesc=$ascdesc"));
			exit;
		}
		break;
}

/******************************************************************************
 3. Eventuelle Dateien zur Darstellung includieren
******************************************************************************/

include('inc/inc.header.php');

/******************************************************************************
 4. Bildschirmausgabe aufbereiten und ausgeben
******************************************************************************/

// Templatedatei laden
$tpl->loadTemplatefile('group_edit.tpl');
$tmp['AREA'] = $dedi_lang['area_group_edit'];
if (!empty($errno)) {
	$tpl -> setCurrentBlock('ERROR');
	$tpl_error['ERRORMESSAGE'] = $dedi_lang['err_'.$errno];
	$tpl->setVariable($tpl_error);
	$tpl->parseCurrentBlock();
}

// Tabellenformatierung
$tmp['CELLPADDING'] = $cellpadding;
$tmp['CELLSPACING'] = $cellspacing;
$tmp['BORDER'] = $border;
$tmp['LANG_NAME'] = $dedi_lang['group_name'];
$tmp['LANG_DESCRIPTION'] = $dedi_lang['group_description'];

// Formulareinstellungen
$tmp['FORM_URL'] = $sess->url('main.php');
if (!isset($name) && !empty($idgroup)) {
	$sql = "SELECT name, description FROM ".$dedi_db['groups']." WHERE idgroup='$idgroup' LIMIT 0, 1";
	$db->query($sql);
	$db->next_record();
	$tmp['FORM_NAME'] = htmlspecialchars($db->f('name'));
	$tmp['FORM_OLDNAME'] = htmlspecialchars($db->f('name'));
	$tmp['FORM_DESCRIPTION'] = htmlspecialchars($db->f('description'));
} else {
	remove_magic_quotes_gpc($name);
	remove_magic_quotes_gpc($description);
	$tmp['FORM_NAME'] = htmlspecialchars($name);
	$tmp['FORM_DESCRIPTION'] = htmlspecialchars($description);
	$tmp['FORM_OLDNAME'] = htmlspecialchars($oldname);
}
if (!is_array($group)) $group['0'] = $idgroup;
$tmp['FORM_ABORT'] = '<a href="'.$sess->url("main.php?area=group&order=$order&ascdesc=$ascdesc").'" onMouseOver="on(\''.$dedi_lang['gen_abort'].'\');return true;" onMouseOut="off()" ;return true;"><img src="tpl/'.$cfg_dedi['skin'].'/img/but_cancel.gif" alt="'.$dedi_lang['gen_abort'].'" title="'.$dedi_lang['gen_abort'].'" width="21" height="21" border="0"></a>';
$tmp['IMGPATH'] = 'tpl/'.$cfg_dedi['skin'].'/img/';
$tmp['IDGROUP'] = $idgroup;
$tmp['ORDER'] = $order;
$tmp['ASCDESC'] = $ascdesc;
$tpl->setVariable($tmp);
unset($tmp);
?>