<?php
//
//	file: includes/acp/acp_attach_config.php
//	author: ptirhiik
//	begin: 24/02/2006
//	version: 1.6.0 - 10/06/2006
//	license: http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
//
//	based on : attachment_mod copyright (c) 2002 Meik Sievertsen (acydburn)
//

if ( !defined('IN_PHPBB') )
{
	die('Hack attempt');
}

$cp_title = 'Attach_settings';
$cp_title_explain = 'Manage_attachments_explain';

// no fields in form : end there
if ( empty($fields) )
{
	// send "no options" with left side menus
	$cp_panels->display_empty();
	return;
}

class attach_config_auto_form extends auto_form
{
	function update_table(&$form_fields)
	{
		global $config, $db;
		global $attach_config;

		if ( empty($form_fields) )
		{
			return;
		}
		$keys = array();
		$db->sql_stack_reset();
		foreach ( $form_fields as $name => $value )
		{
			$keys[] = $db->sql_escape_string($name);
			$fields = array(
				'config_name' => $name,
				'config_value' => $value,
			);
			$db->sql_stack_statement($fields);
		}
		$sql = 'DELETE FROM ' . ATT_CONFIG_TABLE . '
					WHERE config_name IN(\'' . implode('\', \'', $keys) . '\')';
		$db->sql_query($sql, false, __LINE__, __FILE__);
		$db->sql_stack_insert(ATT_CONFIG_TABLE, false, __LINE__, __FILE__);

		// recache config
		$attach_config->read(true);

		// send achievement message
		message_return('Attach_config_updated', $this->return_msg, $config->url($this->requester, $this->return_parms, true));
	}
}

// instantiate the form
$parms = array(
	'mode' => $menu_id,
	'sub' => $subm_id == $menu_id ? '' : $subm_id,
	'ctx' => $ctx_id == $subm_id ? '' : $ctx_id,
);
$form = new attach_config_auto_form($attach_config->data, $fields, $cp_requester, 'Click_return_' . $subm_id, $cp_parms + $parms);
$form->process();
$template->set_switch('form');
$template->set_filenames(array('body' => 'cp_generic.tpl'));

?>