/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: elof.bigestans at gmail
  • Date: 2013-05-24 10:00:47 UTC
  • mto: This revision was merged to the branch mainline in revision 95.
  • Revision ID: elof.bigestans@gmail.com-20130524100047-bqgk67s2g9o3l85x
Solved some bugs in ManageCourses and related files (CSS, JS, View, Controller)

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 ViewStudentsController extends CI_Controller {
 
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');
 
12
                $headTagData = array(
 
13
                        'cssFiles' => array('header', 'examplesMenu', 'examplesBody'),
 
14
                        'jsFiles' => array('header', 'examplesMenu', 'examplesBody', 'userControls')
 
15
                );
 
16
                $this->load->view('headTag', array('headTagData' => $headTagData));
 
17
                
 
18
                $this->load->helper('form');
 
19
                
 
20
                // Loading model to retrieve login data
 
21
                $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);
 
43
                }
 
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
 
 
52
        }
 
53
 
 
54
        
 
55
        public function validate() {
 
56
                //Load required library
 
57
                $this->load->library('form_validation');
 
58
                
 
59
                //Sets validation rules
 
60
                $this->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean');
 
61
                $this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean');
 
62
                
 
63
                //Run validation
 
64
                if($this->form_validation->run() == FALSE) {
 
65
                        //Field validation failed. Display login form (with error message).
 
66
                        $this->drawLoginForm(validation_errors());
 
67
                } else {
 
68
                        $username = $this->input->post('username');
 
69
                        $password = $this->input->post('password');
 
70
                        
 
71
                        //Try to login
 
72
                        if ($this->user->login($username, $password)) {
 
73
                                redirect(base_url().'home', 'refresh');
 
74
                        } else {
 
75
                                $this->drawLoginForm('Access denied!');
 
76
                        }
 
77
                }
 
78
        }
 
79
        
 
80
}
 
81
 
 
82
/* End of file ExamplesController.php */
 
83
/* Location: ./application/controllers/ExamplesController.php */
 
 
b'\\ No newline at end of file'