/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.2.3 by elof.bigestans at gmail
Working on functionality for managecourses
14
		/*
15
		 *	This function loads a popupview to be displayed, the argument is the name of the popupview
16
		 */
17
		public function popup($popupName) {
83.2.5 by elof.bigestans at gmail
* Updated ManageCourses, including JS+Jquery, popups, controller.
18
			$this->load->view('popup/'.$popupName);
83.2.3 by elof.bigestans at gmail
Working on functionality for managecourses
19
		}
20
		
52.1.1 by b11johgu
Added controllers for examplepage, templatelayout.
21
		/*
22
		 *	This function outputs data: user password hint.
23
		 */
64.1.1 by b11johgu
ExamplesController:
24
		public function pwdhint() {
25
		$user = $this->input->post('hintPwd');
52.1.1 by b11johgu
Added controllers for examplepage, templatelayout.
26
			$data = array(
27
				'hint' => $this->user->getPasswordHint($user)
28
			);
29
			
30
			//Output JSON data
31
			echo json_encode($data);
32
		}
69.1.3 by Daniel Hermansson
Added ajax functionality for ladok parser
33
34
		/*
35
		 *	This function outputs data: user password hint.
36
		 */
37
		public function ladok() {
38
			$string = $this->input->post('data');
39
			
40
			$parsedArray = $this->user->parseLadok($string);
41
			
42
			if ($parsedArray === FALSE) {
43
				$data = array('status' => FALSE);				
44
			} else {
45
				//Add users to database
46
				foreach ($parsedArray as $key => $value) {
47
					$this->user->addUser($parsedArray[$key]['username'], $parsedArray[$key]['firstname'] . ' ' . $parsedArray[$key]['lastname'], $parsedArray[$key]['ssn'], $parsedArray[$key]['ssn'], 'Student', 'Default', $parsedArray[$key]['email']);
48
				}
49
			
50
				$data = array('status' => TRUE);			
51
			}
52
			
53
			//Output JSON data
54
			echo json_encode($data);
55
		}
52.1.1 by b11johgu
Added controllers for examplepage, templatelayout.
56
		
57
		/*
58
		 *	This function outputs data: user password hint.
59
		 */
60
		public function pwdchange() {
61
			$pwdOld = $this->input->post('currentPwd');
62
			$pwdNew = $this->input->post('newPwd');
63
			$pwdHint = $this->input->post('hintPwd');
64
		
65
			$data = array(
66
				'status' => $this->user->changePassword($pwdOld, $pwdNew, $pwdHint)
67
			);
68
			
69
			//Output JSON data
70
			echo json_encode($data);
71
		}
64.1.1 by b11johgu
ExamplesController:
72
		
73
		public function categoryOrderDecrease(){
74
			$pwdOld = $this->input->post('currentPwd');
75
			$pwdNew = $this->input->post('newPwd');
76
		}
83.2.3 by elof.bigestans at gmail
Working on functionality for managecourses
77
78
		// Takes a course ID and sets the course to published (isHidden = 0)
79
		public function publishCourse($courseID) {
83.2.5 by elof.bigestans at gmail
* Updated ManageCourses, including JS+Jquery, popups, controller.
80
			$this->load->model('user');
81
			$this->load->model('admin/admin_model');
82
83
			if(!$this->user->isLoggedIn() || $this->user->getUserType() != "Teacher") {
84
				$this->load->view('manageCoursesMessage', array('message' => 'You do not have access to this page'));
85
				echo "not logged in";
86
				return;
87
			}
88
89
			$this->admin_model->unsetCourseHidden($courseID);
83.2.3 by elof.bigestans at gmail
Working on functionality for managecourses
90
		}
91
92
		//Takes a course ID and sets the course to unpublished (isHidden = 1)
93
		public function unpublishCourse($courseID) {
83.2.5 by elof.bigestans at gmail
* Updated ManageCourses, including JS+Jquery, popups, controller.
94
			$this->load->model('user');
95
			$this->load->model('admin/admin_model');
96
97
			if(!$this->user->isLoggedIn() || $this->user->getUserType() != "Teacher") {
98
				$this->load->view('manageCoursesMessage', array('message' => 'You do not have access to this page'));
99
				echo "not logged in";
100
				return;
101
			}
83.2.3 by elof.bigestans at gmail
Working on functionality for managecourses
102
			
83.2.5 by elof.bigestans at gmail
* Updated ManageCourses, including JS+Jquery, popups, controller.
103
			$this->admin_model->setCourseHidden($courseID);
83.2.3 by elof.bigestans at gmail
Working on functionality for managecourses
104
		}
52.1.1 by b11johgu
Added controllers for examplepage, templatelayout.
105
	}
106
?>