1
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
3
class Ajax extends CI_Controller {
7
function __construct() {
10
//Load required library
11
$this->load->model('user', '', TRUE);
15
* This function loads a popupview to be displayed, the argument is the name of the popupview
17
public function popup($popupName) {
18
$this->load->view('popup/'.$popupName);
22
* This function return TRUE if the user is logged in and FALSE otherwise.
24
public function isLoggedIn() {
25
if ($this->user->isLoggedIn()) {
34
* This function outputs data: user password hint.
36
public function pwdhint() {
37
$user = $this->input->post('hintPwd');
39
'hint' => $this->user->getPasswordHint($user)
43
echo json_encode($data);
47
* This function outputs data: user password hint.
49
public function ladok() {
50
$string = $this->input->post('data');
52
$parsedArray = $this->user->parseLadok($string);
54
if ($parsedArray === FALSE) {
55
$data = array('status' => FALSE);
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']);
62
$data = array('status' => TRUE);
66
echo json_encode($data);
70
* This function outputs data: user password hint.
72
public function pwdchange() {
73
$pwdOld = $this->input->post('currentPwd');
74
$pwdNew = $this->input->post('newPwd');
75
$pwdHint = $this->input->post('hintPwd');
78
'status' => $this->user->changePassword($pwdOld, $pwdNew, $pwdHint)
82
echo json_encode($data);
85
public function categoryOrderDecrease(){
86
$pwdOld = $this->input->post('currentPwd');
87
$pwdNew = $this->input->post('newPwd');
90
// Takes a course ID and sets the course to published (isHidden = 0)
91
public function publishCourse($courseID) {
92
$this->load->model('user');
93
$this->load->model('admin/admin_model');
95
if(!$this->user->isLoggedIn() || $this->user->getUserType() != "Teacher") {
96
$this->load->view('manageCoursesMessage', array('message' => 'You do not have access to this page'));
101
$this->admin_model->unsetCourseHidden($courseID);
104
//Takes a course ID and sets the course to unpublished (isHidden = 1)
105
public function unpublishCourse($courseID) {
106
$this->load->model('user');
107
$this->load->model('admin/admin_model');
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";
115
$this->admin_model->setCourseHidden($courseID);
b'\\ No newline at end of file'