/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: a11andoh
  • Date: 2013-05-24 11:28:43 UTC
  • mto: This revision was merged to the branch mainline in revision 97.
  • Revision ID: a11andoh@student.his.se-20130524112843-360je7hu7q13r171
added the cms controller to load all content pages.
added first time registration controller to load the views for the registration
pages.
added and fixed temporarypages for the controllers 
and edited the models to be able to get active courses.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
                        //Load required library
11
11
                        $this->load->model('user', '', TRUE);
12
12
                        $this->load->model('admin/admin_model', '', TRUE);
13
 
                        $this->load->model('filetree');
14
13
                }
15
 
                
16
 
                /*
17
 
                 *Temporary function to be able to be logged in to reach the page
18
 
                 */
 
14
                //Temporary function to be able to be logged in to reach the page
19
15
                public function tempLogin() {
20
16
                        $this->load->model('user');
21
17
                        $loginDetails = array(
25
21
                        'ssn' => '0000',
26
22
                        'activeCourse' => 'DA525G');
27
23
                        $this->session->set_userdata('authenticated', $loginDetails);
28
 
                        redirect(base_url().'cms', 'refresh');
 
24
                        redirect('/cms');
29
25
                }
30
26
                public function tempLogout() {
31
27
                        $this->load->model('user');
32
28
                        $this->session->unset_userdata('authenticated');
33
 
                        redirect(base_url().'home', 'refresh');
 
29
                        redirect('/cms');
34
30
                }
35
 
                
36
31
                /*
37
32
                 *      This function runs when the user navigates directly to this controller
38
33
                 */
46
41
                        }
47
42
                }               
48
43
                
49
 
                public function test(){
50
 
                        
51
 
                        $result = $this->admin_model->getStudentCourses("student");
52
 
                        foreach($result as $res) {
53
 
                                echo $res->courseID. ' - ';
54
 
                                echo $res->name;
55
 
                                echo "<br>";
56
 
                                
57
 
                        }
58
 
                        
59
 
                        //var_dump($result);
60
 
                }
61
 
                
62
 
                
63
44
                /*
64
45
                 *      This function draws the cms page.
65
46
                 */
69
50
                        $activeCourse = $this->user->getActiveCourse();
70
51
                        //Creates an array with all courses.
71
52
                        $courses = $this->admin_model->getCourses();
72
 
                        //Creates an array with all categories for active course
73
 
                        $categories = $this->admin_model->getCategories($activeCourse['courseID']);
74
 
                        
 
53
                        $categories = $this->admin_model->getCategories('DA525G');
75
54
                        //Creates an array with the variables that the bannermenu-view is expecting.
76
55
                        $data = array(
77
56
                                'userType' => $userType,
81
60
                                'activeCourse' => $activeCourse
82
61
                        );
83
62
                        
84
 
                        //Creates an array with the variables that the cmsindex-view is expecting.
85
 
                        $filetree = array();
86
 
                        
87
 
                        //Categories
88
 
                        $categories = $this->filetree->getCategories($data['activeCourse']['courseID']);
89
 
                        foreach ($categories as $category) {
90
 
                                $filetree[$category->categoryName] = array();
91
 
                                
92
 
                                //Sub categories
93
 
                                $subcategories = $this->filetree->getSubCategories($category->categoryName, $data['activeCourse']['courseID']);
94
 
                                foreach ($subcategories as $subcategory) {
95
 
                                        $filetree[$category->categoryName][$subcategory->subCategoryName] = array();
96
 
                                        
97
 
                                        //Examples
98
 
                                        $filetree[$category->categoryName][$subcategory->subCategoryName]['examples'] = array();
99
 
                                        $examples = $this->filetree->getExamples($subcategory->subCategoryName, $category->categoryName, $data['activeCourse']['courseID']);
100
 
                                        foreach ($examples as $example) {
101
 
                                                $filetree[$category->categoryName][$subcategory->subCategoryName]['examples'][] = $example->exampleName;
102
 
                                        }
103
 
                                        
104
 
                                        //Quizzes
105
 
                                        $filetree[$category->categoryName][$subcategory->subCategoryName]['quizzes'] = array();
106
 
                                        $quizzes = $this->filetree->getQuizzes($subcategory->subCategoryName, $category->categoryName, $data['activeCourse']['courseID']);
107
 
                                        foreach ($quizzes as $quiz) {
108
 
                                                $filetree[$category->categoryName][$subcategory->subCategoryName]['quizzes'][] = $quiz->quizNr;
109
 
                                        }
110
 
                                }
111
 
                        }
112
 
                        
113
63
                        //Creates an array with the necessary css- and jsfiles needed for the views that are about to be shown.
114
64
                        $headTagData = array(
115
 
                                'cssFiles' => array('bannermenu', 'sidemenu', 'cmsindex'),
 
65
                                'cssFiles' => array('bannermenu', 'coursemenu', 'statsMenu', 'dummieContent'),//cms tillfällig sida
116
66
                                'jsFiles' => array('bannermenu')
117
67
                        );
118
68
                        
120
70
                        $this->load->view('headTag', array('headTagData' => $headTagData));     
121
71
                        
122
72
                        $this->load->view('bannermenu', $data);
123
 
                        $this->load->view('sidemenu', $data);
124
 
                        $this->load->view('cmsindex', array('filetree' => $filetree));
 
73
                        $this->load->view('coursemenu', $data);
 
74
                        $this->load->view('statsMenu');
 
75
                        $this->load->view('dummieContent');
125
76
                }
126
77
        }
127
78
?>