<?php

class users_control_points{

	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');
		//include_once(MAIN_SOURCE_PATH.'/inc/class.html.php');
		
		$this -> points = array(
			
			'points_register_user' => M_USERS_POINTS_REGISTER,
			'points_auth' => M_USERS_POINTS_AUTH	,
			'points_invite' => M_USERS_POINTS_INVITE,
			'points_del_comment' => M_USERS_POINTS_DEL_COMMENT,
			'points_add_comment' => M_USERS_POINTS_ADD_COMMENT,
			'points_add_news' => M_USERS_POINTS_ADD_NEWS	,
			'points_del_news' => M_USERS_POINTS_DEL_NEWS	,
			'points_add_articles' => M_USERS_POINTS_ADD_ARTICLES	,
			'points_del_articles' => M_USERS_POINTS_DEL_ARTICLES	,
			'points_add_questions' => M_USERS_POINTS_ADD_QUESTION	,
			'points_del_questions' => M_USERS_POINTS_DEL_QUESTION	,
			'points_add_answer' => M_USERS_POINTS_ADD_ANSWER	,
			'points_del_answer' => M_USERS_POINTS_DEL_ANSWER	,
			'points_best_answer' => M_USERS_POINTS_BEST_ANSWER,
			'points_add_pub' => M_USERS_POINTS_ADD_PUB	,
			'points_del_pub' => M_USERS_POINTS_DEL_PUB	,
			'points_add_post_blog' => M_USERS_POINTS_ADD_POST_BLOG	,
			'points_del_post_blog' => M_USERS_POINTS_DEL_POST_BLOG	,
			'points_interview' => M_USERS_POINTS_INTERVIEW	,
			'points_add_brand' => M_USERS_POINTS_ADD_BRAND	,
			'points_del_brand' => M_USERS_POINTS_DEL_BRAND	,
			'points_add_goods' => M_USERS_POINTS_ADD_GOODS	,
			'points_del_goods' => M_USERS_POINTS_DEL_GOODS	,
			'points_register_org' => M_USERS_POINTS_REG_ORG	,
		);
	}
	

	
	public function get(){
	global $MAIN_PAGE;
		if ( !empty($_REQUEST['send']) ){
			$this -> save();
				//	ïåðåçàãðóæàåì îáíîâë¸ííûå ïåðåìåííûå
		}
		$t = new PHPTAL( M_PATH.'/tmpl/control_points/main.html' );
		$t -> ADMIN_URL = sys_url(ADMIN_URL);
		$t -> URL_USERS_CONTROL_POSTS = sys_url(URL_USERS_CONTROL_POSTS);
		
		include(M_PATH.'/cache/points.php');
		$rows = array();
		foreach( $this -> points as $k=>$v ){
			$rows[]=array('name'=>$k,'lang'=>$v,'value'=>$MAIN_PAGE -> config($k) );
		}
		$t -> points = $rows;

		return $t -> execute();
	}
	
	private function save(){
		include_once(MAIN_SOURCE_PATH.'/inc/class.config.php');
		$c = new config(M_PATH.'/cache/points.php');
		foreach( $this -> points as $k=>$v ){
			$c -> set_str($k,$_REQUEST[$k]);
		}
		
		$c ->  save();
		
	}
	

	
}

?>
