/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk
85.1.8 by a11andoh
added the cms controller to load all content pages.
1
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2
3
	class Cms 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
		}
90.1.10 by a11emmjo
Removed coursemenu and statsmenu and replaced it with new combined sidemenu.
14
		
15
		/*
16
		 *Temporary function to be able to be logged in to reach the page
17
		 */
85.1.8 by a11andoh
added the cms controller to load all content pages.
18
		public function tempLogin() {
19
			$this->load->model('user');
20
			$loginDetails = array(
21
			'username' => 'tempTeacher',
22
			'name' => 'tempFoo',
23
			'usertype' => 'Teacher',
24
			'ssn' => '0000',
25
			'activeCourse' => 'DA525G');
26
			$this->session->set_userdata('authenticated', $loginDetails);
90.1.8 by a11emmjo
Fixed some redirect-links.
27
			redirect(base_url().'cms', 'refresh');
85.1.8 by a11andoh
added the cms controller to load all content pages.
28
		}
29
		public function tempLogout() {
30
			$this->load->model('user');
31
			$this->session->unset_userdata('authenticated');
90.1.8 by a11emmjo
Fixed some redirect-links.
32
			redirect(base_url().'home', 'refresh');
85.1.8 by a11andoh
added the cms controller to load all content pages.
33
		}
90.1.10 by a11emmjo
Removed coursemenu and statsmenu and replaced it with new combined sidemenu.
34
		
85.1.8 by a11andoh
added the cms controller to load all content pages.
35
		/*
36
		 *	This function runs when the user navigates directly to this controller
37
		 */
38
		public function index() {
39
			if($this->user->isLoggedIn()) {
40
				//User already logged in
41
				$this->drawCmsPage('');
42
			} else {
43
				//Display the start page
44
				redirect(base_url().'home', 'refresh');
45
			}
46
		}		
47
		
48
		/*
49
		 *	This function draws the cms page.
50
		 */
51
		private function drawCmsPage() {
52
			$userName = $this->user->getUserName();
53
			$userType = $this->user->getUserType();
54
			$activeCourse = $this->user->getActiveCourse();
55
			//Creates an array with all courses.
56
			$courses = $this->admin_model->getCourses();
90.1.10 by a11emmjo
Removed coursemenu and statsmenu and replaced it with new combined sidemenu.
57
			//Creates an array with all categories for active course
58
			$categories = $this->admin_model->getCategories($activeCourse['courseID']);
59
			
85.1.8 by a11andoh
added the cms controller to load all content pages.
60
			//Creates an array with the variables that the bannermenu-view is expecting.
61
			$data = array(
62
				'userType' => $userType,
63
				'userName' => $userName,
64
				'courses' => $courses,
65
				'categories' => $categories,
66
				'activeCourse' => $activeCourse
67
			);
68
			
69
			//Creates an array with the necessary css- and jsfiles needed for the views that are about to be shown.
70
			$headTagData = array(
90.1.10 by a11emmjo
Removed coursemenu and statsmenu and replaced it with new combined sidemenu.
71
				'cssFiles' => array('bannermenu', 'sidemenu', 'dummieContent'),//cms tillfällig sida
85.1.8 by a11andoh
added the cms controller to load all content pages.
72
				'jsFiles' => array('bannermenu')
73
			);
74
			
75
			//Puts the array above in <head></head>
76
			$this->load->view('headTag', array('headTagData' => $headTagData));	
77
			
78
			$this->load->view('bannermenu', $data);
90.1.10 by a11emmjo
Removed coursemenu and statsmenu and replaced it with new combined sidemenu.
79
			$this->load->view('sidemenu', $data);
85.1.8 by a11andoh
added the cms controller to load all content pages.
80
			$this->load->view('dummieContent');
81
		}
82
	}
83
?>