/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk
52.1.1 by b11johgu
Added controllers for examplepage, templatelayout.
1
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2
3
	class Ajax extends CI_Controller {
4
		/*
5
		 *	Constructor
6
		 */
7
		function __construct() {
8
			parent::__construct();
9
			
10
			//Load required library
11
			$this->load->model('user', '', TRUE);
12
		}
13
		
83.1.4 by Erik Wikström
Removed old popup views and model. Added separate views for each popup, as well as a function in the ajax-controller to load them.
14
		/*
15
		 *	This function loads a popupview to be displayed, the argument is the name of the popupview
16
		 */
17
		public function popup($popupName) {
18
			$this->load->view('popup/'.$popupName);
19
		}
20
		
52.1.1 by b11johgu
Added controllers for examplepage, templatelayout.
21
		
22
		/*
23
		 *	This function outputs data: user password hint.
24
		 */
64.1.1 by b11johgu
ExamplesController:
25
		public function pwdhint() {
26
		$user = $this->input->post('hintPwd');
52.1.1 by b11johgu
Added controllers for examplepage, templatelayout.
27
			$data = array(
28
				'hint' => $this->user->getPasswordHint($user)
29
			);
30
			
31
			//Output JSON data
32
			echo json_encode($data);
33
		}
69.1.3 by Daniel Hermansson
Added ajax functionality for ladok parser
34
35
		/*
36
		 *	This function outputs data: user password hint.
37
		 */
38
		public function ladok() {
39
			$string = $this->input->post('data');
40
			
41
			$parsedArray = $this->user->parseLadok($string);
42
			
43
			if ($parsedArray === FALSE) {
44
				$data = array('status' => FALSE);				
45
			} else {
46
				//Add users to database
47
				foreach ($parsedArray as $key => $value) {
48
					$this->user->addUser($parsedArray[$key]['username'], $parsedArray[$key]['firstname'] . ' ' . $parsedArray[$key]['lastname'], $parsedArray[$key]['ssn'], $parsedArray[$key]['ssn'], 'Student', 'Default', $parsedArray[$key]['email']);
49
				}
50
			
51
				$data = array('status' => TRUE);			
52
			}
53
			
54
			//Output JSON data
55
			echo json_encode($data);
56
		}
52.1.1 by b11johgu
Added controllers for examplepage, templatelayout.
57
		
58
		/*
59
		 *	This function outputs data: user password hint.
60
		 */
61
		public function pwdchange() {
62
			$pwdOld = $this->input->post('currentPwd');
63
			$pwdNew = $this->input->post('newPwd');
64
			$pwdHint = $this->input->post('hintPwd');
65
		
66
			$data = array(
67
				'status' => $this->user->changePassword($pwdOld, $pwdNew, $pwdHint)
68
			);
69
			
70
			//Output JSON data
71
			echo json_encode($data);
72
		}
64.1.1 by b11johgu
ExamplesController:
73
		
74
		public function categoryOrderDecrease(){
75
			$pwdOld = $this->input->post('currentPwd');
76
			$pwdNew = $this->input->post('newPwd');
77
		}
52.1.1 by b11johgu
Added controllers for examplepage, templatelayout.
78
	}
79
?>