@@ -60,6 +60,7 @@ |
||
60 | 60 | /** |
61 | 61 | * This function deletes an entire directory |
62 | 62 | * @param string The directory path |
63 | + * @param string $dir |
|
63 | 64 | * @return boolean True on success, false on failure |
64 | 65 | */ |
65 | 66 | function deldir($dir) { |
@@ -34,7 +34,7 @@ |
||
34 | 34 | * @param int $categoryId |
35 | 35 | * @param bool $ignoreCategoryFilter |
36 | 36 | * |
37 | - * @return void |
|
37 | + * @return false|null |
|
38 | 38 | */ |
39 | 39 | public function __construct( |
40 | 40 | $user_id, |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | "; |
106 | 106 | $res = Database::query($sql); |
107 | 107 | $names = array(); |
108 | - while ($row = Database::fetch_array($res,'ASSOC')) { |
|
108 | + while ($row = Database::fetch_array($res, 'ASSOC')) { |
|
109 | 109 | // Use domesticate here instead of Database::escape_string because |
110 | 110 | // it prevents ' to be slashed and the input (done by learnpath.class.php::toggle_visibility()) |
111 | 111 | // is done using domesticate() |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | |
236 | 236 | $lessons = array(); |
237 | 237 | while ($row = Database::fetch_array($result)) { |
238 | - if (api_get_item_visibility($course, 'learnpath', $row['id'], $session_id)) { |
|
238 | + if (api_get_item_visibility($course, 'learnpath', $row['id'], $session_id)) { |
|
239 | 239 | $lessons[$row['id']] = $row; |
240 | 240 | } |
241 | 241 | } |
@@ -20,9 +20,9 @@ |
||
20 | 20 | * @param int $user_id User ID |
21 | 21 | * @param int $view_id View ID |
22 | 22 | * @param int $item_id Item ID |
23 | - * @param float $score Current score |
|
24 | - * @param float $max Maximum score |
|
25 | - * @param float $min Minimum score |
|
23 | + * @param integer $score Current score |
|
24 | + * @param integer $max Maximum score |
|
25 | + * @param integer $min Minimum score |
|
26 | 26 | * @param string $status Lesson status |
27 | 27 | * @param int $time Session time |
28 | 28 | * @param string $suspend Suspend data |
@@ -458,7 +458,7 @@ |
||
458 | 458 | } |
459 | 459 | |
460 | 460 | if ($myLP->get_type() == 2) { |
461 | - $return .= "update_stats();"; |
|
461 | + $return .= "update_stats();"; |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | // To be sure progress is updated. |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | // Set status to completed for hotpotatoes if score > 80%. |
164 | 164 | if ($my_type == 'hotpotatoes') { |
165 | 165 | if ((empty($status) || $status == 'undefined' || $status == 'not attempted') && $max > 0) { |
166 | - if (($score/$max) > 0.8) { |
|
166 | + if (($score / $max) > 0.8) { |
|
167 | 167 | $myStatus = 'completed'; |
168 | 168 | if ($debug > 1) { |
169 | 169 | error_log('Calling set_status('.$myStatus.') for hotpotatoes', 0); |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | error_log('Done calling set_status for hotpotatoes - now '.$myLPI->get_status(false), 0); |
175 | 175 | } |
176 | 176 | } |
177 | - } elseif ($status == 'completed' && $max > 0 && ($score/$max) < 0.8) { |
|
177 | + } elseif ($status == 'completed' && $max > 0 && ($score / $max) < 0.8) { |
|
178 | 178 | $myStatus = 'failed'; |
179 | 179 | if ($debug > 1) { |
180 | 180 | error_log('Calling set_status('.$myStatus.') for hotpotatoes', 0); |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | $myLPI->current_data = $suspend; |
368 | 368 | } |
369 | 369 | |
370 | - if (isset($location) && $location != '' && $location!='undefined') { |
|
370 | + if (isset($location) && $location != '' && $location != 'undefined') { |
|
371 | 371 | $myLPI->set_lesson_location($location); |
372 | 372 | } |
373 | 373 |
@@ -171,7 +171,8 @@ |
||
171 | 171 | /** |
172 | 172 | * Get images files from remote host (with webservices) |
173 | 173 | * @param array current ppt file |
174 | - * @return array images files |
|
174 | + * @param string $file |
|
175 | + * @return string images files |
|
175 | 176 | */ |
176 | 177 | private function _get_remote_ppt2lp_files($file) |
177 | 178 | { |
@@ -49,7 +49,7 @@ |
||
49 | 49 | // Create the directory |
50 | 50 | $result = $this->generate_lp_folder($_course, $this->file_name); |
51 | 51 | |
52 | - // Create the directory |
|
52 | + // Create the directory |
|
53 | 53 | $this->base_work_dir = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
54 | 54 | ///learning_path/ppt_dirname directory |
55 | 55 | $this->created_dir = substr($result['dir'], 0, strlen($result['dir']) -1); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | // Create the directory |
53 | 53 | $this->base_work_dir = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
54 | 54 | ///learning_path/ppt_dirname directory |
55 | - $this->created_dir = substr($result['dir'], 0, strlen($result['dir']) -1); |
|
55 | + $this->created_dir = substr($result['dir'], 0, strlen($result['dir']) - 1); |
|
56 | 56 | $this->file_path = $this->created_dir.'/'.api_replace_dangerous_char($file['name']); |
57 | 57 | |
58 | 58 | //var_dump($this->file_name, $this->file_path, $this->base_work_dir, $this->created_dir); |
@@ -89,18 +89,18 @@ discard block |
||
89 | 89 | $perm = api_get_setting('permissions_for_new_files'); |
90 | 90 | |
91 | 91 | if (IS_WINDOWS_OS) { // IS_WINDOWS_OS has been defined in main_api.lib.php |
92 | - $converter_path = str_replace('/', '\\', api_get_path(SYS_PATH) . 'main/inc/lib/ppt2png'); |
|
93 | - $class_path = $converter_path . ';' . $converter_path . '/jodconverter-2.2.2.jar;' . $converter_path . '/jodconverter-cli-2.2.2.jar'; |
|
92 | + $converter_path = str_replace('/', '\\', api_get_path(SYS_PATH).'main/inc/lib/ppt2png'); |
|
93 | + $class_path = $converter_path.';'.$converter_path.'/jodconverter-2.2.2.jar;'.$converter_path.'/jodconverter-cli-2.2.2.jar'; |
|
94 | 94 | //$cmd = 'java -cp "'.$class_path.'" DokeosConverter'; |
95 | - $cmd = 'java -Dfile.encoding=UTF-8 -cp "' . $class_path . '" DokeosConverter'; |
|
95 | + $cmd = 'java -Dfile.encoding=UTF-8 -cp "'.$class_path.'" DokeosConverter'; |
|
96 | 96 | } else { |
97 | - $converter_path = api_get_path(SYS_PATH) . 'main/inc/lib/ppt2png'; |
|
97 | + $converter_path = api_get_path(SYS_PATH).'main/inc/lib/ppt2png'; |
|
98 | 98 | //$class_path = '-cp .:jodconverter-2.2.1.jar:jodconverter-cli-2.2.1.jar'; |
99 | 99 | $class_path = ' -Dfile.encoding=UTF-8 -cp .:jodconverter-2.2.2.jar:jodconverter-cli-2.2.2.jar'; |
100 | - $cmd = 'cd ' . $converter_path . ' && java ' . $class_path . ' DokeosConverter'; |
|
100 | + $cmd = 'cd '.$converter_path.' && java '.$class_path.' DokeosConverter'; |
|
101 | 101 | } |
102 | 102 | |
103 | - $cmd .= ' -p ' . api_get_setting('service_ppt2lp', 'port'); |
|
103 | + $cmd .= ' -p '.api_get_setting('service_ppt2lp', 'port'); |
|
104 | 104 | // Call to the function implemented by child. |
105 | 105 | $cmd .= $this->add_command_parameters(); |
106 | 106 | // To allow openoffice to manipulate docs. |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | @chmod($this->base_work_dir.$this->file_path, 0777); |
110 | 110 | |
111 | 111 | $locale = $this->original_locale; // TODO: Improve it because we're not sure this locale is present everywhere. |
112 | - putenv('LC_ALL=' . $locale); |
|
112 | + putenv('LC_ALL='.$locale); |
|
113 | 113 | |
114 | 114 | $files = array(); |
115 | 115 | $return = 0; |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | if (!empty($result['images'])) { |
140 | 140 | foreach ($result['images'] as $image => $img_data) { |
141 | 141 | $image_path = $this->base_work_dir.$this->created_dir; |
142 | - @file_put_contents($image_path . '/' . $image, base64_decode($img_data)); |
|
143 | - @chmod($image_path . '/' . $image, 0777); |
|
142 | + @file_put_contents($image_path.'/'.$image, base64_decode($img_data)); |
|
143 | + @chmod($image_path.'/'.$image, 0777); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | $uri = ''; |
183 | 183 | $result = preg_match('/^([a-zA-Z0-9]*):\/\/([^\/]*)\//', $ppt2lp_host, $matches); |
184 | 184 | if ($result) { |
185 | - $uri = $matches[1] . '://' . $matches[2] . '/'; |
|
185 | + $uri = $matches[1].'://'.$matches[2].'/'; |
|
186 | 186 | } else { |
187 | 187 | $uri = $ppt2lp_host; |
188 | 188 | } |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 9, |
202 | 202 | ); |
203 | 203 | if (substr($ppt2lp_host, 0, 5) === 'https') { |
204 | - $options['ssl_method'] = SOAP_SSL_METHOD_TLS; |
|
204 | + $options['ssl_method'] = SOAP_SSL_METHOD_TLS; |
|
205 | 205 | } |
206 | 206 | $client = new SoapClient(null, $options); |
207 | 207 | $result = ''; |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | //error_log('['.time().'] Calling wsConvertPpt webservice on ' . $ppt2lp_host); |
222 | 222 | $result = $client->__call('wsConvertPpt', array('pptData' => $params)); |
223 | 223 | } catch (Exception $e) { |
224 | - error_log('['.time().'] Chamilo SOAP call error: ' . $e->getMessage()); |
|
224 | + error_log('['.time().'] Chamilo SOAP call error: '.$e->getMessage()); |
|
225 | 225 | } |
226 | 226 | // Make sure we destroy the SOAP client as it may generate SSL connection |
227 | 227 | // binding issue (if using SSL) |
@@ -254,38 +254,38 @@ discard block |
||
254 | 254 | $ppt2lpHost = api_get_setting('service_ppt2lp', 'host'); |
255 | 255 | $permissionFile = api_get_permissions_for_new_files(); |
256 | 256 | $permissionFolder = api_get_permissions_for_new_directories(); |
257 | - if (file_exists($this->base_work_dir . '/' . $this->created_dir)) { |
|
257 | + if (file_exists($this->base_work_dir.'/'.$this->created_dir)) { |
|
258 | 258 | |
259 | 259 | return $ids; |
260 | 260 | } |
261 | 261 | |
262 | 262 | if ($ppt2lpHost == 'localhost') { |
263 | 263 | if (IS_WINDOWS_OS) { // IS_WINDOWS_OS has been defined in main_api.lib.php |
264 | - $converterPath = str_replace('/', '\\', api_get_path(SYS_PATH) . 'main/inc/lib/ppt2png'); |
|
265 | - $classPath = $converterPath . ';' . $converterPath . '/jodconverter-2.2.2.jar;' . $converterPath . '/jodconverter-cli-2.2.2.jar'; |
|
266 | - $cmd = 'java -Dfile.encoding=UTF-8 -jar "' . $classPath . '/jodconverter-2.2.2.jar"'; |
|
264 | + $converterPath = str_replace('/', '\\', api_get_path(SYS_PATH).'main/inc/lib/ppt2png'); |
|
265 | + $classPath = $converterPath.';'.$converterPath.'/jodconverter-2.2.2.jar;'.$converterPath.'/jodconverter-cli-2.2.2.jar'; |
|
266 | + $cmd = 'java -Dfile.encoding=UTF-8 -jar "'.$classPath.'/jodconverter-2.2.2.jar"'; |
|
267 | 267 | } else { |
268 | - $converterPath = api_get_path(SYS_PATH) . 'main/inc/lib/ppt2png'; |
|
268 | + $converterPath = api_get_path(SYS_PATH).'main/inc/lib/ppt2png'; |
|
269 | 269 | $classPath = ' -Dfile.encoding=UTF-8 -jar jodconverter-cli-2.2.2.jar'; |
270 | - $cmd = 'cd ' . $converterPath . ' && java ' . $classPath . ' '; |
|
270 | + $cmd = 'cd '.$converterPath.' && java '.$classPath.' '; |
|
271 | 271 | } |
272 | 272 | |
273 | - $cmd .= ' -p ' . api_get_setting('service_ppt2lp', 'port'); |
|
273 | + $cmd .= ' -p '.api_get_setting('service_ppt2lp', 'port'); |
|
274 | 274 | // Call to the function implemented by child. |
275 | - $cmd .= ' "' . $this->base_work_dir . '/' . $this->file_path . '" "' . $this->base_work_dir . '/' . $this->created_dir . '"'; |
|
275 | + $cmd .= ' "'.$this->base_work_dir.'/'.$this->file_path.'" "'.$this->base_work_dir.'/'.$this->created_dir.'"'; |
|
276 | 276 | // To allow openoffice to manipulate docs. |
277 | 277 | @chmod($this->base_work_dir, $permissionFolder); |
278 | - @chmod($this->base_work_dir . '/' . $this->file_path, $permissionFile); |
|
278 | + @chmod($this->base_work_dir.'/'.$this->file_path, $permissionFile); |
|
279 | 279 | |
280 | 280 | $locale = $this->original_locale; // TODO: Improve it because we're not sure this locale is present everywhere. |
281 | - putenv('LC_ALL=' . $locale); |
|
281 | + putenv('LC_ALL='.$locale); |
|
282 | 282 | |
283 | 283 | $files = array(); |
284 | 284 | $return = 0; |
285 | 285 | $shell = exec($cmd, $files, $return); |
286 | 286 | // TODO: Chown is not working, root keep user privileges, should be www-data |
287 | - @chown($this->base_work_dir . '/' . $this->created_dir, 'www-data'); |
|
288 | - @chmod($this->base_work_dir . '/' . $this->created_dir, $permissionFile); |
|
287 | + @chown($this->base_work_dir.'/'.$this->created_dir, 'www-data'); |
|
288 | + @chmod($this->base_work_dir.'/'.$this->created_dir, $permissionFile); |
|
289 | 289 | |
290 | 290 | if ($return != 0) { // If the java application returns an error code. |
291 | 291 | switch ($return) { |
@@ -324,14 +324,14 @@ discard block |
||
324 | 324 | */ |
325 | 325 | } |
326 | 326 | |
327 | - if (file_exists($this->base_work_dir . '/' . $this->created_dir)) { |
|
327 | + if (file_exists($this->base_work_dir.'/'.$this->created_dir)) { |
|
328 | 328 | |
329 | 329 | // Register Files to Document tool |
330 | 330 | $ids[] = add_document( |
331 | 331 | $_course, |
332 | - '/' . $this->created_dir, |
|
332 | + '/'.$this->created_dir, |
|
333 | 333 | 'file', |
334 | - filesize($this->base_work_dir . '/' . $this->created_dir), |
|
334 | + filesize($this->base_work_dir.'/'.$this->created_dir), |
|
335 | 335 | $convertedTitle, |
336 | 336 | sprintf( |
337 | 337 | get_lang('FileConvertedFromXToY'), |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | /** |
43 | 43 | * Gets html pages and compose them into a learning path |
44 | 44 | * @param array The files that will compose the generated learning path. Unused so far. |
45 | - * @return boolean False if file does not exit. Nothing otherwise. |
|
45 | + * @return false|null False if file does not exit. Nothing otherwise. |
|
46 | 46 | */ |
47 | 47 | function make_lp($files = array()) |
48 | 48 | { |
@@ -96,6 +96,7 @@ discard block |
||
96 | 96 | * Manages chapter splitting |
97 | 97 | * @param string Chapter header |
98 | 98 | * @param string Content |
99 | + * @param string $content |
|
99 | 100 | * @return void |
100 | 101 | */ |
101 | 102 | function dealPerChapter($header, $content) |
@@ -187,6 +188,7 @@ discard block |
||
187 | 188 | * Manages page splitting |
188 | 189 | * @param string Page header |
189 | 190 | * @param string Page body |
191 | + * @param string $body |
|
190 | 192 | * @return void |
191 | 193 | */ |
192 | 194 | function dealPerPage($header, $body) |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | if (empty($matches[1][$i])) |
127 | 127 | continue; |
128 | 128 | |
129 | - $content = strstr($content,$matches[0][$i]); |
|
129 | + $content = strstr($content, $matches[0][$i]); |
|
130 | 130 | if ($i + 1 !== count($matches[0])) { |
131 | 131 | $chapter_content = substr($content, 0, strpos($content, $matches[0][$i + 1])); |
132 | 132 | } else { |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | |
149 | 149 | $document_id = add_document($_course, $this->created_dir.'/'.$html_file, 'file', filesize($this->base_work_dir.$this->created_dir.'/'.$html_file), $html_file); |
150 | 150 | |
151 | - if ($document_id){ |
|
151 | + if ($document_id) { |
|
152 | 152 | |
153 | 153 | // Put the document in item_property update. |
154 | 154 | api_item_property_update( |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | foreach ($specific_fields as $specific_field) { |
255 | 255 | if (isset($_REQUEST[$specific_field['code']])) { |
256 | 256 | $sterms = trim($_REQUEST[$specific_field['code']]); |
257 | - $all_specific_terms .= ' '. $sterms; |
|
257 | + $all_specific_terms .= ' '.$sterms; |
|
258 | 258 | if (!empty($sterms)) { |
259 | 259 | $sterms = explode(',', $sterms); |
260 | 260 | foreach ($sterms as $sterm) { |
@@ -263,10 +263,10 @@ discard block |
||
263 | 263 | } |
264 | 264 | } |
265 | 265 | } |
266 | - $page_content = $all_specific_terms .' '. $page_content; |
|
266 | + $page_content = $all_specific_terms.' '.$page_content; |
|
267 | 267 | $ic_slide->addValue('content', $page_content); |
268 | 268 | // Add a comment to say terms separated by commas. |
269 | - $courseid=api_get_course_id(); |
|
269 | + $courseid = api_get_course_id(); |
|
270 | 270 | $ic_slide->addCourseId($courseid); |
271 | 271 | $ic_slide->addToolId(TOOL_LEARNPATH); |
272 | 272 | $lp_id = $this->lp_id; |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | SE_COURSE_ID => $courseid, |
275 | 275 | SE_TOOL_ID => TOOL_LEARNPATH, |
276 | 276 | SE_DATA => array('lp_id' => $lp_id, 'lp_item'=> $previous, 'document_id' => $document_id), |
277 | - SE_USER => (int)api_get_user_id(), |
|
277 | + SE_USER => (int) api_get_user_id(), |
|
278 | 278 | ); |
279 | 279 | $ic_slide->xapian_data = serialize($xapian_data); |
280 | 280 | $di->addChunk($ic_slide); |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | * Returns additional Java command parameters |
299 | 299 | * @return string The additional parameters to be used in the Java call |
300 | 300 | */ |
301 | - function add_command_parameters(){ |
|
301 | + function add_command_parameters() { |
|
302 | 302 | return ' -d woogie "'.$this->base_work_dir.'/'.$this->file_path.'" "'.$this->base_work_dir.$this->created_dir.'/'.$this->file_name.'.html"'; |
303 | 303 | } |
304 | 304 | |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | */ |
311 | 311 | function format_page_content($header, $content) { |
312 | 312 | // Limit the width of the doc. |
313 | - list($max_width, $max_height) = explode('x',api_get_setting('service_ppt2lp','size')); |
|
313 | + list($max_width, $max_height) = explode('x', api_get_setting('service_ppt2lp', 'size')); |
|
314 | 314 | |
315 | 315 | $content = preg_replace("|<body[^>]*>|i", "\\0\r\n<div style=\"width:".$max_width."\">", $content, -1, $count); |
316 | 316 | if ($count < 1) { |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | } |
344 | 344 | |
345 | 345 | } elseif ($img_width > $max_width - 10) { |
346 | - $picture_resized = str_ireplace('width='.$img_width, 'width="'.($max_width-10).'"', $images[0][$key]); |
|
346 | + $picture_resized = str_ireplace('width='.$img_width, 'width="'.($max_width - 10).'"', $images[0][$key]); |
|
347 | 347 | $content = str_replace($images[0][$key], $picture_resized, $content); |
348 | 348 | } |
349 | 349 | } |
@@ -123,8 +123,9 @@ |
||
123 | 123 | |
124 | 124 | for ($i = 0; $i < count($matches[0]); $i++) { |
125 | 125 | |
126 | - if (empty($matches[1][$i])) |
|
127 | - continue; |
|
126 | + if (empty($matches[1][$i])) { |
|
127 | + continue; |
|
128 | + } |
|
128 | 129 | |
129 | 130 | $content = strstr($content,$matches[0][$i]); |
130 | 131 | if ($i + 1 !== count($matches[0])) { |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | /** |
39 | 39 | * Gets html pages and compose them into a learning path |
40 | 40 | * @param array The files that will compose the generated learning path. Unused so far. |
41 | - * @return boolean False if file does not exit. Nothing otherwise. |
|
41 | + * @return false|null False if file does not exit. Nothing otherwise. |
|
42 | 42 | */ |
43 | 43 | public function make_lp($files = array()) |
44 | 44 | { |
@@ -92,6 +92,7 @@ discard block |
||
92 | 92 | * Manages chapter splitting |
93 | 93 | * @param string Chapter header |
94 | 94 | * @param string Content |
95 | + * @param string $content |
|
95 | 96 | * @return void |
96 | 97 | */ |
97 | 98 | function dealPerChapter($header, $content) |
@@ -164,6 +165,7 @@ discard block |
||
164 | 165 | * Manages page splitting |
165 | 166 | * @param string Page header |
166 | 167 | * @param string Page body |
168 | + * @param string $body |
|
167 | 169 | * @return void |
168 | 170 | */ |
169 | 171 | function dealPerPage($header, $body) |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | $intro_content = api_substr($content, 0, api_strpos($content, $matches[0][0])); |
118 | 118 | $items_to_create[get_lang('Introduction')] = $intro_content; |
119 | 119 | |
120 | - for ($i = 0; $i<count($matches[0]); $i++) { |
|
120 | + for ($i = 0; $i < count($matches[0]); $i++) { |
|
121 | 121 | |
122 | 122 | if (empty($matches[1][$i])) |
123 | 123 | continue; |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | |
175 | 175 | $first_item = 0; |
176 | 176 | |
177 | - foreach($pages as $key => $page_content) { |
|
177 | + foreach ($pages as $key => $page_content) { |
|
178 | 178 | // For every pages, we create a new file. |
179 | 179 | |
180 | 180 | $key += 1; |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | foreach ($specific_fields as $specific_field) { |
214 | 214 | if (isset($_REQUEST[$specific_field['code']])) { |
215 | 215 | $sterms = trim($_REQUEST[$specific_field['code']]); |
216 | - $all_specific_terms .= ' '. $sterms; |
|
216 | + $all_specific_terms .= ' '.$sterms; |
|
217 | 217 | if (!empty($sterms)) { |
218 | 218 | $sterms = explode(',', $sterms); |
219 | 219 | foreach ($sterms as $sterm) { |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | } |
223 | 223 | } |
224 | 224 | } |
225 | - $page_content = $all_specific_terms .' '. $page_content; |
|
225 | + $page_content = $all_specific_terms.' '.$page_content; |
|
226 | 226 | $ic_slide->addValue('content', $page_content); |
227 | 227 | // Add a comment to say terms separated by commas. |
228 | 228 | $courseid = api_get_course_id(); |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | SE_COURSE_ID => $courseid, |
234 | 234 | SE_TOOL_ID => TOOL_LEARNPATH, |
235 | 235 | SE_DATA => array('lp_id' => $lp_id, 'lp_item' => $previous, 'document_id' => $document_id), |
236 | - SE_USER => (int)api_get_user_id(), |
|
236 | + SE_USER => (int) api_get_user_id(), |
|
237 | 237 | ); |
238 | 238 | $ic_slide->xapian_data = serialize($xapian_data); |
239 | 239 | $di->addChunk($ic_slide); |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | $content = '<body><div style="width:'.$max_width.'">'.$content; |
277 | 277 | } |
278 | 278 | |
279 | - $content = preg_replace('|</body>|i','</div>\\0', $content, -1, $count); |
|
279 | + $content = preg_replace('|</body>|i', '</div>\\0', $content, -1, $count); |
|
280 | 280 | if ($count < 1) { |
281 | 281 | $content = $content.'</div></body>'; |
282 | 282 | } |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | } |
305 | 305 | |
306 | 306 | } elseif ($img_width > $max_width - 10) { |
307 | - $picture_resized = str_ireplace('width='.$img_width, 'width="'.($max_width-10).'"', $images[0][$key]); |
|
307 | + $picture_resized = str_ireplace('width='.$img_width, 'width="'.($max_width - 10).'"', $images[0][$key]); |
|
308 | 308 | $content = str_replace($images[0][$key], $picture_resized, $content); |
309 | 309 | } |
310 | 310 | } |
@@ -119,8 +119,9 @@ |
||
119 | 119 | |
120 | 120 | for ($i = 0; $i<count($matches[0]); $i++) { |
121 | 121 | |
122 | - if (empty($matches[1][$i])) |
|
123 | - continue; |
|
122 | + if (empty($matches[1][$i])) { |
|
123 | + continue; |
|
124 | + } |
|
124 | 125 | |
125 | 126 | $content = api_strstr($content, $matches[0][$i]); |
126 | 127 | if ($i + 1 !== count($matches[0])) { |
@@ -320,6 +320,10 @@ |
||
320 | 320 | * @param icon - if ="icon" then the small icon will appear |
321 | 321 | * if ="wrap" then wrapped settings are used (and no icon is displayed) |
322 | 322 | * if ="nolink" then only the name is returned with no href and no icon (note:only in this case, the result is not displayed, but returned) |
323 | + * @param string $completed |
|
324 | + * @param string $id_in_path |
|
325 | + * @param string $builder |
|
326 | + * @param string $icon |
|
323 | 327 | * @todo this function is too long, rewrite |
324 | 328 | */ |
325 | 329 | function display_addedresource_link_in_learnpath($type, $id, $completed, $id_in_path, $builder, $icon, $level = 0) { |
@@ -286,14 +286,14 @@ discard block |
||
286 | 286 | $ext = strtolower($ext[sizeof($ext)-1]); |
287 | 287 | $myrow['path'] = rawurlencode($myrow['path']); |
288 | 288 | |
289 | - $array_ext=array('htm', 'html', 'gif', 'jpg', 'jpeg', 'png'); |
|
289 | + $array_ext=array('htm', 'html', 'gif', 'jpg', 'jpeg', 'png'); |
|
290 | 290 | |
291 | - if (api_browser_support('svg')){ |
|
292 | - $array_ext[]='svg'; |
|
293 | - } |
|
294 | - if (api_browser_support('ogg')){ |
|
295 | - $array_ext[]='ogg'; |
|
296 | - } |
|
291 | + if (api_browser_support('svg')){ |
|
292 | + $array_ext[]='svg'; |
|
293 | + } |
|
294 | + if (api_browser_support('ogg')){ |
|
295 | + $array_ext[]='ogg'; |
|
296 | + } |
|
297 | 297 | |
298 | 298 | $in_frames = in_array($ext, $array_ext); |
299 | 299 | |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | $result = Database::query($sql); |
393 | 393 | $row = Database::fetch_array($result); |
394 | 394 | if ($row['title'] != '') { |
395 | - $myrow['content'] = $row['title']; |
|
395 | + $myrow['content'] = $row['title']; |
|
396 | 396 | } |
397 | 397 | $desc = $row['description']; |
398 | 398 | $ann_id = $row['item_id']; |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | if ($icon == 'nolink') { return(shorten($myrow['title'], $length)); } |
470 | 470 | if ($icon == 'icon') { |
471 | 471 | if ($linktype == 'Link _self') { echo "<img src='../img/links.gif' align=\"absmiddle\" alt='links'>"; } |
472 | - else { echo "<img src='../img/link_blank.gif' align=\"absmiddle\" alt='blank links'>"; } |
|
472 | + else { echo "<img src='../img/link_blank.gif' align=\"absmiddle\" alt='blank links'>"; } |
|
473 | 473 | } |
474 | 474 | $thelink = $myrow['url']; |
475 | 475 | if ($builder != 'builder') { |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | $myrow = Database::fetch_array($result); |
495 | 495 | |
496 | 496 | if ($builder == 'builder') { $origin = 'builder'; } |
497 | - // This is needed for the exercise_submit.php can delete the session info about tests. |
|
497 | + // This is needed for the exercise_submit.php can delete the session info about tests. |
|
498 | 498 | |
499 | 499 | $sql = "select * from $tbl_lp_item where id=$id_in_path"; |
500 | 500 | $result = Database::query($sql); |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | $name = GetQuizName($path, $documentPath); |
547 | 547 | |
548 | 548 | if ($builder == 'builder') { $origin='builder'; } |
549 | - // This is needed for the exercise_submit.php can delete the session info about tests. |
|
549 | + // This is needed for the exercise_submit.php can delete the session info about tests. |
|
550 | 550 | |
551 | 551 | $sql = "select * from $tbl_lp_item where id=$id_in_path"; |
552 | 552 | $result = Database::query($sql); $row = Database::fetch_array($result); |
@@ -1106,7 +1106,7 @@ discard block |
||
1106 | 1106 | $myrow = Database::fetch_array($result); |
1107 | 1107 | |
1108 | 1108 | if ($builder == 'builder') { $origin = 'builder'; } |
1109 | - // This is needed for the exercise_submit.php can delete the session info about tests. |
|
1109 | + // This is needed for the exercise_submit.php can delete the session info about tests. |
|
1110 | 1110 | |
1111 | 1111 | $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path"; |
1112 | 1112 | $result = Database::query($sql); $row = Database::fetch_array($result); |
@@ -1330,10 +1330,10 @@ discard block |
||
1330 | 1330 | */ |
1331 | 1331 | function delete_all_resources_type($type) |
1332 | 1332 | { |
1333 | - $course_id = api_get_course_int_id(); |
|
1334 | - $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
1335 | - $sql = "DELETE FROM $TABLERESOURCE WHERE c_id = $course_id AND source_type='$type'"; |
|
1336 | - Database::query($sql); |
|
1333 | + $course_id = api_get_course_int_id(); |
|
1334 | + $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
1335 | + $sql = "DELETE FROM $TABLERESOURCE WHERE c_id = $course_id AND source_type='$type'"; |
|
1336 | + Database::query($sql); |
|
1337 | 1337 | } |
1338 | 1338 | |
1339 | 1339 | /** |
@@ -334,9 +334,14 @@ discard block |
||
334 | 334 | |
335 | 335 | $length = ((($builder == 'builder') && ($icon == 'nolink')) ? 65 : 32); |
336 | 336 | |
337 | - if ($builder != 'builder') $origin = 'learnpath'; //origin = learnpath in student view |
|
337 | + if ($builder != 'builder') { |
|
338 | + $origin = 'learnpath'; |
|
339 | + } |
|
340 | + //origin = learnpath in student view |
|
338 | 341 | $linktype = $type; |
339 | - if (($type == 'Link _self') or ($type == 'Link _blank')) $type = 'Link'; |
|
342 | + if (($type == 'Link _self') or ($type == 'Link _blank')) { |
|
343 | + $type = 'Link'; |
|
344 | + } |
|
340 | 345 | |
341 | 346 | // YW switched litteral tool names to use of constants declared in main_api.lib.php |
342 | 347 | switch ($type) { |
@@ -356,7 +361,7 @@ discard block |
||
356 | 361 | if ($icon != 'nolink') { |
357 | 362 | if ($completed == 'completed') { |
358 | 363 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
359 | - } else { |
|
364 | + } else { |
|
360 | 365 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
361 | 366 | //echo " "; |
362 | 367 | } |
@@ -407,7 +412,7 @@ discard block |
||
407 | 412 | if ($icon != 'nolink') { |
408 | 413 | if ($completed == 'completed') { |
409 | 414 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
410 | - } else { |
|
415 | + } else { |
|
411 | 416 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
412 | 417 | //echo " "; |
413 | 418 | } |
@@ -454,7 +459,7 @@ discard block |
||
454 | 459 | if ($icon != 'nolink') { |
455 | 460 | if ($completed == 'completed') { |
456 | 461 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
457 | - } else { |
|
462 | + } else { |
|
458 | 463 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
459 | 464 | //echo " "; |
460 | 465 | } |
@@ -468,8 +473,7 @@ discard block |
||
468 | 473 | |
469 | 474 | if ($icon == 'nolink') { return(shorten($myrow['title'], $length)); } |
470 | 475 | if ($icon == 'icon') { |
471 | - if ($linktype == 'Link _self') { echo "<img src='../img/links.gif' align=\"absmiddle\" alt='links'>"; } |
|
472 | - else { echo "<img src='../img/link_blank.gif' align=\"absmiddle\" alt='blank links'>"; } |
|
476 | + if ($linktype == 'Link _self') { echo "<img src='../img/links.gif' align=\"absmiddle\" alt='links'>"; } else { echo "<img src='../img/link_blank.gif' align=\"absmiddle\" alt='blank links'>"; } |
|
473 | 477 | } |
474 | 478 | $thelink = $myrow['url']; |
475 | 479 | if ($builder != 'builder') { |
@@ -558,7 +562,7 @@ discard block |
||
558 | 562 | if ($icon != 'nolink') { |
559 | 563 | if ($completed == 'completed') { |
560 | 564 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
561 | - } else { |
|
565 | + } else { |
|
562 | 566 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
563 | 567 | //echo " "; |
564 | 568 | } |
@@ -603,7 +607,7 @@ discard block |
||
603 | 607 | if ($icon != 'nolink') { |
604 | 608 | if ($completed == 'completed') { |
605 | 609 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
606 | - } else { |
|
610 | + } else { |
|
607 | 611 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
608 | 612 | //echo " "; |
609 | 613 | } |
@@ -647,7 +651,7 @@ discard block |
||
647 | 651 | if ($icon != 'nolink') { |
648 | 652 | if ($completed == 'completed') { |
649 | 653 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
650 | - } else { |
|
654 | + } else { |
|
651 | 655 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
652 | 656 | //echo " "; |
653 | 657 | } |
@@ -698,7 +702,7 @@ discard block |
||
698 | 702 | if ($icon != 'nolink') { |
699 | 703 | if ($completed == 'completed') { |
700 | 704 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
701 | - } else { |
|
705 | + } else { |
|
702 | 706 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
703 | 707 | //echo " "; |
704 | 708 | } |
@@ -801,7 +805,7 @@ discard block |
||
801 | 805 | if ($icon != 'nolink') { |
802 | 806 | if ($completed == 'completed') { |
803 | 807 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
804 | - } else { |
|
808 | + } else { |
|
805 | 809 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
806 | 810 | //echo " "; |
807 | 811 | } |
@@ -842,7 +846,7 @@ discard block |
||
842 | 846 | if ($icon != 'nolink') { |
843 | 847 | if ($completed == 'completed') { |
844 | 848 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
845 | - } else { |
|
849 | + } else { |
|
846 | 850 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
847 | 851 | //echo " "; |
848 | 852 | } |
@@ -858,8 +862,7 @@ discard block |
||
858 | 862 | echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path"; |
859 | 863 | if ($desc != '') { |
860 | 864 | if ($icon != 'wrap') { |
861 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>"; } |
|
862 | - else { |
|
865 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>"; } else { |
|
863 | 866 | echo "<div class='description'> ".shorten($desc, ($length-3*$level))."</div>"; } |
864 | 867 | } |
865 | 868 | } else { |
@@ -897,8 +900,7 @@ discard block |
||
897 | 900 | $items[] = api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path"; |
898 | 901 | if ($desc != '') { |
899 | 902 | if ($icon != 'wrap') { |
900 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>"; } |
|
901 | - else { |
|
903 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>"; } else { |
|
902 | 904 | echo "<div class='description'> ".shorten($desc, ($length-3*$level))."</div>"; } |
903 | 905 | } |
904 | 906 | } else { |
@@ -920,7 +922,7 @@ discard block |
||
920 | 922 | if ($icon != 'nolink') { |
921 | 923 | if ($completed == 'completed') { |
922 | 924 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
923 | - } else { |
|
925 | + } else { |
|
924 | 926 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
925 | 927 | //echo " "; |
926 | 928 | } |
@@ -936,8 +938,7 @@ discard block |
||
936 | 938 | echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path"; |
937 | 939 | if ($desc != '') { |
938 | 940 | if ($icon != 'wrap') { |
939 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>"; } |
|
940 | - else { |
|
941 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>"; } else { |
|
941 | 942 | echo "<div class='description'> ".shorten($desc, ($length-3*$level))."</div>"; } |
942 | 943 | } |
943 | 944 | } else { |
@@ -976,8 +977,7 @@ discard block |
||
976 | 977 | echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path"; |
977 | 978 | if ($desc != '') { |
978 | 979 | if ($icon != 'wrap') { |
979 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>"; } |
|
980 | - else { |
|
980 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>"; } else { |
|
981 | 981 | echo "<div class='description'> ".shorten($desc, ($length-3*$level))."</div>"; } |
982 | 982 | } |
983 | 983 | } else { |
@@ -1015,8 +1015,7 @@ discard block |
||
1015 | 1015 | echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path"; |
1016 | 1016 | if ($desc != '') { |
1017 | 1017 | if ($icon != 'wrap') { |
1018 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>"; } |
|
1019 | - else { |
|
1018 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>"; } else { |
|
1020 | 1019 | echo "<div class='description'> ".shorten($desc, ($length-3*$level))."</div>"; } |
1021 | 1020 | } |
1022 | 1021 | } else { |
@@ -1346,11 +1345,12 @@ discard block |
||
1346 | 1345 | WHERE c_id = $course_id AND source_type='$type' and source_id='$id'"; |
1347 | 1346 | $result = Database::query($sql); |
1348 | 1347 | $number_added = Database::num_rows($result); |
1349 | - if ($number_added != 0) |
|
1350 | - return true; |
|
1351 | - else |
|
1352 | - return false; |
|
1353 | -} |
|
1348 | + if ($number_added != 0) { |
|
1349 | + return true; |
|
1350 | + } else { |
|
1351 | + return false; |
|
1352 | + } |
|
1353 | + } |
|
1354 | 1354 | |
1355 | 1355 | /** |
1356 | 1356 | * this function is to load the resources that were added to a specific item |
@@ -1459,8 +1459,7 @@ discard block |
||
1459 | 1459 | next($addedresource); |
1460 | 1460 | } |
1461 | 1461 | echo '</table>'; |
1462 | - } |
|
1463 | - else { // it is a string |
|
1462 | + } else { // it is a string |
|
1464 | 1463 | echo ''; |
1465 | 1464 | } |
1466 | 1465 | } // end of the display_resources function |
@@ -1492,8 +1491,7 @@ discard block |
||
1492 | 1491 | echo "<a href='".api_get_self()."?content=".$type."&source_forum=".$_GET['source_forum']."&add=".$id."&source_id=$source_id&action=$action&lp_id=$learnpath_id&parent_item_id=$chapter_id&originalresource=no&target=$target'>".$lang_add_it_or_resource."</a>"; |
1493 | 1492 | } |
1494 | 1493 | } |
1495 | - } |
|
1496 | - else { // if it is not an array, it is a string |
|
1494 | + } else { // if it is not an array, it is a string |
|
1497 | 1495 | if ($_SESSION['addedresource'] !== $type || $_SESSION['addedresourceid'] !== $id) { |
1498 | 1496 | if ($from_learnpath) { $lang_add_it_or_resource = get_lang('AddIt'); } else { $lang_add_it_or_resource = get_lang('AddResource'); } |
1499 | 1497 | echo "<a href='".api_get_self()."?content=".$type."&folder=".$folder."&source_forum=".$_GET['source_forum']."&add=".$id."&source_id=$source_id&action=$action&lp_id=$learnpath_id&parent_item_id=$chapter_id&originalresource=no&target=$target'>".$lang_add_it_or_resource."</a>"; |
@@ -1519,7 +1517,9 @@ discard block |
||
1519 | 1517 | $course_id = api_get_course_int_id(); |
1520 | 1518 | |
1521 | 1519 | // Styling the link of the added resource |
1522 | - if ($style != '') $styling = ' class="'.$style.'"'; |
|
1520 | + if ($style != '') { |
|
1521 | + $styling = ' class="'.$style.'"'; |
|
1522 | + } |
|
1523 | 1523 | if ($new_window) { $target = ' target = "_blank" '; } else { $target = ' target = "_self" '; } |
1524 | 1524 | |
1525 | 1525 | $output = ''; |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | $use_anonymous = true; |
18 | 18 | |
19 | 19 | require_once '../inc/global.inc.php'; |
20 | -if (!empty($_course['language'])){ |
|
21 | - $resource_linker_file = api_get_path(SYS_CODE_PATH).'lang/'.$_course['language'].'/resourcelinker.inc.php'; |
|
20 | +if (!empty($_course['language'])) { |
|
21 | + $resource_linker_file = api_get_path(SYS_CODE_PATH).'lang/'.$_course['language'].'/resourcelinker.inc.php'; |
|
22 | 22 | if (file_exists($resource_linker_file)) { |
23 | 23 | require_once $resource_linker_file; |
24 | 24 | } |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | echo "<a href='".api_get_self()."?content=Document&source_forum=".$_GET['source_forum']."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no'><img src='../img/folder_up.gif' border='0' />".get_lang('LevelUp')."</a>"; |
48 | 48 | } |
49 | 49 | if ($level && $level != 0 && $level != 1) { |
50 | - $folder_up=$folder; |
|
51 | - $folder_temp=explode('/',$folder); |
|
52 | - $last=count($folder_temp)-1; |
|
50 | + $folder_up = $folder; |
|
51 | + $folder_temp = explode('/', $folder); |
|
52 | + $last = count($folder_temp) - 1; |
|
53 | 53 | unset($folder_temp[$last]); |
54 | - $folder_up=implode('/',$folder_temp); |
|
54 | + $folder_up = implode('/', $folder_temp); |
|
55 | 55 | echo "<a href='".api_get_self()."?content=Document&source_forum=".$_GET['source_forum']."&folder=$folder_up&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no'><img src='../img/folder_up.gif' border='0' />".get_lang('LevelUp')."</a>"; |
56 | 56 | } |
57 | 57 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | $result = Database::query($sql); |
89 | 89 | while ($row = Database::fetch_array($result)) { |
90 | 90 | if (!$folder) { |
91 | - if (get_levels($row['path'])-1 == 1) { |
|
91 | + if (get_levels($row['path']) - 1 == 1) { |
|
92 | 92 | // showing the right icon. |
93 | 93 | if (file_or_folder($row['path'])) { |
94 | 94 | echo '<img src="../img/file.gif" align="middle" />'; |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | echo "&folder=".substr($row['path'], 1)."&source_id=$source_id&source_forum=".$_GET['source_forum']."&action=$action&lp_id=$learnpath_id&parent_item_id=$chapter_id&originalresource=no'>".substr($row['path'], 1).'</a><br />'; |
104 | 104 | } else { |
105 | 105 | echo substr($row['path'], 1).' '; |
106 | - echo showorhide_addresourcelink('Document',$row['id']); |
|
106 | + echo showorhide_addresourcelink('Document', $row['id']); |
|
107 | 107 | echo '<br />'; |
108 | 108 | } |
109 | 109 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | $level = get_levels($folder) + 1; |
114 | 114 | |
115 | 115 | // We calculate each level of the database entry. |
116 | - $file_level=get_levels($row['path'])-1; |
|
116 | + $file_level = get_levels($row['path']) - 1; |
|
117 | 117 | // If the level of the database entry is equal to the level we ar in, we put it into an array |
118 | 118 | // as this is a potential good entry. |
119 | 119 | if ($file_level == $level) { |
@@ -191,14 +191,14 @@ discard block |
||
191 | 191 | $addedresourceid = $_SESSION['addedresourceid']; |
192 | 192 | if ($_SESSION['addedresource']) { |
193 | 193 | foreach ($addedresource as $resource_type) { |
194 | - $sql="INSERT INTO $resource_table (c_id, source_type, source_id, resource_type, resource_id) VALUES |
|
194 | + $sql = "INSERT INTO $resource_table (c_id, source_type, source_id, resource_type, resource_id) VALUES |
|
195 | 195 | ($course_id, '$source_type', '$source_id', '$resource_type', '".$addedresourceid[key($addedresource)]."')"; |
196 | 196 | Database::query($sql); |
197 | - $i=key($addedresource); |
|
197 | + $i = key($addedresource); |
|
198 | 198 | next($addedresource); |
199 | 199 | } |
200 | - $_SESSION['addedresource']=''; |
|
201 | - $_SESSION['addedresourceid']=''; |
|
200 | + $_SESSION['addedresource'] = ''; |
|
201 | + $_SESSION['addedresourceid'] = ''; |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
@@ -278,21 +278,21 @@ discard block |
||
278 | 278 | $dbTable = Database::get_course_table(TABLE_DOCUMENT); |
279 | 279 | $result = Database::query("SELECT * FROM $dbTable WHERE c_id = $course_id AND id=$id"); |
280 | 280 | $myrow = Database::fetch_array($result); |
281 | - $pathname = explode('/',$myrow['path']); // Making a correct name for the link. |
|
282 | - $last = count($pathname) - 1; // Making a correct name for the link. |
|
283 | - $filename = $pathname[$last]; // Making a correct name for the link. |
|
281 | + $pathname = explode('/', $myrow['path']); // Making a correct name for the link. |
|
282 | + $last = count($pathname) - 1; // Making a correct name for the link. |
|
283 | + $filename = $pathname[$last]; // Making a correct name for the link. |
|
284 | 284 | $image = choose_image($filename); |
285 | 285 | $ext = explode('.', $filename); |
286 | - $ext = strtolower($ext[sizeof($ext)-1]); |
|
286 | + $ext = strtolower($ext[sizeof($ext) - 1]); |
|
287 | 287 | $myrow['path'] = rawurlencode($myrow['path']); |
288 | 288 | |
289 | - $array_ext=array('htm', 'html', 'gif', 'jpg', 'jpeg', 'png'); |
|
289 | + $array_ext = array('htm', 'html', 'gif', 'jpg', 'jpeg', 'png'); |
|
290 | 290 | |
291 | - if (api_browser_support('svg')){ |
|
292 | - $array_ext[]='svg'; |
|
291 | + if (api_browser_support('svg')) { |
|
292 | + $array_ext[] = 'svg'; |
|
293 | 293 | } |
294 | - if (api_browser_support('ogg')){ |
|
295 | - $array_ext[]='ogg'; |
|
294 | + if (api_browser_support('ogg')) { |
|
295 | + $array_ext[] = 'ogg'; |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | $in_frames = in_array($ext, $array_ext); |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | |
335 | 335 | $length = ((($builder == 'builder') && ($icon == 'nolink')) ? 65 : 32); |
336 | 336 | |
337 | - if ($builder != 'builder') $origin = 'learnpath'; //origin = learnpath in student view |
|
337 | + if ($builder != 'builder') $origin = 'learnpath'; //origin = learnpath in student view |
|
338 | 338 | $linktype = $type; |
339 | 339 | if (($type == 'Link _self') or ($type == 'Link _blank')) $type = 'Link'; |
340 | 340 | |
@@ -342,12 +342,12 @@ discard block |
||
342 | 342 | switch ($type) { |
343 | 343 | case TOOL_CALENDAR_EVENT: |
344 | 344 | case 'Agenda': |
345 | - $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA); |
|
345 | + $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA); |
|
346 | 346 | $result = Database::query("SELECT * FROM $TABLEAGENDA WHERE c_id = $course_id AND id=$id"); |
347 | 347 | $myrow = Database::fetch_array($result); |
348 | 348 | |
349 | 349 | $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path"; |
350 | - $result = Database::query($sql); $row = Database::fetch_array($result); |
|
350 | + $result = Database::query($sql); $row = Database::fetch_array($result); |
|
351 | 351 | if ($row['title'] != '') { $myrow['title'] = $row['title']; } |
352 | 352 | $desc = $row['description']; |
353 | 353 | $agenda_id = $row['item_id']; |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | if ($icon != 'nolink') { |
357 | 357 | if ($completed == 'completed') { |
358 | 358 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
359 | - } else { |
|
359 | + } else { |
|
360 | 360 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
361 | 361 | //echo " "; |
362 | 362 | } |
@@ -368,17 +368,17 @@ discard block |
||
368 | 368 | if ($icon == 'nolink') { return(shorten($myrow['title'], $length)); } |
369 | 369 | if ($icon == 'icon') { echo "<img src='../img/agenda.gif' align=\"absmiddle\" alt='agenda'>"; } |
370 | 370 | if ($builder != 'builder') { |
371 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path\" class='$completed'>".shorten($myrow['title'], ($length-3*$level))."</a>"; |
|
371 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path\" class='$completed'>".shorten($myrow['title'], ($length - 3 * $level))."</a>"; |
|
372 | 372 | $items[] = api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path"; |
373 | 373 | if ($desc != '') { |
374 | 374 | if ($icon != 'wrap') { |
375 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>"; |
|
375 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length - 3 * $level))."</div></td></tr>"; |
|
376 | 376 | } else { |
377 | - echo "<div class='description'> ".shorten($desc, ($length-3*$level))."</div>"; |
|
377 | + echo "<div class='description'> ".shorten($desc, ($length - 3 * $level))."</div>"; |
|
378 | 378 | } |
379 | 379 | } |
380 | 380 | } else { |
381 | - echo "<a href=\"../calendar/agenda.php?origin=$origin&agenda_id=$agenda_id\" class='$completed' target='_blank'>".shorten($myrow['title'], ($length-3*$level))."</a>"; |
|
381 | + echo "<a href=\"../calendar/agenda.php?origin=$origin&agenda_id=$agenda_id\" class='$completed' target='_blank'>".shorten($myrow['title'], ($length - 3 * $level))."</a>"; |
|
382 | 382 | } |
383 | 383 | break; |
384 | 384 | |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | if ($icon != 'nolink') { |
408 | 408 | if ($completed == 'completed') { |
409 | 409 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
410 | - } else { |
|
410 | + } else { |
|
411 | 411 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
412 | 412 | //echo " "; |
413 | 413 | } |
@@ -420,26 +420,26 @@ discard block |
||
420 | 420 | return(true); |
421 | 421 | } |
422 | 422 | |
423 | - if ($icon == 'nolink') { return(shorten($title,$length)); } |
|
423 | + if ($icon == 'nolink') { return(shorten($title, $length)); } |
|
424 | 424 | if ($icon == 'icon') { echo "<img src='../img/valves.gif' align=\"absmiddle\" alt='ad valvas'>"; } |
425 | 425 | if ($builder != 'builder') { |
426 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$ann_id#$id_in_path\" class='$completed'>".shorten($title, ($length-3*$level))."</a>"; |
|
426 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$ann_id#$id_in_path\" class='$completed'>".shorten($title, ($length - 3 * $level))."</a>"; |
|
427 | 427 | $items[] = api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$ann_id#$id_in_path"; |
428 | 428 | if ($desc != '') { |
429 | 429 | if ($icon != 'wrap') { |
430 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>"; |
|
430 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length - 3 * $level))."</div></td></tr>"; |
|
431 | 431 | } else { |
432 | - echo "<div class='description'> ".shorten($desc, ($length-3*$level))."</div>"; |
|
432 | + echo "<div class='description'> ".shorten($desc, ($length - 3 * $level))."</div>"; |
|
433 | 433 | } |
434 | 434 | } |
435 | 435 | } else { |
436 | - echo "<a href=\"../announcements/announcements.php?origin=$origin&ann_id=$ann_id\" class='$completed' target='_blank'>".shorten($title, ($length-3*$level))."</a>"; |
|
436 | + echo "<a href=\"../announcements/announcements.php?origin=$origin&ann_id=$ann_id\" class='$completed' target='_blank'>".shorten($title, ($length - 3 * $level))."</a>"; |
|
437 | 437 | } |
438 | 438 | break; |
439 | 439 | |
440 | 440 | case TOOL_LINK: |
441 | 441 | case 'Link': |
442 | - $TABLETOOLLINK = Database::get_course_table(TABLE_LINK); |
|
442 | + $TABLETOOLLINK = Database::get_course_table(TABLE_LINK); |
|
443 | 443 | $result = Database::query("SELECT * FROM $TABLETOOLLINK WHERE c_id = $course_id AND id=$id"); |
444 | 444 | $myrow = Database::fetch_array($result); |
445 | 445 | |
@@ -447,14 +447,14 @@ discard block |
||
447 | 447 | $result = Database::query($sql); |
448 | 448 | $row = Database::fetch_array($result); |
449 | 449 | if ($row['title'] != '') { $myrow['title'] = $row['title']; } |
450 | - $desc=$row['description']; |
|
450 | + $desc = $row['description']; |
|
451 | 451 | echo str_repeat(" >", $level); |
452 | 452 | |
453 | 453 | if (($builder != 'builder') && ($icon != 'wrap')) { echo "<td>"; } |
454 | 454 | if ($icon != 'nolink') { |
455 | 455 | if ($completed == 'completed') { |
456 | 456 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
457 | - } else { |
|
457 | + } else { |
|
458 | 458 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
459 | 459 | //echo " "; |
460 | 460 | } |
@@ -473,23 +473,23 @@ discard block |
||
473 | 473 | } |
474 | 474 | $thelink = $myrow['url']; |
475 | 475 | if ($builder != 'builder') { |
476 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path\" class='$completed'>".shorten($myrow['title'], ($length-3*$level))."</a>"; |
|
477 | - $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path"; |
|
476 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path\" class='$completed'>".shorten($myrow['title'], ($length - 3 * $level))."</a>"; |
|
477 | + $items[] = api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path"; |
|
478 | 478 | if ($desc != '') { |
479 | 479 | if ($icon != 'wrap') { |
480 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>"; |
|
480 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length - 3 * $level))."</div></td></tr>"; |
|
481 | 481 | } else { |
482 | - echo "<div class='description'> ".shorten($desc, ($length-3*$level))."</div>"; |
|
482 | + echo "<div class='description'> ".shorten($desc, ($length - 3 * $level))."</div>"; |
|
483 | 483 | } |
484 | 484 | } |
485 | 485 | } else { |
486 | - echo "<a href=\"$thelink\" class='$completed' target='_blank'>".shorten($myrow['title'], ($length-3*$level))."</a>"; |
|
486 | + echo "<a href=\"$thelink\" class='$completed' target='_blank'>".shorten($myrow['title'], ($length - 3 * $level))."</a>"; |
|
487 | 487 | } |
488 | 488 | break; |
489 | 489 | |
490 | 490 | case TOOL_QUIZ: |
491 | 491 | case 'Exercise': |
492 | - $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); |
|
492 | + $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); |
|
493 | 493 | $result = Database::query("SELECT * FROM $TBL_EXERCICES WHERE c_id = $course_id AND id=$id"); |
494 | 494 | $myrow = Database::fetch_array($result); |
495 | 495 | |
@@ -522,35 +522,35 @@ discard block |
||
522 | 522 | if ($icon == 'nolink') { return(shorten($myrow['title'], $length)); } |
523 | 523 | if ($icon == 'icon') { echo "<img src='../img/quiz.gif' align=\"absmiddle\" alt='quizz'>"; } |
524 | 524 | if ($builder != 'builder') { |
525 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path\" class='$completed'>".shorten($myrow['title'], ($length-3*$level))."</a>"; |
|
525 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path\" class='$completed'>".shorten($myrow['title'], ($length - 3 * $level))."</a>"; |
|
526 | 526 | $items[] = api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path"; |
527 | 527 | if ($desc != '') { |
528 | 528 | if ($icon != 'wrap') { |
529 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>"; |
|
529 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length - 3 * $level))."</div></td></tr>"; |
|
530 | 530 | } else { |
531 | - echo "<div class='description'> ".shorten($desc, ($length-3*$level))."</div>"; |
|
531 | + echo "<div class='description'> ".shorten($desc, ($length - 3 * $level))."</div>"; |
|
532 | 532 | } |
533 | 533 | } |
534 | 534 | } else { |
535 | - echo "<a href=\"../exercice/exercise_submit.php?origin=$origin&exerciseId=".$myrow['id']."\" class='$completed' target='_blank'>".shorten($myrow['title'], ($length-3*$level))."</a>"; |
|
535 | + echo "<a href=\"../exercice/exercise_submit.php?origin=$origin&exerciseId=".$myrow['id']."\" class='$completed' target='_blank'>".shorten($myrow['title'], ($length - 3 * $level))."</a>"; |
|
536 | 536 | } |
537 | 537 | break; |
538 | 538 | |
539 | 539 | case 'hotpotatoes': |
540 | 540 | case 'HotPotatoes': |
541 | - $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT); |
|
541 | + $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT); |
|
542 | 542 | $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
543 | 543 | $result = Database::query("SELECT * FROM ".$TBL_DOCUMENT." WHERE c_id = $course_id AND id=$id"); |
544 | 544 | $myrow = Database::fetch_array($result); |
545 | 545 | $path = $myrow['path']; |
546 | 546 | $name = GetQuizName($path, $documentPath); |
547 | 547 | |
548 | - if ($builder == 'builder') { $origin='builder'; } |
|
548 | + if ($builder == 'builder') { $origin = 'builder'; } |
|
549 | 549 | // This is needed for the exercise_submit.php can delete the session info about tests. |
550 | 550 | |
551 | 551 | $sql = "select * from $tbl_lp_item where id=$id_in_path"; |
552 | - $result = Database::query($sql); $row = Database::fetch_array($result); |
|
553 | - if ($row['title'] != '') { $name=$row['title']; } |
|
552 | + $result = Database::query($sql); $row = Database::fetch_array($result); |
|
553 | + if ($row['title'] != '') { $name = $row['title']; } |
|
554 | 554 | $desc = $row['description']; |
555 | 555 | echo str_repeat(" >", $level); |
556 | 556 | |
@@ -558,32 +558,32 @@ discard block |
||
558 | 558 | if ($icon != 'nolink') { |
559 | 559 | if ($completed == 'completed') { |
560 | 560 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
561 | - } else { |
|
561 | + } else { |
|
562 | 562 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
563 | 563 | //echo " "; |
564 | 564 | } |
565 | 565 | } |
566 | 566 | if (($builder != 'builder') && ($icon != 'wrap')) { echo "</td><td>"; } |
567 | 567 | |
568 | - if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
568 | + if ($name == '') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
569 | 569 | |
570 | - if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
570 | + if ($icon == 'nolink') { return(shorten($name, $length)); } |
|
571 | 571 | if ($icon == 'icon') { echo "<img src='../img/jqz.jpg' align=\"absmiddle\" alt='hot potatoes'>"; } |
572 | 572 | |
573 | 573 | $cid = $_course['official_code']; |
574 | 574 | |
575 | 575 | if ($builder != 'builder') { |
576 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; |
|
576 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path\" class='$completed'>".shorten($name, ($length - 3 * $level))."</a>"; |
|
577 | 577 | $items[] = api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path"; |
578 | 578 | if ($desc != '') { |
579 | 579 | if ($icon != 'wrap') { |
580 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>"; |
|
580 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length - 3 * $level))."</div></td></tr>"; |
|
581 | 581 | } else { |
582 | - echo "<div class='description'> ".shorten($desc, ($length-3*$level))."</div>"; |
|
582 | + echo "<div class='description'> ".shorten($desc, ($length - 3 * $level))."</div>"; |
|
583 | 583 | } |
584 | 584 | } |
585 | 585 | } else { |
586 | - echo " <a href=\"../exercice/showinframes.php?file=$path&cid=$cid&uid=".$_user['user_id']."\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
586 | + echo " <a href=\"../exercice/showinframes.php?file=$path&cid=$cid&uid=".$_user['user_id']."\" class='$completed' target='_blank'>".shorten($name, ($length - 3 * $level))."</a>"; |
|
587 | 587 | } |
588 | 588 | break; |
589 | 589 | |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | $myrow = Database::fetch_array($result); |
595 | 595 | |
596 | 596 | $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path"; |
597 | - $result = Database::query($sql); $row = Database::fetch_array($result); |
|
597 | + $result = Database::query($sql); $row = Database::fetch_array($result); |
|
598 | 598 | if ($row['title'] != '') { $myrow["forum_name"] = $row['title']; } |
599 | 599 | $desc = $row['description']; |
600 | 600 | echo str_repeat(" >", $level); |
@@ -603,30 +603,30 @@ discard block |
||
603 | 603 | if ($icon != 'nolink') { |
604 | 604 | if ($completed == 'completed') { |
605 | 605 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
606 | - } else { |
|
606 | + } else { |
|
607 | 607 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
608 | 608 | //echo " "; |
609 | 609 | } |
610 | 610 | } |
611 | 611 | if (($builder != 'builder') && ($icon != 'wrap')) { echo "</td><td>"; } |
612 | 612 | |
613 | - if ($myrow["forum_name"]=='') { $type="Forum"; echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
613 | + if ($myrow["forum_name"] == '') { $type = "Forum"; echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
614 | 614 | |
615 | 615 | if ($icon == 'nolink') { return(shorten($myrow['forum_name'], $length)); } |
616 | 616 | if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; } |
617 | 617 | $forumparameters = "forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]; |
618 | 618 | if ($builder != 'builder') { |
619 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path\" class='$completed'>".shorten($myrow["forum_name"],($length-3*$level))."</a>"; |
|
619 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path\" class='$completed'>".shorten($myrow["forum_name"], ($length - 3 * $level))."</a>"; |
|
620 | 620 | $items[] = api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path"; |
621 | 621 | if ($desc != '') { |
622 | 622 | if ($icon != 'wrap') { |
623 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
623 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length - 3 * $level))."</div></td></tr>"; |
|
624 | 624 | } else { |
625 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
625 | + echo "<div class='description'> ".shorten($desc, ($length - 3 * $level))."</div>"; |
|
626 | 626 | } |
627 | 627 | } |
628 | 628 | } else { |
629 | - echo "<a href=\"../phpbb/viewforum.php?$forumparameters\" class='$completed' target='_blank'>".shorten($myrow["forum_name"],($length-3*$level))."</a>"; |
|
629 | + echo "<a href=\"../phpbb/viewforum.php?$forumparameters\" class='$completed' target='_blank'>".shorten($myrow["forum_name"], ($length - 3 * $level))."</a>"; |
|
630 | 630 | } |
631 | 631 | break; |
632 | 632 | |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | $myrow = Database::fetch_array($result); |
639 | 639 | |
640 | 640 | $sql = "select * from $tbl_lp_item where id=$id_in_path"; |
641 | - $result = Database::query($sql); $row = Database::fetch_array($result); |
|
641 | + $result = Database::query($sql); $row = Database::fetch_array($result); |
|
642 | 642 | if ($row['title'] != '') { $myrow['topic_title'] = $row['title']; } |
643 | 643 | $desc = $row['description']; |
644 | 644 | echo str_repeat(" >", $level); |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | if ($icon != 'nolink') { |
648 | 648 | if ($completed == 'completed') { |
649 | 649 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
650 | - } else { |
|
650 | + } else { |
|
651 | 651 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
652 | 652 | //echo " "; |
653 | 653 | } |
@@ -659,17 +659,17 @@ discard block |
||
659 | 659 | if ($icon == 'nolink') { return(shorten($myrow['topic_title'], $length)); } |
660 | 660 | if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; } |
661 | 661 | if ($builder != 'builder') { |
662 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path\" class='$completed'>".shorten($myrow["topic_title"], ($length-3*$level))."</a>"; |
|
662 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path\" class='$completed'>".shorten($myrow["topic_title"], ($length - 3 * $level))."</a>"; |
|
663 | 663 | $items[] = api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path"; |
664 | 664 | if ($desc != '') { |
665 | 665 | if ($icon != 'wrap') { |
666 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
666 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length - 3 * $level))."</div></td></tr>"; |
|
667 | 667 | } else { |
668 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
668 | + echo "<div class='description'> ".shorten($desc, ($length - 3 * $level))."</div>"; |
|
669 | 669 | } |
670 | 670 | } |
671 | 671 | } else { |
672 | - echo "<a href=\"../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."\" class='$completed' target='_blank'>".shorten($myrow["topic_title"],($length-3*$level))."</a>"; |
|
672 | + echo "<a href=\"../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."\" class='$completed' target='_blank'>".shorten($myrow["topic_title"], ($length - 3 * $level))."</a>"; |
|
673 | 673 | } |
674 | 674 | break; |
675 | 675 | |
@@ -684,13 +684,13 @@ discard block |
||
684 | 684 | |
685 | 685 | $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path"; |
686 | 686 | $result = Database::query($sql); |
687 | - $row=Database::fetch_array($result); |
|
687 | + $row = Database::fetch_array($result); |
|
688 | 688 | if ($row['title'] != '') { $myrow['post_title'] = $row['title']; } |
689 | 689 | $desc = $row['description']; |
690 | 690 | echo str_repeat(" >", $level); |
691 | 691 | |
692 | - $posternom = $myrow['nom']; $posterprenom = $myrow['prenom']; |
|
693 | - $posttime = $myrow['post_time']; $posttext = $myrow['post_text']; |
|
692 | + $posternom = $myrow['nom']; $posterprenom = $myrow['prenom']; |
|
693 | + $posttime = $myrow['post_time']; $posttext = $myrow['post_text']; |
|
694 | 694 | $posttitle = $myrow['post_title']; |
695 | 695 | $posttext = str_replace('"', "'", $posttext); |
696 | 696 | |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | if ($icon != 'nolink') { |
699 | 699 | if ($completed == 'completed') { |
700 | 700 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
701 | - } else { |
|
701 | + } else { |
|
702 | 702 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
703 | 703 | //echo " "; |
704 | 704 | } |
@@ -710,19 +710,19 @@ discard block |
||
710 | 710 | echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); |
711 | 711 | } |
712 | 712 | |
713 | - if ($icon == 'nolink') { return(shorten($myrow["post_title"],$length)); } |
|
713 | + if ($icon == 'nolink') { return(shorten($myrow["post_title"], $length)); } |
|
714 | 714 | if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; } |
715 | 715 | if ($builder != 'builder') { |
716 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".intval($_GET['source_forum'])."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Post&origin=$origin&posternom=$posternom&posterprenom=$posterprenom&posttime=$posttime&posttext=$posttext&posttitle=$posttitle#$id_in_path\" class='$completed'>".shorten($myrow["post_title"],($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".intval($_GET['source_forum'])."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Post&origin=$origin&posternom=$posternom&posterprenom=$posterprenom&posttime=$posttime&posttext=$posttext&posttitle=$posttitle#$id_in_path"; |
|
716 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".intval($_GET['source_forum'])."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Post&origin=$origin&posternom=$posternom&posterprenom=$posterprenom&posttime=$posttime&posttext=$posttext&posttitle=$posttitle#$id_in_path\" class='$completed'>".shorten($myrow["post_title"], ($length - 3 * $level))."</a>"; $items[] = api_get_self()."?action=closelesson&source_forum=".intval($_GET['source_forum'])."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Post&origin=$origin&posternom=$posternom&posterprenom=$posterprenom&posttime=$posttime&posttext=$posttext&posttitle=$posttitle#$id_in_path"; |
|
717 | 717 | if ($desc != '') { |
718 | 718 | if ($icon != 'wrap') { |
719 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
719 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length - 3 * $level))."</div></td></tr>"; |
|
720 | 720 | } else { |
721 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
721 | + echo "<div class='description'> ".shorten($desc, ($length - 3 * $level))."</div>"; |
|
722 | 722 | } |
723 | 723 | } |
724 | 724 | } else { |
725 | - echo "<a href=\"../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."\" class='$completed' target='_blank'>".shorten($myrow["post_title"],($length-3*$level))."</a>"; |
|
725 | + echo "<a href=\"../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."\" class='$completed' target='_blank'>".shorten($myrow["post_title"], ($length - 3 * $level))."</a>"; |
|
726 | 726 | } |
727 | 727 | break; |
728 | 728 | |
@@ -735,14 +735,14 @@ discard block |
||
735 | 735 | $myrow = Database::fetch_array($result); |
736 | 736 | |
737 | 737 | $pathname = explode('/', $myrow['path']); // Making a correct name for the link. |
738 | - $last = count($pathname) - 1; // Making a correct name for the link. |
|
739 | - $filename=$pathname[$last]; // Making a correct name for the link. |
|
738 | + $last = count($pathname) - 1; // Making a correct name for the link. |
|
739 | + $filename = $pathname[$last]; // Making a correct name for the link. |
|
740 | 740 | if (($builder != 'builder') && ($icon != 'wrap')) { echo "<td>"; } |
741 | 741 | |
742 | 742 | echo str_repeat(" >", $level); |
743 | 743 | |
744 | 744 | if ($icon != 'nolink') { |
745 | - if ($completed=='completed') { |
|
745 | + if ($completed == 'completed') { |
|
746 | 746 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
747 | 747 | } else { |
748 | 748 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
@@ -754,9 +754,9 @@ discard block |
||
754 | 754 | |
755 | 755 | $sql = "select * from $tbl_lp_item where id=$id_in_path"; |
756 | 756 | //error_log('New LP - Querying lp_item table: '.$sql, 0); |
757 | - $result = Database::query($sql); $row = Database::fetch_array($result); |
|
757 | + $result = Database::query($sql); $row = Database::fetch_array($result); |
|
758 | 758 | if ($row['title'] != '') { $filename = $row['title']; } |
759 | - $desc=$row['description']; |
|
759 | + $desc = $row['description']; |
|
760 | 760 | |
761 | 761 | if (($myrow['path'] == '') && ($filename == '')) { |
762 | 762 | echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; |
@@ -767,22 +767,22 @@ discard block |
||
767 | 767 | if ($icon == 'icon') { echo "<img src='../img/$image' align=\"absmiddle\" alt='$image'>"; } |
768 | 768 | if ($builder != 'builder') |
769 | 769 | { |
770 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path\" class='$completed'>".shorten($filename,($length-3*$level))."</a>"; |
|
770 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path\" class='$completed'>".shorten($filename, ($length - 3 * $level))."</a>"; |
|
771 | 771 | if ($desc != '') { |
772 | 772 | if ($icon != 'wrap') { |
773 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
773 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length - 3 * $level))."</div></td></tr>"; |
|
774 | 774 | } else { |
775 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
775 | + echo "<div class='description'> ".shorten($desc, ($length - 3 * $level))."</div>"; |
|
776 | 776 | } |
777 | 777 | } $items[] = api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path"; |
778 | 778 | } else { |
779 | - $enableDocumentParsing=yes; |
|
779 | + $enableDocumentParsing = yes; |
|
780 | 780 | if (!$enableDocumentParsing) { |
781 | 781 | // This is the solution for the non-parsing version in the builder. |
782 | 782 | $file = urlencode($myrow['path']); |
783 | - echo "<a href='../document/showinframes.php?file=$file' class='$completed' $hyperlink_target_parameter>".shorten($filename,($length-3*$level))."</a>"; |
|
783 | + echo "<a href='../document/showinframes.php?file=$file' class='$completed' $hyperlink_target_parameter>".shorten($filename, ($length - 3 * $level))."</a>"; |
|
784 | 784 | } else { |
785 | - echo "<a href=\"../document/download.php?doc_url=".$myrow['path']."\" class='$completed' $hyperlink_target_parameter>".shorten($filename,($length-3*$level))."</a>"; |
|
785 | + echo "<a href=\"../document/download.php?doc_url=".$myrow['path']."\" class='$completed' $hyperlink_target_parameter>".shorten($filename, ($length - 3 * $level))."</a>"; |
|
786 | 786 | } |
787 | 787 | } |
788 | 788 | break; |
@@ -793,7 +793,7 @@ discard block |
||
793 | 793 | $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path"; |
794 | 794 | $result = Database::query($sql); |
795 | 795 | $row = Database::fetch_array($result); |
796 | - if ($row['title'] != '') { $name=$row['title']; } |
|
796 | + if ($row['title'] != '') { $name = $row['title']; } |
|
797 | 797 | $desc = $row['description']; |
798 | 798 | echo str_repeat(" >", $level); |
799 | 799 | |
@@ -801,30 +801,30 @@ discard block |
||
801 | 801 | if ($icon != 'nolink') { |
802 | 802 | if ($completed == 'completed') { |
803 | 803 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
804 | - } else { |
|
804 | + } else { |
|
805 | 805 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
806 | 806 | //echo " "; |
807 | 807 | } |
808 | 808 | } |
809 | 809 | if (($builder != 'builder') && ($icon != 'wrap')) { echo "</td><td>"; } |
810 | 810 | |
811 | - if ($name=='') { |
|
811 | + if ($name == '') { |
|
812 | 812 | echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); |
813 | 813 | } |
814 | 814 | |
815 | 815 | if ($icon == 'nolink') { return(shorten($name, $length)); } |
816 | 816 | if ($icon == 'icon') { echo "<img src='../img/works.gif' align=\"absmiddle\">"; } |
817 | 817 | if ($builder != 'builder') { |
818 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path"; |
|
818 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path\" class='$completed'>".shorten($name, ($length - 3 * $level))."</a>"; $items[] = api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path"; |
|
819 | 819 | if ($desc != '') { |
820 | 820 | if ($icon != 'wrap') { |
821 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>"; |
|
821 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length - 3 * $level))."</div></td></tr>"; |
|
822 | 822 | } else { |
823 | - echo "<div class='description'> ".shorten($desc, ($length-3*$level))."</div>"; |
|
823 | + echo "<div class='description'> ".shorten($desc, ($length - 3 * $level))."</div>"; |
|
824 | 824 | } |
825 | 825 | } |
826 | 826 | } else { |
827 | - echo "<a href=\"../work/work.php\" class='$completed' target='_blank'>".shorten($name, ($length-3*$level))."</a>"; |
|
827 | + echo "<a href=\"../work/work.php\" class='$completed' target='_blank'>".shorten($name, ($length - 3 * $level))."</a>"; |
|
828 | 828 | } |
829 | 829 | break; |
830 | 830 | |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | if ($icon != 'nolink') { |
843 | 843 | if ($completed == 'completed') { |
844 | 844 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
845 | - } else { |
|
845 | + } else { |
|
846 | 846 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
847 | 847 | //echo " "; |
848 | 848 | } |
@@ -855,15 +855,15 @@ discard block |
||
855 | 855 | if ($icon == 'icon') { echo "<img src='../img/dropbox.gif' align=\"absmiddle\">"; } |
856 | 856 | |
857 | 857 | if ($builder != 'builder') { |
858 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path"; |
|
858 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path\" class='$completed'>".shorten($name, ($length - 3 * $level))."</a>"; $items[] = api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path"; |
|
859 | 859 | if ($desc != '') { |
860 | 860 | if ($icon != 'wrap') { |
861 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>"; } |
|
861 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length - 3 * $level))."</div></td></tr>"; } |
|
862 | 862 | else { |
863 | - echo "<div class='description'> ".shorten($desc, ($length-3*$level))."</div>"; } |
|
863 | + echo "<div class='description'> ".shorten($desc, ($length - 3 * $level))."</div>"; } |
|
864 | 864 | } |
865 | 865 | } else { |
866 | - echo "<a href=\"../dropbox/index.php\" class='$completed' target='_blank'>".shorten($name, ($length-3*$level))."</a>"; |
|
866 | + echo "<a href=\"../dropbox/index.php\" class='$completed' target='_blank'>".shorten($name, ($length - 3 * $level))."</a>"; |
|
867 | 867 | } |
868 | 868 | break; |
869 | 869 | |
@@ -871,7 +871,7 @@ discard block |
||
871 | 871 | case 'Introduction_text': |
872 | 872 | $name = get_lang('IntroductionText'); |
873 | 873 | $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path"; |
874 | - $result = Database::query($sql); $row = Database::fetch_array($result); |
|
874 | + $result = Database::query($sql); $row = Database::fetch_array($result); |
|
875 | 875 | if ($row['title'] != '') { $name = $row['title']; } |
876 | 876 | $desc = $row['description']; |
877 | 877 | echo str_repeat(" >", $level); |
@@ -893,17 +893,17 @@ discard block |
||
893 | 893 | if ($icon == 'icon') { echo "<img src='../img/introduction.gif' align=\"absmiddle\" alt='introduction'>"; } |
894 | 894 | |
895 | 895 | if ($builder != 'builder') { |
896 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; |
|
896 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path\" class='$completed'>".shorten($name, ($length - 3 * $level))."</a>"; |
|
897 | 897 | $items[] = api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path"; |
898 | 898 | if ($desc != '') { |
899 | 899 | if ($icon != 'wrap') { |
900 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>"; } |
|
900 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length - 3 * $level))."</div></td></tr>"; } |
|
901 | 901 | else { |
902 | - echo "<div class='description'> ".shorten($desc, ($length-3*$level))."</div>"; } |
|
902 | + echo "<div class='description'> ".shorten($desc, ($length - 3 * $level))."</div>"; } |
|
903 | 903 | } |
904 | 904 | } else { |
905 | 905 | $s = api_get_path(WEB_COURSE_PATH)."$_cid/index.php?intro_cmdEdit=1"; |
906 | - echo "<a href=\"$s\" class='$completed' target='_blank'>".shorten($name, ($length-3*$level))."</a>"; |
|
906 | + echo "<a href=\"$s\" class='$completed' target='_blank'>".shorten($name, ($length - 3 * $level))."</a>"; |
|
907 | 907 | } |
908 | 908 | break; |
909 | 909 | |
@@ -911,7 +911,7 @@ discard block |
||
911 | 911 | case 'Course_description': |
912 | 912 | $name = get_lang('CourseDescription'); |
913 | 913 | $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path"; |
914 | - $result = Database::query($sql); $row = Database::fetch_array($result); |
|
914 | + $result = Database::query($sql); $row = Database::fetch_array($result); |
|
915 | 915 | if ($row['title'] != '') { $name = $row['title']; } |
916 | 916 | $desc = $row['description']; |
917 | 917 | echo str_repeat(" >", $level); |
@@ -920,7 +920,7 @@ discard block |
||
920 | 920 | if ($icon != 'nolink') { |
921 | 921 | if ($completed == 'completed') { |
922 | 922 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
923 | - } else { |
|
923 | + } else { |
|
924 | 924 | echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
925 | 925 | //echo " "; |
926 | 926 | } |
@@ -929,20 +929,20 @@ discard block |
||
929 | 929 | |
930 | 930 | if ($name == '') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
931 | 931 | |
932 | - if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
932 | + if ($icon == 'nolink') { return(shorten($name, $length)); } |
|
933 | 933 | if ($icon == 'icon') { echo "<img src='../img/info.gif' align=\"absmiddle\" alt='info'>"; } |
934 | 934 | |
935 | 935 | if ($builder != 'builder') { |
936 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path"; |
|
936 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path\" class='$completed'>".shorten($name, ($length - 3 * $level))."</a>"; $items[] = api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path"; |
|
937 | 937 | if ($desc != '') { |
938 | 938 | if ($icon != 'wrap') { |
939 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>"; } |
|
939 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length - 3 * $level))."</div></td></tr>"; } |
|
940 | 940 | else { |
941 | - echo "<div class='description'> ".shorten($desc, ($length-3*$level))."</div>"; } |
|
941 | + echo "<div class='description'> ".shorten($desc, ($length - 3 * $level))."</div>"; } |
|
942 | 942 | } |
943 | 943 | } else { |
944 | - $s=api_get_path(WEB_CODE_PATH)."course_description"; |
|
945 | - echo "<a href=\"$s\" class='$completed' target='_blank'>".shorten($name, ($length-3*$level))."</a>"; |
|
944 | + $s = api_get_path(WEB_CODE_PATH)."course_description"; |
|
945 | + echo "<a href=\"$s\" class='$completed' target='_blank'>".shorten($name, ($length - 3 * $level))."</a>"; |
|
946 | 946 | } |
947 | 947 | break; |
948 | 948 | |
@@ -952,7 +952,7 @@ discard block |
||
952 | 952 | $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path"; |
953 | 953 | $result = Database::query($sql); |
954 | 954 | $row = Database::fetch_array($result); |
955 | - if ($row['title'] != '') { $name=$row['title']; } |
|
955 | + if ($row['title'] != '') { $name = $row['title']; } |
|
956 | 956 | $desc = $row['description']; |
957 | 957 | echo str_repeat(" >", $level); |
958 | 958 | |
@@ -967,21 +967,21 @@ discard block |
||
967 | 967 | } |
968 | 968 | if (($builder != 'builder') && ($icon != 'wrap')) { echo "</td><td>"; } |
969 | 969 | |
970 | - if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
970 | + if ($name == '') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
971 | 971 | |
972 | 972 | if ($icon == 'nolink') { return(shorten($name, $length)); } |
973 | 973 | if ($icon == 'icon') { echo "<img src='../img/group.gif' align=\"absmiddle\" alt='group'>"; } |
974 | 974 | |
975 | 975 | if ($builder != 'builder') { |
976 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path"; |
|
976 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path\" class='$completed'>".shorten($name, ($length - 3 * $level))."</a>"; $items[] = api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path"; |
|
977 | 977 | if ($desc != '') { |
978 | 978 | if ($icon != 'wrap') { |
979 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>"; } |
|
979 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length - 3 * $level))."</div></td></tr>"; } |
|
980 | 980 | else { |
981 | - echo "<div class='description'> ".shorten($desc, ($length-3*$level))."</div>"; } |
|
981 | + echo "<div class='description'> ".shorten($desc, ($length - 3 * $level))."</div>"; } |
|
982 | 982 | } |
983 | 983 | } else { |
984 | - echo "<a href=\"../group/group.php?origin=$origin\" class='$completed' target='_blank'>".shorten($name, ($length-3*$level))."</a>"; |
|
984 | + echo "<a href=\"../group/group.php?origin=$origin\" class='$completed' target='_blank'>".shorten($name, ($length - 3 * $level))."</a>"; |
|
985 | 985 | } |
986 | 986 | break; |
987 | 987 | |
@@ -1006,21 +1006,21 @@ discard block |
||
1006 | 1006 | } |
1007 | 1007 | if (($builder != 'builder') && ($icon != 'wrap')) { echo "</td><td>"; } |
1008 | 1008 | |
1009 | - if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
1009 | + if ($name == '') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
1010 | 1010 | |
1011 | - if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
1011 | + if ($icon == 'nolink') { return(shorten($name, $length)); } |
|
1012 | 1012 | if ($icon == 'icon') { echo "<img src='../img/members.gif' align=\"absmiddle\" alt='members'>"; } |
1013 | 1013 | |
1014 | 1014 | if ($builder != 'builder') { |
1015 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path"; |
|
1015 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path\" class='$completed'>".shorten($name, ($length - 3 * $level))."</a>"; $items[] = api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path"; |
|
1016 | 1016 | if ($desc != '') { |
1017 | 1017 | if ($icon != 'wrap') { |
1018 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>"; } |
|
1018 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length - 3 * $level))."</div></td></tr>"; } |
|
1019 | 1019 | else { |
1020 | - echo "<div class='description'> ".shorten($desc, ($length-3*$level))."</div>"; } |
|
1020 | + echo "<div class='description'> ".shorten($desc, ($length - 3 * $level))."</div>"; } |
|
1021 | 1021 | } |
1022 | 1022 | } else { |
1023 | - echo "<a href=\"../user/user.php?origin=$origin\" class='$completed' target='_blank'>".shorten($name, ($length-3*$level))."</a>"; |
|
1023 | + echo "<a href=\"../user/user.php?origin=$origin\" class='$completed' target='_blank'>".shorten($name, ($length - 3 * $level))."</a>"; |
|
1024 | 1024 | } |
1025 | 1025 | break; |
1026 | 1026 | }//end huge switch-statement |
@@ -1059,7 +1059,7 @@ discard block |
||
1059 | 1059 | $myrow = Database::fetch_array($result); |
1060 | 1060 | |
1061 | 1061 | $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path"; |
1062 | - $result = Database::query($sql); $row = Database::fetch_array($result); |
|
1062 | + $result = Database::query($sql); $row = Database::fetch_array($result); |
|
1063 | 1063 | if ($row['title'] != '') { $myrow['title'] = $row['title']; } |
1064 | 1064 | $desc = $row['description']; |
1065 | 1065 | $agenda_id = $row['item_id']; |
@@ -1084,7 +1084,7 @@ discard block |
||
1084 | 1084 | break; |
1085 | 1085 | |
1086 | 1086 | case 'Link': |
1087 | - $TABLETOOLLINK = Database::get_course_table(TABLE_LINK); |
|
1087 | + $TABLETOOLLINK = Database::get_course_table(TABLE_LINK); |
|
1088 | 1088 | $result = Database::query("SELECT * FROM $TABLETOOLLINK WHERE c_id = $course_id AND id=$id"); |
1089 | 1089 | $myrow = Database::fetch_array($result); |
1090 | 1090 | |
@@ -1101,7 +1101,7 @@ discard block |
||
1101 | 1101 | break; |
1102 | 1102 | |
1103 | 1103 | case 'Exercise': |
1104 | - $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); |
|
1104 | + $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); |
|
1105 | 1105 | $result = Database::query("SELECT * FROM $TBL_EXERCICES WHERE c_id = $course_id AND id=$id"); |
1106 | 1106 | $myrow = Database::fetch_array($result); |
1107 | 1107 | |
@@ -1109,7 +1109,7 @@ discard block |
||
1109 | 1109 | // This is needed for the exercise_submit.php can delete the session info about tests. |
1110 | 1110 | |
1111 | 1111 | $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path"; |
1112 | - $result = Database::query($sql); $row = Database::fetch_array($result); |
|
1112 | + $result = Database::query($sql); $row = Database::fetch_array($result); |
|
1113 | 1113 | if ($row['title'] != '') { $myrow['title'] = $row['title']; } |
1114 | 1114 | |
1115 | 1115 | if ($builder != 'builder') { |
@@ -1119,7 +1119,7 @@ discard block |
||
1119 | 1119 | } |
1120 | 1120 | break; |
1121 | 1121 | case 'HotPotatoes': |
1122 | - $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT); |
|
1122 | + $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT); |
|
1123 | 1123 | $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
1124 | 1124 | $result = Database::query("SELECT * FROM ".$TBL_DOCUMENT." WHERE c_id = $course_id AND id=$id"); |
1125 | 1125 | $myrow = Database::fetch_array($result); |
@@ -1137,14 +1137,14 @@ discard block |
||
1137 | 1137 | break; |
1138 | 1138 | case 'Forum': |
1139 | 1139 | //deprecated |
1140 | - $TBL_FORUMS = Database::get_course_table(TABLE_FORUM); // TODO: This is the old table name, it should be corrected. |
|
1140 | + $TBL_FORUMS = Database::get_course_table(TABLE_FORUM); // TODO: This is the old table name, it should be corrected. |
|
1141 | 1141 | $result = Database::query("SELECT * FROM $TBL_FORUMS WHERE c_id = $course_id AND forum_id=$id"); |
1142 | 1142 | $myrow = Database::fetch_array($result); |
1143 | 1143 | |
1144 | 1144 | if ($builder == 'builder') { $origin = 'builder'; } |
1145 | 1145 | |
1146 | 1146 | $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path"; |
1147 | - $result = Database::query($sql); $row = Database::fetch_array($result); |
|
1147 | + $result = Database::query($sql); $row = Database::fetch_array($result); |
|
1148 | 1148 | if ($row['title'] != '') { $myrow['forum_name'] = $row['title']; } |
1149 | 1149 | |
1150 | 1150 | if ($myrow['forum_name'] == '') { $type = 'Forum'; } |
@@ -1167,7 +1167,7 @@ discard block |
||
1167 | 1167 | $myrow = Database::fetch_array($result); |
1168 | 1168 | |
1169 | 1169 | $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path"; |
1170 | - $result = Database::query($sql); $row = Database::fetch_array($result); |
|
1170 | + $result = Database::query($sql); $row = Database::fetch_array($result); |
|
1171 | 1171 | |
1172 | 1172 | if ($builder != 'builder') { |
1173 | 1173 | $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path"; |
@@ -1191,8 +1191,8 @@ discard block |
||
1191 | 1191 | $desc = $row['description']; |
1192 | 1192 | //$link .= str_repeat(" >", $level); |
1193 | 1193 | |
1194 | - $posternom = $myrow['nom']; $posterprenom = $myrow['prenom']; |
|
1195 | - $posttime = $myrow['post_time']; $posttext = $myrow['post_text']; |
|
1194 | + $posternom = $myrow['nom']; $posterprenom = $myrow['prenom']; |
|
1195 | + $posttime = $myrow['post_time']; $posttext = $myrow['post_text']; |
|
1196 | 1196 | $posttitle = $myrow['post_title']; |
1197 | 1197 | $posttext = str_replace('"', "'", $posttext); |
1198 | 1198 | |
@@ -1209,8 +1209,8 @@ discard block |
||
1209 | 1209 | $myrow = Database::fetch_array($result); |
1210 | 1210 | |
1211 | 1211 | $pathname = explode('/', $myrow['path']); // Making a correct name for the link. |
1212 | - $last = count($pathname) - 1; // Making a correct name for the link. |
|
1213 | - $filename = $pathname[$last]; // Making a correct name for the link. |
|
1212 | + $last = count($pathname) - 1; // Making a correct name for the link. |
|
1213 | + $filename = $pathname[$last]; // Making a correct name for the link. |
|
1214 | 1214 | |
1215 | 1215 | $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path"; |
1216 | 1216 | $result = Database::query($sql); |
@@ -1288,7 +1288,7 @@ discard block |
||
1288 | 1288 | unset($addedresource[$resource_key]); |
1289 | 1289 | unset($addedresourceid[$resource_key]); |
1290 | 1290 | $_SESSION['addedresource'] = $addedresource; |
1291 | - $_SESSION['addedresourceid'] = $addedresourceid ; |
|
1291 | + $_SESSION['addedresourceid'] = $addedresourceid; |
|
1292 | 1292 | } |
1293 | 1293 | |
1294 | 1294 | /** |
@@ -1363,11 +1363,11 @@ discard block |
||
1363 | 1363 | |
1364 | 1364 | $sql = "SELECT * FROM $TABLERESOURCE |
1365 | 1365 | WHERE c_id = $course_id AND source_type='$type' and source_id=$id"; |
1366 | - $result=Database::query($sql); |
|
1367 | - while ($row=Database::fetch_array($result)) |
|
1366 | + $result = Database::query($sql); |
|
1367 | + while ($row = Database::fetch_array($result)) |
|
1368 | 1368 | { |
1369 | - $addedresource[]=$row["resource_type"]; |
|
1370 | - $addedresourceid[]=$row["resource_id"]; |
|
1369 | + $addedresource[] = $row["resource_type"]; |
|
1370 | + $addedresourceid[] = $row["resource_id"]; |
|
1371 | 1371 | } |
1372 | 1372 | $_SESSION['addedresource'] = $addedresource; |
1373 | 1373 | $_SESSION['addedresourceid'] = $addedresourceid; |
@@ -1413,11 +1413,11 @@ discard block |
||
1413 | 1413 | |
1414 | 1414 | $sql = "SELECT * FROM $TABLERESOURCE WHERE c_id = $course_id AND source_type='$type' and source_id='$id'"; |
1415 | 1415 | $result = Database::query($sql); |
1416 | - while ($row=Database::fetch_array($result)) { |
|
1416 | + while ($row = Database::fetch_array($result)) { |
|
1417 | 1417 | if ($origin != 'learnpath') { |
1418 | - display_addedresource_link($row['resource_type'], $row['resource_id'], $style) ; |
|
1418 | + display_addedresource_link($row['resource_type'], $row['resource_id'], $style); |
|
1419 | 1419 | } else { |
1420 | - display_addedresource_link_in_learnpath($row['resource_type'], $row['resource_id'],'agendaitems','','builder','icon') ; echo "<br>"; |
|
1420 | + display_addedresource_link_in_learnpath($row['resource_type'], $row['resource_id'], 'agendaitems', '', 'builder', 'icon'); echo "<br>"; |
|
1421 | 1421 | } |
1422 | 1422 | } |
1423 | 1423 | } |
@@ -1479,7 +1479,7 @@ discard block |
||
1479 | 1479 | |
1480 | 1480 | if (is_array($_SESSION['addedresource'])) { |
1481 | 1481 | foreach ($addedresource as $toolcompare) { |
1482 | - if ($toolcompare==$type && $addedresourceid[key($addedresource)] == $id) { |
|
1482 | + if ($toolcompare == $type && $addedresourceid[key($addedresource)] == $id) { |
|
1483 | 1483 | $show = 0; |
1484 | 1484 | } |
1485 | 1485 | next($addedresource); |
@@ -1513,7 +1513,7 @@ discard block |
||
1513 | 1513 | * @param boolean Open in a new window (true) or in the current frame/window (false)? |
1514 | 1514 | * @todo use the constants for the type definitions. |
1515 | 1515 | */ |
1516 | -function rl_get_html_resource_link($course_code, $type, $id, $style='', $new_window = true) { |
|
1516 | +function rl_get_html_resource_link($course_code, $type, $id, $style = '', $new_window = true) { |
|
1517 | 1517 | $_course = api_get_course_info($course_code); |
1518 | 1518 | |
1519 | 1519 | $course_id = api_get_course_int_id(); |
@@ -1559,7 +1559,7 @@ discard block |
||
1559 | 1559 | case TOOL_THREAD: //=topics |
1560 | 1560 | //$tbl_forum = Database::get_course_table(TABLE_FORUM); |
1561 | 1561 | //$tbl_thread = Database::get_course_table(TABLE_FORUM_THREAD); |
1562 | - $tbl_post = Database::get_course_table(TABLE_FORUM_POST); |
|
1562 | + $tbl_post = Database::get_course_table(TABLE_FORUM_POST); |
|
1563 | 1563 | // grabbing the title of the post |
1564 | 1564 | $sql_title = "SELECT * FROM $tbl_post WHERE c_id = $course_id AND post_id=".$id; |
1565 | 1565 | $result_title = Database::query($sql_title); |
@@ -1579,8 +1579,8 @@ discard block |
||
1579 | 1579 | $result = Database::query("SELECT * FROM $tbl_doc WHERE c_id = $course_id AND id=$id"); |
1580 | 1580 | $myrow = Database::fetch_array($result); |
1581 | 1581 | $pathname = explode('/', $myrow['path']); // Making a correct name for the link. |
1582 | - $last = count($pathname) - 1; // Making a correct name for the link. |
|
1583 | - $filename = $pathname[$last]; // Making a correct name for the link. |
|
1582 | + $last = count($pathname) - 1; // Making a correct name for the link. |
|
1583 | + $filename = $pathname[$last]; // Making a correct name for the link. |
|
1584 | 1584 | $image = choose_image($filename); |
1585 | 1585 | $ext = explode('.', $filename); |
1586 | 1586 | $ext = strtolower($ext[sizeof($ext) - 1]); |
@@ -1656,8 +1656,8 @@ discard block |
||
1656 | 1656 | if (!empty($id)) { |
1657 | 1657 | $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); |
1658 | 1658 | $sql = "SELECT * FROM $TBL_EXERCICES WHERE c_id = $course_id AND id=$id"; |
1659 | - $result= Database::query($sql); |
|
1660 | - $myrow=Database::fetch_array($result); |
|
1659 | + $result = Database::query($sql); |
|
1660 | + $myrow = Database::fetch_array($result); |
|
1661 | 1661 | if ($row_item['title'] != '') { |
1662 | 1662 | $myrow['title'] = $row_item['title']; |
1663 | 1663 | } |
@@ -1669,8 +1669,8 @@ discard block |
||
1669 | 1669 | $result = Database::query("SELECT * FROM ".$TBL_DOCUMENT." WHERE c_id = $course_id AND id=$id"); |
1670 | 1670 | $myrow = Database::fetch_array($result); |
1671 | 1671 | $path = $myrow['path']; |
1672 | - $link .= $main_dir_path.'exercice/showinframes.php?file='.$path.'' . |
|
1673 | - '&origin='.$origin.'&cid='.$course_code.'&uid='.api_get_user_id().'' . |
|
1672 | + $link .= $main_dir_path.'exercice/showinframes.php?file='.$path.''. |
|
1673 | + '&origin='.$origin.'&cid='.$course_code.'&uid='.api_get_user_id().''. |
|
1674 | 1674 | '&learnpath_id='.$learnpath_id.'&learnpath_item_id='.$id_in_path.'&lp_view_id='.$lpViewId; |
1675 | 1675 | break; |
1676 | 1676 | case TOOL_FORUM: |
@@ -1682,7 +1682,7 @@ discard block |
||
1682 | 1682 | $sql = "SELECT * FROM $tbl_topics WHERE c_id = $course_id AND thread_id=$id"; |
1683 | 1683 | $result = Database::query($sql); |
1684 | 1684 | $myrow = Database::fetch_array($result); |
1685 | - $link .= $main_dir_path.'forum/viewthread.php?origin=learnpath&thread='.$id.'' . |
|
1685 | + $link .= $main_dir_path.'forum/viewthread.php?origin=learnpath&thread='.$id.''. |
|
1686 | 1686 | '&forum='.$myrow['forum_id'].'&lp=true'; |
1687 | 1687 | } |
1688 | 1688 | break; |
@@ -1698,14 +1698,14 @@ discard block |
||
1698 | 1698 | $posttitle = $title; |
1699 | 1699 | $posttext = str_replace('"', "'", $posttext); |
1700 | 1700 | |
1701 | - $link .= $main_dir_path.'forum/viewthread.php?post='.$id.'' . |
|
1702 | - '&thread='.$myrow['thread_id'].'&forum='.$myrow['forum_id'].'' . |
|
1701 | + $link .= $main_dir_path.'forum/viewthread.php?post='.$id.''. |
|
1702 | + '&thread='.$myrow['thread_id'].'&forum='.$myrow['forum_id'].''. |
|
1703 | 1703 | '&lp=true'; |
1704 | 1704 | break; |
1705 | 1705 | case TOOL_DOCUMENT: |
1706 | 1706 | $document = $em |
1707 | 1707 | ->getRepository('ChamiloCourseBundle:CDocument') |
1708 | - ->findOneBy(['cId' => $course_id, 'id' => $id]); |
|
1708 | + ->findOneBy(['cId' => $course_id, 'id' => $id]); |
|
1709 | 1709 | |
1710 | 1710 | if (!$document) { |
1711 | 1711 | break; |
@@ -1717,9 +1717,9 @@ discard block |
||
1717 | 1717 | $showDirectUrl = !in_array($extension, $jplayer_supported_files); |
1718 | 1718 | |
1719 | 1719 | if ($showDirectUrl) { |
1720 | - $link = $main_course_path . 'document' . $document->getPath() . '?' . api_get_cidreq(); |
|
1720 | + $link = $main_course_path.'document'.$document->getPath().'?'.api_get_cidreq(); |
|
1721 | 1721 | } else { |
1722 | - $link = api_get_path(WEB_CODE_PATH) . 'document/showinframes.php?' . http_build_query([ |
|
1722 | + $link = api_get_path(WEB_CODE_PATH).'document/showinframes.php?'.http_build_query([ |
|
1723 | 1723 | 'cidReq' => $course_code, |
1724 | 1724 | 'id' => $id, |
1725 | 1725 | 'origin' => 'learnpathitem' |
@@ -1728,8 +1728,8 @@ discard block |
||
1728 | 1728 | |
1729 | 1729 | $openmethod = 2; |
1730 | 1730 | $officedoc = false; |
1731 | - Session::write('openmethod',$openmethod); |
|
1732 | - Session::write('officedoc',$officedoc); |
|
1731 | + Session::write('openmethod', $openmethod); |
|
1732 | + Session::write('officedoc', $officedoc); |
|
1733 | 1733 | break; |
1734 | 1734 | case TOOL_LP_FINAL_ITEM: |
1735 | 1735 | $link .= api_get_path(WEB_CODE_PATH).'newscorm/lp_final_item.php?'.api_get_cidreq().'&id='.$id.'&lp_id='.$learnpath_id; |
@@ -1856,8 +1856,8 @@ discard block |
||
1856 | 1856 | $result = Database::query("SELECT * FROM $tbl_doc WHERE c_id = $course_id AND id=$id"); |
1857 | 1857 | $myrow = Database::fetch_array($result); |
1858 | 1858 | $pathname = explode('/', $myrow['path']); // Making a correct name for the link. |
1859 | - $last = count($pathname) - 1; // Making a correct name for the link. |
|
1860 | - $filename = $pathname[$last]; // Making a correct name for the link. |
|
1859 | + $last = count($pathname) - 1; // Making a correct name for the link. |
|
1860 | + $filename = $pathname[$last]; // Making a correct name for the link. |
|
1861 | 1861 | $image = choose_image($filename); |
1862 | 1862 | $ext = explode('.', $filename); |
1863 | 1863 | $ext = strtolower($ext[sizeof($ext) - 1]); |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * @param int $userMaxScore |
272 | 272 | * @param int $sessionId |
273 | 273 | * |
274 | - * @return bool Returns -1 on error |
|
274 | + * @return boolean|null Returns -1 on error |
|
275 | 275 | */ |
276 | 276 | public function import_manifest($courseCode, $userMaxScore = 1, $sessionId = 0, $userId = 0) |
277 | 277 | { |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | * @param string course Code |
926 | 926 | * @param string LP ID (in database) |
927 | 927 | * @param string Manifest file path (optional if lp_id defined) |
928 | - * @return integer New LP ID or false on failure |
|
928 | + * @return boolean New LP ID or false on failure |
|
929 | 929 | * TODO @TODO Implement imsmanifest_path parameter |
930 | 930 | */ |
931 | 931 | public function reimport_manifest($courseCode, $lp_id = null, $imsmanifest_path = '') |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | $path = ''; |
394 | 394 | $type = 'dir'; |
395 | 395 | if (isset($this->resources[$item['identifierref']])) { |
396 | - $oRes =& $this->resources[$item['identifierref']]; |
|
396 | + $oRes = & $this->resources[$item['identifierref']]; |
|
397 | 397 | $path = @$oRes->get_path(); |
398 | 398 | if (!empty($path)) { |
399 | 399 | $temptype = $oRes->get_scorm_type(); |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | $item['parameters'] = Database::escape_string($item['parameters']); |
445 | 445 | |
446 | 446 | $sql = "INSERT INTO $new_lp_item (c_id, lp_id,item_type,ref,title, path,min_score,max_score, $field_add parent_item_id,previous_item_id,next_item_id, prerequisite,display_order,launch_data, parameters) |
447 | - VALUES ($courseId, $lp_id, '$type', '$identifier', '$title', '$path' , 0, $max_score, $value_add $parent, $previous, 0, '$prereq', ".$item['rel_order'] .", '".$item['datafromlms']."', '".$item['parameters']."' )"; |
|
447 | + VALUES ($courseId, $lp_id, '$type', '$identifier', '$title', '$path' , 0, $max_score, $value_add $parent, $previous, 0, '$prereq', ".$item['rel_order'].", '".$item['datafromlms']."', '".$item['parameters']."' )"; |
|
448 | 448 | |
449 | 449 | Database::query($sql); |
450 | 450 | if ($this->debug > 1) { error_log('New LP - In import_manifest(), inserting item : '.$sql, 0); } |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | foreach ($specific_fields as $specific_field) { |
479 | 479 | if (isset($_REQUEST[$specific_field['code']])) { |
480 | 480 | $sterms = trim($_REQUEST[$specific_field['code']]); |
481 | - $all_specific_terms .= ' '. $sterms; |
|
481 | + $all_specific_terms .= ' '.$sterms; |
|
482 | 482 | if (!empty($sterms)) { |
483 | 483 | $sterms = explode(',', $sterms); |
484 | 484 | foreach ($sterms as $sterm) { |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | } |
488 | 488 | } |
489 | 489 | } |
490 | - $body_to_index = $all_specific_terms .' '. $title; |
|
490 | + $body_to_index = $all_specific_terms.' '.$title; |
|
491 | 491 | $ic_slide->addValue("content", $body_to_index); |
492 | 492 | // TODO: Add a comment to say terms separated by commas. |
493 | 493 | $courseid = api_get_course_id(); |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | SE_COURSE_ID => $courseid, |
498 | 498 | SE_TOOL_ID => TOOL_LEARNPATH, |
499 | 499 | SE_DATA => array('lp_id' => $lp_id, 'lp_item'=> $previous, 'document_id' => ''), // TODO: Unify with other lp types. |
500 | - SE_USER => (int)api_get_user_id(), |
|
500 | + SE_USER => (int) api_get_user_id(), |
|
501 | 501 | ); |
502 | 502 | $ic_slide->xapian_data = serialize($xapian_data); |
503 | 503 | $di->addChunk($ic_slide); |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | public function import_package($zip_file_info, $current_dir = '', $courseInfo = array()) |
544 | 544 | { |
545 | 545 | if ($this->debug > 0) { |
546 | - error_log('In scorm::import_package('.print_r($zip_file_info,true).',"'.$current_dir.'") method', 0); |
|
546 | + error_log('In scorm::import_package('.print_r($zip_file_info, true).',"'.$current_dir.'") method', 0); |
|
547 | 547 | } |
548 | 548 | |
549 | 549 | $courseInfo = empty($courseInfo) ? api_get_course_info() : $courseInfo; |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | $zip_file_name = $zip_file_info['name']; |
555 | 555 | |
556 | 556 | if ($this->debug > 1) { |
557 | - error_log('New LP - import_package() - zip file path = ' . $zip_file_path . ', zip file name = ' . $zip_file_name, 0); |
|
557 | + error_log('New LP - import_package() - zip file path = '.$zip_file_path.', zip file name = '.$zip_file_name, 0); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | $course_rel_dir = api_get_course_path($courseInfo['code']).'/scorm'; // scorm dir web path starting from /courses |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | $current_dir = api_replace_dangerous_char(trim($current_dir)); // Current dir we are in, inside scorm/ |
563 | 563 | |
564 | 564 | if ($this->debug > 1) { |
565 | - error_log( 'New LP - import_package() - current_dir = ' . $current_dir, 0); |
|
565 | + error_log('New LP - import_package() - current_dir = '.$current_dir, 0); |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | // Get name of the zip file without the extension. |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | $file_info = pathinfo($zip_file_name); |
571 | 571 | $filename = $file_info['basename']; |
572 | 572 | $extension = $file_info['extension']; |
573 | - $file_base_name = str_replace('.'.$extension,'',$filename); // Filename without its extension. |
|
573 | + $file_base_name = str_replace('.'.$extension, '', $filename); // Filename without its extension. |
|
574 | 574 | $this->zipname = $file_base_name; // Save for later in case we don't have a title. |
575 | 575 | |
576 | 576 | if ($this->debug > 1) { error_log("New LP - base file name is : ".$file_base_name, 0); } |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | $slash_count = substr_count($shortest_path, '/'); |
617 | 617 | foreach ($manifest_list as $manifest_path) { |
618 | 618 | $tmp_slash_count = substr_count($manifest_path, '/'); |
619 | - if ($tmp_slash_count<$slash_count) { |
|
619 | + if ($tmp_slash_count < $slash_count) { |
|
620 | 620 | $shortest_path = $manifest_path; |
621 | 621 | $slash_count = $tmp_slash_count; |
622 | 622 | } |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | $this->subdir .= '/'.dirname($shortest_path); // Do not concatenate because already done above. |
626 | 626 | $manifest = $shortest_path; |
627 | 627 | if ($this->debug > 1) { error_log('New LP - Package type is now '.$package_type, 0); } |
628 | - if ($package_type== '') { |
|
628 | + if ($package_type == '') { |
|
629 | 629 | // && defined('CHECK_FOR_SCORM') && CHECK_FOR_SCORM) |
630 | 630 | if ($this->debug > 1) { error_log('New LP - Package type is empty', 0); } |
631 | 631 | return api_failure::set_failure('not_scorm_content'); |
@@ -641,8 +641,8 @@ discard block |
||
641 | 641 | $new_dir = '/'.$new_dir; |
642 | 642 | } |
643 | 643 | |
644 | - if ($new_dir[strlen($new_dir)-1] == '/') { |
|
645 | - $new_dir = substr($new_dir,0,-1); |
|
644 | + if ($new_dir[strlen($new_dir) - 1] == '/') { |
|
645 | + $new_dir = substr($new_dir, 0, -1); |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | /* Uncompressing phase */ |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | if ($file != '.' && $file != '..') { |
684 | 684 | $filetype = 'file'; |
685 | 685 | |
686 | - if (is_dir($course_sys_dir . $new_dir . $file)) { |
|
686 | + if (is_dir($course_sys_dir.$new_dir.$file)) { |
|
687 | 687 | $filetype = 'folder'; |
688 | 688 | } |
689 | 689 | |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | } |
713 | 713 | } |
714 | 714 | } |
715 | - @rename($course_sys_dir.$new_dir.$file,$course_sys_dir.$new_dir.$safe_file); |
|
715 | + @rename($course_sys_dir.$new_dir.$file, $course_sys_dir.$new_dir.$safe_file); |
|
716 | 716 | if ($this->debug >= 1) { error_log('New LP - Renaming '.$course_sys_dir.$new_dir.$file.' to '.$course_sys_dir.$new_dir.$safe_file, 0); } |
717 | 717 | } |
718 | 718 | } |
@@ -901,7 +901,7 @@ discard block |
||
901 | 901 | if ($this->debug > 0) { error_log('In scorm::get_res_path('.$id.') method', 0); } |
902 | 902 | $path = ''; |
903 | 903 | if (isset($this->resources[$id])) { |
904 | - $oRes =& $this->resources[$id]; |
|
904 | + $oRes = & $this->resources[$id]; |
|
905 | 905 | $path = @$oRes->get_path(); |
906 | 906 | } |
907 | 907 | return $path; |
@@ -917,7 +917,7 @@ discard block |
||
917 | 917 | if ($this->debug > 0) { error_log('In scorm::get_res_type('.$id.') method', 0); } |
918 | 918 | $type = ''; |
919 | 919 | if (isset($this->resources[$id])) { |
920 | - $oRes =& $this->resources[$id]; |
|
920 | + $oRes = & $this->resources[$id]; |
|
921 | 921 | $temptype = $oRes->get_scorm_type(); |
922 | 922 | if (!empty($temptype)) { |
923 | 923 | $type = $temptype; |
@@ -936,9 +936,9 @@ discard block |
||
936 | 936 | $title = ''; |
937 | 937 | if (isset($this->manifest['organizations']['default'])) { |
938 | 938 | $title = $this->organizations[$this->manifest['organizations']['default']]->get_name(); |
939 | - } elseif (count($this->organizations)==1) { |
|
939 | + } elseif (count($this->organizations) == 1) { |
|
940 | 940 | // This will only get one title but so we don't need to know the index. |
941 | - foreach($this->organizations as $id => $value) { |
|
941 | + foreach ($this->organizations as $id => $value) { |
|
942 | 942 | $title = $this->organizations[$id]->get_name(); |
943 | 943 | break; |
944 | 944 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | /** |
120 | 120 | * This function retrieves the existing permissions of a user, group or role. |
121 | -* @param $content are we retrieving the rights of a user, a group or a role (the database depends on it) |
|
121 | +* @param string $content are we retrieving the rights of a user, a group or a role (the database depends on it) |
|
122 | 122 | * @param $id the id of the user, group or role |
123 | 123 | * @author Patrick Cool <[email protected]>, Ghent University |
124 | 124 | * @version 1.0 |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | |
527 | 527 | /** |
528 | 528 | * This function gets all the roles that are defined |
529 | -* @param $content are we finding the roles for a user or a group (the database depends on it) |
|
529 | +* @param string $content are we finding the roles for a user or a group (the database depends on it) |
|
530 | 530 | * @param $id the id of the user or group |
531 | 531 | * @param string Deprecated parameter allowing use of 'platform' scope - the corresponding tables don't exist anymore so the scope is always set to 'course' |
532 | 532 | * @return array that contains the name of the roles the user has |
@@ -132,24 +132,20 @@ discard block |
||
132 | 132 | { |
133 | 133 | $table=Database::get_course_table(TABLE_PERMISSION_USER); |
134 | 134 | $id_field = 'user_id'; |
135 | - } |
|
136 | - elseif ($content == 'group') |
|
135 | + } elseif ($content == 'group') |
|
137 | 136 | { |
138 | 137 | $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
139 | 138 | $id_field = 'group_id'; |
140 | - } |
|
141 | - elseif ($content == 'role') |
|
139 | + } elseif ($content == 'role') |
|
142 | 140 | { |
143 | 141 | $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
144 | 142 | $id_field = 'role_id'; |
145 | - } |
|
146 | - elseif ($content == 'platform_role') |
|
143 | + } elseif ($content == 'platform_role') |
|
147 | 144 | { |
148 | 145 | $table=Database::get_main_table(TABLE_ROLE_PERMISSION); |
149 | 146 | $id_field = 'role_id'; |
150 | 147 | $course_id_condition = ''; |
151 | - } |
|
152 | - elseif ($content == 'task') |
|
148 | + } elseif ($content == 'task') |
|
153 | 149 | { |
154 | 150 | $table=Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
155 | 151 | $id_field = 'task_id'; |
@@ -162,8 +158,9 @@ discard block |
||
162 | 158 | WHERE $course_id_condition " . $id_field . "='" . Database::escape_string($id) . "'"; |
163 | 159 | $result = Database::query($sql); |
164 | 160 | |
165 | - while($row = Database::fetch_array($result)) |
|
166 | - $currentpermissions[$row['tool']][] = $row['action']; |
|
161 | + while($row = Database::fetch_array($result)) { |
|
162 | + $currentpermissions[$row['tool']][] = $row['action']; |
|
163 | + } |
|
167 | 164 | |
168 | 165 | return $currentpermissions; |
169 | 166 | } |
@@ -321,14 +318,12 @@ discard block |
||
321 | 318 | if ($course_admin) |
322 | 319 | { |
323 | 320 | echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
324 | - } |
|
325 | - else |
|
321 | + } else |
|
326 | 322 | { |
327 | 323 | if (!empty($inherited_permissions) and in_array($permission,$inherited_permissions[$tool])) |
328 | 324 | { |
329 | 325 | echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
330 | - } |
|
331 | - else |
|
326 | + } else |
|
332 | 327 | { |
333 | 328 | if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) |
334 | 329 | { |
@@ -439,8 +434,7 @@ discard block |
||
439 | 434 | $checked='checked'; |
440 | 435 | $image='checkbox_on2.gif'; |
441 | 436 | $action='revoke'; |
442 | - } |
|
443 | - else |
|
437 | + } else |
|
444 | 438 | { |
445 | 439 | $checked=''; |
446 | 440 | $image='wrong.gif'; |
@@ -25,38 +25,38 @@ discard block |
||
25 | 25 | function store_permissions($content, $id) { |
26 | 26 | $course_id = api_get_course_int_id(); |
27 | 27 | |
28 | - // Which database are we using (depending on the $content parameter) |
|
29 | - if ($content=='user') |
|
30 | - { |
|
31 | - $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
32 | - $id_field = user_id; |
|
33 | - } |
|
34 | - if ($content=='group') |
|
35 | - { |
|
36 | - $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
37 | - $id_field = group_id; |
|
38 | - } |
|
39 | - if ($content=='role') |
|
40 | - { |
|
41 | - $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
42 | - $id_field = role_id; |
|
43 | - } |
|
44 | - |
|
45 | - // We first delete all the existing permissions for that user/group/role |
|
46 | - $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."'"; |
|
47 | - $result=Database::query($sql); |
|
48 | - |
|
49 | - // looping through the post values to find the permission (containing the string permission* ) |
|
50 | - foreach ($_POST as $key => $value) |
|
51 | - { |
|
52 | - if (strstr($key,"permission*")) |
|
53 | - { |
|
54 | - list($brol,$tool,$action)=explode("*",$key); |
|
55 | - $sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($action)."')"; |
|
56 | - $result=Database::query($sql); |
|
57 | - } |
|
58 | - } |
|
59 | - return get_lang('PermissionsStored'); |
|
28 | + // Which database are we using (depending on the $content parameter) |
|
29 | + if ($content=='user') |
|
30 | + { |
|
31 | + $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
32 | + $id_field = user_id; |
|
33 | + } |
|
34 | + if ($content=='group') |
|
35 | + { |
|
36 | + $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
37 | + $id_field = group_id; |
|
38 | + } |
|
39 | + if ($content=='role') |
|
40 | + { |
|
41 | + $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
42 | + $id_field = role_id; |
|
43 | + } |
|
44 | + |
|
45 | + // We first delete all the existing permissions for that user/group/role |
|
46 | + $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."'"; |
|
47 | + $result=Database::query($sql); |
|
48 | + |
|
49 | + // looping through the post values to find the permission (containing the string permission* ) |
|
50 | + foreach ($_POST as $key => $value) |
|
51 | + { |
|
52 | + if (strstr($key,"permission*")) |
|
53 | + { |
|
54 | + list($brol,$tool,$action)=explode("*",$key); |
|
55 | + $sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($action)."')"; |
|
56 | + $result=Database::query($sql); |
|
57 | + } |
|
58 | + } |
|
59 | + return get_lang('PermissionsStored'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -70,50 +70,50 @@ discard block |
||
70 | 70 | * @version 1.0 |
71 | 71 | */ |
72 | 72 | function store_one_permission($content, $action, $id, $tool,$permission) { |
73 | - global $rights_full; |
|
73 | + global $rights_full; |
|
74 | 74 | $course_id = api_get_course_int_id(); |
75 | - // for some reason I don't know, he can't get to the $rights_full array, so commented the following lines out. |
|
75 | + // for some reason I don't know, he can't get to the $rights_full array, so commented the following lines out. |
|
76 | 76 | |
77 | - // check |
|
78 | - //if(!in_array($permission, $rights_full)) |
|
79 | - //{ |
|
80 | - // return get_lang('Error'); |
|
81 | - //} |
|
77 | + // check |
|
78 | + //if(!in_array($permission, $rights_full)) |
|
79 | + //{ |
|
80 | + // return get_lang('Error'); |
|
81 | + //} |
|
82 | 82 | |
83 | - // Which database are we using (depending on the $content parameter) |
|
83 | + // Which database are we using (depending on the $content parameter) |
|
84 | 84 | |
85 | - if ($content=='user') { |
|
86 | - $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
87 | - $id_field = user_id; |
|
88 | - } |
|
89 | - if ($content=='group') |
|
90 | - { |
|
91 | - $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
92 | - $id_field = group_id; |
|
93 | - } |
|
94 | - if ($content=='role') |
|
95 | - { |
|
96 | - $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
97 | - $id_field = role_id; |
|
98 | - } |
|
99 | - |
|
100 | - // grating a right |
|
101 | - if ($action=='grant') { |
|
102 | - $sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($permission)."')"; |
|
103 | - $result=Database::query($sql); |
|
104 | - if($result) { |
|
105 | - $result_message=get_lang('PermissionGranted'); |
|
106 | - } |
|
107 | - } |
|
108 | - if ($action=='revoke') |
|
109 | - { |
|
110 | - $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND tool='".Database::escape_string($tool)."' AND action='".Database::escape_string($permission)."'"; |
|
111 | - $result=Database::query($sql); |
|
112 | - if($result) { |
|
113 | - $result_message=get_lang('PermissionRevoked'); |
|
114 | - } |
|
115 | - } |
|
116 | - return $result_message; |
|
85 | + if ($content=='user') { |
|
86 | + $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
87 | + $id_field = user_id; |
|
88 | + } |
|
89 | + if ($content=='group') |
|
90 | + { |
|
91 | + $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
92 | + $id_field = group_id; |
|
93 | + } |
|
94 | + if ($content=='role') |
|
95 | + { |
|
96 | + $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
97 | + $id_field = role_id; |
|
98 | + } |
|
99 | + |
|
100 | + // grating a right |
|
101 | + if ($action=='grant') { |
|
102 | + $sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($permission)."')"; |
|
103 | + $result=Database::query($sql); |
|
104 | + if($result) { |
|
105 | + $result_message=get_lang('PermissionGranted'); |
|
106 | + } |
|
107 | + } |
|
108 | + if ($action=='revoke') |
|
109 | + { |
|
110 | + $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND tool='".Database::escape_string($tool)."' AND action='".Database::escape_string($permission)."'"; |
|
111 | + $result=Database::query($sql); |
|
112 | + if($result) { |
|
113 | + $result_message=get_lang('PermissionRevoked'); |
|
114 | + } |
|
115 | + } |
|
116 | + return $result_message; |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -125,47 +125,47 @@ discard block |
||
125 | 125 | */ |
126 | 126 | function get_permissions($content, $id) { |
127 | 127 | $course_id = api_get_course_int_id(); |
128 | - $currentpermissions=array(); |
|
129 | - // Which database are we using (depending on the $content parameter) |
|
128 | + $currentpermissions=array(); |
|
129 | + // Which database are we using (depending on the $content parameter) |
|
130 | 130 | $course_id_condition = " c_id = $course_id AND "; |
131 | - if ($content == 'user') |
|
132 | - { |
|
133 | - $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
134 | - $id_field = 'user_id'; |
|
135 | - } |
|
136 | - elseif ($content == 'group') |
|
137 | - { |
|
138 | - $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
139 | - $id_field = 'group_id'; |
|
140 | - } |
|
141 | - elseif ($content == 'role') |
|
142 | - { |
|
143 | - $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
144 | - $id_field = 'role_id'; |
|
145 | - } |
|
146 | - elseif ($content == 'platform_role') |
|
147 | - { |
|
148 | - $table=Database::get_main_table(TABLE_ROLE_PERMISSION); |
|
149 | - $id_field = 'role_id'; |
|
131 | + if ($content == 'user') |
|
132 | + { |
|
133 | + $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
134 | + $id_field = 'user_id'; |
|
135 | + } |
|
136 | + elseif ($content == 'group') |
|
137 | + { |
|
138 | + $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
139 | + $id_field = 'group_id'; |
|
140 | + } |
|
141 | + elseif ($content == 'role') |
|
142 | + { |
|
143 | + $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
144 | + $id_field = 'role_id'; |
|
145 | + } |
|
146 | + elseif ($content == 'platform_role') |
|
147 | + { |
|
148 | + $table=Database::get_main_table(TABLE_ROLE_PERMISSION); |
|
149 | + $id_field = 'role_id'; |
|
150 | 150 | $course_id_condition = ''; |
151 | - } |
|
152 | - elseif ($content == 'task') |
|
153 | - { |
|
154 | - $table=Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
155 | - $id_field = 'task_id'; |
|
156 | - } |
|
157 | - |
|
158 | - // finding all the permissions. We store this in a multidimensional array |
|
159 | - // where the first dimension is the tool. |
|
160 | - $sql=" |
|
151 | + } |
|
152 | + elseif ($content == 'task') |
|
153 | + { |
|
154 | + $table=Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
155 | + $id_field = 'task_id'; |
|
156 | + } |
|
157 | + |
|
158 | + // finding all the permissions. We store this in a multidimensional array |
|
159 | + // where the first dimension is the tool. |
|
160 | + $sql=" |
|
161 | 161 | SELECT * FROM " . $table . " |
162 | 162 | WHERE $course_id_condition " . $id_field . "='" . Database::escape_string($id) . "'"; |
163 | - $result = Database::query($sql); |
|
163 | + $result = Database::query($sql); |
|
164 | 164 | |
165 | - while($row = Database::fetch_array($result)) |
|
166 | - $currentpermissions[$row['tool']][] = $row['action']; |
|
165 | + while($row = Database::fetch_array($result)) |
|
166 | + $currentpermissions[$row['tool']][] = $row['action']; |
|
167 | 167 | |
168 | - return $currentpermissions; |
|
168 | + return $currentpermissions; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -179,38 +179,38 @@ discard block |
||
179 | 179 | */ |
180 | 180 | function limited_or_full($current_permissions) |
181 | 181 | { |
182 | - if (api_get_setting('permissions')=='limited') |
|
183 | - { |
|
184 | - foreach ($current_permissions as $tool=>$tool_rights) |
|
185 | - { |
|
186 | - // we loop through the possible permissions of a tool and unset the entry if it is view |
|
187 | - // if it is visibility or move we have to grant the edit right |
|
188 | - foreach ($tool_rights as $key=>$value) |
|
189 | - { |
|
190 | - if ($value=='View') |
|
191 | - { |
|
192 | - unset($current_permissions[$tool][$key]); |
|
193 | - } |
|
194 | - if ($value=='Visibility' OR $value=='Move') |
|
195 | - { |
|
196 | - if (!in_array('Edit',$current_permissions[$tool])) |
|
197 | - { |
|
198 | - $current_permissions[$tool][]='Edit'; |
|
199 | - } |
|
200 | - unset($current_permissions[$tool][$key]); |
|
201 | - } |
|
202 | - //else |
|
203 | - //{ |
|
204 | - // $current_permissions[$tool][]=$value; |
|
205 | - //} |
|
206 | - } |
|
207 | - } |
|
208 | - return $current_permissions; |
|
209 | - } |
|
210 | - if (api_get_setting('permissions')=='full') |
|
211 | - { |
|
212 | - return $current_permissions; |
|
213 | - } |
|
182 | + if (api_get_setting('permissions')=='limited') |
|
183 | + { |
|
184 | + foreach ($current_permissions as $tool=>$tool_rights) |
|
185 | + { |
|
186 | + // we loop through the possible permissions of a tool and unset the entry if it is view |
|
187 | + // if it is visibility or move we have to grant the edit right |
|
188 | + foreach ($tool_rights as $key=>$value) |
|
189 | + { |
|
190 | + if ($value=='View') |
|
191 | + { |
|
192 | + unset($current_permissions[$tool][$key]); |
|
193 | + } |
|
194 | + if ($value=='Visibility' OR $value=='Move') |
|
195 | + { |
|
196 | + if (!in_array('Edit',$current_permissions[$tool])) |
|
197 | + { |
|
198 | + $current_permissions[$tool][]='Edit'; |
|
199 | + } |
|
200 | + unset($current_permissions[$tool][$key]); |
|
201 | + } |
|
202 | + //else |
|
203 | + //{ |
|
204 | + // $current_permissions[$tool][]=$value; |
|
205 | + //} |
|
206 | + } |
|
207 | + } |
|
208 | + return $current_permissions; |
|
209 | + } |
|
210 | + if (api_get_setting('permissions')=='full') |
|
211 | + { |
|
212 | + return $current_permissions; |
|
213 | + } |
|
214 | 214 | } |
215 | 215 | /** |
216 | 216 | * This function displays a checked or unchecked checkbox. The checkbox will be checked if the |
@@ -224,12 +224,12 @@ discard block |
||
224 | 224 | */ |
225 | 225 | function display_checkbox_matrix($permission_array, $tool, $permission, $inherited_permissions=array()) |
226 | 226 | { |
227 | - $checked=""; |
|
228 | - if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) |
|
229 | - { |
|
230 | - $checked="checked"; |
|
231 | - } |
|
232 | - echo "\t\t\t<input type=\"checkbox\" name=\"permission*$tool*$permission\" $checked>\n"; |
|
227 | + $checked=""; |
|
228 | + if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) |
|
229 | + { |
|
230 | + $checked="checked"; |
|
231 | + } |
|
232 | + echo "\t\t\t<input type=\"checkbox\" name=\"permission*$tool*$permission\" $checked>\n"; |
|
233 | 233 | |
234 | 234 | } |
235 | 235 | |
@@ -245,62 +245,62 @@ discard block |
||
245 | 245 | */ |
246 | 246 | function display_image_matrix($permission_array, $tool, $permission,$inherited_permissions=array(), $course_admin=false, $editable=true) |
247 | 247 | { |
248 | - if ($course_admin) { |
|
249 | - echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
250 | - } else { |
|
251 | - if (in_array($permission,$inherited_permissions[$tool])) { |
|
252 | - echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
253 | - } else { |
|
254 | - if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) { |
|
255 | - if ($editable) { |
|
256 | - $url=api_get_self(); |
|
257 | - $urlparameters = ''; |
|
258 | - foreach($_GET as $key=>$value) { |
|
259 | - $parameter[$key]=$value; |
|
260 | - } |
|
261 | - $parameter['action']='revoke'; |
|
262 | - $parameter['permission']=$permission; |
|
263 | - $parameter['tool']=$tool; |
|
264 | - foreach ($parameter as $key=>$value) { |
|
265 | - $urlparameters.=$key.'='.$value.'&'; |
|
266 | - } |
|
267 | - $url=$url.'?'.$urlparameters; |
|
268 | - |
|
269 | - echo "\t\t\t <a href=\"".$url."\">"; |
|
270 | - } |
|
271 | - echo "<img src=\"../img/checkbox_on2.gif\" border=\"0\"/>"; |
|
272 | - if ($editable) { |
|
273 | - echo "</a>"; |
|
274 | - } |
|
275 | - } else { |
|
276 | - if ($editable) |
|
277 | - { |
|
278 | - $url=api_get_self(); |
|
279 | - $urlparameters = ''; |
|
280 | - foreach ($_GET as $key=>$value) |
|
281 | - { |
|
282 | - $parameter[$key]=$value; |
|
283 | - } |
|
284 | - $parameter['action']='grant'; |
|
285 | - $parameter['permission']=$permission; |
|
286 | - $parameter['tool']=$tool; |
|
287 | - foreach ($parameter as $key=>$value) |
|
288 | - { |
|
289 | - $urlparameters.=$key.'='.$value.'&'; |
|
290 | - } |
|
291 | - $url=$url.'?'.$urlparameters; |
|
292 | - |
|
293 | - //echo "\t\t\t <a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=grant&permission=$permission&tool=$tool\">"; |
|
294 | - echo "\t\t\t <a href=\"".$url."\">"; |
|
295 | - } |
|
296 | - echo "<img src=\"../img/wrong.gif\" border=\"0\"/>"; |
|
297 | - if ($editable) |
|
298 | - { |
|
299 | - echo "</a>"; |
|
300 | - } |
|
301 | - } |
|
302 | - } |
|
303 | - } |
|
248 | + if ($course_admin) { |
|
249 | + echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
250 | + } else { |
|
251 | + if (in_array($permission,$inherited_permissions[$tool])) { |
|
252 | + echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
253 | + } else { |
|
254 | + if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) { |
|
255 | + if ($editable) { |
|
256 | + $url=api_get_self(); |
|
257 | + $urlparameters = ''; |
|
258 | + foreach($_GET as $key=>$value) { |
|
259 | + $parameter[$key]=$value; |
|
260 | + } |
|
261 | + $parameter['action']='revoke'; |
|
262 | + $parameter['permission']=$permission; |
|
263 | + $parameter['tool']=$tool; |
|
264 | + foreach ($parameter as $key=>$value) { |
|
265 | + $urlparameters.=$key.'='.$value.'&'; |
|
266 | + } |
|
267 | + $url=$url.'?'.$urlparameters; |
|
268 | + |
|
269 | + echo "\t\t\t <a href=\"".$url."\">"; |
|
270 | + } |
|
271 | + echo "<img src=\"../img/checkbox_on2.gif\" border=\"0\"/>"; |
|
272 | + if ($editable) { |
|
273 | + echo "</a>"; |
|
274 | + } |
|
275 | + } else { |
|
276 | + if ($editable) |
|
277 | + { |
|
278 | + $url=api_get_self(); |
|
279 | + $urlparameters = ''; |
|
280 | + foreach ($_GET as $key=>$value) |
|
281 | + { |
|
282 | + $parameter[$key]=$value; |
|
283 | + } |
|
284 | + $parameter['action']='grant'; |
|
285 | + $parameter['permission']=$permission; |
|
286 | + $parameter['tool']=$tool; |
|
287 | + foreach ($parameter as $key=>$value) |
|
288 | + { |
|
289 | + $urlparameters.=$key.'='.$value.'&'; |
|
290 | + } |
|
291 | + $url=$url.'?'.$urlparameters; |
|
292 | + |
|
293 | + //echo "\t\t\t <a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=grant&permission=$permission&tool=$tool\">"; |
|
294 | + echo "\t\t\t <a href=\"".$url."\">"; |
|
295 | + } |
|
296 | + echo "<img src=\"../img/wrong.gif\" border=\"0\"/>"; |
|
297 | + if ($editable) |
|
298 | + { |
|
299 | + echo "</a>"; |
|
300 | + } |
|
301 | + } |
|
302 | + } |
|
303 | + } |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | |
@@ -318,72 +318,72 @@ discard block |
||
318 | 318 | function display_image_matrix_for_blogs($permission_array, $user_id, $tool, $permission,$inherited_permissions=array(), $course_admin=false, $editable=true) |
319 | 319 | { |
320 | 320 | |
321 | - if ($course_admin) |
|
322 | - { |
|
323 | - echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
324 | - } |
|
325 | - else |
|
326 | - { |
|
327 | - if (!empty($inherited_permissions) and in_array($permission,$inherited_permissions[$tool])) |
|
328 | - { |
|
329 | - echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
330 | - } |
|
331 | - else |
|
332 | - { |
|
333 | - if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) |
|
334 | - { |
|
335 | - if ($editable) |
|
336 | - { |
|
337 | - $url = api_get_self(); |
|
338 | - $urlparameters = ''; |
|
339 | - foreach($_GET as $key => $value) |
|
340 | - { |
|
341 | - $parameter[$key] = $value; |
|
342 | - } |
|
343 | - $parameter['action']='manage_rights'; |
|
344 | - $parameter['do']='revoke'; |
|
345 | - $parameter['permission']=$permission; |
|
346 | - $parameter['tool']=$tool; |
|
347 | - $parameter['user_id']=$user_id; |
|
348 | - foreach ($parameter as $key=>$value) |
|
349 | - { |
|
350 | - $urlparameters .= $key . '=' . $value . '&'; |
|
351 | - } |
|
352 | - $url = $url . '?' . $urlparameters; |
|
353 | - |
|
354 | - echo "\t\t\t <a href=\"".$url."\">"; |
|
355 | - } |
|
356 | - echo "<img src=\"../img/checkbox_on2.gif\" border=\"0\"/ title=\"".get_lang('UserHasPermission')."\">"; |
|
357 | - if ($editable) { |
|
358 | - echo "</a>"; |
|
359 | - } |
|
360 | - } else { |
|
361 | - if ($editable) { |
|
362 | - $url = api_get_self(); |
|
363 | - $urlparameters = ''; |
|
364 | - foreach ($_GET as $key=>$value) { |
|
365 | - $parameter[$key]=$value; |
|
366 | - } |
|
367 | - $parameter['action']='manage_rights'; |
|
368 | - $parameter['do']='grant'; |
|
369 | - $parameter['permission']=$permission; |
|
370 | - $parameter['tool']=$tool; |
|
371 | - $parameter['user_id']=$user_id; |
|
372 | - foreach ($parameter as $key=>$value) { |
|
373 | - $urlparameters .= $key . '=' . $value . '&'; |
|
374 | - } |
|
375 | - $url=$url.'?'.$urlparameters; |
|
376 | - |
|
377 | - //echo "\t\t\t <a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=grant&permission=$permission&tool=$tool\">"; |
|
378 | - echo "\t\t\t <a href=\"".$url."\">"; |
|
379 | - } |
|
380 | - echo "<img src=\"../img/wrong.gif\" border=\"0\"/ title=\"".get_lang('UserHasPermissionNot')."\">"; |
|
381 | - if ($editable) { |
|
382 | - echo "</a>"; |
|
383 | - } |
|
384 | - } |
|
385 | - } |
|
386 | - } |
|
321 | + if ($course_admin) |
|
322 | + { |
|
323 | + echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
324 | + } |
|
325 | + else |
|
326 | + { |
|
327 | + if (!empty($inherited_permissions) and in_array($permission,$inherited_permissions[$tool])) |
|
328 | + { |
|
329 | + echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
330 | + } |
|
331 | + else |
|
332 | + { |
|
333 | + if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) |
|
334 | + { |
|
335 | + if ($editable) |
|
336 | + { |
|
337 | + $url = api_get_self(); |
|
338 | + $urlparameters = ''; |
|
339 | + foreach($_GET as $key => $value) |
|
340 | + { |
|
341 | + $parameter[$key] = $value; |
|
342 | + } |
|
343 | + $parameter['action']='manage_rights'; |
|
344 | + $parameter['do']='revoke'; |
|
345 | + $parameter['permission']=$permission; |
|
346 | + $parameter['tool']=$tool; |
|
347 | + $parameter['user_id']=$user_id; |
|
348 | + foreach ($parameter as $key=>$value) |
|
349 | + { |
|
350 | + $urlparameters .= $key . '=' . $value . '&'; |
|
351 | + } |
|
352 | + $url = $url . '?' . $urlparameters; |
|
353 | + |
|
354 | + echo "\t\t\t <a href=\"".$url."\">"; |
|
355 | + } |
|
356 | + echo "<img src=\"../img/checkbox_on2.gif\" border=\"0\"/ title=\"".get_lang('UserHasPermission')."\">"; |
|
357 | + if ($editable) { |
|
358 | + echo "</a>"; |
|
359 | + } |
|
360 | + } else { |
|
361 | + if ($editable) { |
|
362 | + $url = api_get_self(); |
|
363 | + $urlparameters = ''; |
|
364 | + foreach ($_GET as $key=>$value) { |
|
365 | + $parameter[$key]=$value; |
|
366 | + } |
|
367 | + $parameter['action']='manage_rights'; |
|
368 | + $parameter['do']='grant'; |
|
369 | + $parameter['permission']=$permission; |
|
370 | + $parameter['tool']=$tool; |
|
371 | + $parameter['user_id']=$user_id; |
|
372 | + foreach ($parameter as $key=>$value) { |
|
373 | + $urlparameters .= $key . '=' . $value . '&'; |
|
374 | + } |
|
375 | + $url=$url.'?'.$urlparameters; |
|
376 | + |
|
377 | + //echo "\t\t\t <a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=grant&permission=$permission&tool=$tool\">"; |
|
378 | + echo "\t\t\t <a href=\"".$url."\">"; |
|
379 | + } |
|
380 | + echo "<img src=\"../img/wrong.gif\" border=\"0\"/ title=\"".get_lang('UserHasPermissionNot')."\">"; |
|
381 | + if ($editable) { |
|
382 | + echo "</a>"; |
|
383 | + } |
|
384 | + } |
|
385 | + } |
|
386 | + } |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | |
@@ -394,41 +394,41 @@ discard block |
||
394 | 394 | */ |
395 | 395 | function display_role_list($current_course_roles, $current_platform_roles) |
396 | 396 | { |
397 | - global $setting_visualisation; |
|
397 | + global $setting_visualisation; |
|
398 | 398 | $course_id = api_get_course_int_id(); |
399 | 399 | |
400 | - $coures_roles_table=Database::get_course_table(TABLE_ROLE); |
|
401 | - |
|
402 | - // course roles |
|
403 | - $sql="SELECT * FROM $coures_roles_table WHERE c_id = $course_id "; |
|
404 | - $result=Database::query($sql); |
|
405 | - while ($row=Database::fetch_array($result)) |
|
406 | - { |
|
407 | - if (in_array($row['role_id'], $current_course_roles)) |
|
408 | - { |
|
409 | - $checked='checked'; |
|
410 | - $image='checkbox_on2.gif'; |
|
411 | - $action='revoke'; |
|
412 | - } |
|
413 | - else |
|
414 | - { |
|
415 | - $checked=''; |
|
416 | - $image='wrong.gif'; |
|
417 | - $action='grant'; |
|
418 | - } |
|
419 | - if ($setting_visualisation=='checkbox') |
|
420 | - { |
|
421 | - echo "<input type=\"checkbox\" name=\"role*course*".$row['role_id']."\" $checked>"; |
|
422 | - } |
|
423 | - if ($setting_visualisation=='image') |
|
424 | - { |
|
425 | - echo "<a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=$action&role=".$row['role_id']."&scope=course\"><img src=\"../img/".$image."\" border=\"0\"/></a>"; |
|
426 | - } |
|
427 | - |
|
428 | - |
|
429 | - echo $row['role_name']." <a href=\"../permissions/roles.php?role_id=".$row['role_id']."&scope=course\"><img src=\"../img/edit.gif\" /></a><br />\n"; |
|
430 | - echo $row['role_comment']."<br />\n"; |
|
431 | - } |
|
400 | + $coures_roles_table=Database::get_course_table(TABLE_ROLE); |
|
401 | + |
|
402 | + // course roles |
|
403 | + $sql="SELECT * FROM $coures_roles_table WHERE c_id = $course_id "; |
|
404 | + $result=Database::query($sql); |
|
405 | + while ($row=Database::fetch_array($result)) |
|
406 | + { |
|
407 | + if (in_array($row['role_id'], $current_course_roles)) |
|
408 | + { |
|
409 | + $checked='checked'; |
|
410 | + $image='checkbox_on2.gif'; |
|
411 | + $action='revoke'; |
|
412 | + } |
|
413 | + else |
|
414 | + { |
|
415 | + $checked=''; |
|
416 | + $image='wrong.gif'; |
|
417 | + $action='grant'; |
|
418 | + } |
|
419 | + if ($setting_visualisation=='checkbox') |
|
420 | + { |
|
421 | + echo "<input type=\"checkbox\" name=\"role*course*".$row['role_id']."\" $checked>"; |
|
422 | + } |
|
423 | + if ($setting_visualisation=='image') |
|
424 | + { |
|
425 | + echo "<a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=$action&role=".$row['role_id']."&scope=course\"><img src=\"../img/".$image."\" border=\"0\"/></a>"; |
|
426 | + } |
|
427 | + |
|
428 | + |
|
429 | + echo $row['role_name']." <a href=\"../permissions/roles.php?role_id=".$row['role_id']."&scope=course\"><img src=\"../img/edit.gif\" /></a><br />\n"; |
|
430 | + echo $row['role_comment']."<br />\n"; |
|
431 | + } |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | /** |
@@ -442,24 +442,24 @@ discard block |
||
442 | 442 | */ |
443 | 443 | function get_roles($content,$id, $scope='course') { |
444 | 444 | $course_id = api_get_course_int_id(); |
445 | - if ($content=='user') { |
|
446 | - $table=Database::get_course_table(TABLE_ROLE_USER); |
|
447 | - $id_field = user_id; |
|
448 | - } |
|
449 | - if ($content=='group') { |
|
450 | - $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
451 | - $id_field = 'group_id'; |
|
452 | - } |
|
453 | - $table_role=Database::get_course_table(TABLE_ROLE); |
|
454 | - |
|
455 | - $current_roles=array(); |
|
456 | - //$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'";$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'"; |
|
457 | - $sql="SELECT role_id FROM $table WHERE c_id = $course_id AND $id_field = '$id' AND scope='".$scope."'"; |
|
458 | - $result=Database::query($sql); |
|
459 | - while ($row=Database::fetch_array($result)) { |
|
460 | - $current_roles[]=$row['role_id']; |
|
461 | - } |
|
462 | - return $current_roles; |
|
445 | + if ($content=='user') { |
|
446 | + $table=Database::get_course_table(TABLE_ROLE_USER); |
|
447 | + $id_field = user_id; |
|
448 | + } |
|
449 | + if ($content=='group') { |
|
450 | + $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
451 | + $id_field = 'group_id'; |
|
452 | + } |
|
453 | + $table_role=Database::get_course_table(TABLE_ROLE); |
|
454 | + |
|
455 | + $current_roles=array(); |
|
456 | + //$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'";$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'"; |
|
457 | + $sql="SELECT role_id FROM $table WHERE c_id = $course_id AND $id_field = '$id' AND scope='".$scope."'"; |
|
458 | + $result=Database::query($sql); |
|
459 | + while ($row=Database::fetch_array($result)) { |
|
460 | + $current_roles[]=$row['role_id']; |
|
461 | + } |
|
462 | + return $current_roles; |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | /** |
@@ -472,25 +472,25 @@ discard block |
||
472 | 472 | $course_id = api_get_course_int_id(); |
473 | 473 | $course_id_condition = " WHERE c_id = $course_id "; |
474 | 474 | |
475 | - if ($content=='course') |
|
476 | - { |
|
477 | - $table_role=Database::get_course_table(TABLE_ROLE); |
|
478 | - } |
|
479 | - if ($content=='platform') |
|
480 | - { |
|
481 | - $table_role=Database::get_main_table(TABLE_ROLE); |
|
482 | - $course_id_condition = ''; |
|
483 | - } |
|
484 | - |
|
485 | - $current_roles=array(); |
|
486 | - $sql="SELECT * FROM $table_role $course_id_condition "; |
|
487 | - $result=Database::query($sql); |
|
488 | - while ($row=Database::fetch_array($result)) |
|
489 | - { |
|
490 | - $roles[]=$row; |
|
491 | - } |
|
492 | - |
|
493 | - return $roles; |
|
475 | + if ($content=='course') |
|
476 | + { |
|
477 | + $table_role=Database::get_course_table(TABLE_ROLE); |
|
478 | + } |
|
479 | + if ($content=='platform') |
|
480 | + { |
|
481 | + $table_role=Database::get_main_table(TABLE_ROLE); |
|
482 | + $course_id_condition = ''; |
|
483 | + } |
|
484 | + |
|
485 | + $current_roles=array(); |
|
486 | + $sql="SELECT * FROM $table_role $course_id_condition "; |
|
487 | + $result=Database::query($sql); |
|
488 | + while ($row=Database::fetch_array($result)) |
|
489 | + { |
|
490 | + $roles[]=$row; |
|
491 | + } |
|
492 | + |
|
493 | + return $roles; |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | |
@@ -506,34 +506,34 @@ discard block |
||
506 | 506 | */ |
507 | 507 | function get_roles_permissions($content,$id, $scope='course') { |
508 | 508 | $course_id = api_get_course_int_id(); |
509 | - if ($content == 'user') { |
|
510 | - $table=Database::get_course_table(TABLE_ROLE_USER); |
|
511 | - $id_field = 'user_id'; |
|
512 | - } |
|
513 | - |
|
514 | - if ($content == 'group') { |
|
515 | - $table = Database::get_course_table(TABLE_ROLE_GROUP); |
|
516 | - $id_field = 'group_id'; |
|
517 | - } |
|
518 | - |
|
519 | - // course roles or platform roles |
|
520 | - $scope = 'course'; |
|
521 | - if ($scope == 'course') { |
|
522 | - $table_role = Database::get_course_table(TABLE_ROLE); |
|
523 | - $table_role_permissions = Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
509 | + if ($content == 'user') { |
|
510 | + $table=Database::get_course_table(TABLE_ROLE_USER); |
|
511 | + $id_field = 'user_id'; |
|
512 | + } |
|
513 | + |
|
514 | + if ($content == 'group') { |
|
515 | + $table = Database::get_course_table(TABLE_ROLE_GROUP); |
|
516 | + $id_field = 'group_id'; |
|
517 | + } |
|
518 | + |
|
519 | + // course roles or platform roles |
|
520 | + $scope = 'course'; |
|
521 | + if ($scope == 'course') { |
|
522 | + $table_role = Database::get_course_table(TABLE_ROLE); |
|
523 | + $table_role_permissions = Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
524 | 524 | |
525 | 525 | $role_condition = " role.c_id = $course_id AND role_permissions.c_id = $course_id AND "; |
526 | - } |
|
526 | + } |
|
527 | 527 | |
528 | - if ($scope == 'platform') { |
|
529 | - $table_role = Database::get_main_table(TABLE_ROLE); |
|
530 | - $table_role_permissions = Database::get_main_table(TABLE_ROLE_PERMISSION); |
|
528 | + if ($scope == 'platform') { |
|
529 | + $table_role = Database::get_main_table(TABLE_ROLE); |
|
530 | + $table_role_permissions = Database::get_main_table(TABLE_ROLE_PERMISSION); |
|
531 | 531 | $role_condition = ''; |
532 | - } |
|
532 | + } |
|
533 | 533 | |
534 | - $current_roles = array(); |
|
534 | + $current_roles = array(); |
|
535 | 535 | |
536 | - $sql = " |
|
536 | + $sql = " |
|
537 | 537 | SELECT * |
538 | 538 | FROM |
539 | 539 | " . $table . " role_group_user, |
@@ -547,12 +547,12 @@ discard block |
||
547 | 547 | role_group_user.role_id = role.role_id AND |
548 | 548 | role.role_id = role_permissions.role_id"; |
549 | 549 | |
550 | - $result = Database::query($sql); |
|
550 | + $result = Database::query($sql); |
|
551 | 551 | $current_role_permissions = array(); |
552 | - while ($row=Database::fetch_array($result)) { |
|
553 | - $current_role_permissions[$row['tool']][]=$row['action']; |
|
552 | + while ($row=Database::fetch_array($result)) { |
|
553 | + $current_role_permissions[$row['tool']][]=$row['action']; |
|
554 | 554 | } |
555 | - return $current_role_permissions; |
|
555 | + return $current_role_permissions; |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | /** |
@@ -566,34 +566,34 @@ discard block |
||
566 | 566 | |
567 | 567 | function assign_role($content, $action, $id, $role_id, $scope='course') { |
568 | 568 | $course_id = api_get_course_int_id(); |
569 | - // Which database are we using (depending on the $content parameter) |
|
570 | - if ($content=='user') { |
|
571 | - $table=Database::get_course_table(TABLE_ROLE_USER); |
|
572 | - $id_field = 'user_id'; |
|
573 | - } elseif($content=='group') { |
|
574 | - $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
575 | - $id_field = 'group_id'; |
|
576 | - } else { |
|
577 | - return get_lang('Error'); |
|
578 | - } |
|
579 | - |
|
580 | - // grating a right |
|
581 | - if ($action=='grant') { |
|
582 | - $sql="INSERT INTO $table (c_id, role_id, scope, $id_field) VALUES ($course_id, '".Database::escape_string($role_id)."','".Database::escape_string($scope)."','".Database::escape_string($id)."')"; |
|
583 | - $result=Database::query($sql); |
|
584 | - if ($result) { |
|
585 | - $result_message=get_lang('RoleGranted'); |
|
586 | - } |
|
587 | - } |
|
569 | + // Which database are we using (depending on the $content parameter) |
|
570 | + if ($content=='user') { |
|
571 | + $table=Database::get_course_table(TABLE_ROLE_USER); |
|
572 | + $id_field = 'user_id'; |
|
573 | + } elseif($content=='group') { |
|
574 | + $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
575 | + $id_field = 'group_id'; |
|
576 | + } else { |
|
577 | + return get_lang('Error'); |
|
578 | + } |
|
579 | + |
|
580 | + // grating a right |
|
581 | + if ($action=='grant') { |
|
582 | + $sql="INSERT INTO $table (c_id, role_id, scope, $id_field) VALUES ($course_id, '".Database::escape_string($role_id)."','".Database::escape_string($scope)."','".Database::escape_string($id)."')"; |
|
583 | + $result=Database::query($sql); |
|
584 | + if ($result) { |
|
585 | + $result_message=get_lang('RoleGranted'); |
|
586 | + } |
|
587 | + } |
|
588 | 588 | |
589 | - if ($action=='revoke') { |
|
590 | - $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND role_id='".Database::escape_string($role_id)."'"; |
|
591 | - $result=Database::query($sql); |
|
592 | - if ($result) { |
|
593 | - $result_message=get_lang('RoleRevoked'); |
|
594 | - } |
|
595 | - } |
|
596 | - return $result_message; |
|
589 | + if ($action=='revoke') { |
|
590 | + $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND role_id='".Database::escape_string($role_id)."'"; |
|
591 | + $result=Database::query($sql); |
|
592 | + if ($result) { |
|
593 | + $result_message=get_lang('RoleRevoked'); |
|
594 | + } |
|
595 | + } |
|
596 | + return $result_message; |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | |
@@ -603,21 +603,21 @@ discard block |
||
603 | 603 | */ |
604 | 604 | function permission_array_merge($array1, $array2) |
605 | 605 | { |
606 | - foreach ($array2 as $tool=>$permissions) |
|
607 | - { |
|
608 | - foreach ($permissions as $permissionkey=>$permissionvalue) |
|
609 | - { |
|
610 | - $array1[$tool][]=$permissionvalue; |
|
611 | - } |
|
612 | - } |
|
613 | - return $array1; |
|
606 | + foreach ($array2 as $tool=>$permissions) |
|
607 | + { |
|
608 | + foreach ($permissions as $permissionkey=>$permissionvalue) |
|
609 | + { |
|
610 | + $array1[$tool][]=$permissionvalue; |
|
611 | + } |
|
612 | + } |
|
613 | + return $array1; |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | |
617 | 617 | function my_print_r($array) |
618 | 618 | { |
619 | - echo '<pre>'; |
|
620 | - print_r($array); |
|
621 | - echo '</pre>'; |
|
619 | + echo '<pre>'; |
|
620 | + print_r($array); |
|
621 | + echo '</pre>'; |
|
622 | 622 | } |
623 | 623 | ?> |
@@ -26,34 +26,34 @@ discard block |
||
26 | 26 | $course_id = api_get_course_int_id(); |
27 | 27 | |
28 | 28 | // Which database are we using (depending on the $content parameter) |
29 | - if ($content=='user') |
|
29 | + if ($content == 'user') |
|
30 | 30 | { |
31 | - $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
31 | + $table = Database::get_course_table(TABLE_PERMISSION_USER); |
|
32 | 32 | $id_field = user_id; |
33 | 33 | } |
34 | - if ($content=='group') |
|
34 | + if ($content == 'group') |
|
35 | 35 | { |
36 | - $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
36 | + $table = Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
37 | 37 | $id_field = group_id; |
38 | 38 | } |
39 | - if ($content=='role') |
|
39 | + if ($content == 'role') |
|
40 | 40 | { |
41 | - $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
41 | + $table = Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
42 | 42 | $id_field = role_id; |
43 | 43 | } |
44 | 44 | |
45 | 45 | // We first delete all the existing permissions for that user/group/role |
46 | - $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."'"; |
|
47 | - $result=Database::query($sql); |
|
46 | + $sql = "DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."'"; |
|
47 | + $result = Database::query($sql); |
|
48 | 48 | |
49 | 49 | // looping through the post values to find the permission (containing the string permission* ) |
50 | 50 | foreach ($_POST as $key => $value) |
51 | 51 | { |
52 | - if (strstr($key,"permission*")) |
|
52 | + if (strstr($key, "permission*")) |
|
53 | 53 | { |
54 | - list($brol,$tool,$action)=explode("*",$key); |
|
55 | - $sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($action)."')"; |
|
56 | - $result=Database::query($sql); |
|
54 | + list($brol, $tool, $action) = explode("*", $key); |
|
55 | + $sql = "INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($action)."')"; |
|
56 | + $result = Database::query($sql); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | return get_lang('PermissionsStored'); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @author Patrick Cool <[email protected]>, Ghent University |
70 | 70 | * @version 1.0 |
71 | 71 | */ |
72 | -function store_one_permission($content, $action, $id, $tool,$permission) { |
|
72 | +function store_one_permission($content, $action, $id, $tool, $permission) { |
|
73 | 73 | global $rights_full; |
74 | 74 | $course_id = api_get_course_int_id(); |
75 | 75 | // for some reason I don't know, he can't get to the $rights_full array, so commented the following lines out. |
@@ -82,35 +82,35 @@ discard block |
||
82 | 82 | |
83 | 83 | // Which database are we using (depending on the $content parameter) |
84 | 84 | |
85 | - if ($content=='user') { |
|
86 | - $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
85 | + if ($content == 'user') { |
|
86 | + $table = Database::get_course_table(TABLE_PERMISSION_USER); |
|
87 | 87 | $id_field = user_id; |
88 | 88 | } |
89 | - if ($content=='group') |
|
89 | + if ($content == 'group') |
|
90 | 90 | { |
91 | - $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
91 | + $table = Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
92 | 92 | $id_field = group_id; |
93 | 93 | } |
94 | - if ($content=='role') |
|
94 | + if ($content == 'role') |
|
95 | 95 | { |
96 | - $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
96 | + $table = Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
97 | 97 | $id_field = role_id; |
98 | 98 | } |
99 | 99 | |
100 | 100 | // grating a right |
101 | - if ($action=='grant') { |
|
102 | - $sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($permission)."')"; |
|
103 | - $result=Database::query($sql); |
|
104 | - if($result) { |
|
105 | - $result_message=get_lang('PermissionGranted'); |
|
101 | + if ($action == 'grant') { |
|
102 | + $sql = "INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($permission)."')"; |
|
103 | + $result = Database::query($sql); |
|
104 | + if ($result) { |
|
105 | + $result_message = get_lang('PermissionGranted'); |
|
106 | 106 | } |
107 | 107 | } |
108 | - if ($action=='revoke') |
|
108 | + if ($action == 'revoke') |
|
109 | 109 | { |
110 | - $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND tool='".Database::escape_string($tool)."' AND action='".Database::escape_string($permission)."'"; |
|
111 | - $result=Database::query($sql); |
|
112 | - if($result) { |
|
113 | - $result_message=get_lang('PermissionRevoked'); |
|
110 | + $sql = "DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND tool='".Database::escape_string($tool)."' AND action='".Database::escape_string($permission)."'"; |
|
111 | + $result = Database::query($sql); |
|
112 | + if ($result) { |
|
113 | + $result_message = get_lang('PermissionRevoked'); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | return $result_message; |
@@ -125,44 +125,44 @@ discard block |
||
125 | 125 | */ |
126 | 126 | function get_permissions($content, $id) { |
127 | 127 | $course_id = api_get_course_int_id(); |
128 | - $currentpermissions=array(); |
|
128 | + $currentpermissions = array(); |
|
129 | 129 | // Which database are we using (depending on the $content parameter) |
130 | 130 | $course_id_condition = " c_id = $course_id AND "; |
131 | 131 | if ($content == 'user') |
132 | 132 | { |
133 | - $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
133 | + $table = Database::get_course_table(TABLE_PERMISSION_USER); |
|
134 | 134 | $id_field = 'user_id'; |
135 | 135 | } |
136 | 136 | elseif ($content == 'group') |
137 | 137 | { |
138 | - $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
138 | + $table = Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
139 | 139 | $id_field = 'group_id'; |
140 | 140 | } |
141 | 141 | elseif ($content == 'role') |
142 | 142 | { |
143 | - $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
143 | + $table = Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
144 | 144 | $id_field = 'role_id'; |
145 | 145 | } |
146 | 146 | elseif ($content == 'platform_role') |
147 | 147 | { |
148 | - $table=Database::get_main_table(TABLE_ROLE_PERMISSION); |
|
148 | + $table = Database::get_main_table(TABLE_ROLE_PERMISSION); |
|
149 | 149 | $id_field = 'role_id'; |
150 | 150 | $course_id_condition = ''; |
151 | 151 | } |
152 | 152 | elseif ($content == 'task') |
153 | 153 | { |
154 | - $table=Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
154 | + $table = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
155 | 155 | $id_field = 'task_id'; |
156 | 156 | } |
157 | 157 | |
158 | 158 | // finding all the permissions. We store this in a multidimensional array |
159 | 159 | // where the first dimension is the tool. |
160 | - $sql=" |
|
161 | - SELECT * FROM " . $table . " |
|
162 | - WHERE $course_id_condition " . $id_field . "='" . Database::escape_string($id) . "'"; |
|
160 | + $sql = " |
|
161 | + SELECT * FROM " . $table." |
|
162 | + WHERE $course_id_condition ".$id_field."='".Database::escape_string($id)."'"; |
|
163 | 163 | $result = Database::query($sql); |
164 | 164 | |
165 | - while($row = Database::fetch_array($result)) |
|
165 | + while ($row = Database::fetch_array($result)) |
|
166 | 166 | $currentpermissions[$row['tool']][] = $row['action']; |
167 | 167 | |
168 | 168 | return $currentpermissions; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | */ |
180 | 180 | function limited_or_full($current_permissions) |
181 | 181 | { |
182 | - if (api_get_setting('permissions')=='limited') |
|
182 | + if (api_get_setting('permissions') == 'limited') |
|
183 | 183 | { |
184 | 184 | foreach ($current_permissions as $tool=>$tool_rights) |
185 | 185 | { |
@@ -187,15 +187,15 @@ discard block |
||
187 | 187 | // if it is visibility or move we have to grant the edit right |
188 | 188 | foreach ($tool_rights as $key=>$value) |
189 | 189 | { |
190 | - if ($value=='View') |
|
190 | + if ($value == 'View') |
|
191 | 191 | { |
192 | 192 | unset($current_permissions[$tool][$key]); |
193 | 193 | } |
194 | - if ($value=='Visibility' OR $value=='Move') |
|
194 | + if ($value == 'Visibility' OR $value == 'Move') |
|
195 | 195 | { |
196 | - if (!in_array('Edit',$current_permissions[$tool])) |
|
196 | + if (!in_array('Edit', $current_permissions[$tool])) |
|
197 | 197 | { |
198 | - $current_permissions[$tool][]='Edit'; |
|
198 | + $current_permissions[$tool][] = 'Edit'; |
|
199 | 199 | } |
200 | 200 | unset($current_permissions[$tool][$key]); |
201 | 201 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | } |
208 | 208 | return $current_permissions; |
209 | 209 | } |
210 | - if (api_get_setting('permissions')=='full') |
|
210 | + if (api_get_setting('permissions') == 'full') |
|
211 | 211 | { |
212 | 212 | return $current_permissions; |
213 | 213 | } |
@@ -222,12 +222,12 @@ discard block |
||
222 | 222 | * @author Patrick Cool <[email protected]>, Ghent University |
223 | 223 | * @version 1.0 |
224 | 224 | */ |
225 | -function display_checkbox_matrix($permission_array, $tool, $permission, $inherited_permissions=array()) |
|
225 | +function display_checkbox_matrix($permission_array, $tool, $permission, $inherited_permissions = array()) |
|
226 | 226 | { |
227 | - $checked=""; |
|
228 | - if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) |
|
227 | + $checked = ""; |
|
228 | + if (is_array($permission_array[$tool]) AND in_array($permission, $permission_array[$tool])) |
|
229 | 229 | { |
230 | - $checked="checked"; |
|
230 | + $checked = "checked"; |
|
231 | 231 | } |
232 | 232 | echo "\t\t\t<input type=\"checkbox\" name=\"permission*$tool*$permission\" $checked>\n"; |
233 | 233 | |
@@ -243,28 +243,28 @@ discard block |
||
243 | 243 | * @author Patrick Cool <[email protected]>, Ghent University |
244 | 244 | * @version 1.0 |
245 | 245 | */ |
246 | -function display_image_matrix($permission_array, $tool, $permission,$inherited_permissions=array(), $course_admin=false, $editable=true) |
|
246 | +function display_image_matrix($permission_array, $tool, $permission, $inherited_permissions = array(), $course_admin = false, $editable = true) |
|
247 | 247 | { |
248 | 248 | if ($course_admin) { |
249 | 249 | echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
250 | 250 | } else { |
251 | - if (in_array($permission,$inherited_permissions[$tool])) { |
|
251 | + if (in_array($permission, $inherited_permissions[$tool])) { |
|
252 | 252 | echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
253 | 253 | } else { |
254 | - if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) { |
|
254 | + if (is_array($permission_array[$tool]) AND in_array($permission, $permission_array[$tool])) { |
|
255 | 255 | if ($editable) { |
256 | - $url=api_get_self(); |
|
256 | + $url = api_get_self(); |
|
257 | 257 | $urlparameters = ''; |
258 | - foreach($_GET as $key=>$value) { |
|
259 | - $parameter[$key]=$value; |
|
258 | + foreach ($_GET as $key=>$value) { |
|
259 | + $parameter[$key] = $value; |
|
260 | 260 | } |
261 | - $parameter['action']='revoke'; |
|
262 | - $parameter['permission']=$permission; |
|
263 | - $parameter['tool']=$tool; |
|
261 | + $parameter['action'] = 'revoke'; |
|
262 | + $parameter['permission'] = $permission; |
|
263 | + $parameter['tool'] = $tool; |
|
264 | 264 | foreach ($parameter as $key=>$value) { |
265 | - $urlparameters.=$key.'='.$value.'&'; |
|
265 | + $urlparameters .= $key.'='.$value.'&'; |
|
266 | 266 | } |
267 | - $url=$url.'?'.$urlparameters; |
|
267 | + $url = $url.'?'.$urlparameters; |
|
268 | 268 | |
269 | 269 | echo "\t\t\t <a href=\"".$url."\">"; |
270 | 270 | } |
@@ -275,20 +275,20 @@ discard block |
||
275 | 275 | } else { |
276 | 276 | if ($editable) |
277 | 277 | { |
278 | - $url=api_get_self(); |
|
278 | + $url = api_get_self(); |
|
279 | 279 | $urlparameters = ''; |
280 | 280 | foreach ($_GET as $key=>$value) |
281 | 281 | { |
282 | - $parameter[$key]=$value; |
|
282 | + $parameter[$key] = $value; |
|
283 | 283 | } |
284 | - $parameter['action']='grant'; |
|
285 | - $parameter['permission']=$permission; |
|
286 | - $parameter['tool']=$tool; |
|
284 | + $parameter['action'] = 'grant'; |
|
285 | + $parameter['permission'] = $permission; |
|
286 | + $parameter['tool'] = $tool; |
|
287 | 287 | foreach ($parameter as $key=>$value) |
288 | 288 | { |
289 | - $urlparameters.=$key.'='.$value.'&'; |
|
289 | + $urlparameters .= $key.'='.$value.'&'; |
|
290 | 290 | } |
291 | - $url=$url.'?'.$urlparameters; |
|
291 | + $url = $url.'?'.$urlparameters; |
|
292 | 292 | |
293 | 293 | //echo "\t\t\t <a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=grant&permission=$permission&tool=$tool\">"; |
294 | 294 | echo "\t\t\t <a href=\"".$url."\">"; |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * @author Patrick Cool <[email protected]>, Ghent University |
316 | 316 | * @version 1.0 |
317 | 317 | */ |
318 | -function display_image_matrix_for_blogs($permission_array, $user_id, $tool, $permission,$inherited_permissions=array(), $course_admin=false, $editable=true) |
|
318 | +function display_image_matrix_for_blogs($permission_array, $user_id, $tool, $permission, $inherited_permissions = array(), $course_admin = false, $editable = true) |
|
319 | 319 | { |
320 | 320 | |
321 | 321 | if ($course_admin) |
@@ -324,32 +324,32 @@ discard block |
||
324 | 324 | } |
325 | 325 | else |
326 | 326 | { |
327 | - if (!empty($inherited_permissions) and in_array($permission,$inherited_permissions[$tool])) |
|
327 | + if (!empty($inherited_permissions) and in_array($permission, $inherited_permissions[$tool])) |
|
328 | 328 | { |
329 | 329 | echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
330 | 330 | } |
331 | 331 | else |
332 | 332 | { |
333 | - if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) |
|
333 | + if (is_array($permission_array[$tool]) AND in_array($permission, $permission_array[$tool])) |
|
334 | 334 | { |
335 | 335 | if ($editable) |
336 | 336 | { |
337 | 337 | $url = api_get_self(); |
338 | 338 | $urlparameters = ''; |
339 | - foreach($_GET as $key => $value) |
|
339 | + foreach ($_GET as $key => $value) |
|
340 | 340 | { |
341 | 341 | $parameter[$key] = $value; |
342 | 342 | } |
343 | - $parameter['action']='manage_rights'; |
|
344 | - $parameter['do']='revoke'; |
|
345 | - $parameter['permission']=$permission; |
|
346 | - $parameter['tool']=$tool; |
|
347 | - $parameter['user_id']=$user_id; |
|
343 | + $parameter['action'] = 'manage_rights'; |
|
344 | + $parameter['do'] = 'revoke'; |
|
345 | + $parameter['permission'] = $permission; |
|
346 | + $parameter['tool'] = $tool; |
|
347 | + $parameter['user_id'] = $user_id; |
|
348 | 348 | foreach ($parameter as $key=>$value) |
349 | 349 | { |
350 | - $urlparameters .= $key . '=' . $value . '&'; |
|
350 | + $urlparameters .= $key.'='.$value.'&'; |
|
351 | 351 | } |
352 | - $url = $url . '?' . $urlparameters; |
|
352 | + $url = $url.'?'.$urlparameters; |
|
353 | 353 | |
354 | 354 | echo "\t\t\t <a href=\"".$url."\">"; |
355 | 355 | } |
@@ -362,17 +362,17 @@ discard block |
||
362 | 362 | $url = api_get_self(); |
363 | 363 | $urlparameters = ''; |
364 | 364 | foreach ($_GET as $key=>$value) { |
365 | - $parameter[$key]=$value; |
|
365 | + $parameter[$key] = $value; |
|
366 | 366 | } |
367 | - $parameter['action']='manage_rights'; |
|
368 | - $parameter['do']='grant'; |
|
369 | - $parameter['permission']=$permission; |
|
370 | - $parameter['tool']=$tool; |
|
371 | - $parameter['user_id']=$user_id; |
|
367 | + $parameter['action'] = 'manage_rights'; |
|
368 | + $parameter['do'] = 'grant'; |
|
369 | + $parameter['permission'] = $permission; |
|
370 | + $parameter['tool'] = $tool; |
|
371 | + $parameter['user_id'] = $user_id; |
|
372 | 372 | foreach ($parameter as $key=>$value) { |
373 | - $urlparameters .= $key . '=' . $value . '&'; |
|
373 | + $urlparameters .= $key.'='.$value.'&'; |
|
374 | 374 | } |
375 | - $url=$url.'?'.$urlparameters; |
|
375 | + $url = $url.'?'.$urlparameters; |
|
376 | 376 | |
377 | 377 | //echo "\t\t\t <a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=grant&permission=$permission&tool=$tool\">"; |
378 | 378 | echo "\t\t\t <a href=\"".$url."\">"; |
@@ -397,30 +397,30 @@ discard block |
||
397 | 397 | global $setting_visualisation; |
398 | 398 | $course_id = api_get_course_int_id(); |
399 | 399 | |
400 | - $coures_roles_table=Database::get_course_table(TABLE_ROLE); |
|
400 | + $coures_roles_table = Database::get_course_table(TABLE_ROLE); |
|
401 | 401 | |
402 | 402 | // course roles |
403 | - $sql="SELECT * FROM $coures_roles_table WHERE c_id = $course_id "; |
|
404 | - $result=Database::query($sql); |
|
405 | - while ($row=Database::fetch_array($result)) |
|
403 | + $sql = "SELECT * FROM $coures_roles_table WHERE c_id = $course_id "; |
|
404 | + $result = Database::query($sql); |
|
405 | + while ($row = Database::fetch_array($result)) |
|
406 | 406 | { |
407 | 407 | if (in_array($row['role_id'], $current_course_roles)) |
408 | 408 | { |
409 | - $checked='checked'; |
|
410 | - $image='checkbox_on2.gif'; |
|
411 | - $action='revoke'; |
|
409 | + $checked = 'checked'; |
|
410 | + $image = 'checkbox_on2.gif'; |
|
411 | + $action = 'revoke'; |
|
412 | 412 | } |
413 | 413 | else |
414 | 414 | { |
415 | - $checked=''; |
|
416 | - $image='wrong.gif'; |
|
417 | - $action='grant'; |
|
415 | + $checked = ''; |
|
416 | + $image = 'wrong.gif'; |
|
417 | + $action = 'grant'; |
|
418 | 418 | } |
419 | - if ($setting_visualisation=='checkbox') |
|
419 | + if ($setting_visualisation == 'checkbox') |
|
420 | 420 | { |
421 | 421 | echo "<input type=\"checkbox\" name=\"role*course*".$row['role_id']."\" $checked>"; |
422 | 422 | } |
423 | - if ($setting_visualisation=='image') |
|
423 | + if ($setting_visualisation == 'image') |
|
424 | 424 | { |
425 | 425 | echo "<a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=$action&role=".$row['role_id']."&scope=course\"><img src=\"../img/".$image."\" border=\"0\"/></a>"; |
426 | 426 | } |
@@ -440,24 +440,24 @@ discard block |
||
440 | 440 | * @author Patrick Cool <[email protected]>, Ghent University |
441 | 441 | * @version 1.0 |
442 | 442 | */ |
443 | -function get_roles($content,$id, $scope='course') { |
|
444 | - $course_id = api_get_course_int_id(); |
|
445 | - if ($content=='user') { |
|
446 | - $table=Database::get_course_table(TABLE_ROLE_USER); |
|
443 | +function get_roles($content, $id, $scope = 'course') { |
|
444 | + $course_id = api_get_course_int_id(); |
|
445 | + if ($content == 'user') { |
|
446 | + $table = Database::get_course_table(TABLE_ROLE_USER); |
|
447 | 447 | $id_field = user_id; |
448 | 448 | } |
449 | - if ($content=='group') { |
|
450 | - $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
449 | + if ($content == 'group') { |
|
450 | + $table = Database::get_course_table(TABLE_ROLE_GROUP); |
|
451 | 451 | $id_field = 'group_id'; |
452 | 452 | } |
453 | - $table_role=Database::get_course_table(TABLE_ROLE); |
|
453 | + $table_role = Database::get_course_table(TABLE_ROLE); |
|
454 | 454 | |
455 | - $current_roles=array(); |
|
455 | + $current_roles = array(); |
|
456 | 456 | //$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'";$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'"; |
457 | - $sql="SELECT role_id FROM $table WHERE c_id = $course_id AND $id_field = '$id' AND scope='".$scope."'"; |
|
458 | - $result=Database::query($sql); |
|
459 | - while ($row=Database::fetch_array($result)) { |
|
460 | - $current_roles[]=$row['role_id']; |
|
457 | + $sql = "SELECT role_id FROM $table WHERE c_id = $course_id AND $id_field = '$id' AND scope='".$scope."'"; |
|
458 | + $result = Database::query($sql); |
|
459 | + while ($row = Database::fetch_array($result)) { |
|
460 | + $current_roles[] = $row['role_id']; |
|
461 | 461 | } |
462 | 462 | return $current_roles; |
463 | 463 | } |
@@ -468,26 +468,26 @@ discard block |
||
468 | 468 | * @author Patrick Cool <[email protected]>, Ghent University |
469 | 469 | * @version 1.0 |
470 | 470 | */ |
471 | -function get_all_roles($content='course') { |
|
471 | +function get_all_roles($content = 'course') { |
|
472 | 472 | $course_id = api_get_course_int_id(); |
473 | 473 | $course_id_condition = " WHERE c_id = $course_id "; |
474 | 474 | |
475 | - if ($content=='course') |
|
475 | + if ($content == 'course') |
|
476 | 476 | { |
477 | - $table_role=Database::get_course_table(TABLE_ROLE); |
|
477 | + $table_role = Database::get_course_table(TABLE_ROLE); |
|
478 | 478 | } |
479 | - if ($content=='platform') |
|
479 | + if ($content == 'platform') |
|
480 | 480 | { |
481 | - $table_role=Database::get_main_table(TABLE_ROLE); |
|
481 | + $table_role = Database::get_main_table(TABLE_ROLE); |
|
482 | 482 | $course_id_condition = ''; |
483 | 483 | } |
484 | 484 | |
485 | - $current_roles=array(); |
|
486 | - $sql="SELECT * FROM $table_role $course_id_condition "; |
|
487 | - $result=Database::query($sql); |
|
488 | - while ($row=Database::fetch_array($result)) |
|
485 | + $current_roles = array(); |
|
486 | + $sql = "SELECT * FROM $table_role $course_id_condition "; |
|
487 | + $result = Database::query($sql); |
|
488 | + while ($row = Database::fetch_array($result)) |
|
489 | 489 | { |
490 | - $roles[]=$row; |
|
490 | + $roles[] = $row; |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | return $roles; |
@@ -504,10 +504,10 @@ discard block |
||
504 | 504 | * @author Patrick Cool <[email protected]>, Ghent University |
505 | 505 | * @version 1.0 |
506 | 506 | */ |
507 | -function get_roles_permissions($content,$id, $scope='course') { |
|
507 | +function get_roles_permissions($content, $id, $scope = 'course') { |
|
508 | 508 | $course_id = api_get_course_int_id(); |
509 | 509 | if ($content == 'user') { |
510 | - $table=Database::get_course_table(TABLE_ROLE_USER); |
|
510 | + $table = Database::get_course_table(TABLE_ROLE_USER); |
|
511 | 511 | $id_field = 'user_id'; |
512 | 512 | } |
513 | 513 | |
@@ -536,21 +536,21 @@ discard block |
||
536 | 536 | $sql = " |
537 | 537 | SELECT * |
538 | 538 | FROM |
539 | - " . $table . " role_group_user, |
|
540 | - " . $table_role . " role, |
|
541 | - " . $table_role_permissions . " role_permissions |
|
539 | + " . $table." role_group_user, |
|
540 | + " . $table_role." role, |
|
541 | + " . $table_role_permissions." role_permissions |
|
542 | 542 | WHERE |
543 | 543 | role_group_user.c_id = $course_id AND |
544 | 544 | $role_condition |
545 | - role_group_user.scope = '" . $scope . "' AND |
|
546 | - role_group_user." . $id_field . " = '" . $id . "' AND |
|
545 | + role_group_user.scope = '".$scope."' AND |
|
546 | + role_group_user." . $id_field." = '".$id."' AND |
|
547 | 547 | role_group_user.role_id = role.role_id AND |
548 | 548 | role.role_id = role_permissions.role_id"; |
549 | 549 | |
550 | 550 | $result = Database::query($sql); |
551 | 551 | $current_role_permissions = array(); |
552 | - while ($row=Database::fetch_array($result)) { |
|
553 | - $current_role_permissions[$row['tool']][]=$row['action']; |
|
552 | + while ($row = Database::fetch_array($result)) { |
|
553 | + $current_role_permissions[$row['tool']][] = $row['action']; |
|
554 | 554 | } |
555 | 555 | return $current_role_permissions; |
556 | 556 | } |
@@ -564,33 +564,33 @@ discard block |
||
564 | 564 | * @author Patrick Cool <[email protected]>, Ghent University |
565 | 565 | */ |
566 | 566 | |
567 | -function assign_role($content, $action, $id, $role_id, $scope='course') { |
|
567 | +function assign_role($content, $action, $id, $role_id, $scope = 'course') { |
|
568 | 568 | $course_id = api_get_course_int_id(); |
569 | 569 | // Which database are we using (depending on the $content parameter) |
570 | - if ($content=='user') { |
|
571 | - $table=Database::get_course_table(TABLE_ROLE_USER); |
|
570 | + if ($content == 'user') { |
|
571 | + $table = Database::get_course_table(TABLE_ROLE_USER); |
|
572 | 572 | $id_field = 'user_id'; |
573 | - } elseif($content=='group') { |
|
574 | - $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
573 | + } elseif ($content == 'group') { |
|
574 | + $table = Database::get_course_table(TABLE_ROLE_GROUP); |
|
575 | 575 | $id_field = 'group_id'; |
576 | 576 | } else { |
577 | 577 | return get_lang('Error'); |
578 | 578 | } |
579 | 579 | |
580 | 580 | // grating a right |
581 | - if ($action=='grant') { |
|
582 | - $sql="INSERT INTO $table (c_id, role_id, scope, $id_field) VALUES ($course_id, '".Database::escape_string($role_id)."','".Database::escape_string($scope)."','".Database::escape_string($id)."')"; |
|
583 | - $result=Database::query($sql); |
|
581 | + if ($action == 'grant') { |
|
582 | + $sql = "INSERT INTO $table (c_id, role_id, scope, $id_field) VALUES ($course_id, '".Database::escape_string($role_id)."','".Database::escape_string($scope)."','".Database::escape_string($id)."')"; |
|
583 | + $result = Database::query($sql); |
|
584 | 584 | if ($result) { |
585 | - $result_message=get_lang('RoleGranted'); |
|
585 | + $result_message = get_lang('RoleGranted'); |
|
586 | 586 | } |
587 | 587 | } |
588 | 588 | |
589 | - if ($action=='revoke') { |
|
590 | - $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND role_id='".Database::escape_string($role_id)."'"; |
|
591 | - $result=Database::query($sql); |
|
589 | + if ($action == 'revoke') { |
|
590 | + $sql = "DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND role_id='".Database::escape_string($role_id)."'"; |
|
591 | + $result = Database::query($sql); |
|
592 | 592 | if ($result) { |
593 | - $result_message=get_lang('RoleRevoked'); |
|
593 | + $result_message = get_lang('RoleRevoked'); |
|
594 | 594 | } |
595 | 595 | } |
596 | 596 | return $result_message; |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | { |
608 | 608 | foreach ($permissions as $permissionkey=>$permissionvalue) |
609 | 609 | { |
610 | - $array1[$tool][]=$permissionvalue; |
|
610 | + $array1[$tool][] = $permissionvalue; |
|
611 | 611 | } |
612 | 612 | } |
613 | 613 | return $array1; |