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