bzr branch
http://gegoxaren.bato24.eu/bzr/lenasys/trunk
83.2.16
by elof.bigestans at gmail
* Merged trunk AND |
1 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
78.1.1
by Johan Gustavsson
added controller, model and view for View students, so that next imp can continue on it |
2 |
|
3 |
class ViewStudentsController extends CI_Controller { |
|
4 |
||
83.2.14
by elof.bigestans at gmail
* Started work on the viewStudents functionality... So far, displaying users works and it outputs correct and standardized html. |
5 |
public function index() { |
6 |
$this->load->model('user'); |
|
7 |
$this->load->model('admin/admin_model'); |
|
8 |
||
83.2.15
by elof.bigestans at gmail
Continuing work on viewstudents |
9 |
if(!$this->user->isLoggedIn() || $this->user->getUserType() != "Teacher") { |
10 |
echo "You do not have access to this page."; |
|
11 |
return; |
|
12 |
}
|
|
13 |
||
83.2.14
by elof.bigestans at gmail
* Started work on the viewStudents functionality... So far, displaying users works and it outputs correct and standardized html. |
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 |
||
83.2.15
by elof.bigestans at gmail
Continuing work on viewstudents |
34 |
public function editStudentDetails() { |
78.1.1
by Johan Gustavsson
added controller, model and view for View students, so that next imp can continue on it |
35 |
$this->load->model('user'); |
83.2.15
by elof.bigestans at gmail
Continuing work on viewstudents |
36 |
if(!$this->input->post('username') || !$this->user->isLoggedIn()) { |
37 |
echo "You do not have access to this page"; |
|
38 |
return; |
|
78.1.1
by Johan Gustavsson
added controller, model and view for View students, so that next imp can continue on it |
39 |
}
|
40 |
||
83.2.16
by elof.bigestans at gmail
* Merged trunk AND |
41 |
$data = array( |
42 |
'name' => $this->input->post('name'); |
|
43 |
);
|
|
78.1.1
by Johan Gustavsson
added controller, model and view for View students, so that next imp can continue on it |
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 */
|