Completed
Pull Request — 1.10.x (#1198)
by
unknown
46:55
created
main/coursecopy/classes/Thematic.class.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -11,13 +11,13 @@
 block discarded – undo
11 11
 {
12 12
     public $params = array();
13 13
     public $thematic_advance_list = array();
14
-	public $thematic_plan_list = array();
14
+    public $thematic_plan_list = array();
15 15
 
16 16
     /**
17
-    * Create a new Thematic
18
-    *
19
-    * @param array $params
20
-    */
17
+     * Create a new Thematic
18
+     *
19
+     * @param array $params
20
+     */
21 21
     public function __construct($params)
22 22
     {
23 23
         parent::__construct($params['id'], RESOURCE_THEMATIC);
Please login to merge, or discard this patch.
main/coursecopy/classes/CourseSelectForm.class.php 1 patch
Indentation   +251 added lines, -251 removed lines patch added patch discarded remove patch
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class CourseSelectForm
13 13
 {
14
-	/**
15
-	 * Display the form
16
-	 * @param array $hidden_fields Hidden fields to add to the form.
17
-	 * @param boolean the document array will be serialize. This is used in the course_copy.php file
18
-	 */
19
-	public static function display_form($course, $hidden_fields = null, $avoid_serialize = false)
14
+    /**
15
+     * Display the form
16
+     * @param array $hidden_fields Hidden fields to add to the form.
17
+     * @param boolean the document array will be serialize. This is used in the course_copy.php file
18
+     */
19
+    public static function display_form($course, $hidden_fields = null, $avoid_serialize = false)
20 20
     {
21 21
         global $charset;
22 22
         $resource_titles[RESOURCE_GRADEBOOK] = get_lang('Gradebook');
@@ -134,50 +134,50 @@  discard block
 block discarded – undo
134 134
 		</script>
135 135
 		<?php
136 136
 
137
-		//get destination course title
138
-		if (!empty($hidden_fields['destination_course'])) {
137
+        //get destination course title
138
+        if (!empty($hidden_fields['destination_course'])) {
139 139
             $sessionTitle = !empty($hidden_fields['destination_session']) ? ' (' . api_get_session_name(
140 140
                 $hidden_fields['destination_session']
141 141
             ) . ')' : null;
142 142
 
143 143
             $course_infos = CourseManager::get_course_information($hidden_fields['destination_course']);
144
-			echo '<h3>';
145
-			echo get_lang('DestinationCourse').' : '.$course_infos['title'] . ' ('.$course_infos['code'].') '.$sessionTitle;
146
-			echo '</h3>';
147
-		}
144
+            echo '<h3>';
145
+            echo get_lang('DestinationCourse').' : '.$course_infos['title'] . ' ('.$course_infos['code'].') '.$sessionTitle;
146
+            echo '</h3>';
147
+        }
148 148
         echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>';
149
-		echo '<script type="text/javascript">var myUpload = new upload(1000);</script>';
149
+        echo '<script type="text/javascript">var myUpload = new upload(1000);</script>';
150 150
         $icon = Display::returnIconPath('myprogress_bar.gif');
151
-		echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="javascript: myUpload.start(\'dynamic_div\',\''.$icon.',\''.get_lang('PleaseStandBy', '').'\',\'upload_form\')">';
152
-		echo '<input type="hidden" name="action" value="course_select_form"/>';
151
+        echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="javascript: myUpload.start(\'dynamic_div\',\''.$icon.',\''.get_lang('PleaseStandBy', '').'\',\'upload_form\')">';
152
+        echo '<input type="hidden" name="action" value="course_select_form"/>';
153 153
 
154
-		if (!empty($hidden_fields['destination_course']) &&
154
+        if (!empty($hidden_fields['destination_course']) &&
155 155
             !empty($hidden_fields['origin_course']) &&
156 156
             !empty($hidden_fields['destination_session']) &&
157 157
             !empty($hidden_fields['origin_session'])
158 158
         ) {
159
-			echo '<input type="hidden" name="destination_course" 	value="'.$hidden_fields['destination_course'].'"/>';
160
-			echo '<input type="hidden" name="origin_course" 		value="'.$hidden_fields['origin_course'].'"/>';
161
-			echo '<input type="hidden" name="destination_session" 	value="'.$hidden_fields['destination_session'].'"/>';
162
-			echo '<input type="hidden" name="origin_session" 		value="'.$hidden_fields['origin_session'].'"/>';
163
-		}
159
+            echo '<input type="hidden" name="destination_course" 	value="'.$hidden_fields['destination_course'].'"/>';
160
+            echo '<input type="hidden" name="origin_course" 		value="'.$hidden_fields['origin_course'].'"/>';
161
+            echo '<input type="hidden" name="destination_session" 	value="'.$hidden_fields['destination_session'].'"/>';
162
+            echo '<input type="hidden" name="origin_session" 		value="'.$hidden_fields['origin_session'].'"/>';
163
+        }
164 164
 
165
-		$element_count = 0;
165
+        $element_count = 0;
166 166
         $forum_categories = array();
167 167
         $forums = array();
168 168
         $forum_topics = array();
169 169
 
170 170
         echo '<p>';
171
-		echo get_lang('SelectResources');
172
-		echo '</p>';
171
+        echo get_lang('SelectResources');
172
+        echo '</p>';
173 173
 
174 174
         Display::display_normal_message(get_lang('DontForgetToSelectTheMediaFilesIfYourResourceNeedIt'));
175 175
 
176 176
         foreach ($course->resources as $type => $resources) {
177 177
             if (count($resources) > 0) {
178
-				switch ($type) {
179
-					//Resources to avoid
180
-					case RESOURCE_FORUMCATEGORY:
178
+                switch ($type) {
179
+                    //Resources to avoid
180
+                    case RESOURCE_FORUMCATEGORY:
181 181
                         foreach ($resources as $id => $resource) {
182 182
                             $forum_categories[$id] = $resource;
183 183
                         }
@@ -196,33 +196,33 @@  discard block
 block discarded – undo
196 196
                         $element_count++;
197 197
                         break;
198 198
                     case RESOURCE_LINKCATEGORY:
199
-					case RESOURCE_FORUMPOST:
200
-					case RESOURCE_QUIZQUESTION:
201
-					case RESOURCE_SURVEYQUESTION:
202
-					case RESOURCE_SURVEYINVITATION:
203
-					case RESOURCE_SCORM:
204
-						break;
199
+                    case RESOURCE_FORUMPOST:
200
+                    case RESOURCE_QUIZQUESTION:
201
+                    case RESOURCE_SURVEYQUESTION:
202
+                    case RESOURCE_SURVEYINVITATION:
203
+                    case RESOURCE_SCORM:
204
+                        break;
205 205
                     default :
206
-						echo '<img id="img_'.$type.'" src="'.Display::returnIconPath('1.gif').'" onclick="javascript:exp('."'$type'".');" />&nbsp;';
207
-						echo '<b onclick="javascript:exp('."'$type'".');" >'.$resource_titles[$type].'</b><br />';
208
-						echo '<div id="div_'.$type.'">';
209
-						if ($type == RESOURCE_LEARNPATH) {
210
-    						Display::display_warning_message(get_lang('ToExportLearnpathWithQuizYouHaveToSelectQuiz'));
211
-    						Display::display_warning_message(get_lang('IfYourLPsHaveAudioFilesIncludedYouShouldSelectThemFromTheDocuments'));
212
-						}
213
-						if ($type == RESOURCE_DOCUMENT) {
206
+                        echo '<img id="img_'.$type.'" src="'.Display::returnIconPath('1.gif').'" onclick="javascript:exp('."'$type'".');" />&nbsp;';
207
+                        echo '<b onclick="javascript:exp('."'$type'".');" >'.$resource_titles[$type].'</b><br />';
208
+                        echo '<div id="div_'.$type.'">';
209
+                        if ($type == RESOURCE_LEARNPATH) {
210
+                            Display::display_warning_message(get_lang('ToExportLearnpathWithQuizYouHaveToSelectQuiz'));
211
+                            Display::display_warning_message(get_lang('IfYourLPsHaveAudioFilesIncludedYouShouldSelectThemFromTheDocuments'));
212
+                        }
213
+                        if ($type == RESOURCE_DOCUMENT) {
214 214
                             if (api_get_setting('show_glossary_in_documents') != 'none') {
215 215
                                 Display::display_warning_message(get_lang('ToExportDocumentsWithGlossaryYouHaveToSelectGlossary'));
216 216
                             }
217
-						}
217
+                        }
218 218
 
219
-						echo '<blockquote>';
219
+                        echo '<blockquote>';
220 220
                         echo '<div class="btn-group">';
221
-						echo "<a class=\"btn btn-default\" href=\"javascript: void(0);\" onclick=\"javascript: setCheckbox('$type',true);\" >".get_lang('All')."</a>";
221
+                        echo "<a class=\"btn btn-default\" href=\"javascript: void(0);\" onclick=\"javascript: setCheckbox('$type',true);\" >".get_lang('All')."</a>";
222 222
                         echo "<a class=\"btn btn-default\" href=\"javascript: void(0);\" onclick=\"javascript:setCheckbox('$type',false);\" >".get_lang('None')."</a>";
223
-						echo '</div><br />';
223
+                        echo '</div><br />';
224 224
 
225
-						foreach ($resources as $id => $resource) {
225
+                        foreach ($resources as $id => $resource) {
226 226
                             if ($resource) {
227 227
                                 Coursecopy\Resource::setClassType($resource);
228 228
                                 echo '<label class="checkbox">';
@@ -230,14 +230,14 @@  discard block
 block discarded – undo
230 230
                                 $resource->show();
231 231
                                 echo '</label>';
232 232
                             }
233
-						}
234
-						echo '</blockquote>';
235
-						echo '</div>';
236
-						echo '<script language="javascript">exp('."'$type'".')</script>';
237
-						$element_count++;
233
+                        }
234
+                        echo '</blockquote>';
235
+                        echo '</div>';
236
+                        echo '<script language="javascript">exp('."'$type'".')</script>';
237
+                        $element_count++;
238 238
                 }
239
-			}
240
-		}
239
+            }
240
+        }
241 241
 
242 242
         //Fixes forum order
243 243
         if (!empty($forum_categories)) {
@@ -293,65 +293,65 @@  discard block
 block discarded – undo
293 293
             echo '<script language="javascript">exp('."'$type'".')</script>';
294 294
         }
295 295
 
296
-		if ($avoid_serialize) {
297
-			/*Documents are avoided due the huge amount of memory that the serialize php function "eats"
296
+        if ($avoid_serialize) {
297
+            /*Documents are avoided due the huge amount of memory that the serialize php function "eats"
298 298
 			(when there are directories with hundred/thousand of files) */
299
-			// this is a known issue of serialize
300
-			$course->resources['document']= null;
301
-		}
299
+            // this is a known issue of serialize
300
+            $course->resources['document']= null;
301
+        }
302 302
 
303
-		echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>';
303
+        echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>';
304 304
 
305
-		if (is_array($hidden_fields)) {
306
-			foreach ($hidden_fields as $key => $value) {
307
-				echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>';
308
-			}
309
-		}
305
+        if (is_array($hidden_fields)) {
306
+            foreach ($hidden_fields as $key => $value) {
307
+                echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>';
308
+            }
309
+        }
310 310
 
311 311
         $recycleOption = isset($_POST['recycle_option']) ? true : false;
312 312
 
313
-		if (empty($element_count)) {
314
-		    Display::display_warning_message(get_lang('NoDataAvailable'));
315
-		} else {
316
-    		if (!empty($hidden_fields['destination_session'])) {
317
-    			echo '<br /><button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES, $charset))."'".')) return false;" >'.
313
+        if (empty($element_count)) {
314
+            Display::display_warning_message(get_lang('NoDataAvailable'));
315
+        } else {
316
+            if (!empty($hidden_fields['destination_session'])) {
317
+                echo '<br /><button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES, $charset))."'".')) return false;" >'.
318 318
                     get_lang('Ok').'</button>';
319
-    		} else {
319
+            } else {
320 320
                 if ($recycleOption) {
321 321
                     echo '<br /><button class="save" type="submit">'.
322 322
                         get_lang('Ok').'</button>';
323 323
                 } else {
324
-    			    echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.
324
+                    echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.
325 325
                     get_lang('Ok').'</button>';
326 326
                 }
327
-    		}
328
-		}
327
+            }
328
+        }
329 329
 
330
-		CourseSelectForm :: display_hidden_quiz_questions($course);
331
-		CourseSelectForm :: display_hidden_scorm_directories($course);
332
-		echo '</form>';
333
-		echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>';
334
-	}
330
+        CourseSelectForm :: display_hidden_quiz_questions($course);
331
+        CourseSelectForm :: display_hidden_scorm_directories($course);
332
+        echo '</form>';
333
+        echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>';
334
+    }
335 335
 
336 336
     /**
337 337
      * @param $course
338 338
      */
339 339
     static function display_hidden_quiz_questions($course)
340 340
     {
341
-		if(is_array($course->resources)){
342
-			foreach ($course->resources as $type => $resources) {
343
-				if (count($resources) > 0) {
344
-					switch ($type) {
345
-						case RESOURCE_QUIZQUESTION:
346
-							foreach ($resources as $id => $resource) {
347
-								echo '<input type="hidden" name="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" id="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" value="On" />';
348
-							}
349
-							break;
350
-					}
351
-				}
352
-			}
353
-		}
354
-	}
341
+        if(is_array($course->resources)){
342
+            foreach ($course->resources as $type => $resources) {
343
+                if (count($resources) > 0) {
344
+                    switch ($type) {
345
+                        case RESOURCE_QUIZQUESTION:
346
+                            foreach ($resources as $id => $resource) {
347
+                                echo '<input type="hidden" name="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" id="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" value="On" />';
348
+                            }
349
+                            break;
350
+                    }
351
+                }
352
+            }
353
+        }
354
+    }
355 355
 
356 356
     /**
357 357
      * @param $course
@@ -359,30 +359,30 @@  discard block
 block discarded – undo
359 359
     static function display_hidden_scorm_directories($course)
360 360
     {
361 361
         if (is_array($course->resources)){
362
-			foreach ($course->resources as $type => $resources) {
363
-				if (count($resources) > 0) {
364
-					switch($type) {
365
-						case RESOURCE_SCORM:
366
-							foreach ($resources as $id => $resource) {
367
-								echo '<input type="hidden" name="resource['.RESOURCE_SCORM.']['.$id.']" id="resource['.RESOURCE_SCORM.']['.$id.']" value="On" />';
368
-							}
369
-							break;
370
-					}
371
-				}
372
-			}
373
-		}
374
-	}
362
+            foreach ($course->resources as $type => $resources) {
363
+                if (count($resources) > 0) {
364
+                    switch($type) {
365
+                        case RESOURCE_SCORM:
366
+                            foreach ($resources as $id => $resource) {
367
+                                echo '<input type="hidden" name="resource['.RESOURCE_SCORM.']['.$id.']" id="resource['.RESOURCE_SCORM.']['.$id.']" value="On" />';
368
+                            }
369
+                            break;
370
+                    }
371
+                }
372
+            }
373
+        }
374
+    }
375 375
 
376
-	/**
377
-	 * Get the posted course
378
-	 * @param string $from who calls the function?
376
+    /**
377
+     * Get the posted course
378
+     * @param string $from who calls the function?
379 379
      * It can be copy_course, create_backup, import_backup or recycle_course
380 380
      * @param int $session_id
381 381
      * @param string $course_code
382
-	 * @return course The course-object with all resources selected by the user
383
-	 * in the form given by display_form(...)
384
-	 */
385
-	public static function get_posted_course($from = '', $session_id = 0, $course_code = '')
382
+     * @return course The course-object with all resources selected by the user
383
+     * in the form given by display_form(...)
384
+     */
385
+    public static function get_posted_course($from = '', $session_id = 0, $course_code = '')
386 386
     {
387 387
         $course = null;
388 388
 
@@ -392,30 +392,30 @@  discard block
 block discarded – undo
392 392
             return false;
393 393
         }
394 394
 
395
-		// Create the resource DOCUMENT objects
396
-		// Loading the results from the checkboxes of ethe javascript
397
-		$resource = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null;
395
+        // Create the resource DOCUMENT objects
396
+        // Loading the results from the checkboxes of ethe javascript
397
+        $resource = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null;
398 398
 
399
-		$course_info = api_get_course_info($course_code);
400
-		$table_doc = Database::get_course_table(TABLE_DOCUMENT);
401
-		$table_prop = Database::get_course_table(TABLE_ITEM_PROPERTY);
402
-		$course_id = $course_info['real_id'];
399
+        $course_info = api_get_course_info($course_code);
400
+        $table_doc = Database::get_course_table(TABLE_DOCUMENT);
401
+        $table_prop = Database::get_course_table(TABLE_ITEM_PROPERTY);
402
+        $course_id = $course_info['real_id'];
403 403
 
404
-		/* Searching the documents resource that have been set to null because
404
+        /* Searching the documents resource that have been set to null because
405 405
         $avoid_serialize is true in the display_form() function*/
406
-		if ($from == 'copy_course') {
407
-			if (is_array($resource)) {
408
-				$resource = array_keys($resource);
406
+        if ($from == 'copy_course') {
407
+            if (is_array($resource)) {
408
+                $resource = array_keys($resource);
409 409
 
410
-				foreach	($resource as $resource_item) {
410
+                foreach	($resource as $resource_item) {
411 411
 
412
-					$condition_session = '';
413
-					if (!empty($session_id)) {
414
-						$session_id = intval($session_id);
415
-						$condition_session = ' AND d.session_id ='.$session_id;
416
-					}
412
+                    $condition_session = '';
413
+                    if (!empty($session_id)) {
414
+                        $session_id = intval($session_id);
415
+                        $condition_session = ' AND d.session_id ='.$session_id;
416
+                    }
417 417
 
418
-					$sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size
418
+                    $sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size
419 419
 							FROM '.$table_doc.' d, '.$table_prop.' p
420 420
 							WHERE
421 421
 							    d.c_id = '.$course_id.' AND
@@ -424,8 +424,8 @@  discard block
 block discarded – undo
424 424
                                 p.ref = d.id AND p.visibility != 2 AND
425 425
                                 d.id = '.$resource_item.$condition_session.'
426 426
 							ORDER BY path';
427
-					$db_result = Database::query($sql);
428
-					while ($obj = Database::fetch_object($db_result)) {
427
+                    $db_result = Database::query($sql);
428
+                    while ($obj = Database::fetch_object($db_result)) {
429 429
                         $doc = new Document(
430 430
                             $obj->id,
431 431
                             $obj->path,
@@ -449,25 +449,25 @@  discard block
 block discarded – undo
449 449
                             }
450 450
                             $course->resources[RESOURCE_DOCUMENT][$resource_item]->item_properties = $all_properties;
451 451
                         }
452
-					}
453
-				}
454
-			}
455
-		}
452
+                    }
453
+                }
454
+            }
455
+        }
456 456
 
457
-		if (is_array($course->resources)) {
458
-			foreach ($course->resources as $type => $resources) {
457
+        if (is_array($course->resources)) {
458
+            foreach ($course->resources as $type => $resources) {
459 459
 
460
-				switch ($type) {
461
-					case RESOURCE_SURVEYQUESTION:
462
-						foreach($resources as $id => $obj) {
463
-						    if (isset($_POST['resource'][RESOURCE_SURVEY]) &&
460
+                switch ($type) {
461
+                    case RESOURCE_SURVEYQUESTION:
462
+                        foreach($resources as $id => $obj) {
463
+                            if (isset($_POST['resource'][RESOURCE_SURVEY]) &&
464 464
                                 is_array($_POST['resource'][RESOURCE_SURVEY]) &&
465 465
                                 !in_array($obj->survey_id, array_keys($_POST['resource'][RESOURCE_SURVEY]))
466 466
                             ) {
467
-								unset($course->resources[$type][$id]);
468
-							}
469
-						}
470
-						break;
467
+                                unset($course->resources[$type][$id]);
468
+                            }
469
+                        }
470
+                        break;
471 471
                     case RESOURCE_FORUMTOPIC:
472 472
                     case RESOURCE_FORUMPOST:
473 473
                        //Add post from topic
@@ -519,62 +519,62 @@  discard block
 block discarded – undo
519 519
                                 }
520 520
                             }
521 521
                         }
522
-					case RESOURCE_LINKCATEGORY :
523
-					case RESOURCE_FORUMCATEGORY :
524
-					case RESOURCE_QUIZQUESTION :
525
-					case RESOURCE_DOCUMENT:
526
-						// Mark folders to import which are not selected by the user to import,
527
-						// but in which a document was selected.
528
-						$documents = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null;
529
-						if (!empty($resources) && is_array($resources))
530
-							foreach ($resources as $id => $obj) {
531
-								if (isset($obj->file_type) && $obj->file_type == 'folder' &&
522
+                    case RESOURCE_LINKCATEGORY :
523
+                    case RESOURCE_FORUMCATEGORY :
524
+                    case RESOURCE_QUIZQUESTION :
525
+                    case RESOURCE_DOCUMENT:
526
+                        // Mark folders to import which are not selected by the user to import,
527
+                        // but in which a document was selected.
528
+                        $documents = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null;
529
+                        if (!empty($resources) && is_array($resources))
530
+                            foreach ($resources as $id => $obj) {
531
+                                if (isset($obj->file_type) && $obj->file_type == 'folder' &&
532 532
                                     !isset($_POST['resource'][RESOURCE_DOCUMENT][$id]) &&
533 533
                                     is_array($documents)
534 534
                                 ) {
535
-									foreach ($documents as $id_to_check => $post_value) {
536
-										$obj_to_check = $resources[$id_to_check];
537
-										$shared_path_part = substr($obj_to_check->path,0,strlen($obj->path));
538
-										if ($id_to_check != $id && $obj->path == $shared_path_part) {
539
-											$_POST['resource'][RESOURCE_DOCUMENT][$id] = 1;
540
-											break;
541
-										}
542
-									}
543
-								}
544
-							}
545
-					default :
546
-						if (!empty($resources) && is_array($resources)) {
547
-							foreach ($resources as $id => $obj) {
548
-								$resource_is_used_elsewhere = $course->is_linked_resource($obj);
549
-								// check if document is in a quiz (audio/video)
550
-								if ($type == RESOURCE_DOCUMENT && $course->has_resources(RESOURCE_QUIZ)) {
551
-									foreach($course->resources[RESOURCE_QUIZ] as $quiz) {
535
+                                    foreach ($documents as $id_to_check => $post_value) {
536
+                                        $obj_to_check = $resources[$id_to_check];
537
+                                        $shared_path_part = substr($obj_to_check->path,0,strlen($obj->path));
538
+                                        if ($id_to_check != $id && $obj->path == $shared_path_part) {
539
+                                            $_POST['resource'][RESOURCE_DOCUMENT][$id] = 1;
540
+                                            break;
541
+                                        }
542
+                                    }
543
+                                }
544
+                            }
545
+                    default :
546
+                        if (!empty($resources) && is_array($resources)) {
547
+                            foreach ($resources as $id => $obj) {
548
+                                $resource_is_used_elsewhere = $course->is_linked_resource($obj);
549
+                                // check if document is in a quiz (audio/video)
550
+                                if ($type == RESOURCE_DOCUMENT && $course->has_resources(RESOURCE_QUIZ)) {
551
+                                    foreach($course->resources[RESOURCE_QUIZ] as $quiz) {
552 552
                                         $quiz = $quiz->obj;
553
-										if (isset($quiz->media) && $quiz->media == $id) {
554
-											$resource_is_used_elsewhere = true;
555
-										}
556
-									}
557
-								}
558
-								if (!isset($_POST['resource'][$type][$id]) && !$resource_is_used_elsewhere) {
559
-									unset($course->resources[$type][$id]);
560
-								}
561
-							}
562
-						}
563
-				}
564
-			}
565
-		}
566
-
567
-		return $course;
568
-	}
569
-
570
-	/**
571
-	 * Display the form session export
572
-	 * @param array $hidden_fields Hidden fields to add to the form.
573
-	 * @param boolean the document array will be serialize. This is used in the course_copy.php file
574
-	 */
575
-	 public static function display_form_session_export($list_course, $hidden_fields = null, $avoid_serialize = false)
576
-     {
577
-         ?>
553
+                                        if (isset($quiz->media) && $quiz->media == $id) {
554
+                                            $resource_is_used_elsewhere = true;
555
+                                        }
556
+                                    }
557
+                                }
558
+                                if (!isset($_POST['resource'][$type][$id]) && !$resource_is_used_elsewhere) {
559
+                                    unset($course->resources[$type][$id]);
560
+                                }
561
+                            }
562
+                        }
563
+                }
564
+            }
565
+        }
566
+
567
+        return $course;
568
+    }
569
+
570
+    /**
571
+     * Display the form session export
572
+     * @param array $hidden_fields Hidden fields to add to the form.
573
+     * @param boolean the document array will be serialize. This is used in the course_copy.php file
574
+     */
575
+        public static function display_form_session_export($list_course, $hidden_fields = null, $avoid_serialize = false)
576
+        {
577
+            ?>
578 578
 		<script>
579 579
 			function exp(item) {
580 580
 				el = document.getElementById('div_'+item);
@@ -616,65 +616,65 @@  discard block
 block discarded – undo
616 616
 		</script>
617 617
 		<?php
618 618
 
619
-		//get destination course title
620
-		if(!empty($hidden_fields['destination_course'])) {
621
-             if (!empty($hidden_fields['destination_session'])) {
622
-                 $sessionTitle = ' (' . api_get_session_name($hidden_fields['destination_session']) . ')';
623
-             } else {
624
-                 $sessionTitle = null;
625
-             }
619
+        //get destination course title
620
+        if(!empty($hidden_fields['destination_course'])) {
621
+                if (!empty($hidden_fields['destination_session'])) {
622
+                    $sessionTitle = ' (' . api_get_session_name($hidden_fields['destination_session']) . ')';
623
+                } else {
624
+                    $sessionTitle = null;
625
+                }
626 626
             $course_infos = CourseManager::get_course_information($hidden_fields['destination_course']);
627
-			echo '<h3>';
628
-				echo get_lang('DestinationCourse') . ' : ' . $course_infos['title'] . $sessionTitle;
629
-			echo '</h3>';
630
-		}
627
+            echo '<h3>';
628
+                echo get_lang('DestinationCourse') . ' : ' . $course_infos['title'] . $sessionTitle;
629
+            echo '</h3>';
630
+        }
631 631
 
632
-		echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>';
633
-		echo '<script type="text/javascript">var myUpload = new upload(1000);</script>';
632
+        echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>';
633
+        echo '<script type="text/javascript">var myUpload = new upload(1000);</script>';
634 634
         $icon = Display::returnIconPath('progress_bar.gif');
635
-		echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="myUpload.start(\'dynamic_div\',\''.$icon.'\',\''.get_lang('PleaseStandBy').'\',\'upload_form\')">';
636
-		echo '<input type="hidden" name="action" value="course_select_form"/>';
637
-		foreach ($list_course as $course){
638
-			foreach ($course->resources as $type => $resources) {
639
-				if (count($resources) > 0) {
640
-					echo '<img id="img_'.$course->code.'" src="'.Display::returnIconPath('1.gif').'" onclick="javascript:exp('."'$course->code'".');" />';
641
-					echo '<b  onclick="javascript:exp('."'$course->code'".');" > '.$course->code.'</b><br />';
642
-					echo '<div id="div_'.$course->code.'">';
643
-					echo '<blockquote>';
635
+        echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="myUpload.start(\'dynamic_div\',\''.$icon.'\',\''.get_lang('PleaseStandBy').'\',\'upload_form\')">';
636
+        echo '<input type="hidden" name="action" value="course_select_form"/>';
637
+        foreach ($list_course as $course){
638
+            foreach ($course->resources as $type => $resources) {
639
+                if (count($resources) > 0) {
640
+                    echo '<img id="img_'.$course->code.'" src="'.Display::returnIconPath('1.gif').'" onclick="javascript:exp('."'$course->code'".');" />';
641
+                    echo '<b  onclick="javascript:exp('."'$course->code'".');" > '.$course->code.'</b><br />';
642
+                    echo '<div id="div_'.$course->code.'">';
643
+                    echo '<blockquote>';
644 644
 
645 645
                     echo '<div class="btn-group">';
646
-					echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',true);\" >".get_lang('All')."</a>";
646
+                    echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',true);\" >".get_lang('All')."</a>";
647 647
                     echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',false);\" >".get_lang('None')."</a>";
648
-					echo '</div><br />';
648
+                    echo '</div><br />';
649 649
 
650
-					foreach ($resources as $id => $resource) {
651
-						echo '<label class="checkbox" for="resource['.$course->code.']['.$id.']">';
650
+                    foreach ($resources as $id => $resource) {
651
+                        echo '<label class="checkbox" for="resource['.$course->code.']['.$id.']">';
652 652
                         echo '<input type="checkbox" name="resource['.$course->code.']['.$id.']" id="resource['.$course->code.']['.$id.']"/>';
653
-						$resource->show();
654
-						echo '</label>';
655
-					}
656
-					echo '</blockquote>';
657
-					echo '</div>';
658
-					echo '<script type="text/javascript">exp('."'$course->code'".')</script>';
659
-				}
660
-			}
661
-		}
662
-		if ($avoid_serialize) {
663
-			//Documents are avoided due the huge amount of memory that the serialize php function "eats" (when there are directories with hundred/thousand of files)
664
-			// this is a known issue of serialize
665
-			$course->resources['document']= null;
666
-		}
667
-		echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>';
668
-		if (is_array($hidden_fields)) {
669
-			foreach ($hidden_fields as $key => $value) {
670
-				echo "\n";
671
-				echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>';
672
-			}
673
-		}
674
-		echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.get_lang('Ok').'</button>';
675
-		CourseSelectForm :: display_hidden_quiz_questions($course);
676
-		CourseSelectForm :: display_hidden_scorm_directories($course);
677
-		echo '</form>';
678
-		echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>';
679
-	}
653
+                        $resource->show();
654
+                        echo '</label>';
655
+                    }
656
+                    echo '</blockquote>';
657
+                    echo '</div>';
658
+                    echo '<script type="text/javascript">exp('."'$course->code'".')</script>';
659
+                }
660
+            }
661
+        }
662
+        if ($avoid_serialize) {
663
+            //Documents are avoided due the huge amount of memory that the serialize php function "eats" (when there are directories with hundred/thousand of files)
664
+            // this is a known issue of serialize
665
+            $course->resources['document']= null;
666
+        }
667
+        echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>';
668
+        if (is_array($hidden_fields)) {
669
+            foreach ($hidden_fields as $key => $value) {
670
+                echo "\n";
671
+                echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>';
672
+            }
673
+        }
674
+        echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.get_lang('Ok').'</button>';
675
+        CourseSelectForm :: display_hidden_quiz_questions($course);
676
+        CourseSelectForm :: display_hidden_scorm_directories($course);
677
+        echo '</form>';
678
+        echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>';
679
+    }
680 680
 }
Please login to merge, or discard this patch.
main/inc/ajax/course_home.ajax.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -63,12 +63,12 @@  discard block
 block discarded – undo
63 63
             echo json_encode($response_data);
64 64
         }
65 65
         break;
66
-	case 'show_course_information' :
67
-		require_once '../global.inc.php';
66
+    case 'show_course_information' :
67
+        require_once '../global.inc.php';
68 68
 
69
-		// Get the name of the database course.
70
-		$tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
71
-		$course_info = api_get_course_info($_GET['code']);
69
+        // Get the name of the database course.
70
+        $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
71
+        $course_info = api_get_course_info($_GET['code']);
72 72
 
73 73
         if (
74 74
             api_get_setting('course_catalog_hide_private') === 'true' &&
@@ -78,24 +78,24 @@  discard block
 block discarded – undo
78 78
             break;
79 79
         }
80 80
 
81
-		$sql = "SELECT * FROM $tbl_course_description
81
+        $sql = "SELECT * FROM $tbl_course_description
82 82
 		        WHERE c_id = ".$course_info['real_id']." AND session_id = 0
83 83
 		        ORDER BY id";
84
-		$result = Database::query($sql);
85
-		if (Database::num_rows($result) > 0 ) {
86
-		    while ($description = Database::fetch_object($result)) {
87
-			    $descriptions[$description->id] = $description;
88
-		    }
84
+        $result = Database::query($sql);
85
+        if (Database::num_rows($result) > 0 ) {
86
+            while ($description = Database::fetch_object($result)) {
87
+                $descriptions[$description->id] = $description;
88
+            }
89 89
             // Function that displays the details of the course description in html.
90
-		    echo CourseManager::get_details_course_description_html(
90
+            echo CourseManager::get_details_course_description_html(
91 91
                 $descriptions,
92 92
                 api_get_system_encoding(),
93 93
                 false
94 94
             );
95
-		} else {
96
-		    echo get_lang('NoDescription');
97
-		}
98
-	    break;
95
+        } else {
96
+            echo get_lang('NoDescription');
97
+        }
98
+        break;
99 99
     case 'session_courses_lp_default':
100 100
         /**
101 101
          * @todo this functions need to belong to a class or a special
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         $sidx  = isset($_REQUEST['sidx']) && !empty($_REQUEST['sidx']) ? $_REQUEST['sidx'] : 'id';
111 111
         $sord  = $_REQUEST['sord'];    //asc or desc
112 112
         if (!in_array($sord, array('asc','desc'))) {
113
-        	$sord = 'desc';
113
+            $sord = 'desc';
114 114
         }
115 115
         $session_id  = intval($_REQUEST['session_id']);
116 116
         $course_id   = intval($_REQUEST['course_id']);
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
                     $my_session_list[] = $item['id_session'];
125 125
             }
126 126
             if (!in_array($session_id, $my_session_list)) {
127
-            	break;
127
+                break;
128 128
             }
129 129
         }
130 130
 
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
                     $date = '-';
446 446
                 }
447 447
 
448
-                 //Checking LP publicated and expired_on dates
448
+                    //Checking LP publicated and expired_on dates
449 449
                 if (!empty($lp_item['publicated_on']) && $lp_item['publicated_on'] != '0000-00-00 00:00:00') {
450 450
                     if ($now < api_strtotime($lp_item['publicated_on'], 'UTC')) {
451 451
                         continue;
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 
500 500
         echo json_encode($response);
501 501
         break;
502
-	default:
503
-		echo '';
502
+    default:
503
+        echo '';
504 504
 }
505 505
 exit;
Please login to merge, or discard this patch.