/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk

« back to all changes in this revision

Viewing changes to codeigniter/application/controllers/cms.php

  • Committer: a11emmjo
  • Date: 2013-05-26 14:42:21 UTC
  • mto: This revision was merged to the branch mainline in revision 105.
  • Revision ID: a11emmjo@student.his.se-20130526144221-6zhtkrqnek1ckyx9
Removed coursemenu and statsmenu and replaced it with new combined sidemenu.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
                
 
15
                /*
 
16
                 *Temporary function to be able to be logged in to reach the page
 
17
                 */
 
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);
 
27
                        redirect(base_url().'cms', 'refresh');
 
28
                }
 
29
                public function tempLogout() {
 
30
                        $this->load->model('user');
 
31
                        $this->session->unset_userdata('authenticated');
 
32
                        redirect(base_url().'home', 'refresh');
 
33
                }
 
34
                
 
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
                
 
48
                /*
 
49
                 *      This function draws the cms page.
 
50
                 */
 
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']);
 
59
                        
 
60
                        //Creates an array with the variables that the bannermenu-view is expecting.
 
61
                        $data = array(
 
62
                                'userType' => $userType,
 
63
                                'userName' => $userName,
 
64
                                'courses' => $courses,
 
65
                                'categories' => $categories,
 
66
                                'activeCourse' => $activeCourse
 
67
                        );
 
68
                        
 
69
                        //Creates an array with the necessary css- and jsfiles needed for the views that are about to be shown.
 
70
                        $headTagData = array(
 
71
                                'cssFiles' => array('bannermenu', 'sidemenu', 'dummieContent'),//cms tillfällig sida
 
72
                                'jsFiles' => array('bannermenu')
 
73
                        );
 
74
                        
 
75
                        //Puts the array above in <head></head>
 
76
                        $this->load->view('headTag', array('headTagData' => $headTagData));     
 
77
                        
 
78
                        $this->load->view('bannermenu', $data);
 
79
                        $this->load->view('sidemenu', $data);
 
80
                        $this->load->view('dummieContent');
 
81
                }
 
82
        }
 
83
?>