/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
		
109.1.2 by c11emian
Added the functions getPublicCourses(), getPrivateCourses() and getStudentCourses().
48
		public function test(){
49
			
50
			$result = $this->admin_model->getStudentCourses("student");
51
			foreach($result as $res) {
52
				echo $res->courseID. ' - ';
53
				echo $res->name;
54
				echo "<br>";
55
				
56
			}
57
			
58
			//var_dump($result);
59
		}
60
		
61
		
85.1.8 by a11andoh
added the cms controller to load all content pages.
62
		/*
63
		 *	This function draws the cms page.
64
		 */
65
		private function drawCmsPage() {
66
			$userName = $this->user->getUserName();
67
			$userType = $this->user->getUserType();
68
			$activeCourse = $this->user->getActiveCourse();
69
			//Creates an array with all courses.
70
			$courses = $this->admin_model->getCourses();
90.1.10 by a11emmjo
Removed coursemenu and statsmenu and replaced it with new combined sidemenu.
71
			//Creates an array with all categories for active course
72
			$categories = $this->admin_model->getCategories($activeCourse['courseID']);
73
			
85.1.8 by a11andoh
added the cms controller to load all content pages.
74
			//Creates an array with the variables that the bannermenu-view is expecting.
75
			$data = array(
76
				'userType' => $userType,
77
				'userName' => $userName,
78
				'courses' => $courses,
79
				'categories' => $categories,
80
				'activeCourse' => $activeCourse
81
			);
82
			
83
			//Creates an array with the necessary css- and jsfiles needed for the views that are about to be shown.
84
			$headTagData = array(
90.1.10 by a11emmjo
Removed coursemenu and statsmenu and replaced it with new combined sidemenu.
85
				'cssFiles' => array('bannermenu', 'sidemenu', 'dummieContent'),//cms tillfällig sida
85.1.8 by a11andoh
added the cms controller to load all content pages.
86
				'jsFiles' => array('bannermenu')
87
			);
88
			
89
			//Puts the array above in <head></head>
90
			$this->load->view('headTag', array('headTagData' => $headTagData));	
91
			
92
			$this->load->view('bannermenu', $data);
90.1.10 by a11emmjo
Removed coursemenu and statsmenu and replaced it with new combined sidemenu.
93
			$this->load->view('sidemenu', $data);
85.1.8 by a11andoh
added the cms controller to load all content pages.
94
			$this->load->view('dummieContent');
95
		}
96
	}
97
?>