/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/start.php

  • Committer: a11andoh
  • Date: 2013-05-23 08:16:45 UTC
  • mfrom: (88 lenasys_b)
  • mto: This revision was merged to the branch mainline in revision 97.
  • Revision ID: a11andoh@student.his.se-20130523081645-jxltw80q135v14ot
blurp

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 Start 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
                 *      This function runs when the user navigates directly to the start controller
 
17
                 */
 
18
                public function index() {
 
19
                        if($this->user->isLoggedIn()) {
 
20
                                //User already logged in
 
21
                                redirect(base_url().'home', 'refresh');
 
22
                        } else {
 
23
                                //Display the start page
 
24
                                $this->drawStartPage('');
 
25
                        }
 
26
                }               
 
27
        
 
28
                /*
 
29
                 *      This function draws the start page.
 
30
                 */
 
31
                private function drawStartPage() {
 
32
                        $userName = $this->user->getUserName();
 
33
                        $userType = $this->user->getUserType();
 
34
                        //Creates an array with all courses.
 
35
                        $courses = $this->admin_model->getCourses();
 
36
                        
 
37
                        //Creates an array with the variables that the bannermenu-view is expecting.
 
38
                        $data = array(
 
39
                                'userType' => $userType,
 
40
                                'userName' => $userName,
 
41
                                'courses' => $courses
 
42
                        );
 
43
                        
 
44
                        //Creates an array with the necessary css- and jsfiles needed for the views that are about to be shown.
 
45
                        $headTagData = array(
 
46
                                'cssFiles' => array('bannermenu', 'startview'),
 
47
                                'jsFiles' => array('bannermenu')
 
48
                        );
 
49
                        
 
50
                        //Puts the array above in <head></head>
 
51
                        $this->load->view('headTag', array('headTagData' => $headTagData));     
 
52
                        
 
53
                        $this->load->view('bannermenu', $data);
 
54
                        $this->load->view('startview', $data);
 
55
                }
 
56
        }
 
57
?>