1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class ViewStudentsController extends CI_Controller {
public function index() {
$this->load->model('user');
$this->load->model('admin/admin_model');
if(!$this->user->isLoggedIn() || $this->user->getUserType() != "Teacher") {
echo "You do not have access to this page.";
return;
}
// NOTE: viewstudents is a deprecated model. Should eventually be replaced by a proper model
$this->load->model('viewstudents');
$userName = $this->user->getUserName();
$userType = $this->user->getUserType();
//Creates an array with the necessary css- and jsfiles needed for the views that are about to be shown.
$headTagData = array(
'cssFiles' => array('bannermenu', 'sidemenu', 'dummieContent', 'viewStudents', 'body'),//cms tillfällig sida
'jsFiles' => array('bannermenu', 'viewStudents')
);
//Puts the array above in <head></head>
$this->load->view('headTag', array('headTagData' => $headTagData));
$students = $this->viewstudents->getStudents();
$this->load->view('viewStudentsBody', array('students' => $students));
}
public function editStudentDetails() {
$this->load->model('user');
if(!$this->input->post('username') || !$this->user->isLoggedIn()) {
echo "You do not have access to this page";
return;
}
$data = array(
'name' => $this->input->post('name');
);
}
public function validate() {
//Load required library
$this->load->library('form_validation');
//Sets validation rules
$this->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean');
$this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean');
//Run validation
if($this->form_validation->run() == FALSE) {
//Field validation failed. Display login form (with error message).
$this->drawLoginForm(validation_errors());
} else {
$username = $this->input->post('username');
$password = $this->input->post('password');
//Try to login
if ($this->user->login($username, $password)) {
redirect(base_url().'home', 'refresh');
} else {
$this->drawLoginForm('Access denied!');
}
}
}
}
/* End of file ExamplesController.php */
/* Location: ./application/controllers/ExamplesController.php */
|