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

  • Committer: a11timgu
  • Date: 2013-05-30 08:52:01 UTC
  • mfrom: (125 lenasys_b)
  • mto: This revision was merged to the branch mainline in revision 127.
  • Revision ID: a11timgu@student.his.se-20130530085201-vzvlcuxzljq5m2zh
sdasdawd:

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
1
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2
2
 
3
3
class ViewStudentsController extends CI_Controller {
4
4
 
5
 
        public function index()
6
 
        {
7
 
                /* headData manages the <head>-tag and loads corresponding CSS.
8
 
                 * The views that are entered will load CSS with same name.
9
 
                 * Ex. test_header will load test_header.css
10
 
                 */
11
 
                $this->load->library('session');
 
5
        public function index() {
 
6
                $this->load->model('user');
 
7
                $this->load->model('admin/admin_model');
 
8
 
 
9
                if(!$this->user->isLoggedIn() || $this->user->getUserType() != "Teacher") {
 
10
                        echo "You do not have access to this page.";
 
11
                        return;
 
12
                }
 
13
 
 
14
                // NOTE: viewstudents is a deprecated model. Should eventually be replaced by a proper model
 
15
                $this->load->model('viewstudents');
 
16
 
 
17
                $userName = $this->user->getUserName();
 
18
                $userType = $this->user->getUserType();
 
19
                
 
20
                //Creates an array with the necessary css- and jsfiles needed for the views that are about to be shown.
12
21
                $headTagData = array(
13
 
                        'cssFiles' => array('header', 'examplesMenu', 'examplesBody'),
14
 
                        'jsFiles' => array('header', 'examplesMenu', 'examplesBody', 'userControls')
 
22
                        'cssFiles' => array('bannermenu', 'sidemenu', 'dummieContent', 'viewStudents', 'body'),//cms tillfällig sida
 
23
                        'jsFiles' => array('bannermenu', 'viewStudents')
15
24
                );
16
 
                $this->load->view('headTag', array('headTagData' => $headTagData));
17
 
                
18
 
                $this->load->helper('form');
19
 
                
20
 
                // Loading model to retrieve login data
 
25
                
 
26
                //Puts the array above in <head></head>
 
27
                $this->load->view('headTag', array('headTagData' => $headTagData));     
 
28
 
 
29
                $students = $this->viewstudents->getStudents();
 
30
                
 
31
                $this->load->view('viewStudentsBody', array('students' => $students));
 
32
        }
 
33
 
 
34
        public function editStudentDetails() {
21
35
                $this->load->model('user');
22
 
                $userInfo = array(
23
 
                        'userType' => $this->user->getUserType(), // Loads different header for teacher/student
24
 
                        'userName' => $this->user->getUserName()
25
 
                );
26
 
                
27
 
                $this->load->view('header', $userInfo);
28
 
                        
29
 
                /* Loads used models */
30
 
                $this->load->model('viewstudents');
31
 
                
32
 
                // menuData loads items to the menu.
33
 
                $allTitles = array();
34
 
                $allStudents = array();
35
 
                
36
 
                /* Loads categorydata into array */
37
 
                $query = $this->viewstudents->getStudents();
38
 
 
39
 
                
40
 
                foreach ($query as $student)
41
 
                {
42
 
                        array_push($allStudents, $student->userName);
 
36
                if(!$this->input->post('username') || !$this->user->isLoggedIn()) {
 
37
                        echo "You do not have access to this page";
 
38
                        return;
43
39
                }
44
 
                
45
 
                /*Menu for examples page showing categories */
46
 
                $this->load->view('examplesMenu', array('titles' => $allTitles));
47
 
                
48
 
                /* Loads body for examples page */
49
 
                
50
 
                $this->load->view('viewStudentsBody', array('students' => $allStudents));       
51
40
 
 
41
                $data = array(
 
42
                        'name' => $this->input->post('name');
 
43
                );
52
44
        }
53
 
 
54
45
        
55
46
        public function validate() {
56
47
                //Load required library