1
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
3
class ViewStudentsController extends CI_Controller {
5
public function index() {
6
$this->load->model('user');
7
$this->load->model('admin/admin_model');
9
if(!$this->user->isLoggedIn() || $this->user->getUserType() != "Teacher") {
10
echo "You do not have access to this page.";
14
// NOTE: viewstudents is a deprecated model. Should eventually be replaced by a proper model
15
$this->load->model('viewstudents');
17
$userName = $this->user->getUserName();
18
$userType = $this->user->getUserType();
20
//Creates an array with the necessary css- and jsfiles needed for the views that are about to be shown.
22
'cssFiles' => array('bannermenu', 'sidemenu', 'dummieContent', 'viewStudents', 'body'),//cms tillfällig sida
23
'jsFiles' => array('bannermenu', 'viewStudents')
26
//Puts the array above in <head></head>
27
$this->load->view('headTag', array('headTagData' => $headTagData));
29
$students = $this->viewstudents->getStudents();
31
$this->load->view('viewStudentsBody', array('students' => $students));
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";
42
'name' => $this->input->post('name');
46
public function validate() {
47
//Load required library
48
$this->load->library('form_validation');
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');
55
if($this->form_validation->run() == FALSE) {
56
//Field validation failed. Display login form (with error message).
57
$this->drawLoginForm(validation_errors());
59
$username = $this->input->post('username');
60
$password = $this->input->post('password');
63
if ($this->user->login($username, $password)) {
64
redirect(base_url().'home', 'refresh');
66
$this->drawLoginForm('Access denied!');
73
/* End of file ExamplesController.php */
74
/* Location: ./application/controllers/ExamplesController.php */
b'\\ No newline at end of file'