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);
21
function showPopup($popupName) {
23
'cssFiles' => array('popup'),
24
'jsFiles' => array('login')
28
'userType' => $this->user->getUserType(), // Loads different header for teacher/student
29
'userName' => $this->user->getUserName()
32
// Loads head views, supplying CSS and JS data
33
$this->load->view('headTag', array('headTagData' => $headTagData));
35
$this->load->view('popup/'.$popupName);
39
* This function return TRUE if the user is logged in and FALSE otherwise.
41
public function isLoggedIn() {
42
if ($this->user->isLoggedIn()) {
51
* This function outputs data: user password hint.
53
public function pwdhint() {
54
$this->load->model('user');
55
if($this->input->post('username')) {
56
$username = $this->input->post('username');
58
'hint' => $this->user->getPasswordHint($username)
62
echo json_encode($data);
67
* This function outputs data: user password hint.
69
public function ladok() {
70
$string = $this->input->post('data');
72
$parsedArray = $this->user->parseLadok($string);
74
if ($parsedArray === FALSE) {
75
$data = array('status' => FALSE);
77
//Add users to database
78
foreach ($parsedArray as $key => $value) {
79
$this->user->addUser($parsedArray[$key]['username'], $parsedArray[$key]['firstname'] . ' ' . $parsedArray[$key]['lastname'], $parsedArray[$key]['ssn'], $parsedArray[$key]['ssn'], 'Student', 'Default', $parsedArray[$key]['email']);
82
$data = array('status' => TRUE);
86
echo json_encode($data);
90
* This function outputs data: user password hint.
92
public function pwdchange() {
93
$pwdOld = $this->input->post('currentPwd');
94
$pwdNew = $this->input->post('newPwd');
95
$pwdHint = $this->input->post('hintPwd');
98
'status' => $this->user->changePassword($pwdOld, $pwdNew, $pwdHint)
102
echo json_encode($data);
105
public function categoryOrderDecrease(){
106
$pwdOld = $this->input->post('currentPwd');
107
$pwdNew = $this->input->post('newPwd');
110
// Takes a course ID and sets the course to published (isHidden = 0)
111
public function publishCourse($courseID) {
112
$this->load->model('user');
113
$this->load->model('admin/admin_model');
115
if(!$this->user->isLoggedIn() || $this->user->getUserType() != "Teacher") {
116
$this->load->view('manageCoursesMessage', array('message' => 'You do not have access to this page'));
117
echo "not logged in";
121
$this->admin_model->unsetCourseHidden($courseID);
124
//Takes a course ID and sets the course to unpublished (isHidden = 1)
125
public function unpublishCourse($courseID) {
126
$this->load->model('user');
127
$this->load->model('admin/admin_model');
129
if(!$this->user->isLoggedIn() || $this->user->getUserType() != "Teacher") {
130
$this->load->view('manageCoursesMessage', array('message' => 'You do not have access to this page'));
131
echo "not logged in";
135
$this->admin_model->setCourseHidden($courseID);
b'\\ No newline at end of file'