Completed
Push — 1.11.x ( 4463da...cd5efc )
by José
55:32 queued 28:22
created
main/glossary/index.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@
 block discarded – undo
133 133
             if (!empty($glossary_data['update_date'])) {
134 134
                 $glossary_data['update_date'] = Display::dateToStringAgoAndLongDate($glossary_data['update_date']);
135 135
             } else {
136
-                 $glossary_data['update_date'] = '';
136
+                    $glossary_data['update_date'] = '';
137 137
             }
138 138
 
139 139
             $form->addLabel(get_lang('CreationDate'), $glossary_data['insert_date']);
Please login to merge, or discard this patch.
src/Chamilo/UserBundle/Repository/UserRepository.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,10 +26,10 @@
 block discarded – undo
26 26
 class UserRepository extends EntityRepository
27 27
 {
28 28
     /**
29
-    * @param string $keyword
29
+     * @param string $keyword
30 30
      *
31
-    * @return mixed
32
-    */
31
+     * @return mixed
32
+     */
33 33
     public function searchUserByKeyword($keyword)
34 34
     {
35 35
         $qb = $this->createQueryBuilder('a');
Please login to merge, or discard this patch.
src/Chamilo/UserBundle/Entity/User.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1891,11 +1891,11 @@  discard block
 block discarded – undo
1891 1891
         return $this->locale;
1892 1892
     }
1893 1893
 
1894
-     /**
1895
-     * @param string $timezone
1896
-     *
1897
-     * @return User
1898
-     */
1894
+        /**
1895
+         * @param string $timezone
1896
+         *
1897
+         * @return User
1898
+         */
1899 1899
     public function setTimezone($timezone)
1900 1900
     {
1901 1901
         $this->timezone = $timezone;
@@ -2073,11 +2073,11 @@  discard block
 block discarded – undo
2073 2073
         }
2074 2074
     }
2075 2075
 
2076
-      /**
2077
-     * Returns the user roles
2078
-     *
2079
-     * @return array The roles
2080
-     */
2076
+        /**
2077
+         * Returns the user roles
2078
+         *
2079
+         * @return array The roles
2080
+         */
2081 2081
     public function getRoles()
2082 2082
     {
2083 2083
         $roles = $this->roles;
Please login to merge, or discard this patch.
src/Chamilo/CourseBundle/Component/CourseCopy/CourseSelectForm.php 1 patch
Indentation   +238 added lines, -238 removed lines patch added patch discarded remove patch
@@ -17,13 +17,13 @@  discard block
 block discarded – undo
17 17
  */
18 18
 class CourseSelectForm
19 19
 {
20
-	/**
21
-	 * Display the form
20
+    /**
21
+     * Display the form
22 22
      * @param array $course
23
-	 * @param array $hidden_fields Hidden fields to add to the form.
24
-	 * @param boolean $avoid_serialize the document array will be serialize. This is used in the course_copy.php file
25
-	 */
26
-	public static function display_form($course, $hidden_fields = null, $avoid_serialize = false)
23
+     * @param array $hidden_fields Hidden fields to add to the form.
24
+     * @param boolean $avoid_serialize the document array will be serialize. This is used in the course_copy.php file
25
+     */
26
+    public static function display_form($course, $hidden_fields = null, $avoid_serialize = false)
27 27
     {
28 28
         global $charset;
29 29
         $resource_titles[RESOURCE_ASSET] = get_lang('Assets');
@@ -139,48 +139,48 @@  discard block
 block discarded – undo
139 139
             }
140 140
 		</script>
141 141
 		<?php
142
-		// get destination course title
143
-		if (!empty($hidden_fields['destination_course'])) {
142
+        // get destination course title
143
+        if (!empty($hidden_fields['destination_course'])) {
144 144
             $sessionTitle = !empty($hidden_fields['destination_session']) ? ' (' . api_get_session_name($hidden_fields['destination_session']) . ')' : null;
145 145
             $course_infos = CourseManager::get_course_information($hidden_fields['destination_course']);
146
-			echo '<h3>';
147
-			echo get_lang('DestinationCourse').' : '.$course_infos['title'] . ' ('.$course_infos['code'].') '.$sessionTitle;
148
-			echo '</h3>';
149
-		}
146
+            echo '<h3>';
147
+            echo get_lang('DestinationCourse').' : '.$course_infos['title'] . ' ('.$course_infos['code'].') '.$sessionTitle;
148
+            echo '</h3>';
149
+        }
150 150
         echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>';
151
-		echo '<script type="text/javascript">var myUpload = new upload(1000);</script>';
151
+        echo '<script type="text/javascript">var myUpload = new upload(1000);</script>';
152 152
         $icon = Display::returnIconPath('myprogress_bar.gif');
153 153
         echo '<div class="tool-backups-options">';
154
-		echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="javascript: myUpload.start(\'dynamic_div\',\''.$icon.',\''.get_lang('PleaseStandBy', '').'\',\'upload_form\')">';
155
-		echo '<input type="hidden" name="action" value="course_select_form"/>';
154
+        echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="javascript: myUpload.start(\'dynamic_div\',\''.$icon.',\''.get_lang('PleaseStandBy', '').'\',\'upload_form\')">';
155
+        echo '<input type="hidden" name="action" value="course_select_form"/>';
156 156
 
157
-		if (!empty($hidden_fields['destination_course']) &&
157
+        if (!empty($hidden_fields['destination_course']) &&
158 158
             !empty($hidden_fields['origin_course']) &&
159 159
             !empty($hidden_fields['destination_session']) &&
160 160
             !empty($hidden_fields['origin_session'])
161 161
         ) {
162
-			echo '<input type="hidden" name="destination_course" 	value="'.$hidden_fields['destination_course'].'"/>';
163
-			echo '<input type="hidden" name="origin_course" 		value="'.$hidden_fields['origin_course'].'"/>';
164
-			echo '<input type="hidden" name="destination_session" 	value="'.$hidden_fields['destination_session'].'"/>';
165
-			echo '<input type="hidden" name="origin_session" 		value="'.$hidden_fields['origin_session'].'"/>';
166
-		}
162
+            echo '<input type="hidden" name="destination_course" 	value="'.$hidden_fields['destination_course'].'"/>';
163
+            echo '<input type="hidden" name="origin_course" 		value="'.$hidden_fields['origin_course'].'"/>';
164
+            echo '<input type="hidden" name="destination_session" 	value="'.$hidden_fields['destination_session'].'"/>';
165
+            echo '<input type="hidden" name="origin_session" 		value="'.$hidden_fields['origin_session'].'"/>';
166
+        }
167 167
 
168
-		$element_count = 0;
168
+        $element_count = 0;
169 169
         $forum_categories = array();
170 170
         $forums = array();
171 171
         $forum_topics = array();
172 172
 
173 173
         echo '<p>';
174
-		echo get_lang('SelectResources');
175
-		echo '</p>';
174
+        echo get_lang('SelectResources');
175
+        echo '</p>';
176 176
 
177 177
         Display::display_normal_message(get_lang('DontForgetToSelectTheMediaFilesIfYourResourceNeedIt'));
178 178
 
179 179
         foreach ($course->resources as $type => $resources) {
180 180
             if (count($resources) > 0) {
181
-				switch ($type) {
182
-					//Resources to avoid
183
-					case RESOURCE_FORUMCATEGORY:
181
+                switch ($type) {
182
+                    //Resources to avoid
183
+                    case RESOURCE_FORUMCATEGORY:
184 184
                         foreach ($resources as $id => $resource) {
185 185
                             $forum_categories[$id] = $resource;
186 186
                         }
@@ -207,29 +207,29 @@  discard block
 block discarded – undo
207 207
                         break;
208 208
                     default:
209 209
                         echo '<div class="item-backup" onclick="javascript:exp('."'$type'".');">';
210
-						echo '<em id="img_'.$type.'" class="fa fa-minus-square-o fa-lg" ></em>';
211
-						echo '<span class="title">'.$resource_titles[$type].'</span></div>';
212
-						echo '<div class="item-content" id="div_'.$type.'">';
213
-						if ($type == RESOURCE_LEARNPATH) {
214
-    						Display::display_warning_message(get_lang('ToExportLearnpathWithQuizYouHaveToSelectQuiz'));
215
-    						Display::display_warning_message(get_lang('IfYourLPsHaveAudioFilesIncludedYouShouldSelectThemFromTheDocuments'));
216
-						}
217
-						if ($type == RESOURCE_DOCUMENT) {
210
+                        echo '<em id="img_'.$type.'" class="fa fa-minus-square-o fa-lg" ></em>';
211
+                        echo '<span class="title">'.$resource_titles[$type].'</span></div>';
212
+                        echo '<div class="item-content" id="div_'.$type.'">';
213
+                        if ($type == RESOURCE_LEARNPATH) {
214
+                            Display::display_warning_message(get_lang('ToExportLearnpathWithQuizYouHaveToSelectQuiz'));
215
+                            Display::display_warning_message(get_lang('IfYourLPsHaveAudioFilesIncludedYouShouldSelectThemFromTheDocuments'));
216
+                        }
217
+                        if ($type == RESOURCE_DOCUMENT) {
218 218
                             if (api_get_setting('show_glossary_in_documents') != 'none') {
219 219
                                 Display::display_warning_message(get_lang('ToExportDocumentsWithGlossaryYouHaveToSelectGlossary'));
220 220
                             }
221
-						}
221
+                        }
222 222
 
223
-						echo '<div class="well">';
223
+                        echo '<div class="well">';
224 224
                         echo '<div class="btn-group">';
225
-						echo "<a class=\"btn btn-default\" href=\"javascript: void(0);\" onclick=\"javascript: setCheckbox('$type',true);\" >".get_lang('All')."</a>";
225
+                        echo "<a class=\"btn btn-default\" href=\"javascript: void(0);\" onclick=\"javascript: setCheckbox('$type',true);\" >".get_lang('All')."</a>";
226 226
                         echo "<a class=\"btn btn-default\" href=\"javascript: void(0);\" onclick=\"javascript:setCheckbox('$type',false);\" >".get_lang('None')."</a>";
227
-						echo '</div>';
227
+                        echo '</div>';
228 228
                         echo '<ul class="list-backups-options">';
229
-						foreach ($resources as $id => $resource) {
229
+                        foreach ($resources as $id => $resource) {
230 230
                             if ($resource) {
231 231
                                 echo '<li>';
232
-								// Event obj in 1.9.x in 1.10.x the class is CalendarEvent
232
+                                // Event obj in 1.9.x in 1.10.x the class is CalendarEvent
233 233
                                 Resource::setClassType($resource);
234 234
                                 echo '<label class="checkbox">';
235 235
                                 echo '<input type="checkbox" name="resource['.$type.']['.$id.']"  id="resource['.$type.']['.$id.']" />';
@@ -237,15 +237,15 @@  discard block
 block discarded – undo
237 237
                                 echo '</label>';
238 238
                                 echo '</li>';
239 239
                             }
240
-						}
240
+                        }
241 241
                         echo '</ul>';
242
-						echo '</div>';
243
-						echo '</div>';
244
-						echo '<script language="javascript">exp('."'$type'".')</script>';
245
-						$element_count++;
242
+                        echo '</div>';
243
+                        echo '</div>';
244
+                        echo '<script language="javascript">exp('."'$type'".')</script>';
245
+                        $element_count++;
246 246
                 }
247
-			}
248
-		}
247
+            }
248
+        }
249 249
 
250 250
         //Fixes forum order
251 251
         if (!empty($forum_categories)) {
@@ -301,66 +301,66 @@  discard block
 block discarded – undo
301 301
             echo '<script language="javascript">exp('."'$type'".')</script>';
302 302
         }
303 303
 
304
-		if ($avoid_serialize) {
305
-			/*Documents are avoided due the huge amount of memory that the serialize php function "eats"
304
+        if ($avoid_serialize) {
305
+            /*Documents are avoided due the huge amount of memory that the serialize php function "eats"
306 306
 			(when there are directories with hundred/thousand of files) */
307
-			// this is a known issue of serialize
308
-			$course->resources['document']= null;
309
-		}
307
+            // this is a known issue of serialize
308
+            $course->resources['document']= null;
309
+        }
310 310
 
311
-		echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>';
311
+        echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>';
312 312
 
313
-		if (is_array($hidden_fields)) {
314
-			foreach ($hidden_fields as $key => $value) {
315
-				echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>';
316
-			}
317
-		}
313
+        if (is_array($hidden_fields)) {
314
+            foreach ($hidden_fields as $key => $value) {
315
+                echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>';
316
+            }
317
+        }
318 318
 
319 319
         $recycleOption = isset($_POST['recycle_option']) ? true : false;
320 320
 
321
-		if (empty($element_count)) {
322
-		    Display::display_warning_message(get_lang('NoDataAvailable'));
323
-		} else {
324
-    		if (!empty($hidden_fields['destination_session'])) {
325
-    			echo '<br /><button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES, $charset))."'".')) return false;" >'.
321
+        if (empty($element_count)) {
322
+            Display::display_warning_message(get_lang('NoDataAvailable'));
323
+        } else {
324
+            if (!empty($hidden_fields['destination_session'])) {
325
+                echo '<br /><button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES, $charset))."'".')) return false;" >'.
326 326
                     get_lang('Ok').'</button>';
327
-    		} else {
327
+            } else {
328 328
                 if ($recycleOption) {
329 329
                     echo '<br /><button class="save" type="submit">'.
330 330
                         get_lang('Ok').'</button>';
331 331
                 } else {
332
-    			    echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.
332
+                    echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.
333 333
                     get_lang('Ok').'</button>';
334 334
                 }
335
-    		}
336
-		}
335
+            }
336
+        }
337 337
 
338
-		CourseSelectForm::display_hidden_quiz_questions($course);
339
-		CourseSelectForm::display_hidden_scorm_directories($course);
340
-		echo '</form>';
338
+        CourseSelectForm::display_hidden_quiz_questions($course);
339
+        CourseSelectForm::display_hidden_scorm_directories($course);
340
+        echo '</form>';
341 341
         echo '</div>';
342
-		echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>';
343
-	}
342
+        echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>';
343
+    }
344 344
 
345 345
     /**
346 346
      * @param $course
347 347
      */
348 348
     public static function display_hidden_quiz_questions($course)
349 349
     {
350
-		if(is_array($course->resources)){
351
-			foreach ($course->resources as $type => $resources) {
352
-				if (count($resources) > 0) {
353
-					switch ($type) {
354
-						case RESOURCE_QUIZQUESTION:
355
-							foreach ($resources as $id => $resource) {
356
-								echo '<input type="hidden" name="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" id="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" value="On" />';
357
-							}
358
-							break;
359
-					}
360
-				}
361
-			}
362
-		}
363
-	}
350
+        if(is_array($course->resources)){
351
+            foreach ($course->resources as $type => $resources) {
352
+                if (count($resources) > 0) {
353
+                    switch ($type) {
354
+                        case RESOURCE_QUIZQUESTION:
355
+                            foreach ($resources as $id => $resource) {
356
+                                echo '<input type="hidden" name="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" id="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" value="On" />';
357
+                            }
358
+                            break;
359
+                    }
360
+                }
361
+            }
362
+        }
363
+    }
364 364
 
365 365
     /**
366 366
      * @param $course
@@ -368,30 +368,30 @@  discard block
 block discarded – undo
368 368
     public static function display_hidden_scorm_directories($course)
369 369
     {
370 370
         if (is_array($course->resources)){
371
-			foreach ($course->resources as $type => $resources) {
372
-				if (count($resources) > 0) {
373
-					switch($type) {
374
-						case RESOURCE_SCORM:
375
-							foreach ($resources as $id => $resource) {
376
-								echo '<input type="hidden" name="resource['.RESOURCE_SCORM.']['.$id.']" id="resource['.RESOURCE_SCORM.']['.$id.']" value="On" />';
377
-							}
378
-							break;
379
-					}
380
-				}
381
-			}
382
-		}
383
-	}
371
+            foreach ($course->resources as $type => $resources) {
372
+                if (count($resources) > 0) {
373
+                    switch($type) {
374
+                        case RESOURCE_SCORM:
375
+                            foreach ($resources as $id => $resource) {
376
+                                echo '<input type="hidden" name="resource['.RESOURCE_SCORM.']['.$id.']" id="resource['.RESOURCE_SCORM.']['.$id.']" value="On" />';
377
+                            }
378
+                            break;
379
+                    }
380
+                }
381
+            }
382
+        }
383
+    }
384 384
 
385
-	/**
386
-	 * Get the posted course
387
-	 * @param string $from who calls the function?
385
+    /**
386
+     * Get the posted course
387
+     * @param string $from who calls the function?
388 388
      * It can be copy_course, create_backup, import_backup or recycle_course
389 389
      * @param int $session_id
390 390
      * @param string $course_code
391
-	 * @return course The course-object with all resources selected by the user
392
-	 * in the form given by display_form(...)
393
-	 */
394
-	public static function get_posted_course($from = '', $session_id = 0, $course_code = '')
391
+     * @return course The course-object with all resources selected by the user
392
+     * in the form given by display_form(...)
393
+     */
394
+    public static function get_posted_course($from = '', $session_id = 0, $course_code = '')
395 395
     {
396 396
         $course = null;
397 397
 
@@ -401,30 +401,30 @@  discard block
 block discarded – undo
401 401
             return false;
402 402
         }
403 403
 
404
-		// Create the resource DOCUMENT objects
405
-		// Loading the results from the checkboxes of ethe javascript
406
-		$resource = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null;
404
+        // Create the resource DOCUMENT objects
405
+        // Loading the results from the checkboxes of ethe javascript
406
+        $resource = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null;
407 407
 
408
-		$course_info = api_get_course_info($course_code);
409
-		$table_doc = Database::get_course_table(TABLE_DOCUMENT);
410
-		$table_prop = Database::get_course_table(TABLE_ITEM_PROPERTY);
411
-		$course_id = $course_info['real_id'];
408
+        $course_info = api_get_course_info($course_code);
409
+        $table_doc = Database::get_course_table(TABLE_DOCUMENT);
410
+        $table_prop = Database::get_course_table(TABLE_ITEM_PROPERTY);
411
+        $course_id = $course_info['real_id'];
412 412
 
413
-		/* Searching the documents resource that have been set to null because
413
+        /* Searching the documents resource that have been set to null because
414 414
         $avoid_serialize is true in the display_form() function*/
415
-		if ($from === 'copy_course') {
416
-			if (is_array($resource)) {
417
-				$resource = array_keys($resource);
415
+        if ($from === 'copy_course') {
416
+            if (is_array($resource)) {
417
+                $resource = array_keys($resource);
418 418
 
419
-				foreach	($resource as $resource_item) {
419
+                foreach	($resource as $resource_item) {
420 420
 
421
-					$condition_session = '';
422
-					if (!empty($session_id)) {
423
-						$session_id = intval($session_id);
424
-						$condition_session = ' AND d.session_id ='.$session_id;
425
-					}
421
+                    $condition_session = '';
422
+                    if (!empty($session_id)) {
423
+                        $session_id = intval($session_id);
424
+                        $condition_session = ' AND d.session_id ='.$session_id;
425
+                    }
426 426
 
427
-					$sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size
427
+                    $sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size
428 428
 							FROM '.$table_doc.' d, '.$table_prop.' p
429 429
 							WHERE
430 430
 							    d.c_id = '.$course_id.' AND
@@ -433,8 +433,8 @@  discard block
 block discarded – undo
433 433
                                 p.ref = d.id AND p.visibility != 2 AND
434 434
                                 d.id = '.$resource_item.$condition_session.'
435 435
 							ORDER BY path';
436
-					$db_result = Database::query($sql);
437
-					while ($obj = Database::fetch_object($db_result)) {
436
+                    $db_result = Database::query($sql);
437
+                    while ($obj = Database::fetch_object($db_result)) {
438 438
                         $doc = new Document(
439 439
                             $obj->id,
440 440
                             $obj->path,
@@ -458,25 +458,25 @@  discard block
 block discarded – undo
458 458
                             }
459 459
                             $course->resources[RESOURCE_DOCUMENT][$resource_item]->item_properties = $all_properties;
460 460
                         }
461
-					}
462
-				}
463
-			}
464
-		}
461
+                    }
462
+                }
463
+            }
464
+        }
465 465
 
466
-		if (is_array($course->resources)) {
467
-			foreach ($course->resources as $type => $resources) {
466
+        if (is_array($course->resources)) {
467
+            foreach ($course->resources as $type => $resources) {
468 468
 
469
-				switch ($type) {
470
-					case RESOURCE_SURVEYQUESTION:
471
-						foreach($resources as $id => $obj) {
472
-						    if (isset($_POST['resource'][RESOURCE_SURVEY]) &&
469
+                switch ($type) {
470
+                    case RESOURCE_SURVEYQUESTION:
471
+                        foreach($resources as $id => $obj) {
472
+                            if (isset($_POST['resource'][RESOURCE_SURVEY]) &&
473 473
                                 is_array($_POST['resource'][RESOURCE_SURVEY]) &&
474 474
                                 !in_array($obj->survey_id, array_keys($_POST['resource'][RESOURCE_SURVEY]))
475 475
                             ) {
476
-								unset($course->resources[$type][$id]);
477
-							}
478
-						}
479
-						break;
476
+                                unset($course->resources[$type][$id]);
477
+                            }
478
+                        }
479
+                        break;
480 480
                     case RESOURCE_FORUMTOPIC:
481 481
                     case RESOURCE_FORUMPOST:
482 482
                        //Add post from topic
@@ -528,21 +528,21 @@  discard block
 block discarded – undo
528 528
                                 }
529 529
                             }
530 530
                         }
531
-					case RESOURCE_LINKCATEGORY:
532
-					case RESOURCE_FORUMCATEGORY:
533
-					case RESOURCE_QUIZQUESTION:
534
-					case RESOURCE_DOCUMENT:
535
-						// Mark folders to import which are not selected by the user to import,
536
-						// but in which a document was selected.
537
-						$documents = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null;
538
-						if (!empty($resources) && is_array($resources))
539
-							foreach ($resources as $id => $obj) {
540
-								if (isset($obj->file_type) && $obj->file_type == 'folder' &&
531
+                    case RESOURCE_LINKCATEGORY:
532
+                    case RESOURCE_FORUMCATEGORY:
533
+                    case RESOURCE_QUIZQUESTION:
534
+                    case RESOURCE_DOCUMENT:
535
+                        // Mark folders to import which are not selected by the user to import,
536
+                        // but in which a document was selected.
537
+                        $documents = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null;
538
+                        if (!empty($resources) && is_array($resources))
539
+                            foreach ($resources as $id => $obj) {
540
+                                if (isset($obj->file_type) && $obj->file_type == 'folder' &&
541 541
                                     !isset($_POST['resource'][RESOURCE_DOCUMENT][$id]) &&
542 542
                                     is_array($documents)
543 543
                                 ) {
544
-									foreach ($documents as $id_to_check => $post_value) {
545
-									    if (isset($resources[$id_to_check])) {
544
+                                    foreach ($documents as $id_to_check => $post_value) {
545
+                                        if (isset($resources[$id_to_check])) {
546 546
                                             $obj_to_check = $resources[$id_to_check];
547 547
                                             $shared_path_part = substr(
548 548
                                                 $obj_to_check->path,
@@ -554,43 +554,43 @@  discard block
 block discarded – undo
554 554
                                                 break;
555 555
                                             }
556 556
                                         }
557
-									}
558
-								}
559
-							}
560
-					default :
561
-						if (!empty($resources) && is_array($resources)) {
562
-							foreach ($resources as $id => $obj) {
563
-								$resource_is_used_elsewhere = $course->is_linked_resource($obj);
564
-								// check if document is in a quiz (audio/video)
565
-								if ($type == RESOURCE_DOCUMENT && $course->has_resources(RESOURCE_QUIZ)) {
566
-									foreach($course->resources[RESOURCE_QUIZ] as $quiz) {
557
+                                    }
558
+                                }
559
+                            }
560
+                    default :
561
+                        if (!empty($resources) && is_array($resources)) {
562
+                            foreach ($resources as $id => $obj) {
563
+                                $resource_is_used_elsewhere = $course->is_linked_resource($obj);
564
+                                // check if document is in a quiz (audio/video)
565
+                                if ($type == RESOURCE_DOCUMENT && $course->has_resources(RESOURCE_QUIZ)) {
566
+                                    foreach($course->resources[RESOURCE_QUIZ] as $quiz) {
567 567
                                         $quiz = $quiz->obj;
568
-										if (isset($quiz->media) && $quiz->media == $id) {
569
-											$resource_is_used_elsewhere = true;
570
-										}
571
-									}
572
-								}
573
-								if (!isset($_POST['resource'][$type][$id]) && !$resource_is_used_elsewhere) {
574
-									unset($course->resources[$type][$id]);
575
-								}
576
-							}
577
-						}
578
-				}
579
-			}
580
-		}
568
+                                        if (isset($quiz->media) && $quiz->media == $id) {
569
+                                            $resource_is_used_elsewhere = true;
570
+                                        }
571
+                                    }
572
+                                }
573
+                                if (!isset($_POST['resource'][$type][$id]) && !$resource_is_used_elsewhere) {
574
+                                    unset($course->resources[$type][$id]);
575
+                                }
576
+                            }
577
+                        }
578
+                }
579
+            }
580
+        }
581 581
 
582
-		return $course;
583
-	}
582
+        return $course;
583
+    }
584 584
 
585
-	/**
586
-	 * Display the form session export
585
+    /**
586
+     * Display the form session export
587 587
      * @param array $list_course
588
-	 * @param array $hidden_fields Hidden fields to add to the form.
588
+     * @param array $hidden_fields Hidden fields to add to the form.
589 589
      * @param boolean $avoid_serialize the document array will be serialize. This is used in the course_copy.php file
590
-	 */
591
-	 public static function display_form_session_export($list_course, $hidden_fields = null, $avoid_serialize = false)
592
-     {
593
-         ?>
590
+     */
591
+        public static function display_form_session_export($list_course, $hidden_fields = null, $avoid_serialize = false)
592
+        {
593
+            ?>
594 594
 		<script>
595 595
 			function exp(item) {
596 596
 				el = document.getElementById('div_'+item);
@@ -632,68 +632,68 @@  discard block
 block discarded – undo
632 632
 		</script>
633 633
 		<?php
634 634
 
635
-		//get destination course title
636
-		if(!empty($hidden_fields['destination_course'])) {
637
-             if (!empty($hidden_fields['destination_session'])) {
638
-                 $sessionTitle = ' (' . api_get_session_name($hidden_fields['destination_session']) . ')';
639
-             } else {
640
-                 $sessionTitle = null;
641
-             }
635
+        //get destination course title
636
+        if(!empty($hidden_fields['destination_course'])) {
637
+                if (!empty($hidden_fields['destination_session'])) {
638
+                    $sessionTitle = ' (' . api_get_session_name($hidden_fields['destination_session']) . ')';
639
+                } else {
640
+                    $sessionTitle = null;
641
+                }
642 642
             $course_infos = CourseManager::get_course_information($hidden_fields['destination_course']);
643
-			echo '<h3>';
644
-				echo get_lang('DestinationCourse') . ' : ' . $course_infos['title'] . $sessionTitle;
645
-			echo '</h3>';
646
-		}
643
+            echo '<h3>';
644
+                echo get_lang('DestinationCourse') . ' : ' . $course_infos['title'] . $sessionTitle;
645
+            echo '</h3>';
646
+        }
647 647
 
648
-		echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>';
649
-		echo '<script type="text/javascript">var myUpload = new upload(1000);</script>';
648
+        echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>';
649
+        echo '<script type="text/javascript">var myUpload = new upload(1000);</script>';
650 650
         $icon = Display::returnIconPath('progress_bar.gif');
651 651
         echo '<div class="tool-backups-options">';
652
-		echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="myUpload.start(\'dynamic_div\',\''.$icon.'\',\''.get_lang('PleaseStandBy').'\',\'upload_form\')">';
653
-		echo '<input type="hidden" name="action" value="course_select_form"/>';
654
-		foreach ($list_course as $course) {
655
-			foreach ($course->resources as $type => $resources) {
656
-				if (count($resources) > 0) {
652
+        echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="myUpload.start(\'dynamic_div\',\''.$icon.'\',\''.get_lang('PleaseStandBy').'\',\'upload_form\')">';
653
+        echo '<input type="hidden" name="action" value="course_select_form"/>';
654
+        foreach ($list_course as $course) {
655
+            foreach ($course->resources as $type => $resources) {
656
+                if (count($resources) > 0) {
657 657
                     echo '<div class="item-backup" onclick="javascript:exp('."'$course->code'".');">';
658
-					echo '<em id="img_'.$course->code.'" class="fa fa-minus-square-o fa-lg"></em>';
659
-					echo '<span class="title"> '.$course->code.'</span></div>';
660
-					echo '<div class="item-content" id="div_'.$course->code.'">';
661
-					echo '<blockquote>';
658
+                    echo '<em id="img_'.$course->code.'" class="fa fa-minus-square-o fa-lg"></em>';
659
+                    echo '<span class="title"> '.$course->code.'</span></div>';
660
+                    echo '<div class="item-content" id="div_'.$course->code.'">';
661
+                    echo '<blockquote>';
662 662
 
663 663
                     echo '<div class="btn-group">';
664
-					echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',true);\" >".get_lang('All')."</a>";
664
+                    echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',true);\" >".get_lang('All')."</a>";
665 665
                     echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',false);\" >".get_lang('None')."</a>";
666
-					echo '</div>';
666
+                    echo '</div>';
667 667
 
668
-					foreach ($resources as $id => $resource) {
669
-						echo '<label class="checkbox" for="resource['.$course->code.']['.$id.']">';
668
+                    foreach ($resources as $id => $resource) {
669
+                        echo '<label class="checkbox" for="resource['.$course->code.']['.$id.']">';
670 670
                         echo '<input type="checkbox" name="resource['.$course->code.']['.$id.']" id="resource['.$course->code.']['.$id.']"/>';
671
-						$resource->show();
672
-						echo '</label>';
673
-					}
674
-					echo '</blockquote>';
675
-					echo '</div>';
676
-					echo '<script type="text/javascript">exp('."'$course->code'".')</script>';
677
-				}
678
-			}
679
-		}
680
-		if ($avoid_serialize) {
681
-			//Documents are avoided due the huge amount of memory that the serialize php function "eats" (when there are directories with hundred/thousand of files)
682
-			// this is a known issue of serialize
683
-			$course->resources['document']= null;
684
-		}
685
-		echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>';
686
-		if (is_array($hidden_fields)) {
687
-			foreach ($hidden_fields as $key => $value) {
688
-				echo "\n";
689
-				echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>';
690
-			}
691
-		}
692
-		echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.get_lang('Ok').'</button>';
693
-		CourseSelectForm :: display_hidden_quiz_questions($course);
694
-		CourseSelectForm :: display_hidden_scorm_directories($course);
695
-		echo '</form>';
671
+                        $resource->show();
672
+                        echo '</label>';
673
+                    }
674
+                    echo '</blockquote>';
675
+                    echo '</div>';
676
+                    echo '<script type="text/javascript">exp('."'$course->code'".')</script>';
677
+                }
678
+            }
679
+        }
680
+        if ($avoid_serialize) {
681
+            //Documents are avoided due the huge amount of memory that the serialize php function "eats" (when there are directories with hundred/thousand of files)
682
+            // this is a known issue of serialize
683
+            $course->resources['document']= null;
684
+        }
685
+        echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>';
686
+        if (is_array($hidden_fields)) {
687
+            foreach ($hidden_fields as $key => $value) {
688
+                echo "\n";
689
+                echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>';
690
+            }
691
+        }
692
+        echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.get_lang('Ok').'</button>';
693
+        CourseSelectForm :: display_hidden_quiz_questions($course);
694
+        CourseSelectForm :: display_hidden_scorm_directories($course);
695
+        echo '</form>';
696 696
         echo '</div>';
697
-		echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>';
698
-	}
697
+        echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>';
698
+    }
699 699
 }
Please login to merge, or discard this patch.
src/Chamilo/CourseBundle/Component/CourseCopy/CourseRestorer.php 1 patch
Indentation   +576 added lines, -576 removed lines patch added patch discarded remove patch
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
 class CourseRestorer
25 25
 {
26 26
     /**
27
-    * The course-object
28
-    */
27
+     * The course-object
28
+     */
29 29
     public $course;
30 30
     public $destination_course_info;
31 31
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
         'events',
45 45
         'forum_category',
46 46
         'forums',
47
-       // 'forum_topics',
47
+        // 'forum_topics',
48 48
         'glossary',
49 49
         'quizzes',
50 50
         'test_category',
@@ -113,15 +113,15 @@  discard block
 block discarded – undo
113 113
         $this->tool_copy_settings = $array;
114 114
     }
115 115
 
116
-	/**
117
-	 * Restore a course.
116
+    /**
117
+     * Restore a course.
118 118
      *
119
-	 * @param string    $destination_course_code code of the Chamilo-course in
120
-	 * @param int	    $session_id
121
-	 * @param bool	    $update_course_settings Course settings are going to be restore?
119
+     * @param string    $destination_course_code code of the Chamilo-course in
120
+     * @param int	    $session_id
121
+     * @param bool	    $update_course_settings Course settings are going to be restore?
122 122
      * @param bool      $respect_base_content
123 123
      * @return false|null
124
-	 */
124
+     */
125 125
     public function restore(
126 126
         $destination_course_code = '',
127 127
         $session_id = 0,
@@ -237,17 +237,17 @@  discard block
 block discarded – undo
237 237
         }
238 238
     }
239 239
 
240
-	/**
241
-	 * Restore only harmless course settings:
240
+    /**
241
+     * Restore only harmless course settings:
242 242
      * course_language, visibility, department_name,department_url,
243 243
      * subscribe, unsubscribe ,category_code
244
-	 *
245
-	 * @param string $destination_course_code
246
-	 */
244
+     *
245
+     * @param string $destination_course_code
246
+     */
247 247
     public function restore_course_settings($destination_course_code)
248 248
     {
249
-	    $origin_course_info = api_get_course_info($destination_course_code);
250
-	    $course_info = $this->course->info;
249
+        $origin_course_info = api_get_course_info($destination_course_code);
250
+        $course_info = $this->course->info;
251 251
         $params['course_language'] = $course_info['language'];
252 252
         $params['visibility'] = $course_info['visibility'];
253 253
         $params['department_name'] = $course_info['department_name'];
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
         $params['subscribe'] = $course_info['subscribe_allowed'];
258 258
         $params['unsubscribe'] = $course_info['unsubscribe'];
259 259
         CourseManager::update_attributes($origin_course_info['real_id'], $params);
260
-	}
260
+    }
261 261
 
262 262
     /**
263 263
      * Restore documents
@@ -923,56 +923,56 @@  discard block
 block discarded – undo
923 923
         unset($_SESSION['new_base_foldername']);
924 924
         unset($_SESSION['orig_base_foldername']);
925 925
         unset($_SESSION['new_base_path']);
926
-	}
926
+    }
927 927
 
928
-	/**
929
-	 * Restore scorm documents
930
-	 * TODO @TODO check that the restore function with renaming doesn't break the scorm structure!
928
+    /**
929
+     * Restore scorm documents
930
+     * TODO @TODO check that the restore function with renaming doesn't break the scorm structure!
931 931
      * see #7029
932
-	 */
933
-	public function restore_scorm_documents()
932
+     */
933
+    public function restore_scorm_documents()
934 934
     {
935
-		$perm = api_get_permissions_for_new_directories();
935
+        $perm = api_get_permissions_for_new_directories();
936 936
 
937
-		if ($this->course->has_resources(RESOURCE_SCORM)) {
938
-			$resources = $this->course->resources;
937
+        if ($this->course->has_resources(RESOURCE_SCORM)) {
938
+            $resources = $this->course->resources;
939 939
 
940
-			foreach ($resources[RESOURCE_SCORM] as $document) {
941
-				$path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/';
942
-				@mkdir(dirname($path.$document->path), $perm, true);
940
+            foreach ($resources[RESOURCE_SCORM] as $document) {
941
+                $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/';
942
+                @mkdir(dirname($path.$document->path), $perm, true);
943 943
 
944
-				if (file_exists($path.$document->path)) {
945
-					switch ($this->file_option) {
946
-						case FILE_OVERWRITE:
947
-							rmdirr($path.$document->path);
944
+                if (file_exists($path.$document->path)) {
945
+                    switch ($this->file_option) {
946
+                        case FILE_OVERWRITE:
947
+                            rmdirr($path.$document->path);
948 948
                             copyDirTo(
949 949
                                 $this->course->backup_path . '/' . $document->path,
950 950
                                 $path . dirname($document->path),
951 951
                                 false
952 952
                             );
953
-							break;
954
-						case FILE_SKIP:
955
-							break;
953
+                            break;
954
+                        case FILE_SKIP:
955
+                            break;
956 956
                         case FILE_RENAME:
957
-							$i = 1;
958
-							$ext = explode('.', basename($document->path));
959
-							if (count($ext) > 1) {
960
-								$ext = array_pop($ext);
961
-								$file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1));
962
-								$ext = '.'.$ext;
963
-							} else {
964
-								$ext = '';
965
-								$file_name_no_ext = $document->path;
966
-							}
967
-
968
-							$new_file_name = $file_name_no_ext.'_'.$i.$ext;
969
-							$file_exists = file_exists($path.$new_file_name);
970
-
971
-							while ($file_exists) {
972
-								$i ++;
973
-								$new_file_name = $file_name_no_ext.'_'.$i.$ext;
974
-								$file_exists = file_exists($path.$new_file_name);
975
-							}
957
+                            $i = 1;
958
+                            $ext = explode('.', basename($document->path));
959
+                            if (count($ext) > 1) {
960
+                                $ext = array_pop($ext);
961
+                                $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1));
962
+                                $ext = '.'.$ext;
963
+                            } else {
964
+                                $ext = '';
965
+                                $file_name_no_ext = $document->path;
966
+                            }
967
+
968
+                            $new_file_name = $file_name_no_ext.'_'.$i.$ext;
969
+                            $file_exists = file_exists($path.$new_file_name);
970
+
971
+                            while ($file_exists) {
972
+                                $i ++;
973
+                                $new_file_name = $file_name_no_ext.'_'.$i.$ext;
974
+                                $file_exists = file_exists($path.$new_file_name);
975
+                            }
976 976
 
977 977
                             rename(
978 978
                                 $this->course->backup_path . '/' . $document->path,
@@ -988,32 +988,32 @@  discard block
 block discarded – undo
988 988
                                 $this->course->backup_path . '/' . $document->path
989 989
                             );
990 990
 
991
-							break;
992
-					} // end switch
993
-				} else {
991
+                            break;
992
+                    } // end switch
993
+                } else {
994 994
                     // end if file exists
995 995
                     copyDirTo(
996 996
                         $this->course->backup_path . '/' . $document->path,
997 997
                         $path . dirname($document->path),
998 998
                         false
999 999
                     );
1000
-				}
1001
-			} // end for each
1002
-		}
1003
-	}
1000
+                }
1001
+            } // end for each
1002
+        }
1003
+    }
1004 1004
 
1005
-	/**
1006
-	 * Restore forums
1005
+    /**
1006
+     * Restore forums
1007 1007
      *
1008 1008
      * @param int $sessionId
1009 1009
      */
1010
-	public function restore_forums($sessionId = 0)
1010
+    public function restore_forums($sessionId = 0)
1011 1011
     {
1012
-		if ($this->course->has_resources(RESOURCE_FORUM)) {
1012
+        if ($this->course->has_resources(RESOURCE_FORUM)) {
1013 1013
             $sessionId = intval($sessionId);
1014
-			$table_forum = Database::get_course_table(TABLE_FORUM);
1015
-			$resources = $this->course->resources;
1016
-			foreach ($resources[RESOURCE_FORUM] as $id => $forum) {
1014
+            $table_forum = Database::get_course_table(TABLE_FORUM);
1015
+            $resources = $this->course->resources;
1016
+            foreach ($resources[RESOURCE_FORUM] as $id => $forum) {
1017 1017
                 $params = (array)$forum->obj;
1018 1018
                 $cat_id = '';
1019 1019
                 if (isset($this->course->resources[RESOURCE_FORUMCATEGORY]) &&
@@ -1060,33 +1060,33 @@  discard block
 block discarded – undo
1060 1060
                     Database::query($sql);
1061 1061
                 }
1062 1062
 
1063
-				$this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id;
1064
-
1065
-				$forum_topics = 0;
1066
-				if (is_array($this->course->resources[RESOURCE_FORUMTOPIC])) {
1067
-					foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) {
1068
-						if ($topic->obj->forum_id == $id) {
1069
-							$this->restore_topic($topic_id, $new_id, $sessionId);
1070
-							$forum_topics ++;
1071
-						}
1072
-					}
1073
-				}
1074
-				if ($forum_topics > 0) {
1075
-					$sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics."
1063
+                $this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id;
1064
+
1065
+                $forum_topics = 0;
1066
+                if (is_array($this->course->resources[RESOURCE_FORUMTOPIC])) {
1067
+                    foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) {
1068
+                        if ($topic->obj->forum_id == $id) {
1069
+                            $this->restore_topic($topic_id, $new_id, $sessionId);
1070
+                            $forum_topics ++;
1071
+                        }
1072
+                    }
1073
+                }
1074
+                if ($forum_topics > 0) {
1075
+                    $sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics."
1076 1076
                             WHERE c_id = {$this->destination_course_id} AND forum_id = ".(int)$new_id;
1077
-					Database::query($sql);
1078
-				}
1079
-			}
1080
-		}
1081
-	}
1082
-
1083
-	/**
1084
-	 * Restore forum-categories
1085
-	 */
1077
+                    Database::query($sql);
1078
+                }
1079
+            }
1080
+        }
1081
+    }
1082
+
1083
+    /**
1084
+     * Restore forum-categories
1085
+     */
1086 1086
     public function restore_forum_category($my_id = null, $sessionId = 0)
1087 1087
     {
1088
-		$forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY);
1089
-		$resources = $this->course->resources;
1088
+        $forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY);
1089
+        $resources = $this->course->resources;
1090 1090
         if (!empty($resources[RESOURCE_FORUMCATEGORY])) {
1091 1091
             foreach ($resources[RESOURCE_FORUMCATEGORY] as $id => $forum_cat) {
1092 1092
                 if (!empty($my_id)) {
@@ -1124,16 +1124,16 @@  discard block
 block discarded – undo
1124 1124
                 }
1125 1125
             }
1126 1126
         }
1127
-	}
1127
+    }
1128 1128
 
1129
-	/**
1130
-	 * Restore a forum-topic
1131
-	 * @param false|string $forum_id
1132
-	 */
1129
+    /**
1130
+     * Restore a forum-topic
1131
+     * @param false|string $forum_id
1132
+     */
1133 1133
     public function restore_topic($thread_id, $forum_id, $sessionId = 0)
1134 1134
     {
1135
-		$table = Database :: get_course_table(TABLE_FORUM_THREAD);
1136
-		$topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id];
1135
+        $table = Database :: get_course_table(TABLE_FORUM_THREAD);
1136
+        $topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id];
1137 1137
 
1138 1138
         $params = (array)$topic->obj;
1139 1139
         $params = self::DBUTF8_array($params);
@@ -1170,27 +1170,27 @@  discard block
 block discarded – undo
1170 1170
             $sessionId
1171 1171
         );
1172 1172
 
1173
-		$this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id;
1174
-		$topic_replies = -1;
1175
-
1176
-		foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) {
1177
-			if ($post->obj->thread_id == $thread_id) {
1178
-				$topic_replies++;
1179
-				$this->restore_post($post_id, $new_id, $forum_id, $sessionId);
1180
-			}
1181
-		}
1182
-		return $new_id;
1183
-	}
1184
-
1185
-	/**
1186
-	 * Restore a forum-post
1187
-	 * @TODO Restore tree-structure of posts. For example: attachments to posts.
1188
-	 * @param false|string $topic_id
1189
-	 */
1173
+        $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id;
1174
+        $topic_replies = -1;
1175
+
1176
+        foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) {
1177
+            if ($post->obj->thread_id == $thread_id) {
1178
+                $topic_replies++;
1179
+                $this->restore_post($post_id, $new_id, $forum_id, $sessionId);
1180
+            }
1181
+        }
1182
+        return $new_id;
1183
+    }
1184
+
1185
+    /**
1186
+     * Restore a forum-post
1187
+     * @TODO Restore tree-structure of posts. For example: attachments to posts.
1188
+     * @param false|string $topic_id
1189
+     */
1190 1190
     public function restore_post($id, $topic_id, $forum_id, $sessionId = 0)
1191 1191
     {
1192
-		$table_post = Database :: get_course_table(TABLE_FORUM_POST);
1193
-		$post = $this->course->resources[RESOURCE_FORUMPOST][$id];
1192
+        $table_post = Database :: get_course_table(TABLE_FORUM_POST);
1193
+        $post = $this->course->resources[RESOURCE_FORUMPOST][$id];
1194 1194
         $params = (array) $post->obj;
1195 1195
         $params['c_id'] = $this->destination_course_id;
1196 1196
         $params['forum_id'] = $forum_id;
@@ -1226,37 +1226,37 @@  discard block
 block discarded – undo
1226 1226
             null,
1227 1227
             $sessionId
1228 1228
         );
1229
-		$this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id;
1229
+        $this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id;
1230 1230
 
1231
-		return $new_id;
1232
-	}
1231
+        return $new_id;
1232
+    }
1233 1233
 
1234
-	/**
1235
-	 * Restore links
1236
-	 */
1234
+    /**
1235
+     * Restore links
1236
+     */
1237 1237
     public function restore_links($session_id = 0)
1238 1238
     {
1239
-		if ($this->course->has_resources(RESOURCE_LINK)) {
1240
-			$link_table = Database :: get_course_table(TABLE_LINK);
1241
-			$resources = $this->course->resources;
1239
+        if ($this->course->has_resources(RESOURCE_LINK)) {
1240
+            $link_table = Database :: get_course_table(TABLE_LINK);
1241
+            $resources = $this->course->resources;
1242 1242
 
1243
-			foreach ($resources[RESOURCE_LINK] as $id => $link) {
1243
+            foreach ($resources[RESOURCE_LINK] as $id => $link) {
1244 1244
                 $cat_id = $this->restore_link_category(
1245 1245
                     $link->category_id,
1246 1246
                     $session_id
1247 1247
                 );
1248
-				$sql = "SELECT MAX(display_order)
1248
+                $sql = "SELECT MAX(display_order)
1249 1249
 				        FROM $link_table
1250 1250
 				        WHERE
1251 1251
 				            c_id = ".$this->destination_course_id." AND
1252 1252
 				            category_id='" . intval($cat_id). "'";
1253
-				$result = Database::query($sql);
1254
-    			list($max_order) = Database::fetch_array($result);
1253
+                $result = Database::query($sql);
1254
+                list($max_order) = Database::fetch_array($result);
1255 1255
 
1256 1256
                 $params = [];
1257
-    			if (!empty($session_id)) {
1257
+                if (!empty($session_id)) {
1258 1258
                     $params['session_id'] = $session_id;
1259
-    			}
1259
+                }
1260 1260
 
1261 1261
                 $params['c_id'] = $this->destination_course_id;
1262 1262
                 $params['url'] = self::DBUTF8($link->url);
@@ -1285,9 +1285,9 @@  discard block
 block discarded – undo
1285 1285
                     }
1286 1286
                     $this->course->resources[RESOURCE_LINK][$id]->destination_id = $id;
1287 1287
                 }
1288
-			}
1289
-		}
1290
-	}
1288
+            }
1289
+        }
1290
+    }
1291 1291
 
1292 1292
     /**
1293 1293
      * Restore a link-category
@@ -1331,21 +1331,21 @@  discard block
 block discarded – undo
1331 1331
         return $this->course->resources[RESOURCE_LINKCATEGORY][$id]->destination_id;
1332 1332
     }
1333 1333
 
1334
-	/**
1335
-	 * Restore tool intro
1336
-	 */
1334
+    /**
1335
+     * Restore tool intro
1336
+     */
1337 1337
     public function restore_tool_intro($sessionId = 0)
1338 1338
     {
1339
-		if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) {
1339
+        if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) {
1340 1340
             $sessionId = intval($sessionId);
1341
-			$tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO);
1342
-			$resources = $this->course->resources;
1343
-			foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) {
1344
-				$sql = "DELETE FROM $tool_intro_table
1341
+            $tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO);
1342
+            $resources = $this->course->resources;
1343
+            foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) {
1344
+                $sql = "DELETE FROM $tool_intro_table
1345 1345
 				        WHERE
1346 1346
 				            c_id = ".$this->destination_course_id." AND
1347 1347
 				            id='".self::DBUTF8escapestring($tool_intro->id)."'";
1348
-				Database::query($sql);
1348
+                Database::query($sql);
1349 1349
 
1350 1350
                 $tool_intro->intro_text = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1351 1351
                     $tool_intro->intro_text,
@@ -1370,21 +1370,21 @@  discard block
 block discarded – undo
1370 1370
 
1371 1371
                     $this->course->resources[RESOURCE_TOOL_INTRO][$id]->destination_id = $id;
1372 1372
                 }
1373
-			}
1374
-		}
1375
-	}
1373
+            }
1374
+        }
1375
+    }
1376 1376
 
1377
-	/**
1378
-	 * Restore events
1379
-	 */
1377
+    /**
1378
+     * Restore events
1379
+     */
1380 1380
     public function restore_events($sessionId = 0)
1381 1381
     {
1382
-		if ($this->course->has_resources(RESOURCE_EVENT)) {
1382
+        if ($this->course->has_resources(RESOURCE_EVENT)) {
1383 1383
             $sessionId = intval($sessionId);
1384
-			$table = Database :: get_course_table(TABLE_AGENDA);
1385
-			$resources = $this->course->resources;
1386
-			foreach ($resources[RESOURCE_EVENT] as $id => $event) {
1387
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
1384
+            $table = Database :: get_course_table(TABLE_AGENDA);
1385
+            $resources = $this->course->resources;
1386
+            foreach ($resources[RESOURCE_EVENT] as $id => $event) {
1387
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
1388 1388
                 $event->content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1389 1389
                     $event->content,
1390 1390
                     $this->course->code,
@@ -1402,7 +1402,7 @@  discard block
 block discarded – undo
1402 1402
                     'end_date' => $event->end_date,
1403 1403
                     'session_id' => $sessionId,
1404 1404
                 ];
1405
-				$new_event_id = Database::insert($table, $params);
1405
+                $new_event_id = Database::insert($table, $params);
1406 1406
 
1407 1407
                 if ($new_event_id) {
1408 1408
                     $sql = "UPDATE $table SET id = iid WHERE iid = $new_event_id";
@@ -1414,32 +1414,32 @@  discard block
 block discarded – undo
1414 1414
                     $this->course->resources[RESOURCE_EVENT][$id]->destination_id = $new_event_id;
1415 1415
                 }
1416 1416
 
1417
-				// Copy event attachment
1418
-				$origin_path = $this->course->backup_path.'/upload/calendar/';
1419
-				$destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/';
1417
+                // Copy event attachment
1418
+                $origin_path = $this->course->backup_path.'/upload/calendar/';
1419
+                $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/';
1420 1420
 
1421
-				if (!empty($this->course->orig)) {
1421
+                if (!empty($this->course->orig)) {
1422 1422
 
1423
-					$table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1424
-					$sql = 'SELECT path, comment, size, filename
1423
+                    $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1424
+                    $sql = 'SELECT path, comment, size, filename
1425 1425
 					        FROM '.$table_attachment.'
1426 1426
 					        WHERE c_id = '.$this->destination_course_id.' AND agenda_id = '.$id;
1427
-					$attachment_event = Database::query($sql);
1428
-					$attachment_event = Database::fetch_object($attachment_event);
1427
+                    $attachment_event = Database::query($sql);
1428
+                    $attachment_event = Database::fetch_object($attachment_event);
1429 1429
 
1430
-					if (file_exists($origin_path.$attachment_event->path) &&
1430
+                    if (file_exists($origin_path.$attachment_event->path) &&
1431 1431
                         !is_dir($origin_path.$attachment_event->path)
1432 1432
                     ) {
1433
-						$new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1433
+                        $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1434 1434
                         $copy_result = copy(
1435 1435
                             $origin_path.$attachment_event->path,
1436 1436
                             $destination_path.$new_filename
1437 1437
                         );
1438
-						//$copy_result = true;
1439
-						if ($copy_result) {
1440
-							$table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1438
+                        //$copy_result = true;
1439
+                        if ($copy_result) {
1440
+                            $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1441 1441
 
1442
-							$params = [
1442
+                            $params = [
1443 1443
                                 'c_id' => $this->destination_course_id,
1444 1444
                                 'path' => self::DBUTF8($new_filename),
1445 1445
                                 'comment' => self::DBUTF8($attachment_event->comment),
@@ -1453,20 +1453,20 @@  discard block
 block discarded – undo
1453 1453
                                 Database::query($sql);
1454 1454
                             }
1455 1455
                         }
1456
-					}
1457
-				} else {
1458
-					// get the info of the file
1459
-					if (!empty($event->attachment_path) &&
1456
+                    }
1457
+                } else {
1458
+                    // get the info of the file
1459
+                    if (!empty($event->attachment_path) &&
1460 1460
                         is_file($origin_path.$event->attachment_path) &&
1461 1461
                         is_readable($origin_path.$event->attachment_path)
1462 1462
                     ) {
1463
-						$new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1463
+                        $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1464 1464
                         $copy_result = copy(
1465 1465
                             $origin_path.$event->attachment_path,
1466 1466
                             $destination_path.$new_filename
1467 1467
                         );
1468
-						if ($copy_result) {
1469
-							$table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1468
+                        if ($copy_result) {
1469
+                            $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1470 1470
 
1471 1471
                             $params = [
1472 1472
                                 'c_id' => $this->destination_course_id,
@@ -1482,29 +1482,29 @@  discard block
 block discarded – undo
1482 1482
                                 $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $id";
1483 1483
                                 Database::query($sql);
1484 1484
                             }
1485
-						}
1486
-					}
1487
-				}
1488
-			}
1489
-		}
1490
-	}
1491
-
1492
-	/**
1493
-	 * Restore course-description
1494
-	 */
1485
+                        }
1486
+                    }
1487
+                }
1488
+            }
1489
+        }
1490
+    }
1491
+
1492
+    /**
1493
+     * Restore course-description
1494
+     */
1495 1495
     public function restore_course_descriptions($session_id = 0)
1496 1496
     {
1497
-		if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) {
1498
-			$table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION);
1499
-			$resources = $this->course->resources;
1500
-			foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) {
1497
+        if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) {
1498
+            $table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION);
1499
+            $resources = $this->course->resources;
1500
+            foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) {
1501 1501
                 $courseDescription = (array) $cd;
1502 1502
 
1503 1503
                 $content = isset($courseDescription['content']) ? $courseDescription['content'] : '';
1504 1504
                 $descriptionType = isset($courseDescription['description_type']) ? $courseDescription['description_type'] : '';
1505 1505
                 $title = isset($courseDescription['title']) ? $courseDescription['title'] : '';
1506 1506
 
1507
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
1507
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
1508 1508
                 $description_content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1509 1509
                     $content,
1510 1510
                     $this->course->code,
@@ -1533,22 +1533,22 @@  discard block
 block discarded – undo
1533 1533
                     }
1534 1534
                     $this->course->resources[RESOURCE_COURSEDESCRIPTION][$id]->destination_id = $id;
1535 1535
                 }
1536
-			}
1537
-		}
1538
-	}
1536
+            }
1537
+        }
1538
+    }
1539 1539
 
1540
-	/**
1541
-	 * Restore announcements
1542
-	 */
1540
+    /**
1541
+     * Restore announcements
1542
+     */
1543 1543
     public function restore_announcements($sessionId = 0)
1544 1544
     {
1545
-		if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) {
1545
+        if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) {
1546 1546
             $sessionId = intval($sessionId);
1547
-			$table = Database :: get_course_table(TABLE_ANNOUNCEMENT);
1548
-			$resources = $this->course->resources;
1549
-			foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) {
1547
+            $table = Database :: get_course_table(TABLE_ANNOUNCEMENT);
1548
+            $resources = $this->course->resources;
1549
+            foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) {
1550 1550
 
1551
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
1551
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
1552 1552
                 $announcement->content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1553 1553
                     $announcement->content,
1554 1554
                     $this->course->code,
@@ -1567,7 +1567,7 @@  discard block
 block discarded – undo
1567 1567
                     'session_id' => $sessionId,
1568 1568
                 ];
1569 1569
 
1570
-				$new_announcement_id = Database::insert($table, $params);
1570
+                $new_announcement_id = Database::insert($table, $params);
1571 1571
 
1572 1572
                 if ($new_announcement_id) {
1573 1573
                     $sql = "UPDATE $table SET id = iid WHERE iid = $new_announcement_id";
@@ -1579,32 +1579,32 @@  discard block
 block discarded – undo
1579 1579
                     $this->course->resources[RESOURCE_ANNOUNCEMENT][$id]->destination_id = $new_announcement_id;
1580 1580
                 }
1581 1581
 
1582
-				$origin_path = $this->course->backup_path.'/upload/announcements/';
1583
-				$destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/';
1582
+                $origin_path = $this->course->backup_path.'/upload/announcements/';
1583
+                $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/';
1584 1584
 
1585
-				// Copy announcement attachment file
1586
-				if (!empty($this->course->orig)) {
1585
+                // Copy announcement attachment file
1586
+                if (!empty($this->course->orig)) {
1587 1587
 
1588
-					$table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1589
-					$sql = 'SELECT path, comment, size, filename
1588
+                    $table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1589
+                    $sql = 'SELECT path, comment, size, filename
1590 1590
 					        FROM '.$table_attachment.'
1591 1591
 					        WHERE
1592 1592
 					            c_id = '.$this->destination_course_id.' AND
1593 1593
 					            announcement_id = '.$id;
1594
-					$attachment_event = Database::query($sql);
1595
-					$attachment_event = Database::fetch_object($attachment_event);
1594
+                    $attachment_event = Database::query($sql);
1595
+                    $attachment_event = Database::fetch_object($attachment_event);
1596 1596
 
1597
-					if (file_exists($origin_path.$attachment_event->path) &&
1597
+                    if (file_exists($origin_path.$attachment_event->path) &&
1598 1598
                         !is_dir($origin_path.$attachment_event->path)
1599 1599
                     ) {
1600
-						$new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1600
+                        $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1601 1601
                         $copy_result = copy(
1602 1602
                             $origin_path.$attachment_event->path,
1603 1603
                             $destination_path.$new_filename
1604 1604
                         );
1605 1605
 
1606
-						if ($copy_result) {
1607
-							$table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1606
+                        if ($copy_result) {
1607
+                            $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1608 1608
 
1609 1609
                             $params = [
1610 1610
                                 'c_id' => $this->destination_course_id,
@@ -1621,19 +1621,19 @@  discard block
 block discarded – undo
1621 1621
                                 $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId";
1622 1622
                                 Database::query($sql);
1623 1623
                             }
1624
-						}
1625
-					}
1626
-				} else {
1627
-					// get the info of the file
1628
-					if (!empty($announcement->attachment_path) &&
1624
+                        }
1625
+                    }
1626
+                } else {
1627
+                    // get the info of the file
1628
+                    if (!empty($announcement->attachment_path) &&
1629 1629
                         is_file($origin_path.$announcement->attachment_path) &&
1630 1630
                         is_readable($origin_path.$announcement->attachment_path)
1631 1631
                     ) {
1632
-						$new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1633
-						$copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename);
1632
+                        $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1633
+                        $copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename);
1634 1634
 
1635
-						if ($copy_result) {
1636
-							$table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1635
+                        if ($copy_result) {
1636
+                            $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1637 1637
 
1638 1638
                             $params = [
1639 1639
                                 'c_id' => $this->destination_course_id,
@@ -1650,12 +1650,12 @@  discard block
 block discarded – undo
1650 1650
                                 $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId";
1651 1651
                                 Database::query($sql);
1652 1652
                             }
1653
-						}
1654
-					}
1655
-				}
1656
-			}
1657
-		}
1658
-	}
1653
+                        }
1654
+                    }
1655
+                }
1656
+            }
1657
+        }
1658
+    }
1659 1659
 
1660 1660
     /**
1661 1661
      * Restore Quiz
@@ -1666,13 +1666,13 @@  discard block
 block discarded – undo
1666 1666
         $session_id = 0,
1667 1667
         $respect_base_content = false
1668 1668
     ) {
1669
-		if ($this->course->has_resources(RESOURCE_QUIZ)) {
1670
-			$table_qui = Database :: get_course_table(TABLE_QUIZ_TEST);
1671
-			$table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION);
1672
-			$table_doc = Database :: get_course_table(TABLE_DOCUMENT);
1673
-			$resources = $this->course->resources;
1669
+        if ($this->course->has_resources(RESOURCE_QUIZ)) {
1670
+            $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST);
1671
+            $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION);
1672
+            $table_doc = Database :: get_course_table(TABLE_DOCUMENT);
1673
+            $resources = $this->course->resources;
1674 1674
 
1675
-			foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) {
1675
+            foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) {
1676 1676
                 if (isset($quiz->obj)) {
1677 1677
                     //For new imports
1678 1678
                     $quiz = $quiz->obj;
@@ -1681,7 +1681,7 @@  discard block
 block discarded – undo
1681 1681
                     $quiz->obj = $quiz;
1682 1682
                 }
1683 1683
 
1684
-				$doc = '';
1684
+                $doc = '';
1685 1685
                 if (!empty($quiz->sound)) {
1686 1686
                     if (isset($this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]) &&
1687 1687
                         $this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]->is_restored()) {
@@ -1689,14 +1689,14 @@  discard block
 block discarded – undo
1689 1689
                                 WHERE
1690 1690
                                     c_id = " . $this->destination_course_id . "  AND
1691 1691
                                     id = " . $resources[RESOURCE_DOCUMENT][$quiz->sound]->destination_id;
1692
-						$doc = Database::query($sql);
1693
-						$doc = Database::fetch_object($doc);
1694
-						$doc = str_replace('/audio/', '', $doc->path);
1695
-					}
1696
-				}
1697
-
1698
-				if ($id != -1) {
1699
-					// check resources inside html from ckeditor tool and copy correct urls into recipient course
1692
+                        $doc = Database::query($sql);
1693
+                        $doc = Database::fetch_object($doc);
1694
+                        $doc = str_replace('/audio/', '', $doc->path);
1695
+                    }
1696
+                }
1697
+
1698
+                if ($id != -1) {
1699
+                    // check resources inside html from ckeditor tool and copy correct urls into recipient course
1700 1700
                     $quiz->description = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1701 1701
                         $quiz->description,
1702 1702
                         $this->course->code,
@@ -1708,13 +1708,13 @@  discard block
 block discarded – undo
1708 1708
                     $quiz->start_time = $quiz->start_time == '0000-00-00 00:00:00' ? null : $quiz->start_time;
1709 1709
                     $quiz->end_time = $quiz->end_time == '0000-00-00 00:00:00' ? null : $quiz->end_time;
1710 1710
 
1711
-					global $_custom;
1712
-					if (isset($_custom['exercises_clean_dates_when_restoring']) &&
1711
+                    global $_custom;
1712
+                    if (isset($_custom['exercises_clean_dates_when_restoring']) &&
1713 1713
                         $_custom['exercises_clean_dates_when_restoring']
1714 1714
                     ) {
1715
-						$quiz->start_time = null;
1716
-						$quiz->end_time   = null;
1717
-					}
1715
+                        $quiz->start_time = null;
1716
+                        $quiz->end_time   = null;
1717
+                    }
1718 1718
 
1719 1719
                     $params = array(
1720 1720
                         'c_id' => $this->destination_course_id,
@@ -1748,10 +1748,10 @@  discard block
 block discarded – undo
1748 1748
                         }
1749 1749
                         $params['session_id'] = $my_session_id;
1750 1750
                     } else {
1751
-        				if (!empty($session_id)) {
1752
-        					$session_id = intval($session_id);
1751
+                        if (!empty($session_id)) {
1752
+                            $session_id = intval($session_id);
1753 1753
                             $params['session_id'] = $session_id;
1754
-    				    }
1754
+                        }
1755 1755
                     }
1756 1756
                     $new_id = Database::insert($table_qui, $params);
1757 1757
 
@@ -1760,15 +1760,15 @@  discard block
 block discarded – undo
1760 1760
                         Database::query($sql);
1761 1761
                     }
1762 1762
 
1763
-				} else {
1764
-					// $id = -1 identifies the fictionary test for collecting
1765
-					// orphan questions. We do not store it in the database.
1766
-					$new_id = -1;
1767
-				}
1763
+                } else {
1764
+                    // $id = -1 identifies the fictionary test for collecting
1765
+                    // orphan questions. We do not store it in the database.
1766
+                    $new_id = -1;
1767
+                }
1768 1768
 
1769
-				$this->course->resources[RESOURCE_QUIZ][$id]->destination_id = $new_id;
1769
+                $this->course->resources[RESOURCE_QUIZ][$id]->destination_id = $new_id;
1770 1770
 
1771
-				$order = 0;
1771
+                $order = 0;
1772 1772
                 if (!empty($quiz->question_ids)) {
1773 1773
                     foreach ($quiz->question_ids as $index => $question_id) {
1774 1774
                         $qid = $this->restore_quiz_question($question_id);
@@ -1781,31 +1781,31 @@  discard block
 block discarded – undo
1781 1781
                         Database::query($sql);
1782 1782
                     }
1783 1783
                 }
1784
-			}
1785
-		}
1786
-	}
1784
+            }
1785
+        }
1786
+    }
1787 1787
 
1788
-	/**
1789
-	 * Restore quiz-questions
1788
+    /**
1789
+     * Restore quiz-questions
1790 1790
      * @params int question id
1791
-	 */
1791
+     */
1792 1792
     public function restore_quiz_question($id)
1793 1793
     {
1794 1794
         $em = Database::getManager();
1795
-		$resources = $this->course->resources;
1795
+        $resources = $this->course->resources;
1796 1796
         $question = isset($resources[RESOURCE_QUIZQUESTION][$id]) ? $resources[RESOURCE_QUIZQUESTION][$id] : null;
1797 1797
 
1798
-		$new_id = 0;
1798
+        $new_id = 0;
1799 1799
 
1800
-		if (is_object($question)) {
1801
-			if ($question->is_restored()) {
1802
-				return $question->destination_id;
1803
-			}
1804
-			$table_que = Database::get_course_table(TABLE_QUIZ_QUESTION);
1805
-			$table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER);
1800
+        if (is_object($question)) {
1801
+            if ($question->is_restored()) {
1802
+                return $question->destination_id;
1803
+            }
1804
+            $table_que = Database::get_course_table(TABLE_QUIZ_QUESTION);
1805
+            $table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER);
1806 1806
             $table_options = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION);
1807 1807
 
1808
-			// check resources inside html from ckeditor tool and copy correct urls into recipient course
1808
+            // check resources inside html from ckeditor tool and copy correct urls into recipient course
1809 1809
             $question->description = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1810 1810
                 $question->description,
1811 1811
                 $this->course->code,
@@ -1826,7 +1826,7 @@  discard block
 block discarded – undo
1826 1826
                 'extra' => self::DBUTF8($question->extra),
1827 1827
             ];
1828 1828
 
1829
-			$new_id = Database::insert($table_que, $params);
1829
+            $new_id = Database::insert($table_que, $params);
1830 1830
 
1831 1831
             if ($new_id) {
1832 1832
                 $sql = "UPDATE $table_que SET id = iid WHERE iid = $new_id";
@@ -1861,7 +1861,7 @@  discard block
 block discarded – undo
1861 1861
             $allAnswers = [];
1862 1862
             $onlyAnswers = [];
1863 1863
 
1864
-           if (in_array($question->quiz_type, [DRAGGABLE, MATCHING, MATCHING_DRAGGABLE])) {
1864
+            if (in_array($question->quiz_type, [DRAGGABLE, MATCHING, MATCHING_DRAGGABLE])) {
1865 1865
                 $allAnswers = array_column($question->answers, 'answer', 'id');
1866 1866
             }
1867 1867
 
@@ -1901,11 +1901,11 @@  discard block
 block discarded – undo
1901 1901
                         $correctAnswers[$answerId] = $answer['correct'];
1902 1902
                         $onlyAnswers[$answerId] = $answer['answer'];
1903 1903
                     }
1904
-				}
1905
-			} else {
1904
+                }
1905
+            } else {
1906 1906
 
1907
-				foreach ($question->answers as $index => $answer) {
1908
-					// check resources inside html from ckeditor tool and copy correct urls into recipient course
1907
+                foreach ($question->answers as $index => $answer) {
1908
+                    // check resources inside html from ckeditor tool and copy correct urls into recipient course
1909 1909
                     $answer['answer'] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1910 1910
                         $answer['answer'],
1911 1911
                         $this->course->code,
@@ -1945,8 +1945,8 @@  discard block
 block discarded – undo
1945 1945
 
1946 1946
                     $correctAnswers[$answerId] = $answer['correct'];
1947 1947
                     $onlyAnswers[$answerId] = $answer['answer'];
1948
-				}
1949
-			}
1948
+                }
1949
+            }
1950 1950
 
1951 1951
             // Current course id
1952 1952
             $course_id = api_get_course_int_id();
@@ -2067,13 +2067,13 @@  discard block
 block discarded – undo
2067 2067
                 }
2068 2068
             }
2069 2069
 
2070
-			$this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id;
2071
-		}
2070
+            $this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id;
2071
+        }
2072 2072
 
2073
-		return $new_id;
2074
-	}
2073
+        return $new_id;
2074
+    }
2075 2075
 
2076
-	/**
2076
+    /**
2077 2077
      * @todo : add session id when used for session
2078 2078
      */
2079 2079
     public function restore_test_category($session_id, $respect_base_content, $destination_course_code)
@@ -2158,21 +2158,21 @@  discard block
 block discarded – undo
2158 2158
         $sessionId = intval($sessionId);
2159 2159
 
2160 2160
         if ($this->course->has_resources(RESOURCE_SURVEY)) {
2161
-			$table_sur = Database :: get_course_table(TABLE_SURVEY);
2162
-			$table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2163
-			$table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2164
-			$resources = $this->course->resources;
2165
-			foreach ($resources[RESOURCE_SURVEY] as $id => $survey) {
2161
+            $table_sur = Database :: get_course_table(TABLE_SURVEY);
2162
+            $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2163
+            $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2164
+            $resources = $this->course->resources;
2165
+            foreach ($resources[RESOURCE_SURVEY] as $id => $survey) {
2166 2166
 
2167
-				$sql = 'SELECT survey_id FROM '.$table_sur.'
2167
+                $sql = 'SELECT survey_id FROM '.$table_sur.'
2168 2168
                         WHERE
2169 2169
                             c_id = '.$this->destination_course_id.' AND
2170 2170
                             code = "'.self::DBUTF8escapestring($survey->code).'" AND
2171 2171
                             lang = "'.self::DBUTF8escapestring($survey->lang).'" ';
2172 2172
 
2173
-				$result_check = Database::query($sql);
2173
+                $result_check = Database::query($sql);
2174 2174
 
2175
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
2175
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
2176 2176
                 $survey->title = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2177 2177
                     $survey->title,
2178 2178
                     $this->course->code,
@@ -2226,20 +2226,20 @@  discard block
 block discarded – undo
2226 2226
                     'session_id' => $sessionId,
2227 2227
                 ];
2228 2228
 
2229
-				//An existing survey exists with the same code and the same language
2230
-				if (Database::num_rows($result_check) == 1) {
2231
-					switch ($this->file_option) {
2232
-						case FILE_SKIP:
2233
-							//Do nothing
2234
-							break;
2235
-						case FILE_RENAME:
2236
-							$survey_code = $survey->code.'_';
2237
-							$i=1;
2238
-							$temp_survey_code = $survey_code.$i;
2239
-							while (!$this->is_survey_code_available($temp_survey_code)) {
2240
-								$temp_survey_code = $survey_code.++$i;
2241
-							}
2242
-							$survey_code = $temp_survey_code;
2229
+                //An existing survey exists with the same code and the same language
2230
+                if (Database::num_rows($result_check) == 1) {
2231
+                    switch ($this->file_option) {
2232
+                        case FILE_SKIP:
2233
+                            //Do nothing
2234
+                            break;
2235
+                        case FILE_RENAME:
2236
+                            $survey_code = $survey->code.'_';
2237
+                            $i=1;
2238
+                            $temp_survey_code = $survey_code.$i;
2239
+                            while (!$this->is_survey_code_available($temp_survey_code)) {
2240
+                                $temp_survey_code = $survey_code.++$i;
2241
+                            }
2242
+                            $survey_code = $temp_survey_code;
2243 2243
 
2244 2244
                             $params['code'] = $survey_code;
2245 2245
                             $new_id = Database::insert($table_sur, $params);
@@ -2258,25 +2258,25 @@  discard block
 block discarded – undo
2258 2258
                                     Database::query($sql);
2259 2259
                                 }
2260 2260
                             }
2261
-							break;
2262
-						case FILE_OVERWRITE:
2263
-							// Delete the existing survey with the same code and language and import the one of the source course
2264
-							// getting the information of the survey (used for when the survey is shared)
2261
+                            break;
2262
+                        case FILE_OVERWRITE:
2263
+                            // Delete the existing survey with the same code and language and import the one of the source course
2264
+                            // getting the information of the survey (used for when the survey is shared)
2265 2265
 
2266
-							$sql = "SELECT * FROM $table_sur
2266
+                            $sql = "SELECT * FROM $table_sur
2267 2267
 							        WHERE
2268 2268
 							            c_id = ".$this->destination_course_id." AND
2269 2269
 							            survey_id='".self::DBUTF8escapestring(Database::result($result_check,0,0))."'";
2270
-							$result = Database::query($sql);
2271
-							$survey_data = Database::fetch_array($result,'ASSOC');
2270
+                            $result = Database::query($sql);
2271
+                            $survey_data = Database::fetch_array($result,'ASSOC');
2272 2272
 
2273
-							// if the survey is shared => also delete the shared content
2274
-							if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) {
2273
+                            // if the survey is shared => also delete the shared content
2274
+                            if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) {
2275 2275
                                 SurveyManager::delete_survey($survey_data['survey_share'], true,$this->destination_course_id);
2276
-							}
2277
-							SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id);
2276
+                            }
2277
+                            SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id);
2278 2278
 
2279
-							// Insert the new source survey
2279
+                            // Insert the new source survey
2280 2280
                             $new_id = Database::insert($table_sur, $params);
2281 2281
 
2282 2282
                             if ($new_id) {
@@ -2297,11 +2297,11 @@  discard block
 block discarded – undo
2297 2297
                                     Database::query($sql);
2298 2298
                                 }
2299 2299
                             }
2300
-							break;
2301
-						default:
2302
-							break;
2303
-					}
2304
-				} else {
2300
+                            break;
2301
+                        default:
2302
+                            break;
2303
+                    }
2304
+                } else {
2305 2305
                     // No existing survey with the same language and the same code, we just copy the survey
2306 2306
                     $new_id = Database::insert($table_sur, $params);
2307 2307
 
@@ -2323,48 +2323,48 @@  discard block
 block discarded – undo
2323 2323
                             Database::query($sql);
2324 2324
                         }
2325 2325
                     }
2326
-				}
2327
-			}
2328
-		}
2329
-	}
2330
-
2331
-	/**
2332
-	 * Check availability of a survey code
2333
-	 * @param string $survey_code
2334
-	 */
2326
+                }
2327
+            }
2328
+        }
2329
+    }
2330
+
2331
+    /**
2332
+     * Check availability of a survey code
2333
+     * @param string $survey_code
2334
+     */
2335 2335
     public function is_survey_code_available($survey_code)
2336 2336
     {
2337
-		$table_sur = Database :: get_course_table(TABLE_SURVEY);
2338
-		$sql = "SELECT * FROM $table_sur
2337
+        $table_sur = Database :: get_course_table(TABLE_SURVEY);
2338
+        $sql = "SELECT * FROM $table_sur
2339 2339
 		        WHERE
2340 2340
 		            c_id = ".$this->destination_course_id." AND
2341 2341
 		            code = '".self::DBUTF8escapestring($survey_code)."'";
2342
-		$result = Database::query($sql);
2342
+        $result = Database::query($sql);
2343 2343
         if (Database::num_rows($result) > 0) {
2344 2344
             return false;
2345 2345
         } else {
2346 2346
             return true;
2347 2347
         }
2348
-	}
2348
+    }
2349 2349
 
2350
-	/**
2351
-	 * Restore survey-questions
2352
-	 * @param string $survey_id
2353
-	 */
2350
+    /**
2351
+     * Restore survey-questions
2352
+     * @param string $survey_id
2353
+     */
2354 2354
     public function restore_survey_question($id, $survey_id)
2355 2355
     {
2356
-		$resources = $this->course->resources;
2357
-		$question = $resources[RESOURCE_SURVEYQUESTION][$id];
2356
+        $resources = $this->course->resources;
2357
+        $question = $resources[RESOURCE_SURVEYQUESTION][$id];
2358 2358
         $new_id = 0;
2359 2359
 
2360
-		if (is_object($question)) {
2361
-			if ($question->is_restored()) {
2362
-				return $question->destination_id;
2363
-			}
2364
-			$table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2365
-			$table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2360
+        if (is_object($question)) {
2361
+            if ($question->is_restored()) {
2362
+                return $question->destination_id;
2363
+            }
2364
+            $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2365
+            $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2366 2366
 
2367
-			// check resources inside html from ckeditor tool and copy correct urls into recipient course
2367
+            // check resources inside html from ckeditor tool and copy correct urls into recipient course
2368 2368
             $question->survey_question = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2369 2369
                 $question->survey_question,
2370 2370
                 $this->course->code,
@@ -2418,10 +2418,10 @@  discard block
 block discarded – undo
2418 2418
                 }
2419 2419
                 $this->course->resources[RESOURCE_SURVEYQUESTION][$id]->destination_id = $new_id;
2420 2420
             }
2421
-		}
2421
+        }
2422 2422
 
2423
-		return $new_id;
2424
-	}
2423
+        return $new_id;
2424
+    }
2425 2425
 
2426 2426
     /**
2427 2427
      * Restoring learning paths
@@ -2432,19 +2432,19 @@  discard block
 block discarded – undo
2432 2432
     {
2433 2433
         $session_id = intval($session_id);
2434 2434
 
2435
-		if ($this->course->has_resources(RESOURCE_LEARNPATH)) {
2435
+        if ($this->course->has_resources(RESOURCE_LEARNPATH)) {
2436 2436
             $table_main = Database::get_course_table(TABLE_LP_MAIN);
2437 2437
             $table_item = Database::get_course_table(TABLE_LP_ITEM);
2438 2438
             $table_tool = Database::get_course_table(TABLE_TOOL_LIST);
2439 2439
 
2440
-			$resources = $this->course->resources;
2440
+            $resources = $this->course->resources;
2441 2441
 
2442
-			$origin_path = $this->course->backup_path.'/upload/learning_path/images/';
2443
-			$destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/';
2442
+            $origin_path = $this->course->backup_path.'/upload/learning_path/images/';
2443
+            $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/';
2444 2444
 
2445
-			foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) {
2446
-				$condition_session = '';
2447
-				if (!empty($session_id)) {
2445
+            foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) {
2446
+                $condition_session = '';
2447
+                if (!empty($session_id)) {
2448 2448
                     if ($respect_base_content) {
2449 2449
                         $my_session_id = $lp->session_id;
2450 2450
                         if (!empty($lp->session_id)) {
@@ -2455,20 +2455,20 @@  discard block
 block discarded – undo
2455 2455
                         $session_id = intval($session_id);
2456 2456
                         $condition_session = $session_id;
2457 2457
                     }
2458
-				}
2459
-
2460
-				// Adding the author's image
2461
-				if (!empty($lp->preview_image)) {
2462
-					$new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image));
2463
-					if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) {
2464
-						$copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename);
2465
-						if ($copy_result) {
2466
-							$lp->preview_image = $new_filename;
2467
-						} else {
2468
-							$lp->preview_image ='';
2469
-						}
2470
-					}
2471
-				}
2458
+                }
2459
+
2460
+                // Adding the author's image
2461
+                if (!empty($lp->preview_image)) {
2462
+                    $new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image));
2463
+                    if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) {
2464
+                        $copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename);
2465
+                        if ($copy_result) {
2466
+                            $lp->preview_image = $new_filename;
2467
+                        } else {
2468
+                            $lp->preview_image ='';
2469
+                        }
2470
+                    }
2471
+                }
2472 2472
 
2473 2473
                 if ($this->add_text_in_items) {
2474 2474
                     $lp->name = $lp->name.' '.get_lang('CopyLabelSuffix');
@@ -2526,7 +2526,7 @@  discard block
 block discarded – undo
2526 2526
                     $params['session_id'] = $condition_session;
2527 2527
                 }
2528 2528
 
2529
-				$new_lp_id = Database::insert($table_main, $params);
2529
+                $new_lp_id = Database::insert($table_main, $params);
2530 2530
 
2531 2531
                 if ($new_lp_id) {
2532 2532
 
@@ -2587,13 +2587,13 @@  discard block
 block discarded – undo
2587 2587
                 $old_refs = array();
2588 2588
                 $prerequisite_ids = array();
2589 2589
 
2590
-				foreach ($lp->get_items() as $index => $item) {
2591
-					// we set the ref code here and then we update in a for loop
2592
-					$ref = $item['ref'];
2590
+                foreach ($lp->get_items() as $index => $item) {
2591
+                    // we set the ref code here and then we update in a for loop
2592
+                    $ref = $item['ref'];
2593 2593
 
2594
-					// Dealing with path the same way as ref as some data has
2594
+                    // Dealing with path the same way as ref as some data has
2595 2595
                     // been put into path when it's a local resource
2596
-					// Only fix the path for no scos
2596
+                    // Only fix the path for no scos
2597 2597
                     if ($item['item_type'] == 'sco') {
2598 2598
                         $path = $item['path'];
2599 2599
                     } else {
@@ -2624,128 +2624,128 @@  discard block
 block discarded – undo
2624 2624
                         'launch_data' => self::DBUTF8($item['launch_data']),
2625 2625
                     ];
2626 2626
 
2627
-					$new_item_id = Database::insert($table_item, $params);
2627
+                    $new_item_id = Database::insert($table_item, $params);
2628 2628
 
2629 2629
                     $sql = "UPDATE $table_item SET id = iid WHERE iid = $new_item_id";
2630 2630
                     Database::query($sql);
2631 2631
 
2632
-					//save a link between old and new item IDs
2633
-					$new_item_ids[$item['id']] = $new_item_id;
2634
-					//save a reference of items that need a parent_item_id refresh
2635
-					$parent_item_ids[$new_item_id] = $item['parent_item_id'];
2636
-					//save a reference of items that need a previous_item_id refresh
2637
-					$previous_item_ids[$new_item_id] = $item['previous_item_id'];
2638
-					//save a reference of items that need a next_item_id refresh
2639
-					$next_item_ids[$new_item_id] = $item['next_item_id'];
2640
-
2641
-					if (!empty($item['prerequisite'])) {
2642
-						if ($lp->lp_type =='2') {
2643
-							// if is an sco
2644
-							$old_prerequisite[$new_item_id]= $item['prerequisite'];
2645
-						} else {
2646
-							$old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']];
2647
-						}
2648
-					}
2649
-
2650
-					if (!empty($ref)) {
2651
-						if ($lp->lp_type =='2') {
2652
-							// if is an sco
2653
-							$old_refs[$new_item_id]= $ref;
2654
-						} elseif (isset($new_item_ids[$ref])) {
2632
+                    //save a link between old and new item IDs
2633
+                    $new_item_ids[$item['id']] = $new_item_id;
2634
+                    //save a reference of items that need a parent_item_id refresh
2635
+                    $parent_item_ids[$new_item_id] = $item['parent_item_id'];
2636
+                    //save a reference of items that need a previous_item_id refresh
2637
+                    $previous_item_ids[$new_item_id] = $item['previous_item_id'];
2638
+                    //save a reference of items that need a next_item_id refresh
2639
+                    $next_item_ids[$new_item_id] = $item['next_item_id'];
2640
+
2641
+                    if (!empty($item['prerequisite'])) {
2642
+                        if ($lp->lp_type =='2') {
2643
+                            // if is an sco
2644
+                            $old_prerequisite[$new_item_id]= $item['prerequisite'];
2645
+                        } else {
2646
+                            $old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']];
2647
+                        }
2648
+                    }
2649
+
2650
+                    if (!empty($ref)) {
2651
+                        if ($lp->lp_type =='2') {
2652
+                            // if is an sco
2653
+                            $old_refs[$new_item_id]= $ref;
2654
+                        } elseif (isset($new_item_ids[$ref])) {
2655 2655
                             $old_refs[$new_item_id]= $new_item_ids[$ref];
2656 2656
                         }
2657
-					}
2657
+                    }
2658 2658
 
2659
-					$prerequisite_ids[$new_item_id] = $item['prerequisite'];
2660
-				}
2659
+                    $prerequisite_ids[$new_item_id] = $item['prerequisite'];
2660
+                }
2661 2661
 
2662
-				// Updating prerequisites
2663
-				foreach ($old_prerequisite  as $key=>$my_old_prerequisite) {
2664
-					if ($my_old_prerequisite != ''){
2665
-						$sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."'
2662
+                // Updating prerequisites
2663
+                foreach ($old_prerequisite  as $key=>$my_old_prerequisite) {
2664
+                    if ($my_old_prerequisite != ''){
2665
+                        $sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."'
2666 2666
 						        WHERE c_id = ".$this->destination_course_id." AND id = '".$key."'  ";
2667
-						Database::query($sql);
2668
-					}
2669
-				}
2670
-
2671
-				// Updating refs
2672
-				foreach ($old_refs  as $key=>$my_old_ref) {
2673
-					if ($my_old_ref != '') {
2674
-						$sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."'
2667
+                        Database::query($sql);
2668
+                    }
2669
+                }
2670
+
2671
+                // Updating refs
2672
+                foreach ($old_refs  as $key=>$my_old_ref) {
2673
+                    if ($my_old_ref != '') {
2674
+                        $sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."'
2675 2675
 						        WHERE c_id = ".$this->destination_course_id." AND id = '".$key."'  ";
2676
-						Database::query($sql);
2677
-					}
2678
-				}
2679
-
2680
-				foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) {
2681
-					$parent_new_id = 0;
2682
-					if($parent_item_old_id != 0){
2683
-						$parent_new_id = $new_item_ids[$parent_item_old_id];
2684
-					}
2685
-					$sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."'
2676
+                        Database::query($sql);
2677
+                    }
2678
+                }
2679
+
2680
+                foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) {
2681
+                    $parent_new_id = 0;
2682
+                    if($parent_item_old_id != 0){
2683
+                        $parent_new_id = $new_item_ids[$parent_item_old_id];
2684
+                    }
2685
+                    $sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."'
2686 2686
 					        WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'";
2687
-					Database::query($sql);
2688
-				}
2689
-				foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) {
2690
-					$previous_new_id = 0;
2691
-					if ($previous_item_old_id != 0){
2692
-						$previous_new_id = $new_item_ids[$previous_item_old_id];
2693
-					}
2694
-					$sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."'
2687
+                    Database::query($sql);
2688
+                }
2689
+                foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) {
2690
+                    $previous_new_id = 0;
2691
+                    if ($previous_item_old_id != 0){
2692
+                        $previous_new_id = $new_item_ids[$previous_item_old_id];
2693
+                    }
2694
+                    $sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."'
2695 2695
 					        WHERE  c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'";
2696
-					Database::query($sql);
2697
-				}
2698
-
2699
-				foreach ($next_item_ids as $new_item_id => $next_item_old_id) {
2700
-					$next_new_id = 0;
2701
-					if ($next_item_old_id != 0){
2702
-						$next_new_id = $new_item_ids[$next_item_old_id];
2703
-					}
2704
-					$sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."'
2696
+                    Database::query($sql);
2697
+                }
2698
+
2699
+                foreach ($next_item_ids as $new_item_id => $next_item_old_id) {
2700
+                    $next_new_id = 0;
2701
+                    if ($next_item_old_id != 0){
2702
+                        $next_new_id = $new_item_ids[$next_item_old_id];
2703
+                    }
2704
+                    $sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."'
2705 2705
 					        WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'";
2706
-					Database::query($sql);
2707
-				}
2708
-
2709
-				foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) {
2710
-					$prerequisite_new_id = 0;
2711
-					if ($prerequisite_old_id != 0){
2712
-						$prerequisite_new_id = $new_item_ids[$prerequisite_old_id];
2713
-					}
2714
-					$sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."'
2706
+                    Database::query($sql);
2707
+                }
2708
+
2709
+                foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) {
2710
+                    $prerequisite_new_id = 0;
2711
+                    if ($prerequisite_old_id != 0){
2712
+                        $prerequisite_new_id = $new_item_ids[$prerequisite_old_id];
2713
+                    }
2714
+                    $sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."'
2715 2715
 					        WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'";
2716
-					Database::query($sql);
2717
-				}
2718
-				$this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id;
2719
-			}
2720
-		}
2721
-	}
2722
-
2723
-	/**
2724
-	 * Restore works
2716
+                    Database::query($sql);
2717
+                }
2718
+                $this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id;
2719
+            }
2720
+        }
2721
+    }
2722
+
2723
+    /**
2724
+     * Restore works
2725 2725
      * @deprecated use restore_works
2726 2726
      *
2727
-	 */
2728
-	public function restore_student_publication($sessionId = 0)
2727
+     */
2728
+    public function restore_student_publication($sessionId = 0)
2729 2729
     {
2730 2730
         $sessionId = intval($sessionId);
2731 2731
         $work_assignment_table = Database:: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
2732 2732
         $work_table = Database:: get_course_table(TABLE_STUDENT_PUBLICATION);
2733 2733
         $item_property_table = Database:: get_course_table(TABLE_ITEM_PROPERTY);
2734 2734
 
2735
-		// Query in student publication
2736
-		$sql = 'SELECT * FROM '.$work_table.'
2735
+        // Query in student publication
2736
+        $sql = 'SELECT * FROM '.$work_table.'
2737 2737
 		        WHERE c_id = '.$this->course_origin_id.' AND filetype = "folder" AND active IN (0, 1) ';
2738 2738
 
2739
-		$result = Database::query($sql);
2740
-		$folders = Database::store_result($result, 'ASSOC');
2739
+        $result = Database::query($sql);
2740
+        $folders = Database::store_result($result, 'ASSOC');
2741 2741
 
2742
-		foreach ($folders  as $folder) {
2743
-		    $old_id = $folder['id'];
2742
+        foreach ($folders  as $folder) {
2743
+            $old_id = $folder['id'];
2744 2744
             unset($folder['id']);
2745
-			$folder['c_id'] = $this->destination_course_id;
2745
+            $folder['c_id'] = $this->destination_course_id;
2746 2746
             $folder['parent_id'] = 0;
2747 2747
             $folder['session_id'] = $sessionId ? $sessionId : null;
2748
-			$new_id = Database::insert($work_table, $folder);
2748
+            $new_id = Database::insert($work_table, $folder);
2749 2749
 
2750 2750
             if ($new_id) {
2751 2751
                 // query in item property
@@ -2804,23 +2804,23 @@  discard block
 block discarded – undo
2804 2804
                     }
2805 2805
                 }
2806 2806
             }
2807
-		}
2807
+        }
2808 2808
 
2809 2809
         $destination = '../..'.api_get_path(REL_COURSE_PATH).$this->course->destination_path.'/work/';
2810 2810
         $origin = '../..'.api_get_path(REL_COURSE_PATH).$this->course->info['path'].'/work/';
2811 2811
         self::allow_create_all_directory($origin, $destination, false);
2812
-	}
2812
+    }
2813 2813
 
2814 2814
     /**
2815
-    * copy all directory and sub directory
2816
-    * @param string The path origin
2817
-    * @param string The path destination
2818
-    * @param boolean Option Overwrite
2819
-    * @param string $source
2820
-    * @param string $dest
2821
-    * @return void()
2822
-    * @deprecated
2823
-    */
2815
+     * copy all directory and sub directory
2816
+     * @param string The path origin
2817
+     * @param string The path destination
2818
+     * @param boolean Option Overwrite
2819
+     * @param string $source
2820
+     * @param string $dest
2821
+     * @return void()
2822
+     * @deprecated
2823
+     */
2824 2824
     public function allow_create_all_directory($source, $dest, $overwrite = false)
2825 2825
     {
2826 2826
         if (!is_dir($dest)) {
@@ -2831,7 +2831,7 @@  discard block
 block discarded – undo
2831 2831
                 if ($file != '.' && $file != '..') {
2832 2832
                     $path = $source . '/' . $file;
2833 2833
                     if (is_file($path)) {
2834
-                       /* if (!is_file($dest . '/' . $file) || $overwrite)
2834
+                        /* if (!is_file($dest . '/' . $file) || $overwrite)
2835 2835
                         if (!@copy($path, $dest . '/' . $file)) {
2836 2836
                             echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>';
2837 2837
                         }*/
@@ -2846,12 +2846,12 @@  discard block
 block discarded – undo
2846 2846
         }
2847 2847
     }
2848 2848
 
2849
-	/**
2850
-	 * Gets the new ID of one specific tool item from the tool name and the old ID
2851
-	 * @param	string	Tool name
2852
-	 * @param	integer	Old ID
2853
-	 * @return	integer	New ID
2854
-	 */
2849
+    /**
2850
+     * Gets the new ID of one specific tool item from the tool name and the old ID
2851
+     * @param	string	Tool name
2852
+     * @param	integer	Old ID
2853
+     * @return	integer	New ID
2854
+     */
2855 2855
     public function get_new_id($tool, $ref)
2856 2856
     {
2857 2857
         // Check if the value exist in the current array.
@@ -2873,25 +2873,25 @@  discard block
 block discarded – undo
2873 2873
         }
2874 2874
 
2875 2875
         return '';
2876
-	}
2876
+    }
2877 2877
 
2878
-	/**
2879
-	 * Restore glossary
2880
-	 */
2878
+    /**
2879
+     * Restore glossary
2880
+     */
2881 2881
     public function restore_glossary($session_id = 0)
2882 2882
     {
2883
-		if ($this->course->has_resources(RESOURCE_GLOSSARY)) {
2884
-			$table_glossary = Database :: get_course_table(TABLE_GLOSSARY);
2885
-			$resources = $this->course->resources;
2886
-			foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) {
2883
+        if ($this->course->has_resources(RESOURCE_GLOSSARY)) {
2884
+            $table_glossary = Database :: get_course_table(TABLE_GLOSSARY);
2885
+            $resources = $this->course->resources;
2886
+            foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) {
2887 2887
 
2888 2888
                 $params = [];
2889
-    			if (!empty($session_id)) {
2890
-    				$session_id = intval($session_id);
2889
+                if (!empty($session_id)) {
2890
+                    $session_id = intval($session_id);
2891 2891
                     $params['session_id'] = $session_id;
2892
-    			}
2892
+                }
2893 2893
 
2894
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
2894
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
2895 2895
                 $glossary->description = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2896 2896
                     $glossary->description,
2897 2897
                     $this->course->code,
@@ -2925,27 +2925,27 @@  discard block
 block discarded – undo
2925 2925
 
2926 2926
                     $this->course->resources[RESOURCE_GLOSSARY][$id]->destination_id = $my_id;
2927 2927
                 }
2928
-			}
2929
-		}
2930
-	}
2928
+            }
2929
+        }
2930
+    }
2931 2931
 
2932 2932
     /**
2933 2933
      * @param int $session_id
2934 2934
      */
2935 2935
     public function restore_wiki($session_id = 0)
2936 2936
     {
2937
-		if ($this->course->has_resources(RESOURCE_WIKI)) {
2938
-			// wiki table of the target course
2939
-			$table_wiki = Database :: get_course_table(TABLE_WIKI);
2940
-			$table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF);
2937
+        if ($this->course->has_resources(RESOURCE_WIKI)) {
2938
+            // wiki table of the target course
2939
+            $table_wiki = Database :: get_course_table(TABLE_WIKI);
2940
+            $table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF);
2941 2941
 
2942
-			// storing all the resources that have to be copied in an array
2943
-			$resources = $this->course->resources;
2942
+            // storing all the resources that have to be copied in an array
2943
+            $resources = $this->course->resources;
2944 2944
 
2945
-			foreach ($resources[RESOURCE_WIKI] as $id => $wiki) {
2946
-				// the sql statement to insert the groups from the old course to the new course
2945
+            foreach ($resources[RESOURCE_WIKI] as $id => $wiki) {
2946
+                // the sql statement to insert the groups from the old course to the new course
2947 2947
 
2948
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
2948
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
2949 2949
                 $wiki->content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2950 2950
                     $wiki->content,
2951 2951
                     $this->course->code,
@@ -2980,7 +2980,7 @@  discard block
 block discarded – undo
2980 2980
                     'user_ip' => '',
2981 2981
                 ];
2982 2982
 
2983
-				$new_id = Database::insert($table_wiki, $params);
2983
+                $new_id = Database::insert($table_wiki, $params);
2984 2984
 
2985 2985
                 if ($new_id) {
2986 2986
                     $sql = "UPDATE $table_wiki SET page_id = '$new_id', id = iid
@@ -3010,9 +3010,9 @@  discard block
 block discarded – undo
3010 3010
 
3011 3011
                     Database::insert($table_wiki_conf, $params);
3012 3012
                 }
3013
-			}
3014
-		}
3015
-	}
3013
+            }
3014
+        }
3015
+    }
3016 3016
 
3017 3017
     /**
3018 3018
      * Restore Thematics
@@ -3020,15 +3020,15 @@  discard block
 block discarded – undo
3020 3020
      */
3021 3021
     public function restore_thematic($session_id = 0)
3022 3022
     {
3023
-		if ($this->course->has_resources(RESOURCE_THEMATIC)) {
3023
+        if ($this->course->has_resources(RESOURCE_THEMATIC)) {
3024 3024
             $table_thematic = Database::get_course_table(TABLE_THEMATIC);
3025 3025
             $table_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
3026 3026
             $table_thematic_plan = Database::get_course_table(TABLE_THEMATIC_PLAN);
3027 3027
 
3028
-			$resources = $this->course->resources;
3029
-			foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) {
3028
+            $resources = $this->course->resources;
3029
+            foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) {
3030 3030
 
3031
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
3031
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
3032 3032
                 $thematic->params['content'] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
3033 3033
                     $thematic->params['content'],
3034 3034
                     $this->course->code,
@@ -3036,13 +3036,13 @@  discard block
 block discarded – undo
3036 3036
                     $this->course->backup_path,
3037 3037
                     $this->course->info['path']
3038 3038
                 );
3039
-				$thematic->params['c_id']  = $this->destination_course_id;
3040
-				unset($thematic->params['id']);
3039
+                $thematic->params['c_id']  = $this->destination_course_id;
3040
+                unset($thematic->params['id']);
3041 3041
                 unset($thematic->params['iid']);
3042 3042
 
3043
-				$last_id = Database::insert($table_thematic, $thematic->params, false);
3043
+                $last_id = Database::insert($table_thematic, $thematic->params, false);
3044 3044
 
3045
-				if ($last_id) {
3045
+                if ($last_id) {
3046 3046
 
3047 3047
                     $sql = "UPDATE $table_thematic SET id = iid WHERE iid = $last_id";
3048 3048
                     Database::query($sql);
@@ -3055,12 +3055,12 @@  discard block
 block discarded – undo
3055 3055
                         api_get_user_id()
3056 3056
                     );
3057 3057
 
3058
-					foreach ($thematic->thematic_advance_list as $thematic_advance) {
3059
-						unset($thematic_advance['id']);
3058
+                    foreach ($thematic->thematic_advance_list as $thematic_advance) {
3059
+                        unset($thematic_advance['id']);
3060 3060
                         unset($thematic_advance['iid']);
3061
-						$thematic_advance['attendance_id'] = 0;
3062
-						$thematic_advance['thematic_id'] = $last_id;
3063
-						$thematic_advance['c_id']  = $this->destination_course_id;
3061
+                        $thematic_advance['attendance_id'] = 0;
3062
+                        $thematic_advance['thematic_id'] = $last_id;
3063
+                        $thematic_advance['c_id']  = $this->destination_course_id;
3064 3064
 
3065 3065
                         $my_id = Database::insert(
3066 3066
                             $table_thematic_advance,
@@ -3068,7 +3068,7 @@  discard block
 block discarded – undo
3068 3068
                             false
3069 3069
                         );
3070 3070
 
3071
-						if ($my_id) {
3071
+                        if ($my_id) {
3072 3072
 
3073 3073
                             $sql = "UPDATE $table_thematic_advance SET id = iid WHERE iid = $my_id";
3074 3074
                             Database::query($sql);
@@ -3080,17 +3080,17 @@  discard block
 block discarded – undo
3080 3080
                                 'ThematicAdvanceAdded',
3081 3081
                                 api_get_user_id()
3082 3082
                             );
3083
-						}
3084
-					}
3083
+                        }
3084
+                    }
3085 3085
 
3086
-					foreach($thematic->thematic_plan_list as $thematic_plan) {
3087
-						unset($thematic_plan['id']);
3086
+                    foreach($thematic->thematic_plan_list as $thematic_plan) {
3087
+                        unset($thematic_plan['id']);
3088 3088
                         unset($thematic_plan['iid']);
3089
-						$thematic_plan['thematic_id'] = $last_id;
3090
-						$thematic_plan['c_id'] = $this->destination_course_id;
3091
-						$my_id = Database::insert($table_thematic_plan, $thematic_plan, false);
3089
+                        $thematic_plan['thematic_id'] = $last_id;
3090
+                        $thematic_plan['c_id'] = $this->destination_course_id;
3091
+                        $my_id = Database::insert($table_thematic_plan, $thematic_plan, false);
3092 3092
 
3093
-						if ($my_id) {
3093
+                        if ($my_id) {
3094 3094
 
3095 3095
                             $sql = "UPDATE $table_thematic_plan SET id = iid WHERE iid = $my_id";
3096 3096
                             Database::query($sql);
@@ -3102,12 +3102,12 @@  discard block
 block discarded – undo
3102 3102
                                 'ThematicPlanAdded',
3103 3103
                                 api_get_user_id()
3104 3104
                             );
3105
-						}
3106
-					}
3107
-				}
3108
-			}
3109
-		}
3110
-	}
3105
+                        }
3106
+                    }
3107
+                }
3108
+            }
3109
+        }
3110
+    }
3111 3111
 
3112 3112
     /**
3113 3113
      * Restore Attendance
@@ -3115,14 +3115,14 @@  discard block
 block discarded – undo
3115 3115
      */
3116 3116
     public function restore_attendance($session_id = 0)
3117 3117
     {
3118
-		if ($this->course->has_resources(RESOURCE_ATTENDANCE)) {
3119
-			$table_attendance = Database :: get_course_table(TABLE_ATTENDANCE);
3120
-			$table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR);
3118
+        if ($this->course->has_resources(RESOURCE_ATTENDANCE)) {
3119
+            $table_attendance = Database :: get_course_table(TABLE_ATTENDANCE);
3120
+            $table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR);
3121 3121
 
3122
-			$resources = $this->course->resources;
3123
-			foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) {
3122
+            $resources = $this->course->resources;
3123
+            foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) {
3124 3124
 
3125
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
3125
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
3126 3126
                 $obj->params['description'] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
3127 3127
                     $obj->params['description'],
3128 3128
                     $this->course->code,
@@ -3134,11 +3134,11 @@  discard block
 block discarded – undo
3134 3134
                 unset($obj->params['id']);
3135 3135
                 unset($obj->params['iid']);
3136 3136
 
3137
-				$obj->params['c_id'] = $this->destination_course_id;
3137
+                $obj->params['c_id'] = $this->destination_course_id;
3138 3138
 
3139
-				$last_id = Database::insert($table_attendance, $obj->params);
3139
+                $last_id = Database::insert($table_attendance, $obj->params);
3140 3140
 
3141
-				if (is_numeric($last_id)) {
3141
+                if (is_numeric($last_id)) {
3142 3142
 
3143 3143
                     $sql = "UPDATE $table_attendance SET id = iid WHERE iid = $last_id";
3144 3144
                     Database::query($sql);
@@ -3152,11 +3152,11 @@  discard block
 block discarded – undo
3152 3152
                     );
3153 3153
 
3154 3154
                     foreach ($obj->attendance_calendar as $attendance_calendar) {
3155
-						unset($attendance_calendar['id']);
3155
+                        unset($attendance_calendar['id']);
3156 3156
                         unset($attendance_calendar['iid']);
3157 3157
 
3158
-						$attendance_calendar['attendance_id'] = $last_id;
3159
-						$attendance_calendar['c_id'] = $this->destination_course_id;
3158
+                        $attendance_calendar['attendance_id'] = $last_id;
3159
+                        $attendance_calendar['c_id'] = $this->destination_course_id;
3160 3160
                         $attendanceCalendarId = Database::insert(
3161 3161
                             $table_attendance_calendar,
3162 3162
                             $attendance_calendar
@@ -3164,11 +3164,11 @@  discard block
 block discarded – undo
3164 3164
 
3165 3165
                         $sql = "UPDATE $table_attendance_calendar SET id = iid WHERE iid = $attendanceCalendarId";
3166 3166
                         Database::query($sql);
3167
-					}
3168
-				}
3169
-			}
3170
-		}
3171
-	}
3167
+                    }
3168
+                }
3169
+            }
3170
+        }
3171
+    }
3172 3172
 
3173 3173
     /**
3174 3174
      * Restore Works
@@ -3340,11 +3340,11 @@  discard block
 block discarded – undo
3340 3340
      */
3341 3341
     public function DBUTF8($str)
3342 3342
     {
3343
-		if (UTF8_CONVERT) {
3343
+        if (UTF8_CONVERT) {
3344 3344
             $str = utf8_encode($str);
3345 3345
         }
3346
-		return $str;
3347
-	}
3346
+        return $str;
3347
+    }
3348 3348
 
3349 3349
     /**
3350 3350
      * @param string $str
@@ -3355,8 +3355,8 @@  discard block
 block discarded – undo
3355 3355
         if (UTF8_CONVERT) {
3356 3356
             $str = utf8_encode($str);
3357 3357
         }
3358
-		return Database::escape_string($str);
3359
-	}
3358
+        return Database::escape_string($str);
3359
+    }
3360 3360
 
3361 3361
     /**
3362 3362
      * @param array $array
Please login to merge, or discard this patch.
main/ticket/status.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -173,7 +173,7 @@
 block discarded – undo
173 173
         );
174 174
     }
175 175
 
176
-	return $result;
176
+    return $result;
177 177
 }
178 178
 
179 179
 $table->set_header(0, '', false);
Please login to merge, or discard this patch.
main/ticket/priorities.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -173,7 +173,7 @@
 block discarded – undo
173 173
         );
174 174
     }
175 175
 
176
-	return $result;
176
+    return $result;
177 177
 }
178 178
 
179 179
 $table->set_header(0, '', false);
Please login to merge, or discard this patch.
src/Chamilo/UserBundle/Entity/Repository/UserRepository.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,10 +26,10 @@
 block discarded – undo
26 26
 class UserRepository extends EntityRepository
27 27
 {
28 28
     /**
29
-    * @param string $keyword
29
+     * @param string $keyword
30 30
      *
31
-    * @return mixed
32
-    */
31
+     * @return mixed
32
+     */
33 33
     public function searchUserByKeyword($keyword)
34 34
     {
35 35
         $qb = $this->createQueryBuilder('a');
Please login to merge, or discard this patch.
main/gradebook/lib/fe/exportgradebook.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
  */
15 15
 function print_table($data_array,$header_names,$view,$coursename)
16 16
 {
17
-	$printdata = '<!DOCTYPE html
17
+    $printdata = '<!DOCTYPE html
18 18
      PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
19 19
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
20 20
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'.api_get_language_isocode().'" lang="'.api_get_language_isocode().'">
@@ -98,13 +98,13 @@  discard block
 block discarded – undo
98 98
 function export_pdf_attendance($headers_table, $data_table, $headers_pdf, $footers_pdf, $title_pdf)
99 99
 {
100 100
     $mpdf = new mPDF('UTF-8', 'A4-L', '', '', 15, 10, 35, 20, 4, 2, 'L');
101
-	$mpdf->useOnlyCoreFonts = true;
102
-	$mpdf->mirrorMargins = 0;
101
+    $mpdf->useOnlyCoreFonts = true;
102
+    $mpdf->mirrorMargins = 0;
103 103
     // Use different Odd/Even headers and footers and mirror margins
104 104
 
105
-	if (is_array($headers_pdf)) {
106
-		// preparing headers pdf
107
-		$header = '
105
+    if (is_array($headers_pdf)) {
106
+        // preparing headers pdf
107
+        $header = '
108 108
             <table width="100%"  cellspacing="1" cellpadding="1" border="0" class="strong">
109 109
             <tr>
110 110
                 <td ROWSPAN="3" style="text-align: left;" class="title">
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
         $items_per_page = count($data_table);
160 160
     }
161 161
 
162
-	$count_pages = ceil(count($data_table) / $items_per_page);
162
+    $count_pages = ceil(count($data_table) / $items_per_page);
163 163
     $content_table = '';
164 164
     for ($x = 0; $x<$count_pages; $x++) {
165 165
         $content_table .= '<table width="100%" border="1" style="border-collapse:collapse">';
@@ -327,10 +327,10 @@  discard block
 block discarded – undo
327 327
  */
328 328
 function export_pdf($pdf, $newarray, $header_names, $format)
329 329
 {
330
-	$pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm');
331
-	$pdf->ezSetCmMargins(0,0,0,0);
332
-	$pdf->ezSetY(($format=='portrait')?'820':'570');
333
-	$pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm');
330
+    $pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm');
331
+    $pdf->ezSetCmMargins(0,0,0,0);
332
+    $pdf->ezSetY(($format=='portrait')?'820':'570');
333
+    $pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm');
334 334
     if ($format == 'portrait') {
335 335
         $pdf->line(40, 790, 540, 790);
336 336
         $pdf->line(40, 40, 540, 40);
@@ -346,5 +346,5 @@  discard block
 block discarded – undo
346 346
         'rowGap' => 3,
347 347
         'width' => (($format == 'portrait') ? '500' : '750'),
348 348
     ));
349
-	$pdf->ezStream();
349
+    $pdf->ezStream();
350 350
 }
Please login to merge, or discard this patch.