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);
16
*Temporary function to be able to be logged in to reach the page
18
public function tempLogin() {
19
$this->load->model('user');
20
$loginDetails = array(
21
'username' => 'tempTeacher',
23
'usertype' => 'Teacher',
25
'activeCourse' => 'DA525G');
26
$this->session->set_userdata('authenticated', $loginDetails);
27
redirect(base_url().'cms', 'refresh');
29
public function tempLogout() {
30
$this->load->model('user');
31
$this->session->unset_userdata('authenticated');
32
redirect(base_url().'home', 'refresh');
36
* This function runs when the user navigates directly to this controller
38
public function index() {
39
if($this->user->isLoggedIn()) {
40
//User already logged in
41
$this->drawCmsPage('');
43
//Display the start page
44
redirect(base_url().'home', 'refresh');
49
* This function draws the cms page.
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();
57
//Creates an array with all categories for active course
58
$categories = $this->admin_model->getCategories($activeCourse['courseID']);
60
//Creates an array with the variables that the bannermenu-view is expecting.
62
'userType' => $userType,
63
'userName' => $userName,
64
'courses' => $courses,
65
'categories' => $categories,
66
'activeCourse' => $activeCourse
69
//Creates an array with the necessary css- and jsfiles needed for the views that are about to be shown.
71
'cssFiles' => array('bannermenu', 'sidemenu', 'dummieContent'),//cms tillfällig sida
72
'jsFiles' => array('bannermenu')
75
//Puts the array above in <head></head>
76
$this->load->view('headTag', array('headTagData' => $headTagData));
78
$this->load->view('bannermenu', $data);
79
$this->load->view('sidemenu', $data);
80
$this->load->view('dummieContent');