/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: a11andoh
  • Date: 2013-05-24 11:28:43 UTC
  • mto: This revision was merged to the branch mainline in revision 97.
  • Revision ID: a11andoh@student.his.se-20130524112843-360je7hu7q13r171
added the cms controller to load all content pages.
added first time registration controller to load the views for the registration
pages.
added and fixed temporarypages for the controllers 
and edited the models to be able to get active courses.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
                 *      This function loads a popupview to be displayed, the argument is the name of the popupview
16
16
                 */
17
17
                public function popup($popupName) {
18
 
                        $this->load->view('popup/'.$popupName);
19
 
                }
20
 
 
21
 
                function showPopup($popupName) {
22
 
                        $headTagData = array(
23
 
                                'cssFiles' => array('popup'),
24
 
                                'jsFiles' => array('login')
25
 
                        );
26
 
 
27
 
                        $userInfo = array(
28
 
                                'userType' => $this->user->getUserType(), // Loads different header for teacher/student
29
 
                                'userName' => $this->user->getUserName()
30
 
                        );
31
 
 
32
 
                        // Loads head views, supplying CSS and JS data
33
 
                        $this->load->view('headTag', array('headTagData' => $headTagData));
34
 
 
35
 
                        $this->load->view('popup/'.$popupName);
 
18
                        $popup = $this->load->view('popup/'.$popupName, '', TRUE);
 
19
                        return $popup;
36
20
                }
37
21
                
38
 
                /*
39
 
                 *      This function return TRUE if the user is logged in and FALSE otherwise.
40
 
                 */
41
 
                public function isLoggedIn() {
42
 
                        if ($this->user->isLoggedIn()) {
43
 
                                echo 'yes';
44
 
                        }
45
 
                        else {
46
 
                                echo 'no';
47
 
                        }
48
 
                }
49
22
                
50
23
                /*
51
24
                 *      This function outputs data: user password hint.
52
25
                 */
53
26
                public function pwdhint() {
54
 
                        $this->load->model('user');
55
 
                        if($this->input->post('username')) {
56
 
                                $username = $this->input->post('username');
57
 
                                $data = array(
58
 
                                        'hint' => $this->user->getPasswordHint($username)
59
 
                                );
 
27
                $user = $this->input->post('hintPwd');
 
28
                        $data = array(
 
29
                                'hint' => $this->user->getPasswordHint($user)
 
30
                        );
60
31
                        
61
 
                                //Output JSON data
62
 
                                echo json_encode($data);
63
 
                        }
 
32
                        //Output JSON data
 
33
                        echo json_encode($data);
64
34
                }
65
35
 
66
36
                /*
106
76
                        $pwdOld = $this->input->post('currentPwd');
107
77
                        $pwdNew = $this->input->post('newPwd');
108
78
                }
109
 
 
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');
114
 
 
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";
118
 
                                return;
119
 
                        }
120
 
 
121
 
                        $this->admin_model->unsetCourseHidden($courseID);
122
 
                }
123
 
 
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');
128
 
 
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";
132
 
                                return;
133
 
                        }
134
 
                        
135
 
                        $this->admin_model->setCourseHidden($courseID);
136
 
                }
137
79
        }
138
80
?>
 
 
b'\\ No newline at end of file'