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