<?php 
/**
 * Система управления сайтом HostCMS v. 5.xx
 * Copyright © 2005-2010 ООО "Хостмэйк" (Hostmake LLC), http://www.hostcms.ru
 *
 * Обработчик добавления/редактирования поисковой характеристики.
 * 
 * Файл: /admin/seo/action/add_characteristic.php
 * 
 * @author Hostmake LLC
 * @version 5.x
 */
// Получаем переданные поля
$param['seo_characteristic_id'] = to_int($_POST['seo_characteristic_id']);
$param['seo_characteristic_yc_rubric'] = to_str($_POST['seo_characteristic_yc_rubric']);
$param['seo_characteristic_yc'] = to_int($_POST['seo_characteristic_yc']);
$param['seo_characteristic_pr'] = to_int($_POST['seo_characteristic_pr']);
$param['seo_characteristic_links_google'] = to_int($_POST['seo_characteristic_links_google']);
$param['seo_characteristic_links_yandex'] = to_int($_POST['seo_characteristic_links_yandex']);
$param['seo_characteristic_links_yahoo'] = to_int($_POST['seo_characteristic_links_yahoo']);
$param['seo_characteristic_links_msn'] = to_int($_POST['seo_characteristic_links_msn']);
$param['seo_characteristic_indexed_aport'] = to_int($_POST['seo_characteristic_indexed_aport']);
$param['seo_characteristic_indexed_yandex'] = to_int($_POST['seo_characteristic_indexed_yandex']);
$param['seo_characteristic_indexed_yahoo'] = to_int($_POST['seo_characteristic_indexed_yahoo']);
$param['seo_characteristic_indexed_msn'] = to_int($_POST['seo_characteristic_indexed_msn']);
$param['seo_characteristic_indexed_rambler'] = to_int($_POST['seo_characteristic_indexed_rambler']);
$param['seo_characteristic_indexed_google'] = to_int($_POST['seo_characteristic_indexed_google']);
$param['seo_characteristic_catalog_yandex'] = isset($_POST['seo_characteristic_catalog_yandex']) ? 1 : 0;
$param['seo_characteristic_catalog_rambler'] = isset($_POST['seo_characteristic_catalog_rambler']) ? 1 : 0;
$param['seo_characteristic_catalog_mail'] = isset($_POST['seo_characteristic_catalog_mail']) ? 1 : 0;
$param['seo_characteristic_catalog_dmoz'] = isset($_POST['seo_characteristic_catalog_dmoz']) ? 1 : 0;
$param['seo_characteristic_catalog_aport'] = isset($_POST['seo_characteristic_catalog_aport']) ? 1 : 0;
$param['seo_characteristic_counter_rambler'] = isset($_POST['seo_characteristic_counter_rambler']) ? 1 : 0;
$param['seo_characteristic_counter_spylog'] = isset($_POST['seo_characteristic_counter_spylog']) ? 1 : 0;
$param['seo_characteristic_counter_hotlog'] = isset($_POST['seo_characteristic_counter_hotlog']) ? 1 : 0;
$param['seo_characteristic_counter_mail'] = isset($_POST['seo_characteristic_counter_mail']) ? 1 : 0;
$param['seo_characteristic_counter_liveinternet'] = isset($_POST['seo_characteristic_counter_liveinternet']) ? 1 : 0;

if (isset($_POST['seo_characteristic_date_time']))
{
	$param['seo_characteristic_date_time'] = to_str($_POST['seo_characteristic_date_time']);
}
else
{
	$param['seo_characteristic_date_time'] = date("Y-m-d H:i:s");
}

if (isset($_REQUEST['users_id'])) 
{
	$param['users_id'] = to_int($_REQUEST['users_id']);
}
else 
{
	$param['users_id'] = 0;
}

// Если добавление прошло успешно, обязательно добавим на форму скрытое поле с ID добавленной записи
if ($insert_id = $seo->InsertCharacteristic($param))
{
	$admin_forms = new admin_forms();
	$window_id = $admin_forms->GetWindowId();
	?><script type="text/javascript">
	$.appendInput('<?php echo $window_id?>', 'EditAddCharacteristic', 'seo_characteristic_id', '<?php echo $insert_id?>');
	</script><?php
	
	// Редактирование сущности
	if ($param['seo_characteristic_id'])
	{
		show_message($GLOBALS['MSG_seo']['edit_success']);
	}
	else // Добавление сущности
	{
		show_message($GLOBALS['MSG_seo']['add_success']);
	}
}
else // Ошибка добавления/редактирования
{
	if ($param['seo_characteristic_id'])
	{
		show_error_message($GLOBALS['MSG_seo']['edit_error']);
	}
	else
	{
		show_error_message($GLOBALS['MSG_seo']['add_error']);
	}
}
?>