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
|
<?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);
}
/*
* 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();
//Creates an array with all courses.
//Creates an array with the variables that the bannermenu-view is expecting.
$data = array(
'userType' => $userType,
'userName' => $userName,
);
//Creates an array with the necessary css- and jsfiles needed for the views that are about to be shown.
$headTagData = array(
'cssFiles' => array('bannermenu', 'registration', 'startview'),
'jsFiles' => array('bannermenu')
);
//Puts the array above in <head></head>
$this->load->view('headTag', array('headTagData' => $headTagData));
$this->load->view('bannermenu', $data);
if ($userType=='1'){
$this->load->view('registrationTeacher');
}
else if($userType=='2'){
$this->load->view('registrationStudent');
}
else{
$this->load->view('startview');
}
}
}
?>
|