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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Ajax extends CI_Controller {
/*
* Constructor
*/
function __construct() {
parent::__construct();
//Load required library
$this->load->model('user', '', TRUE);
}
/*
* This function loads a popupview to be displayed, the argument is the name of the popupview
*/
public function popup($popupName) {
$this->load->view('popup/'.$popupName);
}
/*
* This function outputs data: user password hint.
*/
public function pwdhint() {
$user = $this->input->post('hintPwd');
$data = array(
'hint' => $this->user->getPasswordHint($user)
);
//Output JSON data
echo json_encode($data);
}
/*
* This function outputs data: user password hint.
*/
public function ladok() {
$string = $this->input->post('data');
$parsedArray = $this->user->parseLadok($string);
if ($parsedArray === FALSE) {
$data = array('status' => FALSE);
} else {
//Add users to database
foreach ($parsedArray as $key => $value) {
$this->user->addUser($parsedArray[$key]['username'], $parsedArray[$key]['firstname'] . ' ' . $parsedArray[$key]['lastname'], $parsedArray[$key]['ssn'], $parsedArray[$key]['ssn'], 'Student', 'Default', $parsedArray[$key]['email']);
}
$data = array('status' => TRUE);
}
//Output JSON data
echo json_encode($data);
}
/*
* This function outputs data: user password hint.
*/
public function pwdchange() {
$pwdOld = $this->input->post('currentPwd');
$pwdNew = $this->input->post('newPwd');
$pwdHint = $this->input->post('hintPwd');
$data = array(
'status' => $this->user->changePassword($pwdOld, $pwdNew, $pwdHint)
);
//Output JSON data
echo json_encode($data);
}
public function categoryOrderDecrease(){
$pwdOld = $this->input->post('currentPwd');
$pwdNew = $this->input->post('newPwd');
}
// Takes a course ID and sets the course to published (isHidden = 0)
public function publishCourse($courseID) {
$this->load->model('user');
$this->load->model('admin/admin_model');
if(!$this->user->isLoggedIn() || $this->user->getUserType() != "Teacher") {
$this->load->view('manageCoursesMessage', array('message' => 'You do not have access to this page'));
echo "not logged in";
return;
}
$this->admin_model->unsetCourseHidden($courseID);
}
//Takes a course ID and sets the course to unpublished (isHidden = 1)
public function unpublishCourse($courseID) {
$this->load->model('user');
$this->load->model('admin/admin_model');
if(!$this->user->isLoggedIn() || $this->user->getUserType() != "Teacher") {
$this->load->view('manageCoursesMessage', array('message' => 'You do not have access to this page'));
echo "not logged in";
return;
}
$this->admin_model->setCourseHidden($courseID);
}
}
?>
|