1
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
3
class Cms extends CI_Controller {
8
function __construct() {
10
//Load required library
11
$this->load->model('user', '', TRUE);
12
$this->load->model('admin/admin_model', '', TRUE);
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',
20
'usertype' => 'Teacher',
22
'activeCourse' => 'DA525G');
23
$this->session->set_userdata('authenticated', $loginDetails);
26
public function tempLogout() {
27
$this->load->model('user');
28
$this->session->unset_userdata('authenticated');
32
* This function runs when the user navigates directly to this controller
34
public function index() {
35
if($this->user->isLoggedIn()) {
36
//User already logged in
37
$this->drawCmsPage('');
39
//Display the start page
40
redirect(base_url().'home', 'refresh');
45
* This function draws the cms page.
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();
53
$categories = $this->admin_model->getCategories('DA525G');
54
//Creates an array with the variables that the bannermenu-view is expecting.
56
'userType' => $userType,
57
'userName' => $userName,
58
'courses' => $courses,
59
'categories' => $categories,
60
'activeCourse' => $activeCourse
63
//Creates an array with the necessary css- and jsfiles needed for the views that are about to be shown.
65
'cssFiles' => array('bannermenu', 'coursemenu', 'statsMenu', 'dummieContent'),//cms tillfällig sida
66
'jsFiles' => array('bannermenu')
69
//Puts the array above in <head></head>
70
$this->load->view('headTag', array('headTagData' => $headTagData));
72
$this->load->view('bannermenu', $data);
73
$this->load->view('coursemenu', $data);
74
$this->load->view('statsMenu');
75
$this->load->view('dummieContent');