@@ -8,102 +8,102 @@ discard block |
||
8 | 8 | */ |
9 | 9 | class StudentPublicationLink extends AbstractLink |
10 | 10 | { |
11 | - private $studpub_table = null; |
|
12 | - private $itemprop_table = null; |
|
13 | - |
|
14 | - /** |
|
15 | - * Constructor |
|
16 | - */ |
|
17 | - public function __construct() |
|
18 | - { |
|
19 | - parent::__construct(); |
|
20 | - $this->set_type(LINK_STUDENTPUBLICATION); |
|
21 | - } |
|
22 | - |
|
23 | - /** |
|
24 | - * |
|
25 | - * Returns the URL of a document |
|
26 | - * This function is loaded when using a gradebook as a tab (gradebook = -1) |
|
27 | - * see issue #2705 |
|
28 | - * |
|
29 | - */ |
|
30 | - public function get_view_url($stud_id) |
|
31 | - { |
|
32 | - // find a file uploaded by the given student, |
|
33 | - // with the same title as the evaluation name |
|
34 | - |
|
35 | - $eval = $this->get_evaluation(); |
|
36 | - $stud_id = intval($stud_id); |
|
37 | - |
|
38 | - $sql = 'SELECT pub.url |
|
11 | + private $studpub_table = null; |
|
12 | + private $itemprop_table = null; |
|
13 | + |
|
14 | + /** |
|
15 | + * Constructor |
|
16 | + */ |
|
17 | + public function __construct() |
|
18 | + { |
|
19 | + parent::__construct(); |
|
20 | + $this->set_type(LINK_STUDENTPUBLICATION); |
|
21 | + } |
|
22 | + |
|
23 | + /** |
|
24 | + * |
|
25 | + * Returns the URL of a document |
|
26 | + * This function is loaded when using a gradebook as a tab (gradebook = -1) |
|
27 | + * see issue #2705 |
|
28 | + * |
|
29 | + */ |
|
30 | + public function get_view_url($stud_id) |
|
31 | + { |
|
32 | + // find a file uploaded by the given student, |
|
33 | + // with the same title as the evaluation name |
|
34 | + |
|
35 | + $eval = $this->get_evaluation(); |
|
36 | + $stud_id = intval($stud_id); |
|
37 | + |
|
38 | + $sql = 'SELECT pub.url |
|
39 | 39 | FROM '.$this->get_itemprop_table().' prop, '.$this->get_studpub_table().' pub' |
40 | - ." WHERE |
|
40 | + ." WHERE |
|
41 | 41 | prop.c_id = ".$this->course_id." AND |
42 | 42 | pub.c_id = ".$this->course_id." AND |
43 | 43 | prop.tool = 'work'" |
44 | - .' AND prop.insert_user_id = '.$stud_id |
|
45 | - .' AND prop.ref = pub.id' |
|
46 | - ." AND pub.title = '".Database::escape_string($eval->get_name())."' AND pub.session_id=".api_get_session_id().""; |
|
47 | - |
|
48 | - $result = Database::query($sql); |
|
49 | - if ($fileurl = Database::fetch_row($result)) { |
|
50 | - return null; |
|
51 | - } else { |
|
52 | - return null; |
|
53 | - } |
|
54 | - } |
|
55 | - |
|
56 | - public function get_type_name() |
|
57 | - { |
|
58 | - return get_lang('Works'); |
|
59 | - } |
|
60 | - |
|
61 | - public function is_allowed_to_change_name() |
|
62 | - { |
|
63 | - return false; |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * Generate an array of exercises that a teacher hasn't created a link for. |
|
68 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
69 | - */ |
|
70 | - public function get_not_created_links() |
|
71 | - { |
|
72 | - return false; |
|
73 | - if (empty($this->course_code)) { |
|
74 | - die('Error in get_not_created_links() : course code not set'); |
|
75 | - } |
|
76 | - $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
77 | - |
|
78 | - $sql = 'SELECT id, url from '.$this->get_studpub_table() |
|
79 | - .' pup WHERE c_id = '.$this->course_id.' AND has_properties != '."''".' AND id NOT IN' |
|
80 | - .' (SELECT ref_id FROM '.$tbl_grade_links |
|
81 | - .' WHERE type = '.LINK_STUDENTPUBLICATION |
|
82 | - ." AND course_code = '".Database::escape_string($this->get_course_code())."'" |
|
83 | - .') AND pub.session_id='.api_get_session_id().''; |
|
84 | - |
|
85 | - $result = Database::query($sql); |
|
86 | - |
|
87 | - $cats=array(); |
|
88 | - while ($data=Database::fetch_array($result)) { |
|
89 | - $cats[] = array ($data['id'], $data['url']); |
|
90 | - } |
|
91 | - return $cats; |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * Generate an array of all exercises available. |
|
96 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
97 | - */ |
|
98 | - public function get_all_links() |
|
99 | - { |
|
100 | - if (empty($this->course_code)) { |
|
101 | - die('Error in get_not_created_links() : course code not set'); |
|
102 | - } |
|
103 | - $tbl_grade_links = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
|
104 | - |
|
105 | - $session_id = api_get_session_id(); |
|
106 | - /* |
|
44 | + .' AND prop.insert_user_id = '.$stud_id |
|
45 | + .' AND prop.ref = pub.id' |
|
46 | + ." AND pub.title = '".Database::escape_string($eval->get_name())."' AND pub.session_id=".api_get_session_id().""; |
|
47 | + |
|
48 | + $result = Database::query($sql); |
|
49 | + if ($fileurl = Database::fetch_row($result)) { |
|
50 | + return null; |
|
51 | + } else { |
|
52 | + return null; |
|
53 | + } |
|
54 | + } |
|
55 | + |
|
56 | + public function get_type_name() |
|
57 | + { |
|
58 | + return get_lang('Works'); |
|
59 | + } |
|
60 | + |
|
61 | + public function is_allowed_to_change_name() |
|
62 | + { |
|
63 | + return false; |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * Generate an array of exercises that a teacher hasn't created a link for. |
|
68 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
69 | + */ |
|
70 | + public function get_not_created_links() |
|
71 | + { |
|
72 | + return false; |
|
73 | + if (empty($this->course_code)) { |
|
74 | + die('Error in get_not_created_links() : course code not set'); |
|
75 | + } |
|
76 | + $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
77 | + |
|
78 | + $sql = 'SELECT id, url from '.$this->get_studpub_table() |
|
79 | + .' pup WHERE c_id = '.$this->course_id.' AND has_properties != '."''".' AND id NOT IN' |
|
80 | + .' (SELECT ref_id FROM '.$tbl_grade_links |
|
81 | + .' WHERE type = '.LINK_STUDENTPUBLICATION |
|
82 | + ." AND course_code = '".Database::escape_string($this->get_course_code())."'" |
|
83 | + .') AND pub.session_id='.api_get_session_id().''; |
|
84 | + |
|
85 | + $result = Database::query($sql); |
|
86 | + |
|
87 | + $cats=array(); |
|
88 | + while ($data=Database::fetch_array($result)) { |
|
89 | + $cats[] = array ($data['id'], $data['url']); |
|
90 | + } |
|
91 | + return $cats; |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * Generate an array of all exercises available. |
|
96 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
97 | + */ |
|
98 | + public function get_all_links() |
|
99 | + { |
|
100 | + if (empty($this->course_code)) { |
|
101 | + die('Error in get_not_created_links() : course code not set'); |
|
102 | + } |
|
103 | + $tbl_grade_links = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
|
104 | + |
|
105 | + $session_id = api_get_session_id(); |
|
106 | + /* |
|
107 | 107 | if (empty($session_id)) { |
108 | 108 | $session_condition = api_get_session_condition(0, true); |
109 | 109 | } else { |
@@ -112,68 +112,68 @@ discard block |
||
112 | 112 | $sql = "SELECT id, url, title FROM $tbl_grade_links |
113 | 113 | WHERE c_id = {$this->course_id} AND filetype='folder' AND active = 1 $session_condition ";*/ |
114 | 114 | |
115 | - //Only show works from the session |
|
116 | - //AND has_properties != '' |
|
117 | - $sql = "SELECT id, url, title FROM $tbl_grade_links |
|
115 | + //Only show works from the session |
|
116 | + //AND has_properties != '' |
|
117 | + $sql = "SELECT id, url, title FROM $tbl_grade_links |
|
118 | 118 | WHERE |
119 | 119 | c_id = {$this->course_id} AND |
120 | 120 | active = 1 AND |
121 | 121 | filetype='folder' AND |
122 | 122 | session_id = ".api_get_session_id().""; |
123 | 123 | |
124 | - $result = Database::query($sql); |
|
125 | - while ($data = Database::fetch_array($result)) { |
|
126 | - $work_name = $data['title']; |
|
127 | - if (empty($work_name)) { |
|
128 | - $work_name = basename($data['url']); |
|
129 | - } |
|
130 | - $cats[] = array ($data['id'], $work_name); |
|
131 | - } |
|
132 | - $cats=isset($cats) ? $cats : array(); |
|
133 | - return $cats; |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * Has anyone done this exercise yet ? |
|
138 | - */ |
|
139 | - public function has_results() |
|
140 | - { |
|
141 | - $tbl_grade_links = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
|
142 | - $sql = 'SELECT count(*) AS number FROM '.$tbl_grade_links." |
|
124 | + $result = Database::query($sql); |
|
125 | + while ($data = Database::fetch_array($result)) { |
|
126 | + $work_name = $data['title']; |
|
127 | + if (empty($work_name)) { |
|
128 | + $work_name = basename($data['url']); |
|
129 | + } |
|
130 | + $cats[] = array ($data['id'], $work_name); |
|
131 | + } |
|
132 | + $cats=isset($cats) ? $cats : array(); |
|
133 | + return $cats; |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * Has anyone done this exercise yet ? |
|
138 | + */ |
|
139 | + public function has_results() |
|
140 | + { |
|
141 | + $tbl_grade_links = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
|
142 | + $sql = 'SELECT count(*) AS number FROM '.$tbl_grade_links." |
|
143 | 143 | WHERE c_id = {$this->course_id} AND |
144 | 144 | parent_id = '".intval($this->get_ref_id())."' AND |
145 | 145 | session_id =".api_get_session_id().""; |
146 | - $result = Database::query($sql); |
|
147 | - $number = Database::fetch_row($result); |
|
148 | - return ($number[0] != 0); |
|
149 | - } |
|
150 | - |
|
151 | - /** |
|
152 | - * @param null $stud_id |
|
153 | - * @return array|null |
|
154 | - */ |
|
155 | - public function calc_score($stud_id = null, $type = null) |
|
156 | - { |
|
157 | - $stud_id = intval($stud_id); |
|
158 | - $table = Database::get_course_table(TABLE_STUDENT_PUBLICATION); |
|
159 | - $sql = 'SELECT * FROM '.$table." |
|
146 | + $result = Database::query($sql); |
|
147 | + $number = Database::fetch_row($result); |
|
148 | + return ($number[0] != 0); |
|
149 | + } |
|
150 | + |
|
151 | + /** |
|
152 | + * @param null $stud_id |
|
153 | + * @return array|null |
|
154 | + */ |
|
155 | + public function calc_score($stud_id = null, $type = null) |
|
156 | + { |
|
157 | + $stud_id = intval($stud_id); |
|
158 | + $table = Database::get_course_table(TABLE_STUDENT_PUBLICATION); |
|
159 | + $sql = 'SELECT * FROM '.$table." |
|
160 | 160 | WHERE |
161 | 161 | c_id = {$this->course_id} AND |
162 | 162 | id = '".intval($this->get_ref_id())."' AND |
163 | 163 | session_id = ".api_get_session_id()." |
164 | 164 | " |
165 | - ; |
|
165 | + ; |
|
166 | 166 | |
167 | - $query = Database::query($sql); |
|
168 | - $assignment = Database::fetch_array($query); |
|
167 | + $query = Database::query($sql); |
|
168 | + $assignment = Database::fetch_array($query); |
|
169 | 169 | |
170 | - if (count($assignment) == 0) { |
|
171 | - $parentId = '0'; |
|
172 | - } else { |
|
173 | - $parentId = $assignment['id']; |
|
174 | - } |
|
170 | + if (count($assignment) == 0) { |
|
171 | + $parentId = '0'; |
|
172 | + } else { |
|
173 | + $parentId = $assignment['id']; |
|
174 | + } |
|
175 | 175 | |
176 | - $sql = 'SELECT * FROM '.$table.' |
|
176 | + $sql = 'SELECT * FROM '.$table.' |
|
177 | 177 | WHERE |
178 | 178 | c_id = '.$this->course_id.' AND |
179 | 179 | active = 1 AND |
@@ -181,190 +181,190 @@ discard block |
||
181 | 181 | session_id = '.api_get_session_id() .' AND |
182 | 182 | qualificator_id <> 0 |
183 | 183 | '; |
184 | - if (!empty($stud_id)) { |
|
185 | - $sql .= " AND user_id = $stud_id "; |
|
186 | - } |
|
187 | - |
|
188 | - $order = api_get_setting('student_publication_to_take_in_gradebook'); |
|
189 | - |
|
190 | - switch ($order) { |
|
191 | - case 'last': |
|
192 | - // latest attempt |
|
193 | - $sql .= ' ORDER BY sent_date DESC'; |
|
194 | - break; |
|
195 | - case 'first': |
|
196 | - default: |
|
197 | - // first attempt |
|
198 | - $sql .= ' ORDER BY id'; |
|
199 | - break; |
|
200 | - } |
|
201 | - |
|
202 | - $scores = Database::query($sql); |
|
203 | - |
|
204 | - // for 1 student |
|
205 | - if (!empty($stud_id)) { |
|
206 | - if ($data = Database::fetch_array($scores)) { |
|
207 | - return array( |
|
208 | - $data['qualification'], |
|
209 | - $assignment['qualification'] |
|
210 | - ); |
|
211 | - } else { |
|
212 | - return ''; |
|
213 | - } |
|
214 | - } else { |
|
215 | - $students = array(); // user list, needed to make sure we only |
|
216 | - // take first attempts into account |
|
217 | - $rescount = 0; |
|
218 | - $sum = 0; |
|
219 | - $bestResult = 0; |
|
220 | - $weight = 0; |
|
221 | - $sumResult = 0; |
|
222 | - $myResult = 0; |
|
223 | - |
|
224 | - while ($data = Database::fetch_array($scores)) { |
|
225 | - if (!(array_key_exists($data['user_id'], $students))) { |
|
226 | - if ($assignment['qualification'] != 0) { |
|
227 | - $students[$data['user_id']] = $data['qualification']; |
|
228 | - $rescount++; |
|
229 | - $sum += $data['qualification'] / $assignment['qualification']; |
|
230 | - $sumResult += $data['qualification']; |
|
231 | - |
|
232 | - if ($data['qualification'] > $bestResult) { |
|
233 | - $bestResult = $data['qualification']; |
|
234 | - } |
|
235 | - $weight = $assignment['qualification']; |
|
236 | - } |
|
237 | - } |
|
238 | - } |
|
239 | - |
|
240 | - if ($rescount == 0) { |
|
241 | - return null; |
|
242 | - } else { |
|
243 | - switch ($type) { |
|
244 | - case 'best': |
|
245 | - return array($bestResult, $weight); |
|
246 | - break; |
|
247 | - case 'average': |
|
248 | - return array($sumResult/$rescount, $weight); |
|
249 | - break; |
|
250 | - case 'ranking': |
|
251 | - return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
252 | - break; |
|
253 | - default: |
|
254 | - return array($sum, $rescount); |
|
255 | - break; |
|
256 | - } |
|
257 | - } |
|
258 | - } |
|
259 | - } |
|
260 | - |
|
261 | - /** |
|
262 | - * Lazy load function to get the database table of the student publications |
|
263 | - */ |
|
264 | - private function get_studpub_table() |
|
265 | - { |
|
266 | - return $this->studpub_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
|
267 | - } |
|
268 | - |
|
269 | - /** |
|
270 | - * Lazy load function to get the database table of the item properties |
|
271 | - */ |
|
272 | - private function get_itemprop_table() |
|
273 | - { |
|
274 | - return $this->itemprop_table = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
275 | - } |
|
276 | - |
|
277 | - public function needs_name_and_description() |
|
278 | - { |
|
279 | - return false; |
|
280 | - } |
|
281 | - |
|
282 | - public function get_name() |
|
283 | - { |
|
284 | - $this->get_exercise_data(); |
|
285 | - return (isset($this->exercise_data['title']) && !empty($this->exercise_data['title'])) ? $this->exercise_data['title'] : get_lang('Untitled'); |
|
286 | - } |
|
287 | - |
|
288 | - public function get_description() |
|
289 | - { |
|
290 | - $this->get_exercise_data(); |
|
291 | - return isset($this->exercise_data['description']) ? $this->exercise_data['description'] : null; |
|
292 | - } |
|
293 | - |
|
294 | - public function get_test_id() |
|
295 | - { |
|
296 | - return 'DEBUG:ID'; |
|
297 | - } |
|
298 | - |
|
299 | - public function get_link() |
|
300 | - { |
|
301 | - $session_id = api_get_session_id(); |
|
302 | - $url = api_get_path(WEB_PATH).'main/work/work.php?session_id='.$session_id.'&cidReq='.$this->get_course_code().'&id='.$this->exercise_data['id'].'&gradebook=view'; |
|
303 | - return $url; |
|
304 | - } |
|
305 | - |
|
306 | - private function get_exercise_data() |
|
307 | - { |
|
308 | - $tbl_name = $this->get_studpub_table(); |
|
309 | - $course_info = api_get_course_info($this->get_course_code()); |
|
310 | - if ($tbl_name=='') { |
|
311 | - return false; |
|
312 | - } elseif (!isset($this->exercise_data)) { |
|
313 | - $sql = 'SELECT * FROM '.$this->get_studpub_table()." |
|
184 | + if (!empty($stud_id)) { |
|
185 | + $sql .= " AND user_id = $stud_id "; |
|
186 | + } |
|
187 | + |
|
188 | + $order = api_get_setting('student_publication_to_take_in_gradebook'); |
|
189 | + |
|
190 | + switch ($order) { |
|
191 | + case 'last': |
|
192 | + // latest attempt |
|
193 | + $sql .= ' ORDER BY sent_date DESC'; |
|
194 | + break; |
|
195 | + case 'first': |
|
196 | + default: |
|
197 | + // first attempt |
|
198 | + $sql .= ' ORDER BY id'; |
|
199 | + break; |
|
200 | + } |
|
201 | + |
|
202 | + $scores = Database::query($sql); |
|
203 | + |
|
204 | + // for 1 student |
|
205 | + if (!empty($stud_id)) { |
|
206 | + if ($data = Database::fetch_array($scores)) { |
|
207 | + return array( |
|
208 | + $data['qualification'], |
|
209 | + $assignment['qualification'] |
|
210 | + ); |
|
211 | + } else { |
|
212 | + return ''; |
|
213 | + } |
|
214 | + } else { |
|
215 | + $students = array(); // user list, needed to make sure we only |
|
216 | + // take first attempts into account |
|
217 | + $rescount = 0; |
|
218 | + $sum = 0; |
|
219 | + $bestResult = 0; |
|
220 | + $weight = 0; |
|
221 | + $sumResult = 0; |
|
222 | + $myResult = 0; |
|
223 | + |
|
224 | + while ($data = Database::fetch_array($scores)) { |
|
225 | + if (!(array_key_exists($data['user_id'], $students))) { |
|
226 | + if ($assignment['qualification'] != 0) { |
|
227 | + $students[$data['user_id']] = $data['qualification']; |
|
228 | + $rescount++; |
|
229 | + $sum += $data['qualification'] / $assignment['qualification']; |
|
230 | + $sumResult += $data['qualification']; |
|
231 | + |
|
232 | + if ($data['qualification'] > $bestResult) { |
|
233 | + $bestResult = $data['qualification']; |
|
234 | + } |
|
235 | + $weight = $assignment['qualification']; |
|
236 | + } |
|
237 | + } |
|
238 | + } |
|
239 | + |
|
240 | + if ($rescount == 0) { |
|
241 | + return null; |
|
242 | + } else { |
|
243 | + switch ($type) { |
|
244 | + case 'best': |
|
245 | + return array($bestResult, $weight); |
|
246 | + break; |
|
247 | + case 'average': |
|
248 | + return array($sumResult/$rescount, $weight); |
|
249 | + break; |
|
250 | + case 'ranking': |
|
251 | + return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
252 | + break; |
|
253 | + default: |
|
254 | + return array($sum, $rescount); |
|
255 | + break; |
|
256 | + } |
|
257 | + } |
|
258 | + } |
|
259 | + } |
|
260 | + |
|
261 | + /** |
|
262 | + * Lazy load function to get the database table of the student publications |
|
263 | + */ |
|
264 | + private function get_studpub_table() |
|
265 | + { |
|
266 | + return $this->studpub_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
|
267 | + } |
|
268 | + |
|
269 | + /** |
|
270 | + * Lazy load function to get the database table of the item properties |
|
271 | + */ |
|
272 | + private function get_itemprop_table() |
|
273 | + { |
|
274 | + return $this->itemprop_table = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
275 | + } |
|
276 | + |
|
277 | + public function needs_name_and_description() |
|
278 | + { |
|
279 | + return false; |
|
280 | + } |
|
281 | + |
|
282 | + public function get_name() |
|
283 | + { |
|
284 | + $this->get_exercise_data(); |
|
285 | + return (isset($this->exercise_data['title']) && !empty($this->exercise_data['title'])) ? $this->exercise_data['title'] : get_lang('Untitled'); |
|
286 | + } |
|
287 | + |
|
288 | + public function get_description() |
|
289 | + { |
|
290 | + $this->get_exercise_data(); |
|
291 | + return isset($this->exercise_data['description']) ? $this->exercise_data['description'] : null; |
|
292 | + } |
|
293 | + |
|
294 | + public function get_test_id() |
|
295 | + { |
|
296 | + return 'DEBUG:ID'; |
|
297 | + } |
|
298 | + |
|
299 | + public function get_link() |
|
300 | + { |
|
301 | + $session_id = api_get_session_id(); |
|
302 | + $url = api_get_path(WEB_PATH).'main/work/work.php?session_id='.$session_id.'&cidReq='.$this->get_course_code().'&id='.$this->exercise_data['id'].'&gradebook=view'; |
|
303 | + return $url; |
|
304 | + } |
|
305 | + |
|
306 | + private function get_exercise_data() |
|
307 | + { |
|
308 | + $tbl_name = $this->get_studpub_table(); |
|
309 | + $course_info = api_get_course_info($this->get_course_code()); |
|
310 | + if ($tbl_name=='') { |
|
311 | + return false; |
|
312 | + } elseif (!isset($this->exercise_data)) { |
|
313 | + $sql = 'SELECT * FROM '.$this->get_studpub_table()." |
|
314 | 314 | WHERE |
315 | 315 | c_id ='".$course_info['real_id']."' AND |
316 | 316 | id = '".intval($this->get_ref_id())."' "; |
317 | - $query = Database::query($sql); |
|
318 | - $this->exercise_data = Database::fetch_array($query); |
|
319 | - } |
|
320 | - return $this->exercise_data; |
|
321 | - } |
|
322 | - |
|
323 | - public function needs_max() |
|
324 | - { |
|
325 | - return false; |
|
326 | - } |
|
327 | - |
|
328 | - public function needs_results() |
|
329 | - { |
|
330 | - return false; |
|
331 | - } |
|
332 | - |
|
333 | - public function is_valid_link() |
|
334 | - { |
|
335 | - $sql = 'SELECT count(id) FROM '.$this->get_studpub_table().' |
|
317 | + $query = Database::query($sql); |
|
318 | + $this->exercise_data = Database::fetch_array($query); |
|
319 | + } |
|
320 | + return $this->exercise_data; |
|
321 | + } |
|
322 | + |
|
323 | + public function needs_max() |
|
324 | + { |
|
325 | + return false; |
|
326 | + } |
|
327 | + |
|
328 | + public function needs_results() |
|
329 | + { |
|
330 | + return false; |
|
331 | + } |
|
332 | + |
|
333 | + public function is_valid_link() |
|
334 | + { |
|
335 | + $sql = 'SELECT count(id) FROM '.$this->get_studpub_table().' |
|
336 | 336 | WHERE c_id = "'.$this->course_id.'" AND id = '.intval($this->get_ref_id()).''; |
337 | - $result = Database::query($sql); |
|
338 | - $number = Database::fetch_row($result); |
|
339 | - return ($number[0] != 0); |
|
340 | - } |
|
341 | - |
|
342 | - public function get_icon_name() |
|
343 | - { |
|
344 | - return 'studentpublication'; |
|
345 | - } |
|
346 | - |
|
347 | - public function save_linked_data() |
|
348 | - { |
|
349 | - $weight = (float)$this->get_weight(); |
|
350 | - $ref_id = $this->get_ref_id(); |
|
351 | - |
|
352 | - if (!empty($ref_id)) { |
|
353 | - //Cleans works |
|
354 | - $sql = 'UPDATE '.$this->get_studpub_table().' SET weight= '.$weight.' |
|
337 | + $result = Database::query($sql); |
|
338 | + $number = Database::fetch_row($result); |
|
339 | + return ($number[0] != 0); |
|
340 | + } |
|
341 | + |
|
342 | + public function get_icon_name() |
|
343 | + { |
|
344 | + return 'studentpublication'; |
|
345 | + } |
|
346 | + |
|
347 | + public function save_linked_data() |
|
348 | + { |
|
349 | + $weight = (float)$this->get_weight(); |
|
350 | + $ref_id = $this->get_ref_id(); |
|
351 | + |
|
352 | + if (!empty($ref_id)) { |
|
353 | + //Cleans works |
|
354 | + $sql = 'UPDATE '.$this->get_studpub_table().' SET weight= '.$weight.' |
|
355 | 355 | WHERE c_id = '.$this->course_id.' AND id ='.$ref_id; |
356 | - Database::query($sql); |
|
357 | - } |
|
358 | - } |
|
359 | - |
|
360 | - public function delete_linked_data() |
|
361 | - { |
|
362 | - $ref_id = $this->get_ref_id(); |
|
363 | - if (!empty($ref_id)) { |
|
364 | - //Cleans works |
|
365 | - $sql = 'UPDATE '.$this->get_studpub_table().' SET weight=0 |
|
356 | + Database::query($sql); |
|
357 | + } |
|
358 | + } |
|
359 | + |
|
360 | + public function delete_linked_data() |
|
361 | + { |
|
362 | + $ref_id = $this->get_ref_id(); |
|
363 | + if (!empty($ref_id)) { |
|
364 | + //Cleans works |
|
365 | + $sql = 'UPDATE '.$this->get_studpub_table().' SET weight=0 |
|
366 | 366 | WHERE c_id = '.$this->course_id.' AND id ='.$ref_id; |
367 | - Database::query($sql); |
|
368 | - } |
|
369 | - } |
|
367 | + Database::query($sql); |
|
368 | + } |
|
369 | + } |
|
370 | 370 | } |
@@ -249,7 +249,7 @@ |
||
249 | 249 | } |
250 | 250 | } |
251 | 251 | |
252 | - $modify_icons .= '<a href="gradebook_edit_all.php?selectcat=' .$cat->get_id() . '&cidReq=' . $cat->get_course_code() . '&id_session='.$cat->get_session_id().'">' . |
|
252 | + $modify_icons .= '<a href="gradebook_edit_all.php?selectcat=' .$cat->get_id() . '&cidReq=' . $cat->get_course_code() . '&id_session='.$cat->get_session_id().'">' . |
|
253 | 253 | Display::return_icon( |
254 | 254 | 'percentage.png', |
255 | 255 | get_lang('EditAllWeights'), |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | array('name'=>'name', 'index'=>'name', 'width'=>'80', 'align'=>'left'), |
81 | 81 | array('name'=>'description', 'index'=>'description', 'width'=>'500', 'align'=>'left','sortable'=>'false'), |
82 | 82 | array('name'=>'actions', 'index'=>'actions', 'width'=>'100', 'align'=>'left','formatter'=>'action_formatter','sortable'=>'false') |
83 | - ); |
|
83 | + ); |
|
84 | 84 | //Autowidth |
85 | 85 | $extra_params['autowidth'] = 'true'; |
86 | 86 | //height auto |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | //With this function we can add actions to the jgrid (edit, delete, etc) |
90 | 90 | $action_links = 'function action_formatter(cellvalue, options, rowObject) { |
91 | 91 | return \'<a href="?action=edit&id=\'+options.rowId+\'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'. |
92 | - ' <a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;" href="?sec_token='.$token.'&action=delete&id=\'+options.rowId+\'">'.Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'. |
|
93 | - '\'; |
|
92 | + ' <a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;" href="?sec_token='.$token.'&action=delete&id=\'+options.rowId+\'">'.Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'. |
|
93 | + '\'; |
|
94 | 94 | }'; |
95 | 95 | ?> |
96 | 96 | <script> |
@@ -87,7 +87,7 @@ |
||
87 | 87 | <?php |
88 | 88 | echo Display::get_alphabet_options($firstLetterUserGroup); |
89 | 89 | echo Display::get_numeric_options(0, 9, $firstLetterUserGroup); |
90 | - ?> |
|
90 | + ?> |
|
91 | 91 | </select> |
92 | 92 | </td> |
93 | 93 | <td width="20%"> </td> |
@@ -18,93 +18,93 @@ discard block |
||
18 | 18 | |
19 | 19 | $defaults = array(); |
20 | 20 | $term_preview = array( |
21 | - 'type' => 0, |
|
22 | - 'content' => '', |
|
23 | - 'changes' => '', |
|
21 | + 'type' => 0, |
|
22 | + 'content' => '', |
|
23 | + 'changes' => '', |
|
24 | 24 | ); |
25 | 25 | if ($form->validate()) { |
26 | - $check = Security::check_token('post'); |
|
27 | - if ($check) { |
|
28 | - $values = $form->getSubmitValues(); |
|
29 | - $lang = $values['language']; |
|
30 | - //language id |
|
31 | - $lang = api_get_language_id($lang); |
|
32 | - |
|
33 | - if (isset($values['type'])) { |
|
34 | - $type = $values['type']; |
|
35 | - } else { |
|
36 | - $type = 0; |
|
37 | - } |
|
38 | - if (isset($values['content'])) { |
|
39 | - $content = $values['content']; |
|
40 | - } else { |
|
41 | - $content = ''; |
|
42 | - } |
|
43 | - if (isset($values['changes'])) { |
|
44 | - $changes = $values['changes']; |
|
45 | - } else { |
|
46 | - $changes = ''; |
|
47 | - } |
|
48 | - $navigator_info = api_get_navigator(); |
|
49 | - |
|
50 | - if ($navigator_info['name']=='Internet Explorer' && $navigator_info['version']=='6') { |
|
51 | - if (isset($values['preview'])) { |
|
52 | - $submit ='preview'; |
|
53 | - } elseif (isset($values['save'])) { |
|
54 | - $submit ='save'; |
|
55 | - } elseif (isset($values['back'])) { |
|
56 | - $submit ='back'; |
|
57 | - } |
|
58 | - } else { |
|
59 | - $submit = $values['send']; |
|
60 | - } |
|
61 | - |
|
62 | - $default['content'] = $content; |
|
63 | - if (isset($values['language'])) { |
|
64 | - if ($submit == 'back') { |
|
65 | - header('Location: legal_add.php'); |
|
66 | - exit; |
|
67 | - } elseif ($submit == 'save') { |
|
68 | - $insert_result = LegalManager::add($lang, $content, $type, $changes); |
|
69 | - if ($insert_result ) { |
|
70 | - $message = get_lang('TermAndConditionSaved'); |
|
71 | - } else { |
|
72 | - $message = get_lang('TermAndConditionNotSaved'); |
|
73 | - } |
|
74 | - Security::clear_token(); |
|
75 | - $tok = Security::get_token(); |
|
76 | - header('Location: legal_list.php?action=show_message&message='.urlencode($message).'&sec_token='.$tok); |
|
77 | - exit(); |
|
78 | - } elseif ($submit=='preview') { |
|
79 | - $defaults['type'] = $type; |
|
80 | - $defaults['content'] = $content; |
|
81 | - $defaults['changes'] = $changes; |
|
82 | - $term_preview = $defaults; |
|
83 | - $term_preview['type'] = intval($_POST['type']); |
|
84 | - } else { |
|
85 | - $my_lang = $_POST['language']; |
|
86 | - if (isset($_POST['language'])){ |
|
87 | - $all_langs = api_get_languages(); |
|
88 | - if (in_array($my_lang, $all_langs['folder'])){ |
|
89 | - $language = api_get_language_id($my_lang); |
|
90 | - $term_preview = LegalManager::get_last_condition($language); |
|
91 | - $defaults = $term_preview; |
|
92 | - if (!$term_preview) { |
|
93 | - // there are not terms and conditions |
|
94 | - $term_preview['type']=-1; |
|
95 | - $defaults['type']=0; |
|
96 | - } |
|
97 | - } |
|
98 | - } |
|
99 | - } |
|
100 | - } |
|
101 | - } |
|
26 | + $check = Security::check_token('post'); |
|
27 | + if ($check) { |
|
28 | + $values = $form->getSubmitValues(); |
|
29 | + $lang = $values['language']; |
|
30 | + //language id |
|
31 | + $lang = api_get_language_id($lang); |
|
32 | + |
|
33 | + if (isset($values['type'])) { |
|
34 | + $type = $values['type']; |
|
35 | + } else { |
|
36 | + $type = 0; |
|
37 | + } |
|
38 | + if (isset($values['content'])) { |
|
39 | + $content = $values['content']; |
|
40 | + } else { |
|
41 | + $content = ''; |
|
42 | + } |
|
43 | + if (isset($values['changes'])) { |
|
44 | + $changes = $values['changes']; |
|
45 | + } else { |
|
46 | + $changes = ''; |
|
47 | + } |
|
48 | + $navigator_info = api_get_navigator(); |
|
49 | + |
|
50 | + if ($navigator_info['name']=='Internet Explorer' && $navigator_info['version']=='6') { |
|
51 | + if (isset($values['preview'])) { |
|
52 | + $submit ='preview'; |
|
53 | + } elseif (isset($values['save'])) { |
|
54 | + $submit ='save'; |
|
55 | + } elseif (isset($values['back'])) { |
|
56 | + $submit ='back'; |
|
57 | + } |
|
58 | + } else { |
|
59 | + $submit = $values['send']; |
|
60 | + } |
|
61 | + |
|
62 | + $default['content'] = $content; |
|
63 | + if (isset($values['language'])) { |
|
64 | + if ($submit == 'back') { |
|
65 | + header('Location: legal_add.php'); |
|
66 | + exit; |
|
67 | + } elseif ($submit == 'save') { |
|
68 | + $insert_result = LegalManager::add($lang, $content, $type, $changes); |
|
69 | + if ($insert_result ) { |
|
70 | + $message = get_lang('TermAndConditionSaved'); |
|
71 | + } else { |
|
72 | + $message = get_lang('TermAndConditionNotSaved'); |
|
73 | + } |
|
74 | + Security::clear_token(); |
|
75 | + $tok = Security::get_token(); |
|
76 | + header('Location: legal_list.php?action=show_message&message='.urlencode($message).'&sec_token='.$tok); |
|
77 | + exit(); |
|
78 | + } elseif ($submit=='preview') { |
|
79 | + $defaults['type'] = $type; |
|
80 | + $defaults['content'] = $content; |
|
81 | + $defaults['changes'] = $changes; |
|
82 | + $term_preview = $defaults; |
|
83 | + $term_preview['type'] = intval($_POST['type']); |
|
84 | + } else { |
|
85 | + $my_lang = $_POST['language']; |
|
86 | + if (isset($_POST['language'])){ |
|
87 | + $all_langs = api_get_languages(); |
|
88 | + if (in_array($my_lang, $all_langs['folder'])){ |
|
89 | + $language = api_get_language_id($my_lang); |
|
90 | + $term_preview = LegalManager::get_last_condition($language); |
|
91 | + $defaults = $term_preview; |
|
92 | + if (!$term_preview) { |
|
93 | + // there are not terms and conditions |
|
94 | + $term_preview['type']=-1; |
|
95 | + $defaults['type']=0; |
|
96 | + } |
|
97 | + } |
|
98 | + } |
|
99 | + } |
|
100 | + } |
|
101 | + } |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | $form->setDefaults($defaults); |
105 | 105 | |
106 | 106 | if (isset($_POST['send'])) { |
107 | - Security::clear_token(); |
|
107 | + Security::clear_token(); |
|
108 | 108 | } |
109 | 109 | $token = Security::get_token(); |
110 | 110 | |
@@ -115,34 +115,34 @@ discard block |
||
115 | 115 | |
116 | 116 | if (isset($_POST['language'])) { |
117 | 117 | |
118 | - $form->addElement('static', Security::remove_XSS($_POST['language'])); |
|
119 | - $form->addElement('hidden', 'language',Security::remove_XSS($_POST['language'])); |
|
120 | - $form->addHtmlEditor('content', get_lang('Content'), true, false, array('ToolbarSet' => 'terms_and_conditions', 'Width' => '100%', 'Height' => '250')); |
|
118 | + $form->addElement('static', Security::remove_XSS($_POST['language'])); |
|
119 | + $form->addElement('hidden', 'language',Security::remove_XSS($_POST['language'])); |
|
120 | + $form->addHtmlEditor('content', get_lang('Content'), true, false, array('ToolbarSet' => 'terms_and_conditions', 'Width' => '100%', 'Height' => '250')); |
|
121 | 121 | |
122 | - $form->addElement('radio', 'type', '', get_lang('HTMLText') ,'0'); |
|
123 | - $form->addElement('radio', 'type', '', get_lang('PageLink') ,'1'); |
|
124 | - $form->addElement('textarea', 'changes', get_lang('ExplainChanges'),array('width'=>'20')); |
|
122 | + $form->addElement('radio', 'type', '', get_lang('HTMLText') ,'0'); |
|
123 | + $form->addElement('radio', 'type', '', get_lang('PageLink') ,'1'); |
|
124 | + $form->addElement('textarea', 'changes', get_lang('ExplainChanges'),array('width'=>'20')); |
|
125 | 125 | |
126 | - $preview = LegalManager::show_last_condition($term_preview); |
|
126 | + $preview = LegalManager::show_last_condition($term_preview); |
|
127 | 127 | |
128 | - if ($term_preview['type']!=-1) { |
|
129 | - $form->addElement('label', get_lang('Preview'), $preview); |
|
130 | - } |
|
128 | + if ($term_preview['type']!=-1) { |
|
129 | + $form->addElement('label', get_lang('Preview'), $preview); |
|
130 | + } |
|
131 | 131 | |
132 | - // Submit & preview button |
|
132 | + // Submit & preview button |
|
133 | 133 | $navigator_info = api_get_navigator(); |
134 | 134 | |
135 | 135 | //ie6 fix |
136 | - if ($navigator_info['name']=='Internet Explorer' && $navigator_info['version']=='6') { |
|
137 | - $buttons = '<div class="row" align="center"> |
|
136 | + if ($navigator_info['name']=='Internet Explorer' && $navigator_info['version']=='6') { |
|
137 | + $buttons = '<div class="row" align="center"> |
|
138 | 138 | <div class="formw"> |
139 | 139 | <input type="submit" name="back" value="'.get_lang('Back').'"/> |
140 | 140 | <input type="submit" name="preview" value="'.get_lang('Preview').'"/> |
141 | 141 | <input type="submit" name="save" value="'.get_lang('Save').'"/> |
142 | 142 | </div> |
143 | 143 | </div>'; |
144 | - $form->addElement('html',$buttons); |
|
145 | - } else { |
|
144 | + $form->addElement('html',$buttons); |
|
145 | + } else { |
|
146 | 146 | $buttons = '<div class="row" align="center"> |
147 | 147 | <div class="formw"> |
148 | 148 | <button type="submit" class="back" name="send" value="back">'.get_lang('Back').'</button> |
@@ -150,11 +150,11 @@ discard block |
||
150 | 150 | <button type="submit" class="save" name="send" value="save">'.get_lang('Save').'</button> |
151 | 151 | </div> |
152 | 152 | </div>'; |
153 | - $form->addElement('html',$buttons); |
|
154 | - } |
|
153 | + $form->addElement('html',$buttons); |
|
154 | + } |
|
155 | 155 | } else { |
156 | - $form->addElement('select_language', 'language', get_lang('Language'),null,array()); |
|
157 | - $form->addElement('button', 'send', get_lang('Load')); |
|
156 | + $form->addElement('select_language', 'language', get_lang('Language'),null,array()); |
|
157 | + $form->addElement('button', 'send', get_lang('Load')); |
|
158 | 158 | |
159 | 159 | } |
160 | 160 | |
@@ -176,11 +176,11 @@ discard block |
||
176 | 176 | echo '</div>'; |
177 | 177 | |
178 | 178 | if (isset ($_GET['action'])) { |
179 | - switch ($_GET['action']) { |
|
180 | - case 'show_message' : |
|
181 | - Display :: display_normal_message(stripslashes($_GET['message'])); |
|
182 | - break; |
|
183 | - } |
|
179 | + switch ($_GET['action']) { |
|
180 | + case 'show_message' : |
|
181 | + Display :: display_normal_message(stripslashes($_GET['message'])); |
|
182 | + break; |
|
183 | + } |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | $form->setDefaults($defaults); |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | <select name="firstLetterClass" onchange="javascript:document.formulaire.formSent.value='2'; document.formulaire.submit();"> |
91 | 91 | <option value="">--</option> |
92 | 92 | <?php |
93 | - echo Display::get_alphabet_options($first_letter_class); |
|
94 | - ?> |
|
93 | + echo Display::get_alphabet_options($first_letter_class); |
|
94 | + ?> |
|
95 | 95 | </select> |
96 | 96 | </td> |
97 | 97 | <td width="20%"> </td> |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | <select name="firstLetterCourse" onchange="javascript:document.formulaire.formSent.value='2'; document.formulaire.submit();"> |
103 | 103 | <option value="">--</option> |
104 | 104 | <?php |
105 | - echo Display::get_alphabet_options($first_letter_course); |
|
106 | - ?> |
|
105 | + echo Display::get_alphabet_options($first_letter_course); |
|
106 | + ?> |
|
107 | 107 | </select> |
108 | 108 | </td> |
109 | 109 | </tr> |
@@ -157,27 +157,27 @@ discard block |
||
157 | 157 | $form->addElement('hidden', 'user_id', $user_id); |
158 | 158 | |
159 | 159 | if (api_is_western_name_order()) { |
160 | - // Firstname |
|
161 | - $form->addElement('text', 'firstname', get_lang('FirstName')); |
|
162 | - $form->applyFilter('firstname', 'html_filter'); |
|
163 | - $form->applyFilter('firstname', 'trim'); |
|
164 | - $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required'); |
|
165 | - // Lastname |
|
166 | - $form->addElement('text', 'lastname', get_lang('LastName')); |
|
167 | - $form->applyFilter('lastname', 'html_filter'); |
|
168 | - $form->applyFilter('lastname', 'trim'); |
|
169 | - $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required'); |
|
160 | + // Firstname |
|
161 | + $form->addElement('text', 'firstname', get_lang('FirstName')); |
|
162 | + $form->applyFilter('firstname', 'html_filter'); |
|
163 | + $form->applyFilter('firstname', 'trim'); |
|
164 | + $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required'); |
|
165 | + // Lastname |
|
166 | + $form->addElement('text', 'lastname', get_lang('LastName')); |
|
167 | + $form->applyFilter('lastname', 'html_filter'); |
|
168 | + $form->applyFilter('lastname', 'trim'); |
|
169 | + $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required'); |
|
170 | 170 | } else { |
171 | - // Lastname |
|
172 | - $form->addElement('text', 'lastname', get_lang('LastName')); |
|
173 | - $form->applyFilter('lastname', 'html_filter'); |
|
174 | - $form->applyFilter('lastname', 'trim'); |
|
175 | - $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required'); |
|
176 | - // Firstname |
|
177 | - $form->addElement('text', 'firstname', get_lang('FirstName')); |
|
178 | - $form->applyFilter('firstname', 'html_filter'); |
|
179 | - $form->applyFilter('firstname', 'trim'); |
|
180 | - $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required'); |
|
171 | + // Lastname |
|
172 | + $form->addElement('text', 'lastname', get_lang('LastName')); |
|
173 | + $form->applyFilter('lastname', 'html_filter'); |
|
174 | + $form->applyFilter('lastname', 'trim'); |
|
175 | + $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required'); |
|
176 | + // Firstname |
|
177 | + $form->addElement('text', 'firstname', get_lang('FirstName')); |
|
178 | + $form->applyFilter('firstname', 'html_filter'); |
|
179 | + $form->applyFilter('firstname', 'trim'); |
|
180 | + $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required'); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | // Official code |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | |
200 | 200 | // OpenID |
201 | 201 | if (api_get_setting('openid_authentication') == 'true') { |
202 | - $form->addElement('text', 'openid', get_lang('OpenIDURL')); |
|
202 | + $form->addElement('text', 'openid', get_lang('OpenIDURL')); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | // Phone |
@@ -225,18 +225,18 @@ discard block |
||
225 | 225 | $form->addHidden('cropResult', ''); |
226 | 226 | |
227 | 227 | $form->addRule( |
228 | - 'picture', |
|
229 | - get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', |
|
230 | - 'filetype', |
|
231 | - $allowed_picture_types |
|
228 | + 'picture', |
|
229 | + get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', |
|
230 | + 'filetype', |
|
231 | + $allowed_picture_types |
|
232 | 232 | ); |
233 | 233 | if (strlen($user_data['picture_uri']) > 0) { |
234 | - $form->addElement('checkbox', 'delete_picture', '', get_lang('DelImage')); |
|
234 | + $form->addElement('checkbox', 'delete_picture', '', get_lang('DelImage')); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | // Username |
238 | 238 | if (api_get_setting('login_is_email') != 'true') { |
239 | - $form->addElement('text', 'username', get_lang('LoginName'), array('maxlength' => USERNAME_MAX_LENGTH)); |
|
239 | + $form->addElement('text', 'username', get_lang('LoginName'), array('maxlength' => USERNAME_MAX_LENGTH)); |
|
240 | 240 | $form->addRule('username', get_lang('ThisFieldIsRequired'), 'required'); |
241 | 241 | $form->addRule('username', sprintf(get_lang('UsernameMaxXCharacters'), (string)USERNAME_MAX_LENGTH), 'maxlength', USERNAME_MAX_LENGTH); |
242 | 242 | $form->addRule('username', get_lang('OnlyLettersAndNumbersAllowed'), 'username'); |
@@ -308,15 +308,15 @@ discard block |
||
308 | 308 | |
309 | 309 | // Platform admin |
310 | 310 | if (api_is_platform_admin()) { |
311 | - $group = array(); |
|
312 | - $group[] =$form->createElement('radio', 'platform_admin', null, get_lang('Yes'), 1); |
|
313 | - $group[] =$form->createElement('radio', 'platform_admin', null, get_lang('No'), 0); |
|
311 | + $group = array(); |
|
312 | + $group[] =$form->createElement('radio', 'platform_admin', null, get_lang('Yes'), 1); |
|
313 | + $group[] =$form->createElement('radio', 'platform_admin', null, get_lang('No'), 0); |
|
314 | 314 | |
315 | - $user_data['status'] == 1 ? $display = 'block':$display = 'none'; |
|
315 | + $user_data['status'] == 1 ? $display = 'block':$display = 'none'; |
|
316 | 316 | |
317 | - $form->addElement('html', '<div id="id_platform_admin" style="display:'.$display.'">'); |
|
318 | - $form->addGroup($group, 'admin', get_lang('PlatformAdmin'), null, false); |
|
319 | - $form->addElement('html', '</div>'); |
|
317 | + $form->addElement('html', '<div id="id_platform_admin" style="display:'.$display.'">'); |
|
318 | + $form->addGroup($group, 'admin', get_lang('PlatformAdmin'), null, false); |
|
319 | + $form->addElement('html', '</div>'); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | //Language |
@@ -334,16 +334,16 @@ discard block |
||
334 | 334 | $form->addElement('label', get_lang('RegistrationDate'), $date); |
335 | 335 | |
336 | 336 | if (!$user_data['platform_admin']) { |
337 | - // Expiration Date |
|
338 | - $form->addElement('radio', 'radio_expiration_date', get_lang('ExpirationDate'), get_lang('NeverExpires'), 0); |
|
339 | - $group = array (); |
|
340 | - $group[] = $form->createElement('radio', 'radio_expiration_date', null, get_lang('Enabled'), 1); |
|
341 | - $group[] = $form->createElement('DateTimePicker', 'expiration_date', null, array('onchange' => 'javascript: enable_expiration_date();')); |
|
342 | - $form->addGroup($group, 'max_member_group', null, '', false); |
|
343 | - |
|
344 | - // Active account or inactive account |
|
345 | - $form->addElement('radio', 'active', get_lang('ActiveAccount'), get_lang('Active'), 1); |
|
346 | - $form->addElement('radio', 'active', '', get_lang('Inactive'), 0); |
|
337 | + // Expiration Date |
|
338 | + $form->addElement('radio', 'radio_expiration_date', get_lang('ExpirationDate'), get_lang('NeverExpires'), 0); |
|
339 | + $group = array (); |
|
340 | + $group[] = $form->createElement('radio', 'radio_expiration_date', null, get_lang('Enabled'), 1); |
|
341 | + $group[] = $form->createElement('DateTimePicker', 'expiration_date', null, array('onchange' => 'javascript: enable_expiration_date();')); |
|
342 | + $form->addGroup($group, 'max_member_group', null, '', false); |
|
343 | + |
|
344 | + // Active account or inactive account |
|
345 | + $form->addElement('radio', 'active', get_lang('ActiveAccount'), get_lang('Active'), 1); |
|
346 | + $form->addElement('radio', 'active', '', get_lang('Inactive'), 0); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | // EXTRA FIELDS |
@@ -366,18 +366,18 @@ discard block |
||
366 | 366 | $expiration_date = $user_data['expiration_date']; |
367 | 367 | |
368 | 368 | if (empty($expiration_date)) { |
369 | - $user_data['radio_expiration_date'] = 0; |
|
370 | - $user_data['expiration_date'] = api_get_local_time(); |
|
369 | + $user_data['radio_expiration_date'] = 0; |
|
370 | + $user_data['expiration_date'] = api_get_local_time(); |
|
371 | 371 | } else { |
372 | - $user_data['radio_expiration_date'] = 1; |
|
373 | - $user_data['expiration_date'] = api_get_local_time($expiration_date); |
|
372 | + $user_data['radio_expiration_date'] = 1; |
|
373 | + $user_data['expiration_date'] = api_get_local_time($expiration_date); |
|
374 | 374 | } |
375 | 375 | $form->setDefaults($user_data); |
376 | 376 | |
377 | 377 | $error_drh = false; |
378 | 378 | // Validate form |
379 | 379 | if ($form->validate()) { |
380 | - $user = $form->getSubmitValues(1); |
|
380 | + $user = $form->getSubmitValues(1); |
|
381 | 381 | $reset_password = intval($user['reset_password']); |
382 | 382 | if ($reset_password == 2 && empty($user['password'])) { |
383 | 383 | Display::addFlash(Display::return_message(get_lang('PasswordIsTooShort'))); |
@@ -385,18 +385,18 @@ discard block |
||
385 | 385 | exit(); |
386 | 386 | } |
387 | 387 | |
388 | - $is_user_subscribed_in_course = CourseManager::is_user_subscribed_in_course($user['user_id']); |
|
388 | + $is_user_subscribed_in_course = CourseManager::is_user_subscribed_in_course($user['user_id']); |
|
389 | 389 | |
390 | - if ($user['status'] == DRH && $is_user_subscribed_in_course) { |
|
391 | - $error_drh = true; |
|
392 | - } else { |
|
393 | - $picture_element = $form->getElement('picture'); |
|
394 | - $picture = $picture_element->getValue(); |
|
390 | + if ($user['status'] == DRH && $is_user_subscribed_in_course) { |
|
391 | + $error_drh = true; |
|
392 | + } else { |
|
393 | + $picture_element = $form->getElement('picture'); |
|
394 | + $picture = $picture_element->getValue(); |
|
395 | 395 | |
396 | - $picture_uri = $user_data['picture_uri']; |
|
397 | - if (isset($user['delete_picture']) && $user['delete_picture']) { |
|
398 | - $picture_uri = UserManager::delete_user_picture($user_id); |
|
399 | - } elseif (!empty($picture['name'])) { |
|
396 | + $picture_uri = $user_data['picture_uri']; |
|
397 | + if (isset($user['delete_picture']) && $user['delete_picture']) { |
|
398 | + $picture_uri = UserManager::delete_user_picture($user_id); |
|
399 | + } elseif (!empty($picture['name'])) { |
|
400 | 400 | $picture_uri = UserManager::update_user_picture( |
401 | 401 | $user_id, |
402 | 402 | $_FILES['picture']['name'], |
@@ -404,30 +404,30 @@ discard block |
||
404 | 404 | $user['cropResult'] |
405 | 405 | |
406 | 406 | ); |
407 | - } |
|
407 | + } |
|
408 | 408 | |
409 | - $lastname = $user['lastname']; |
|
410 | - $firstname = $user['firstname']; |
|
409 | + $lastname = $user['lastname']; |
|
410 | + $firstname = $user['firstname']; |
|
411 | 411 | $password = $user['password']; |
412 | 412 | $auth_source = isset($user['auth_source']) ? $user['auth_source'] : $userInfo['auth_source']; |
413 | - $official_code = $user['official_code']; |
|
414 | - $email = $user['email']; |
|
415 | - $phone = $user['phone']; |
|
416 | - $username = isset($user['username']) ? $user['username'] : $userInfo['username']; |
|
417 | - $status = intval($user['status']); |
|
418 | - $platform_admin = intval($user['platform_admin']); |
|
419 | - $send_mail = intval($user['send_mail']); |
|
420 | - $reset_password = intval($user['reset_password']); |
|
421 | - $hr_dept_id = isset($user['hr_dept_id']) ? intval($user['hr_dept_id']) : null; |
|
422 | - $language = $user['language']; |
|
423 | - |
|
424 | - if ($user['radio_expiration_date'] == '1' && !$user_data['platform_admin']) { |
|
413 | + $official_code = $user['official_code']; |
|
414 | + $email = $user['email']; |
|
415 | + $phone = $user['phone']; |
|
416 | + $username = isset($user['username']) ? $user['username'] : $userInfo['username']; |
|
417 | + $status = intval($user['status']); |
|
418 | + $platform_admin = intval($user['platform_admin']); |
|
419 | + $send_mail = intval($user['send_mail']); |
|
420 | + $reset_password = intval($user['reset_password']); |
|
421 | + $hr_dept_id = isset($user['hr_dept_id']) ? intval($user['hr_dept_id']) : null; |
|
422 | + $language = $user['language']; |
|
423 | + |
|
424 | + if ($user['radio_expiration_date'] == '1' && !$user_data['platform_admin']) { |
|
425 | 425 | $expiration_date = $user['expiration_date']; |
426 | - } else { |
|
427 | - $expiration_date = null; |
|
428 | - } |
|
426 | + } else { |
|
427 | + $expiration_date = null; |
|
428 | + } |
|
429 | 429 | |
430 | - $active = $user_data['platform_admin'] ? 1 : intval($user['active']); |
|
430 | + $active = $user_data['platform_admin'] ? 1 : intval($user['active']); |
|
431 | 431 | |
432 | 432 | //If the user is set to admin the status will be overwrite by COURSEMANAGER = 1 |
433 | 433 | if ($platform_admin == 1) { |
@@ -461,31 +461,31 @@ discard block |
||
461 | 461 | $reset_password |
462 | 462 | ); |
463 | 463 | |
464 | - if (api_get_setting('openid_authentication') == 'true' && !empty($user['openid'])) { |
|
465 | - $up = UserManager::update_openid($user_id, $user['openid']); |
|
466 | - } |
|
464 | + if (api_get_setting('openid_authentication') == 'true' && !empty($user['openid'])) { |
|
465 | + $up = UserManager::update_openid($user_id, $user['openid']); |
|
466 | + } |
|
467 | 467 | $currentUserId = api_get_user_id(); |
468 | - if ($user_id != $currentUserId) { |
|
469 | - if ($platform_admin == 1) { |
|
468 | + if ($user_id != $currentUserId) { |
|
469 | + if ($platform_admin == 1) { |
|
470 | 470 | UserManager::add_user_as_admin($user_id); |
471 | - } else { |
|
471 | + } else { |
|
472 | 472 | UserManager::remove_user_admin($user_id); |
473 | - } |
|
474 | - } |
|
473 | + } |
|
474 | + } |
|
475 | 475 | |
476 | 476 | $extraFieldValue = new ExtraFieldValue('user'); |
477 | 477 | $extraFieldValue->saveFieldValues($user); |
478 | 478 | |
479 | - $tok = Security::get_token(); |
|
480 | - header('Location: user_list.php?action=show_message&message='.urlencode(get_lang('UserUpdated')).'&sec_token='.$tok); |
|
481 | - exit(); |
|
482 | - } |
|
479 | + $tok = Security::get_token(); |
|
480 | + header('Location: user_list.php?action=show_message&message='.urlencode(get_lang('UserUpdated')).'&sec_token='.$tok); |
|
481 | + exit(); |
|
482 | + } |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | $message = null; |
486 | 486 | if ($error_drh) { |
487 | - $err_msg = get_lang('StatusCanNotBeChangedToHumanResourcesManager'); |
|
488 | - $message = Display::return_message($err_msg, 'error'); |
|
487 | + $err_msg = get_lang('StatusCanNotBeChangedToHumanResourcesManager'); |
|
488 | + $message = Display::return_message($err_msg, 'error'); |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | $content = null; |
@@ -229,31 +229,31 @@ discard block |
||
229 | 229 | <td align="center"> |
230 | 230 | <div id="content_source"> |
231 | 231 | <?php |
232 | - if (!($add_type=='multiple')) { |
|
232 | + if (!($add_type=='multiple')) { |
|
233 | 233 | ?> |
234 | 234 | <input type="text" id="user_to_add" onkeyup="xajax_search_users(this.value,'single')" /> |
235 | 235 | <div id="ajax_list_users_single"></div> |
236 | 236 | <?php |
237 | - } else { |
|
238 | - ?> |
|
237 | + } else { |
|
238 | + ?> |
|
239 | 239 | <div id="ajax_list_multiple"> |
240 | 240 | <?php echo Display::select('elements_not_in_name', $elements_not_in, '', array('style'=>'width:360px', 'multiple'=>'multiple','id'=>'elements_not_in','size'=>'15px'),false); ?> |
241 | 241 | </div> |
242 | 242 | <?php |
243 | - } |
|
244 | - ?> |
|
243 | + } |
|
244 | + ?> |
|
245 | 245 | </div> |
246 | 246 | </td> |
247 | 247 | <td width="10%" valign="middle" align="center"> |
248 | 248 | <?php |
249 | - if ($ajax_search) { |
|
250 | - ?> |
|
249 | + if ($ajax_search) { |
|
250 | + ?> |
|
251 | 251 | <button class="btn bt-default" type="button" onclick="remove_item(document.getElementById('elements_in'))" > |
252 | 252 | <em class="fa fa-arrow-left"></em> |
253 | 253 | </button> |
254 | 254 | <?php |
255 | - } else { |
|
256 | - ?> |
|
255 | + } else { |
|
256 | + ?> |
|
257 | 257 | <button class="btn btn-default" type="button" onclick="moveItem(document.getElementById('elements_not_in'), document.getElementById('elements_in'))" onclick="moveItem(document.getElementById('elements_not_in'), document.getElementById('elements_in'))"> |
258 | 258 | <em class="fa fa-arrow-right"></em> |
259 | 259 | </button> |
@@ -262,8 +262,8 @@ discard block |
||
262 | 262 | <em class="fa fa-arrow-left"></em> |
263 | 263 | </button> |
264 | 264 | <?php |
265 | - } |
|
266 | - ?> |
|
265 | + } |
|
266 | + ?> |
|
267 | 267 | <br /><br /><br /><br /><br /><br /> |
268 | 268 | </td> |
269 | 269 | <td align="center"> |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $courses = $course_list; |
47 | 47 | } |
48 | 48 | |
49 | - if (!empty($courses)) { |
|
49 | + if (!empty($courses)) { |
|
50 | 50 | |
51 | 51 | $archiveFile = 'export_courses_list_'.api_get_local_time(); |
52 | 52 | |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | Export::arrayToXls($listToExport, $archiveFile); |
99 | 99 | break; |
100 | 100 | } |
101 | - } else { |
|
101 | + } else { |
|
102 | 102 | Display::addFlash( |
103 | 103 | Display::return_message( |
104 | 104 | get_lang('ThereAreNotSelectedCoursesOrCoursesListIsEmpty') |
105 | 105 | ) |
106 | 106 | ); |
107 | - } |
|
107 | + } |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | |
@@ -114,29 +114,29 @@ discard block |
||
114 | 114 | $form->addHeader($tool_name); |
115 | 115 | $form->addHidden('formSent', 1); |
116 | 116 | $form->addElement( |
117 | - 'radio', |
|
118 | - 'select_type', |
|
119 | - get_lang('Option'), |
|
120 | - get_lang('ExportAllCoursesList'), |
|
121 | - '1', |
|
122 | - ['onclick' => "javascript: if(this.checked){document.getElementById('div-course-list').style.display='none';}"] |
|
117 | + 'radio', |
|
118 | + 'select_type', |
|
119 | + get_lang('Option'), |
|
120 | + get_lang('ExportAllCoursesList'), |
|
121 | + '1', |
|
122 | + ['onclick' => "javascript: if(this.checked){document.getElementById('div-course-list').style.display='none';}"] |
|
123 | 123 | ); |
124 | 124 | |
125 | 125 | $form->addElement( |
126 | - 'radio', |
|
127 | - 'select_type', |
|
128 | - '', |
|
129 | - get_lang('ExportSelectedCoursesFromCoursesList'), |
|
130 | - '2', |
|
131 | - ['onclick' => "javascript: if(this.checked){document.getElementById('div-course-list').style.display='block';}"] |
|
126 | + 'radio', |
|
127 | + 'select_type', |
|
128 | + '', |
|
129 | + get_lang('ExportSelectedCoursesFromCoursesList'), |
|
130 | + '2', |
|
131 | + ['onclick' => "javascript: if(this.checked){document.getElementById('div-course-list').style.display='block';}"] |
|
132 | 132 | ); |
133 | 133 | |
134 | 134 | if (!empty($course_list)) { |
135 | - $form->addHtml('<div id="div-course-list" style="display:none">'); |
|
136 | - $coursesInList = []; |
|
137 | - foreach ($course_list as $course) { |
|
138 | - $coursesInList[$course['code']] = $course['title'].' ('.$course['code'].')'; |
|
139 | - } |
|
135 | + $form->addHtml('<div id="div-course-list" style="display:none">'); |
|
136 | + $coursesInList = []; |
|
137 | + foreach ($course_list as $course) { |
|
138 | + $coursesInList[$course['code']] = $course['title'].' ('.$course['code'].')'; |
|
139 | + } |
|
140 | 140 | |
141 | 141 | $form->addSelect( |
142 | 142 | 'course_code', |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | ['multiple' => 'multiple'] |
146 | 146 | ); |
147 | 147 | |
148 | - $form->addHtml('</div>'); |
|
148 | + $form->addHtml('</div>'); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | $form->addElement('radio', 'file_type', get_lang('OutputFileType'), 'CSV' , 'csv', null); |