/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk

« back to all changes in this revision

Viewing changes to codeigniter/application/controllers/ajax.php

  • Committer: elof.bigestans at gmail
  • Date: 2013-05-24 10:00:47 UTC
  • mto: This revision was merged to the branch mainline in revision 95.
  • Revision ID: elof.bigestans@gmail.com-20130524100047-bqgk67s2g9o3l85x
Solved some bugs in ManageCourses and related files (CSS, JS, View, Controller)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
                
 
14
                /*
 
15
                 *      This function loads a popupview to be displayed, the argument is the name of the popupview
 
16
                 */
 
17
                public function popup($popupName) {
 
18
                        $this->load->view('popup/'.$popupName);
 
19
                }
 
20
                
 
21
                /*
 
22
                 *      This function outputs data: user password hint.
 
23
                 */
 
24
                public function pwdhint() {
 
25
                $user = $this->input->post('hintPwd');
 
26
                        $data = array(
 
27
                                'hint' => $this->user->getPasswordHint($user)
 
28
                        );
 
29
                        
 
30
                        //Output JSON data
 
31
                        echo json_encode($data);
 
32
                }
 
33
 
 
34
                /*
 
35
                 *      This function outputs data: user password hint.
 
36
                 */
 
37
                public function ladok() {
 
38
                        $string = $this->input->post('data');
 
39
                        
 
40
                        $parsedArray = $this->user->parseLadok($string);
 
41
                        
 
42
                        if ($parsedArray === FALSE) {
 
43
                                $data = array('status' => FALSE);                               
 
44
                        } else {
 
45
                                //Add users to database
 
46
                                foreach ($parsedArray as $key => $value) {
 
47
                                        $this->user->addUser($parsedArray[$key]['username'], $parsedArray[$key]['firstname'] . ' ' . $parsedArray[$key]['lastname'], $parsedArray[$key]['ssn'], $parsedArray[$key]['ssn'], 'Student', 'Default', $parsedArray[$key]['email']);
 
48
                                }
 
49
                        
 
50
                                $data = array('status' => TRUE);                        
 
51
                        }
 
52
                        
 
53
                        //Output JSON data
 
54
                        echo json_encode($data);
 
55
                }
 
56
                
 
57
                /*
 
58
                 *      This function outputs data: user password hint.
 
59
                 */
 
60
                public function pwdchange() {
 
61
                        $pwdOld = $this->input->post('currentPwd');
 
62
                        $pwdNew = $this->input->post('newPwd');
 
63
                        $pwdHint = $this->input->post('hintPwd');
 
64
                
 
65
                        $data = array(
 
66
                                'status' => $this->user->changePassword($pwdOld, $pwdNew, $pwdHint)
 
67
                        );
 
68
                        
 
69
                        //Output JSON data
 
70
                        echo json_encode($data);
 
71
                }
 
72
                
 
73
                public function categoryOrderDecrease(){
 
74
                        $pwdOld = $this->input->post('currentPwd');
 
75
                        $pwdNew = $this->input->post('newPwd');
 
76
                }
 
77
 
 
78
                // Takes a course ID and sets the course to published (isHidden = 0)
 
79
                public function publishCourse($courseID) {
 
80
                        $this->load->model('user');
 
81
                        $this->load->model('admin/admin_model');
 
82
 
 
83
                        if(!$this->user->isLoggedIn() || $this->user->getUserType() != "Teacher") {
 
84
                                $this->load->view('manageCoursesMessage', array('message' => 'You do not have access to this page'));
 
85
                                echo "not logged in";
 
86
                                return;
 
87
                        }
 
88
 
 
89
                        $this->admin_model->unsetCourseHidden($courseID);
 
90
                }
 
91
 
 
92
                //Takes a course ID and sets the course to unpublished (isHidden = 1)
 
93
                public function unpublishCourse($courseID) {
 
94
                        $this->load->model('user');
 
95
                        $this->load->model('admin/admin_model');
 
96
 
 
97
                        if(!$this->user->isLoggedIn() || $this->user->getUserType() != "Teacher") {
 
98
                                $this->load->view('manageCoursesMessage', array('message' => 'You do not have access to this page'));
 
99
                                echo "not logged in";
 
100
                                return;
 
101
                        }
 
102
                        
 
103
                        $this->admin_model->setCourseHidden($courseID);
 
104
                }
 
105
        }
 
106
?>
 
 
b'\\ No newline at end of file'