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 |
}
|
|
14 |
//Temporary function to be able to be logged in to reach the page
|
|
15 |
public function tempLogin() { |
|
16 |
$this->load->model('user'); |
|
17 |
$loginDetails = array( |
|
18 |
'username' => 'tempTeacher', |
|
19 |
'name' => 'tempFoo', |
|
20 |
'usertype' => 'Teacher', |
|
21 |
'ssn' => '0000', |
|
22 |
'activeCourse' => 'DA525G'); |
|
23 |
$this->session->set_userdata('authenticated', $loginDetails); |
|
90.1.8
by a11emmjo
Fixed some redirect-links. |
24 |
redirect(base_url().'cms', 'refresh'); |
85.1.8
by a11andoh
added the cms controller to load all content pages. |
25 |
}
|
26 |
public function tempLogout() { |
|
27 |
$this->load->model('user'); |
|
28 |
$this->session->unset_userdata('authenticated'); |
|
90.1.8
by a11emmjo
Fixed some redirect-links. |
29 |
redirect(base_url().'home', 'refresh'); |
85.1.8
by a11andoh
added the cms controller to load all content pages. |
30 |
}
|
31 |
/*
|
|
32 |
* This function runs when the user navigates directly to this controller
|
|
33 |
*/
|
|
34 |
public function index() { |
|
35 |
if($this->user->isLoggedIn()) { |
|
36 |
//User already logged in
|
|
37 |
$this->drawCmsPage(''); |
|
38 |
} else { |
|
39 |
//Display the start page
|
|
40 |
redirect(base_url().'home', 'refresh'); |
|
41 |
}
|
|
42 |
}
|
|
43 |
||
44 |
/*
|
|
45 |
* This function draws the cms page.
|
|
46 |
*/
|
|
47 |
private function drawCmsPage() { |
|
48 |
$userName = $this->user->getUserName(); |
|
49 |
$userType = $this->user->getUserType(); |
|
50 |
$activeCourse = $this->user->getActiveCourse(); |
|
51 |
//Creates an array with all courses.
|
|
52 |
$courses = $this->admin_model->getCourses(); |
|
85.1.10
by a11andoh
change from hardcoded categorylisting |
53 |
$categories = $this->admin_model->getCategories($activeCourse); |
85.1.8
by a11andoh
added the cms controller to load all content pages. |
54 |
//Creates an array with the variables that the bannermenu-view is expecting.
|
55 |
$data = array( |
|
56 |
'userType' => $userType, |
|
57 |
'userName' => $userName, |
|
58 |
'courses' => $courses, |
|
59 |
'categories' => $categories, |
|
60 |
'activeCourse' => $activeCourse |
|
61 |
);
|
|
62 |
||
63 |
//Creates an array with the necessary css- and jsfiles needed for the views that are about to be shown.
|
|
64 |
$headTagData = array( |
|
65 |
'cssFiles' => array('bannermenu', 'coursemenu', 'statsMenu', 'dummieContent'),//cms tillfällig sida |
|
66 |
'jsFiles' => array('bannermenu') |
|
67 |
);
|
|
68 |
||
69 |
//Puts the array above in <head></head>
|
|
70 |
$this->load->view('headTag', array('headTagData' => $headTagData)); |
|
71 |
||
72 |
$this->load->view('bannermenu', $data); |
|
73 |
$this->load->view('coursemenu', $data); |
|
74 |
$this->load->view('statsMenu'); |
|
75 |
$this->load->view('dummieContent'); |
|
76 |
}
|
|
77 |
}
|
|
78 |
?>
|