/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk
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
75
76
77
78
79
80
81
82
83
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class ViewStudentsController extends CI_Controller {

	public function index()
	{
		/* headData manages the <head>-tag and loads corresponding CSS.
		 * The views that are entered will load CSS with same name.
		 * Ex. test_header will load test_header.css
		 */
		$this->load->library('session');
		$headTagData = array(
			'cssFiles' => array('header', 'examplesMenu', 'examplesBody'),
			'jsFiles' => array('header', 'examplesMenu', 'examplesBody', 'userControls')
		);
		$this->load->view('headTag', array('headTagData' => $headTagData));
		
		$this->load->helper('form');
		
		// Loading model to retrieve login data
		$this->load->model('user');
		$userInfo = array(
			'userType' => $this->user->getUserType(), // Loads different header for teacher/student
			'userName' => $this->user->getUserName()
		);
		
		$this->load->view('header', $userInfo);
			
		/* Loads used models */
		$this->load->model('viewstudents');
		
		// menuData loads items to the menu.
		$allTitles = array();
		$allStudents = array();
		
		/* Loads categorydata into array */
		$query = $this->viewstudents->getStudents();

		
		foreach ($query as $student)
		{
			array_push($allStudents, $student->userName);
		}
		
		/*Menu for examples page showing categories */
		$this->load->view('examplesMenu', array('titles' => $allTitles));
		
		/* Loads body for examples page */
		
		$this->load->view('viewStudentsBody', array('students' => $allStudents));	

	}

	
	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 */