<?php
/*
* @ServerMon v1.1
* @Developed by Maksa988
* @www.Server-Mon.ru
* @Copyright (C) 2014
*/
 if(!defined('SMON'))
	die('Hacking attempt!');
	
class user extends Controller {
	public function __construct() {
		$this->header();
		$this->data['activeSection'] = 'profile';
		$this->data['navbarName'] = 'Профиль пользователя';

		if(empty($_SESSION['user_id'])):
			return $this->view(array('common/header', 'user/access', 'common/footer'), $this->data); //Загружаем шаблон
		endif;
		
		$this->model('users');
		$this->data['user'] = $this->usersModel->getUser($_SESSION['user_id']);
		
		if($this->POST('changeavatar')):
			if($this->POST('avatar')):
				$this->usersModel->changeavatarUser($this->POST('avatar'));
				$this->data['success'] = 'Вы изменили аватар!';
			else:
				$this->data['error'] = 'Укажите ссылку на аватар!';
			endif;
		endif;
		
		return $this->view(array('common/header', 'user/profile', 'common/footer'), $this->data); //Загружаем шаблон
	}
}