/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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

	class Cms extends CI_Controller {
	
		/*
		 *	Constructor
		 */
		function __construct() {
			parent::__construct();
			//Load required library
			$this->load->model('user', '', TRUE);
			$this->load->model('admin/admin_model', '', TRUE);
		}
		//Temporary function to be able to be logged in to reach the page
		public function tempLogin() {
			$this->load->model('user');
			$loginDetails = array(
			'username' => 'tempTeacher',
			'name' => 'tempFoo',
			'usertype' => 'Teacher',
			'ssn' => '0000',
			'activeCourse' => 'DA525G');
			$this->session->set_userdata('authenticated', $loginDetails);
			redirect(base_url().'cms', 'refresh');
		}
		public function tempLogout() {
			$this->load->model('user');
			$this->session->unset_userdata('authenticated');
			redirect(base_url().'home', 'refresh');
		}
		/*
		 *	This function runs when the user navigates directly to this controller
		 */
		public function index() {
			if($this->user->isLoggedIn()) {
				//User already logged in
				$this->drawCmsPage('');
			} else {
				//Display the start page
				redirect(base_url().'home', 'refresh');
			}
		}		
		
		/*
		 *	This function draws the cms page.
		 */
		private function drawCmsPage() {
			$userName = $this->user->getUserName();
			$userType = $this->user->getUserType();
			$activeCourse = $this->user->getActiveCourse();
			//Creates an array with all courses.
			$courses = $this->admin_model->getCourses();
			$categories = $this->admin_model->getCategories($activeCourse);
			//Creates an array with the variables that the bannermenu-view is expecting.
			$data = array(
				'userType' => $userType,
				'userName' => $userName,
				'courses' => $courses,
				'categories' => $categories,
				'activeCourse' => $activeCourse
			);
			
			//Creates an array with the necessary css- and jsfiles needed for the views that are about to be shown.
			$headTagData = array(
				'cssFiles' => array('bannermenu', 'coursemenu', 'statsMenu', 'dummieContent'),//cms tillfällig sida
				'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('coursemenu', $data);
			$this->load->view('statsMenu');
			$this->load->view('dummieContent');
		}
	}
?>