<?php 
/**
 * Система управления сайтом HostCMS v. 5.xx
 * Copyright © 2005-2010 ООО "Хостмэйк" (Hostmake LLC), http://www.hostcms.ru
 *
 * Обработчик регистрации.
 * 
 * Файл: /admin/site/action/add_regdata.php
 * 
 * @author Hostmake LLC
 * @version 5.x
 */
$constant = new Constants();
$user_access = new user_access();

$HOSTCMS_USER_LOGIN = trim(to_str($_REQUEST['HOSTCMS_USER_LOGIN']));

$HOSTCMS_CONTRACT_NUMBER = trim(to_str($_REQUEST['HOSTCMS_CONTRACT_NUMBER']));

$HOSTCMS_PIN_CODE = trim(to_str($_REQUEST['HOSTCMS_PIN_CODE']));

// Определяем информацию об объекте
$HOSTCMS_USER_LOGIN_row = $constant->GetConstantByName('HOSTCMS_USER_LOGIN');
$HOSTCMS_CONTRACT_NUMBER_row = $constant->GetConstantByName('HOSTCMS_CONTRACT_NUMBER');
$HOSTCMS_PIN_CODE_row = $constant->GetConstantByName('HOSTCMS_PIN_CODE');

// Обрабатываем первую константу
$object_user_id = $HOSTCMS_USER_LOGIN_row['users_id'];

if ($user_access->IssetUserAccessForObject($object_user_id))
{
	// редактирование константы разрешено
	$constant->AddEditConstants(0, $HOSTCMS_USER_LOGIN_row['constants_id'], 'HOSTCMS_USER_LOGIN', $HOSTCMS_USER_LOGIN, '', 1);

	show_message(sprintf($GLOBALS['MSG_site']['constant_succesfully_changed'], 'HOSTCMS_USER_LOGIN'));
}
else
{
	$user_access->MessageOnlyOwn();
}


// Обрабатываем вторую константу

$object_user_id = $HOSTCMS_CONTRACT_NUMBER_row['users_id'];

if ($user_access->IssetUserAccessForObject($object_user_id))
{
	// редактирование константы разрешено
	$constant->AddEditConstants(0, $HOSTCMS_CONTRACT_NUMBER_row['constants_id'], 'HOSTCMS_CONTRACT_NUMBER', $HOSTCMS_CONTRACT_NUMBER, '', 1);

	show_message(sprintf($GLOBALS['MSG_site']['constant_succesfully_changed'], 'HOSTCMS_CONTRACT_NUMBER'));
}
else
{
	$user_access->MessageOnlyOwn();
}


// Обрабатываем третью константу

$object_user_id = $HOSTCMS_PIN_CODE_row['users_id'];

if ($user_access->IssetUserAccessForObject($object_user_id))
{
	// редактирование константы разрешено
	$constant->AddEditConstants(0, $HOSTCMS_PIN_CODE_row['constants_id'], 'HOSTCMS_PIN_CODE', $HOSTCMS_PIN_CODE, '', 1);

	show_message(sprintf($GLOBALS['MSG_site']['constant_succesfully_changed'], 'HOSTCMS_PIN_CODE'));
}
else
{
	$user_access->MessageOnlyOwn();
}

?>