/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

	class Start extends CI_Controller {
	
		/*
		 *	Constructor
		 */
		function __construct() {
			parent::__construct();
			//Load required library
			$this->load->model('user', '', TRUE);
			$this->load->model('admin/admin_model', '', TRUE);
		}
	
		/*
		 *	This function runs when the user navigates directly to the start controller
		 */
		public function index() {
			if($this->user->isLoggedIn()) {
				//User already logged in
				redirect(base_url().'home', 'refresh');
			} else {
				//Display the start page
				$this->drawStartPage('');
			}
		}		
	
		/*
		 *	This function draws the start page.
		 */
		private function drawStartPage() {
			$userName = $this->user->getUserName();
			$userType = $this->user->getUserType();
			//Creates an array with all courses.
			$courses = $this->admin_model->getCourses();
			
			//Creates an array with the variables that the bannermenu-view is expecting.
			$data = array(
				'userType' => $userType,
				'userName' => $userName,
				'courses' => $courses
			);
			
			//Creates an array with the necessary css- and jsfiles needed for the views that are about to be shown.
			$headTagData = array(
				'cssFiles' => array('bannermenu', 'startview'),
				'jsFiles' => array('bannermenu')
			);
			
			//Puts the array above in <head></head>
			$this->load->view('headTag', array('headTagData' => $headTagData));	
			
			$this->load->view('bannermenu', $data);
			$this->load->view('startview', $data);
		}
	}
?>