/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk
85.2.1 by a11emmjo
Combined bannermenu with startview to get correct start-page.
1
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2
3
	class Start extends CI_Controller {
4
	
5
		/*
6
		 *	Constructor
7
		 */
8
		function __construct() {
9
			parent::__construct();
10
			//Load required library
11
			$this->load->model('user', '', TRUE);
12
			$this->load->model('admin/admin_model', '', TRUE);
13
		}
14
	
15
		/*
16
		 *	This function runs when the user navigates directly to the start controller
17
		 */
18
		public function index() {
19
			if($this->user->isLoggedIn()) {
20
				//User already logged in
21
				redirect(base_url().'home', 'refresh');
22
			} else {
23
				//Display the start page
24
				$this->drawStartPage('');
25
			}
26
		}		
27
	
28
		/*
29
		 *	This function draws the start page.
30
		 */
31
		private function drawStartPage() {
32
			$userName = $this->user->getUserName();
33
			$userType = $this->user->getUserType();
34
			//Creates an array with all courses.
35
			$courses = $this->admin_model->getCourses();
36
			
37
			//Creates an array with the variables that the bannermenu-view is expecting.
38
			$data = array(
39
				'userType' => $userType,
40
				'userName' => $userName,
41
				'courses' => $courses
42
			);
43
			
44
			//Creates an array with the necessary css- and jsfiles needed for the views that are about to be shown.
45
			$headTagData = array(
46
				'cssFiles' => array('bannermenu', 'startview'),
47
				'jsFiles' => array('bannermenu')
48
			);
49
			
50
			//Puts the array above in <head></head>
51
			$this->load->view('headTag', array('headTagData' => $headTagData));	
52
			
53
			$this->load->view('bannermenu', $data);
54
			$this->load->view('startview', $data);
55
		}
56
	}
57
?>