<?php

class users_control_config{

	public function __construct(){
	global $MAIN_PAGE;
		define('M_PATH',MAIN_SOURCE_PATH.'/modules/'.$MAIN_PAGE -> dirname() );
		define('M_URL',MAIN_SOURCE_URL.'/modules/'.$MAIN_PAGE -> dirname() );
		include_once(M_PATH.'/inc/url.php');
		include_once(MAIN_SOURCE_PATH.'/inc/class.config.php');
		
	}
	
	public function get(){
	global $MAIN_PAGE;
		if ( !empty($_REQUEST['send']) ){
			$this -> save();
		}
		$t = new PHPTAL( false);
		$t -> setSnippet('users','config');
		include_once(MAIN_PATH.'/tmp/config/users.php');
		$t -> users_pub_on_page = $MAIN_PAGE -> config('users_pub_on_page');
		$t -> user_default_avatar = $MAIN_PAGE -> config('user_default_avatar');
    $t -> users_active = $MAIN_PAGE -> config('users_active');
    $t -> users_register_group = $MAIN_PAGE -> config('users_register_group');
    $t -> users_avatar_width = $MAIN_PAGE -> config('users_avatar_width');
    $t -> users_avatar_height = $MAIN_PAGE -> config('users_avatar_height');
    
		return $t -> execute();
	}
	
	private function save(){
		include_once(MAIN_SOURCE_PATH.'/inc/class.config.php');
		$c = new config(MAIN_PATH.'/tmp/config/users.php');
		$c -> set_int('users_pub_on_page',$_REQUEST['users_pub_on_page']);
		$c -> set_str('user_default_avatar',$_REQUEST['user_default_avatar']);
		$c -> set_bin('users_active',$_REQUEST['users_active']);
		$c -> set_int('users_avatar_width',$_REQUEST['users_avatar_width']);
		$c -> set_int('users_avatar_height',$_REQUEST['users_avatar_height']);
		
		    //  скрытые
		$c -> set_int('users_register_group',$_REQUEST['users_register_group']  );
		$c ->  save();
		
	}
	

	
}

?>
