bzr branch
http://gegoxaren.bato24.eu/bzr/lenasys/trunk
79.1.1
by a10rolch
- Updated admin_model function addCourse to also include courseData. |
1 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
2 |
||
3 |
class ManageCourses extends CI_Controller { |
|
4 |
||
83.2.1
by elof.bigestans at gmail
Fixed various bugs in the ManageCourses function |
5 |
/*
|
6 |
* tempLogin and tempLogout are temporary functions to debug user validation functionality
|
|
7 |
* They should be removed when lenasys is complete
|
|
8 |
*/
|
|
83.2.2
by elof.bigestans at gmail
Further cleaned up ManageCourses |
9 |
|
83.2.1
by elof.bigestans at gmail
Fixed various bugs in the ManageCourses function |
10 |
public function tempLogin() { |
11 |
$this->load->model('user'); |
|
12 |
$loginDetails = array( |
|
13 |
'username' => 'tempTeacher', |
|
14 |
'name' => 'tempFoo', |
|
15 |
'usertype' => 'Teacher', |
|
16 |
'ssn' => '0000'); |
|
17 |
$this->session->set_userdata('authenticated', $loginDetails); |
|
18 |
redirect('/ManageCourses'); |
|
19 |
}
|
|
20 |
||
21 |
public function tempLogout() { |
|
22 |
$this->load->model('user'); |
|
23 |
$this->session->unset_userdata('authenticated'); |
|
24 |
redirect('/ManageCourses'); |
|
25 |
}
|
|
26 |
||
27 |
||
28 |
/*
|
|
29 |
* Manage courses index page
|
|
30 |
* RESTRICTED-LEVEL: Teacher
|
|
31 |
*/
|
|
79.1.1
by a10rolch
- Updated admin_model function addCourse to also include courseData. |
32 |
public function index() |
33 |
{
|
|
34 |
/* Loads used models */
|
|
35 |
$this->load->model('user'); |
|
36 |
$this->load->model('admin/admin_model'); |
|
37 |
$this->load->model('ExamplesModel'); |
|
83.2.1
by elof.bigestans at gmail
Fixed various bugs in the ManageCourses function |
38 |
|
39 |
$this->load->library('session'); |
|
40 |
$this->load->helper('form'); |
|
79.1.1
by a10rolch
- Updated admin_model function addCourse to also include courseData. |
41 |
|
42 |
// Arrays
|
|
43 |
$headTagData = array( |
|
83.2.12
by elof.bigestans at gmail
* Merged trunk |
44 |
'cssFiles' => array('manageCoursesBody', 'popup'), |
83.2.6
by elof.bigestans at gmail
Solved some bugs in ManageCourses and related files (CSS, JS, View, Controller) |
45 |
'jsFiles' => array('examplesBody', 'userControls', 'manageCourses') |
79.1.1
by a10rolch
- Updated admin_model function addCourse to also include courseData. |
46 |
);
|
83.2.1
by elof.bigestans at gmail
Fixed various bugs in the ManageCourses function |
47 |
|
79.1.1
by a10rolch
- Updated admin_model function addCourse to also include courseData. |
48 |
$userInfo = array( |
49 |
'userType' => $this->user->getUserType(), // Loads different header for teacher/student |
|
50 |
'userName' => $this->user->getUserName() |
|
51 |
);
|
|
83.2.1
by elof.bigestans at gmail
Fixed various bugs in the ManageCourses function |
52 |
|
83.2.5
by elof.bigestans at gmail
* Updated ManageCourses, including JS+Jquery, popups, controller. |
53 |
// Loads head views, supplying CSS and JS data
|
79.1.1
by a10rolch
- Updated admin_model function addCourse to also include courseData. |
54 |
$this->load->view('headTag', array('headTagData' => $headTagData)); |
83.2.12
by elof.bigestans at gmail
* Merged trunk |
55 |
//$this->load->view('bannermenu', $userInfo);
|
83.2.1
by elof.bigestans at gmail
Fixed various bugs in the ManageCourses function |
56 |
|
57 |
// Check user login and display message if not logged in
|
|
58 |
if(!$this->user->isLoggedIn() || $this->user->getUserType() != "Teacher") { |
|
59 |
$this->load->view('manageCoursesMessage', array('message' => 'You do not have access to this page')); |
|
60 |
return; |
|
61 |
}
|
|
62 |
||
83.2.5
by elof.bigestans at gmail
* Updated ManageCourses, including JS+Jquery, popups, controller. |
63 |
// Loads data into $courses
|
83.2.1
by elof.bigestans at gmail
Fixed various bugs in the ManageCourses function |
64 |
$courses = $this->admin_model->getCourses(); |
65 |
||
83.2.5
by elof.bigestans at gmail
* Updated ManageCourses, including JS+Jquery, popups, controller. |
66 |
// Loads manageCourses view with $courses
|
79.1.1
by a10rolch
- Updated admin_model function addCourse to also include courseData. |
67 |
$this->load->view('manageCoursesBody', array("courses" => $courses)); |
68 |
||
69 |
}
|
|
83.2.1
by elof.bigestans at gmail
Fixed various bugs in the ManageCourses function |
70 |
|
71 |
||
72 |
/*
|
|
73 |
* Add course page - handles form submission from index page
|
|
74 |
* RESTRICTED-LEVEL: Teacher
|
|
75 |
*/
|
|
76 |
public function addCourse(){ |
|
77 |
$this->load->model('user'); |
|
78 |
||
79 |
// User has to be logged in and usertype has to be Tea
|
|
80 |
if(!$this->user->isLoggedIn() || $this->user->getUserType() != "Teacher") { |
|
81 |
$this->load->view('manageCoursesMessage', array('message' => 'You do not have access to this page')); |
|
82 |
return; |
|
83 |
}
|
|
84 |
||
83.2.5
by elof.bigestans at gmail
* Updated ManageCourses, including JS+Jquery, popups, controller. |
85 |
if($this->input->post('addCourseID')){ |
79.1.1
by a10rolch
- Updated admin_model function addCourse to also include courseData. |
86 |
$this->load->model('admin/admin_model'); |
83.2.5
by elof.bigestans at gmail
* Updated ManageCourses, including JS+Jquery, popups, controller. |
87 |
$this->admin_model->addCourse($this->input->post("addCourseID"), $this->input->post("addCourseName"), $this->input->post("addCourseData")); |
79.1.1
by a10rolch
- Updated admin_model function addCourse to also include courseData. |
88 |
redirect("/ManageCourses"); |
89 |
}
|
|
90 |
else{ |
|
91 |
redirect("/ManageCourses"); |
|
92 |
}
|
|
83.2.1
by elof.bigestans at gmail
Fixed various bugs in the ManageCourses function |
93 |
}
|
94 |
||
95 |
/*
|
|
96 |
* Edit course page - handles form submission from index page
|
|
97 |
* RESTRICTED-LEVEL: Teacher
|
|
98 |
*/
|
|
99 |
function editCourse() { |
|
100 |
$this->load->model('user'); |
|
101 |
// User has to be logged in and usertype has to be Teacher
|
|
102 |
if(!$this->user->isLoggedIn() || $this->user->getUserType() != "Teacher") { |
|
103 |
$this->load->view('manageCoursesMessage', array('message' => 'You do not have access to this page')); |
|
104 |
return; |
|
105 |
}
|
|
106 |
||
107 |
if($this->input->post('editCourseID')) { |
|
108 |
$this->load->model('admin/admin_model'); |
|
109 |
$this->admin_model->editCourse($this->input->post('editCourseID'), $this->input->post('editCourseName'), $this->input->post('editCourseData')); |
|
110 |
redirect('/ManageCourses'); |
|
111 |
} else { |
|
112 |
echo "Something went wrong"; |
|
113 |
}
|
|
79.1.1
by a10rolch
- Updated admin_model function addCourse to also include courseData. |
114 |
}
|
115 |
||
116 |
public function validate() { |
|
117 |
//Load required library
|
|
118 |
$this->load->library('form_validation'); |
|
119 |
||
120 |
//Sets validation rules
|
|
121 |
$this->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean'); |
|
122 |
$this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean'); |
|
123 |
||
124 |
//Run validation
|
|
125 |
if($this->form_validation->run() == FALSE) { |
|
126 |
//Field validation failed. Display login form (with error message).
|
|
127 |
$this->drawLoginForm(validation_errors()); |
|
128 |
} else { |
|
129 |
$username = $this->input->post('username'); |
|
130 |
$password = $this->input->post('password'); |
|
131 |
||
132 |
//Try to login
|
|
133 |
if ($this->user->login($username, $password)) { |
|
134 |
redirect(base_url().'home', 'refresh'); |
|
135 |
} else { |
|
136 |
$this->drawLoginForm('Access denied!'); |
|
137 |
}
|
|
138 |
}
|
|
139 |
}
|
|
83.2.2
by elof.bigestans at gmail
Further cleaned up ManageCourses |
140 |
|
141 |
public function manageCourse($cid) { |
|
142 |
$cid = urldecode($cid); |
|
143 |
$this->load->model('admin/Admin_model'); |
|
144 |
$categories = $this->Admin_model->getCategories($cid); |
|
145 |
$this->load->view('admin/header', array("title" => "Manage course - ".$cid)); |
|
146 |
$menu = $this->Admin_model->getMenu(); |
|
147 |
$this->load->view('admin/menu', array("menu" => $menu)); |
|
148 |
$this->load->view('admin/manage_course', array("categories" => $categories, "cid" => $cid)); |
|
149 |
}
|
|
79.1.1
by a10rolch
- Updated admin_model function addCourse to also include courseData. |
150 |
|
151 |
}
|
|
152 |
||
153 |
/* End of file ManageCourses.php */
|
|
154 |
/* Location: ./application/controllers/ExamplesController.php */
|