/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: elof.bigestans at gmail
  • Date: 2013-05-24 14:10:14 UTC
  • mfrom: (102 lenasys_b)
  • mto: This revision was merged to the branch mainline in revision 107.
  • Revision ID: elof.bigestans@gmail.com-20130524141014-8pni44bog1rf5ijp
Merged from trunk

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
                //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);
 
24
                        redirect('/cms');
 
25
                }
 
26
                public function tempLogout() {
 
27
                        $this->load->model('user');
 
28
                        $this->session->unset_userdata('authenticated');
 
29
                        redirect('/cms');
 
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();
 
53
                        $categories = $this->admin_model->getCategories($activeCourse);
 
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
?>