/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.7 by elof.bigestans at gmail
Started work on normalizing popups. Lots to go.
18
			// Arrays
19
			$headTagData = array(
20
				'cssFiles' => array('bannermenu', 'popup')
21
			);
22
23
			$userInfo = array(
24
				'userType' => $this->user->getUserType(), // Loads different header for teacher/student
25
				'userName' => $this->user->getUserName()
26
			);
27
28
			// Loads head views, supplying CSS and JS data
29
			$this->load->view('headTag', array('headTagData' => $headTagData));
30
			$this->load->view('bannermenu', $userInfo);
31
83.2.5 by elof.bigestans at gmail
* Updated ManageCourses, including JS+Jquery, popups, controller.
32
			$this->load->view('popup/'.$popupName);
83.2.3 by elof.bigestans at gmail
Working on functionality for managecourses
33
		}
34
		
52.1.1 by b11johgu
Added controllers for examplepage, templatelayout.
35
		/*
36
		 *	This function outputs data: user password hint.
37
		 */
64.1.1 by b11johgu
ExamplesController:
38
		public function pwdhint() {
39
		$user = $this->input->post('hintPwd');
52.1.1 by b11johgu
Added controllers for examplepage, templatelayout.
40
			$data = array(
41
				'hint' => $this->user->getPasswordHint($user)
42
			);
43
			
44
			//Output JSON data
45
			echo json_encode($data);
46
		}
69.1.3 by Daniel Hermansson
Added ajax functionality for ladok parser
47
48
		/*
49
		 *	This function outputs data: user password hint.
50
		 */
51
		public function ladok() {
52
			$string = $this->input->post('data');
53
			
54
			$parsedArray = $this->user->parseLadok($string);
55
			
56
			if ($parsedArray === FALSE) {
57
				$data = array('status' => FALSE);				
58
			} else {
59
				//Add users to database
60
				foreach ($parsedArray as $key => $value) {
61
					$this->user->addUser($parsedArray[$key]['username'], $parsedArray[$key]['firstname'] . ' ' . $parsedArray[$key]['lastname'], $parsedArray[$key]['ssn'], $parsedArray[$key]['ssn'], 'Student', 'Default', $parsedArray[$key]['email']);
62
				}
63
			
64
				$data = array('status' => TRUE);			
65
			}
66
			
67
			//Output JSON data
68
			echo json_encode($data);
69
		}
52.1.1 by b11johgu
Added controllers for examplepage, templatelayout.
70
		
71
		/*
72
		 *	This function outputs data: user password hint.
73
		 */
74
		public function pwdchange() {
75
			$pwdOld = $this->input->post('currentPwd');
76
			$pwdNew = $this->input->post('newPwd');
77
			$pwdHint = $this->input->post('hintPwd');
78
		
79
			$data = array(
80
				'status' => $this->user->changePassword($pwdOld, $pwdNew, $pwdHint)
81
			);
82
			
83
			//Output JSON data
84
			echo json_encode($data);
85
		}
64.1.1 by b11johgu
ExamplesController:
86
		
87
		public function categoryOrderDecrease(){
88
			$pwdOld = $this->input->post('currentPwd');
89
			$pwdNew = $this->input->post('newPwd');
90
		}
83.2.3 by elof.bigestans at gmail
Working on functionality for managecourses
91
92
		// Takes a course ID and sets the course to published (isHidden = 0)
93
		public function publishCourse($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
			}
102
103
			$this->admin_model->unsetCourseHidden($courseID);
83.2.3 by elof.bigestans at gmail
Working on functionality for managecourses
104
		}
105
106
		//Takes a course ID and sets the course to unpublished (isHidden = 1)
107
		public function unpublishCourse($courseID) {
83.2.5 by elof.bigestans at gmail
* Updated ManageCourses, including JS+Jquery, popups, controller.
108
			$this->load->model('user');
109
			$this->load->model('admin/admin_model');
110
111
			if(!$this->user->isLoggedIn() || $this->user->getUserType() != "Teacher") {
112
				$this->load->view('manageCoursesMessage', array('message' => 'You do not have access to this page'));
113
				echo "not logged in";
114
				return;
115
			}
83.2.3 by elof.bigestans at gmail
Working on functionality for managecourses
116
			
83.2.5 by elof.bigestans at gmail
* Updated ManageCourses, including JS+Jquery, popups, controller.
117
			$this->admin_model->setCourseHidden($courseID);
83.2.3 by elof.bigestans at gmail
Working on functionality for managecourses
118
		}
52.1.1 by b11johgu
Added controllers for examplepage, templatelayout.
119
	}
120
?>