<?php
/*
+--------------------------------------------------------------------------
|   TanyaCMS - Question and Answer Sofware
|   -----------------------------------------------------------------------
|   by fbschool dev team
|   (c) 2011 - 2012 FBSCHOOL
|   http://www.fbschool.com/tanyacms
|   -----------------------------------------------------------------------
|   This is NOT a freeware, use is subject to license terms
|   Support: 13455n@gmail.com
+--------------------------------------------------------------------------
*/


if (!defined('IN_TANYACMS'))
{
	die;
}

class setting extends ASK_CONTROLLER
{

	public function get_access_rule()
	{
		$rule_action['rule_type'] = 'white'; //Blacklist, blacklist check  'white' white list, outside the whitelist check
		$rule_action['actions'] = array();
		
		return $rule_action;
	}

	function setup()
	{
		$this->crumb('Settings', '/account/setting/');
		
		TPL::import_css(array(
			'css/main.css'
		));
	}

	function index_action()
	{
		$this->profile_action();
	}

	function profile_action()
	{		
		if ($this->user_info['birthday'] != 0)
		{
			TPL::assign('birthday_y_s', date('Y', $this->user_info['birthday']));
			TPL::assign('birthday_m_s', date('m', $this->user_info['birthday']));
			TPL::assign('birthday_d_s', date('d', $this->user_info['birthday']));
		}
				
		for ($i = date('Y'); $i > 1900; $i --)
		{
			$years[$i] = $i;
		}
		
		TPL::assign('birthday_y', $years);
		
		// Month character value
		TPL::assign('birthday_m', array(
			0 => '', 
			1 => 1, 
			2 => 2, 
			3 => 3, 
			4 => 4, 
			5 => 5, 
			6 => 6, 
			7 => 7, 
			8 => 8, 
			9 => 9, 
			10 => 10, 
			11 => 11, 
			12 => 12
		));
		
		for ($tmp_i = 1; $tmp_i <= 31; $tmp_i ++)
		{
			$day_array[$tmp_i] = $tmp_i;
		}
		
		TPL::assign('birthday_d', $day_array);
		
		TPL::assign('job_list', $this->model('work')->get_jobs_list());
		
		TPL::assign('education_experience_list', $this->model('education')->get_education_experience_list($this->user_id));
		
		$jobs_list = $this->model('work')->get_jobs_list();
		
		if ($work_experience_list = $this->model('work')->get_work_experience_list($this->user_id))
		{
			foreach ($work_experience_list as $key => $val)
			{
				$work_experience_list[$key]['job_name'] = $jobs_list[$val['job_id']];
			}
		}
		
		TPL::assign('work_experience_list', $work_experience_list);
		
		$this->crumb('Basic Information', '/account/setting/profile/');
		
		TPL::import_js(array(
			'js/ajaxupload.js', 
			'js/LocationSelect.js'
		));
		
		TPL::output('account/setting/profile');
	}
	
	function privacy_action()
	{
		TPL::assign('email_setting', $this->model('account')->get_email_setting_by_uid($this->user_id));
		TPL::assign('notification_setting', $this->model('account')->get_notification_setting_by_uid($this->user_id));
		TPL::assign('notify_actions', $this->model('notify')->notify_action_details);
		
		$this->crumb('Private/Alert', '/account/setting/privacy');
		
		TPL::output('account/setting/privacy');
	}
	
	function integral_action()
	{
		$this->crumb('My Credits', '/account/setting/integral/');
		
		TPL::output("account/setting/integral");
	}
	
	function security_action()
	{
		$this->crumb('Security Setting', '/account/setting/security/');
		
		TPL::output("account/setting/security");
	}
}
