/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: Gustav Hatvigsson
  • Date: 2013-05-31 06:15:46 UTC
  • mfrom: (90.1.20 lenasys2)
  • Revision ID: gustav.hartvigsson@gmail.com-20130531061546-vj8z28sq375kvghq
Merged Jonsson:s changes:
Fixed the layout on cms index so the arrows and dots marks expanded objects.
Fixed so the course content is sorted by course occasion and not by name

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
                $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.
 
21
                $headTagData = array(
 
22
                        'cssFiles' => array('bannermenu', 'sidemenu', 'dummieContent', 'viewStudents', 'body'),//cms tillfällig sida
 
23
                        'jsFiles' => array('bannermenu', 'viewStudents')
 
24
                );
 
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() {
 
35
                $this->load->model('user');
 
36
                if(!$this->input->post('username') || !$this->user->isLoggedIn()) {
 
37
                        echo "You do not have access to this page";
 
38
                        return;
 
39
                }
 
40
 
 
41
                $data = array(
 
42
                        'name' => $this->input->post('name');
 
43
                );
 
44
        }
 
45
        
 
46
        public function validate() {
 
47
                //Load required library
 
48
                $this->load->library('form_validation');
 
49
                
 
50
                //Sets validation rules
 
51
                $this->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean');
 
52
                $this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean');
 
53
                
 
54
                //Run validation
 
55
                if($this->form_validation->run() == FALSE) {
 
56
                        //Field validation failed. Display login form (with error message).
 
57
                        $this->drawLoginForm(validation_errors());
 
58
                } else {
 
59
                        $username = $this->input->post('username');
 
60
                        $password = $this->input->post('password');
 
61
                        
 
62
                        //Try to login
 
63
                        if ($this->user->login($username, $password)) {
 
64
                                redirect(base_url().'home', 'refresh');
 
65
                        } else {
 
66
                                $this->drawLoginForm('Access denied!');
 
67
                        }
 
68
                }
 
69
        }
 
70
        
 
71
}
 
72
 
 
73
/* End of file ExamplesController.php */
 
74
/* Location: ./application/controllers/ExamplesController.php */
 
 
b'\\ No newline at end of file'