Completed
Push — 1.10.x ( f2aaaf...ef00db )
by Yannick
241:15 queued 197:35
created
main/coursecopy/classes/CourseSession.class.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -11,24 +11,24 @@
 block discarded – undo
11 11
 class CourseSession extends Coursecopy\Resource
12 12
 {
13 13
     // The title session
14
-	public $title;
14
+    public $title;
15 15
 
16
-	/**
17
-	 * Create a new Session
18
-	 * @param int $id
19
-	 * @param string $title
20
-	 */
21
-	public function __construct($id,$title)
22
-	{
23
-		parent::__construct($id, RESOURCE_SESSION_COURSE);
24
-		$this->title = $title;
25
-	}
16
+    /**
17
+     * Create a new Session
18
+     * @param int $id
19
+     * @param string $title
20
+     */
21
+    public function __construct($id,$title)
22
+    {
23
+        parent::__construct($id, RESOURCE_SESSION_COURSE);
24
+        $this->title = $title;
25
+    }
26 26
 
27
-	/**
28
-	 * Show this Event
29
-	 */
30
-	function show() {
31
-		parent::show();
32
-		echo $this->title;
33
-	}
27
+    /**
28
+     * Show this Event
29
+     */
30
+    function show() {
31
+        parent::show();
32
+        echo $this->title;
33
+    }
34 34
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 	 * @param int $id
19 19
 	 * @param string $title
20 20
 	 */
21
-	public function __construct($id,$title)
21
+	public function __construct($id, $title)
22 22
 	{
23 23
 		parent::__construct($id, RESOURCE_SESSION_COURSE);
24 24
 		$this->title = $title;
Please login to merge, or discard this patch.
main/coursecopy/classes/ForumTopic.class.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,6 +47,6 @@
 block discarded – undo
47 47
             $user_info = api_get_user_info($this->obj->thread_poster_id);
48 48
             $extra = $user_info['complete_name'].', '.$extra;
49 49
         }
50
-        echo $this->obj->thread_title . ' (' . $extra . ')';
50
+        echo $this->obj->thread_title.' ('.$extra.')';
51 51
     }
52 52
 }
Please login to merge, or discard this patch.
main/coursecopy/classes/CourseRestorer.class.php 4 patches
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
                                             $this->course->backup_path,
521 521
                                             $this->course->info['path']
522 522
                                         );
523
-                                        file_put_contents($path.$document->path,$content);
523
+                                        file_put_contents($path.$document->path, $content);
524 524
                                     }
525 525
 
526 526
                                     $params = [
@@ -564,14 +564,14 @@  discard block
 block discarded – undo
564 564
 								$new_file_name = $file_name_no_ext.'_'.$i.$ext;
565 565
 								$file_exists = file_exists($path.$new_file_name);
566 566
 								while ($file_exists) {
567
-									$i ++;
567
+									$i++;
568 568
 									$new_file_name = $file_name_no_ext.'_'.$i.$ext;
569 569
 									$file_exists = file_exists($path.$new_file_name);
570 570
 								}
571 571
 
572 572
 								if (!empty($session_id)) {
573 573
 
574
-									$document_path = explode('/',$document->path,3);
574
+									$document_path = explode('/', $document->path, 3);
575 575
 									$course_path = $path;
576 576
 									$orig_base_folder = $document_path[1];
577 577
 									$orig_base_path   = $course_path.$document_path[0].'/'.$document_path[1];
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 
590 590
 										$folder_exists = file_exists($new_base_path);
591 591
 										if ($folder_exists) {
592
-											$_SESSION['orig_base_foldername'] = $new_base_foldername; 		// e.g: carpeta1 in session
592
+											$_SESSION['orig_base_foldername'] = $new_base_foldername; // e.g: carpeta1 in session
593 593
 											$x = '';
594 594
 											while ($folder_exists) {
595 595
 												$x = $x + 1;
@@ -609,9 +609,9 @@  discard block
 block discarded – undo
609 609
 											$new_base_path = $_SESSION['new_base_path'];
610 610
 										}
611 611
 
612
-										$dest_document_path = $new_base_path.'/'.$document_path[2];		// e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png"
613
-										$basedir_dest_path 	= dirname($dest_document_path);				// e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1"
614
-										$base_path_document = $course_path.$document_path[0];			// e.g: "/var/www/wiener/courses/CURSO4/document"
612
+										$dest_document_path = $new_base_path.'/'.$document_path[2]; // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png"
613
+										$basedir_dest_path 	= dirname($dest_document_path); // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1"
614
+										$base_path_document = $course_path.$document_path[0]; // e.g: "/var/www/wiener/courses/CURSO4/document"
615 615
 
616 616
 										$path_title = '/'.$new_base_foldername.'/'.$document_path[2];
617 617
 
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
                                         //Replace old course code with the new destination code see BT#1985
632 632
                                         if (file_exists($dest_document_path)) {
633 633
                                             $file_info = pathinfo($dest_document_path);
634
-                                            if (in_array($file_info['extension'], array('html','htm'))) {
634
+                                            if (in_array($file_info['extension'], array('html', 'htm'))) {
635 635
                                                 $content = file_get_contents($dest_document_path);
636 636
                                                 if (UTF8_CONVERT) {
637 637
                                                     $content = utf8_encode($content);
@@ -687,8 +687,8 @@  discard block
 block discarded – undo
687 687
                                         //Replace old course code with the new destination code see BT#1985
688 688
                                         if (file_exists($path.$new_file_name)) {
689 689
                                             $file_info = pathinfo($path.$new_file_name);
690
-                                            if (in_array($file_info['extension'], array('html','htm'))) {
691
-                                                $content    = file_get_contents($path.$new_file_name);
690
+                                            if (in_array($file_info['extension'], array('html', 'htm'))) {
691
+                                                $content = file_get_contents($path.$new_file_name);
692 692
                                                 if (UTF8_CONVERT) {
693 693
                                                     $content = utf8_encode($content);
694 694
                                                 }
@@ -741,8 +741,8 @@  discard block
 block discarded – undo
741 741
                                     //Replace old course code with the new destination code see BT#1985
742 742
                                     if (file_exists($path.$new_file_name)) {
743 743
                                         $file_info = pathinfo($path.$new_file_name);
744
-                                        if (in_array($file_info['extension'], array('html','htm'))) {
745
-                                            $content    = file_get_contents($path.$new_file_name);
744
+                                        if (in_array($file_info['extension'], array('html', 'htm'))) {
745
+                                            $content = file_get_contents($path.$new_file_name);
746 746
                                             if (UTF8_CONVERT) {
747 747
                                                 $content = utf8_encode($content);
748 748
                                             }
@@ -805,8 +805,8 @@  discard block
 block discarded – undo
805 805
                             //Replace old course code with the new destination code see BT#1985
806 806
                             if (file_exists($path.$document->path)) {
807 807
                                 $file_info = pathinfo($path.$document->path);
808
-                                if (in_array($file_info['extension'], array('html','htm'))) {
809
-                                    $content    = file_get_contents($path.$document->path);
808
+                                if (in_array($file_info['extension'], array('html', 'htm'))) {
809
+                                    $content = file_get_contents($path.$document->path);
810 810
                                     if (UTF8_CONVERT) {
811 811
                                         $content = utf8_encode($content);
812 812
                                     }
@@ -896,8 +896,8 @@  discard block
 block discarded – undo
896 896
 						case FILE_OVERWRITE:
897 897
 							rmdirr($path.$document->path);
898 898
                             copyDirTo(
899
-                                $this->course->backup_path . '/' . $document->path,
900
-                                $path . dirname($document->path),
899
+                                $this->course->backup_path.'/'.$document->path,
900
+                                $path.dirname($document->path),
901 901
                                 false
902 902
                             );
903 903
 							break;
@@ -919,23 +919,23 @@  discard block
 block discarded – undo
919 919
 							$file_exists = file_exists($path.$new_file_name);
920 920
 
921 921
 							while ($file_exists) {
922
-								$i ++;
922
+								$i++;
923 923
 								$new_file_name = $file_name_no_ext.'_'.$i.$ext;
924 924
 								$file_exists = file_exists($path.$new_file_name);
925 925
 							}
926 926
 
927 927
                             rename(
928
-                                $this->course->backup_path . '/' . $document->path,
929
-                                $this->course->backup_path . '/' . $new_file_name
928
+                                $this->course->backup_path.'/'.$document->path,
929
+                                $this->course->backup_path.'/'.$new_file_name
930 930
                             );
931 931
                             copyDirTo(
932
-                                $this->course->backup_path . '/' . $new_file_name,
933
-                                $path . dirname($new_file_name),
932
+                                $this->course->backup_path.'/'.$new_file_name,
933
+                                $path.dirname($new_file_name),
934 934
                                 false
935 935
                             );
936 936
                             rename(
937
-                                $this->course->backup_path . '/' . $new_file_name,
938
-                                $this->course->backup_path . '/' . $document->path
937
+                                $this->course->backup_path.'/'.$new_file_name,
938
+                                $this->course->backup_path.'/'.$document->path
939 939
                             );
940 940
 
941 941
 							break;
@@ -943,8 +943,8 @@  discard block
 block discarded – undo
943 943
 				} else {
944 944
                     // end if file exists
945 945
                     copyDirTo(
946
-                        $this->course->backup_path . '/' . $document->path,
947
-                        $path . dirname($document->path),
946
+                        $this->course->backup_path.'/'.$document->path,
947
+                        $path.dirname($document->path),
948 948
                         false
949 949
                     );
950 950
 				}
@@ -962,7 +962,7 @@  discard block
 block discarded – undo
962 962
 			$table_forum = Database::get_course_table(TABLE_FORUM);
963 963
 			$resources = $this->course->resources;
964 964
 			foreach ($resources[RESOURCE_FORUM] as $id => $forum) {
965
-                $params = (array)$forum->obj;
965
+                $params = (array) $forum->obj;
966 966
                 $cat_id = '';
967 967
                 if (isset($this->course->resources[RESOURCE_FORUMCATEGORY]) &&
968 968
                     isset($this->course->resources[RESOURCE_FORUMCATEGORY][$params['forum_category']])) {
@@ -1014,13 +1014,13 @@  discard block
 block discarded – undo
1014 1014
 					foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) {
1015 1015
 						if ($topic->obj->forum_id == $id) {
1016 1016
 							$this->restore_topic($topic_id, $new_id, $sessionId);
1017
-							$forum_topics ++;
1017
+							$forum_topics++;
1018 1018
 						}
1019 1019
 					}
1020 1020
 				}
1021 1021
 				if ($forum_topics > 0) {
1022 1022
 					$sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics."
1023
-                            WHERE c_id = {$this->destination_course_id} AND forum_id = ".(int)$new_id;
1023
+                            WHERE c_id = {$this->destination_course_id} AND forum_id = ".(int) $new_id;
1024 1024
 					Database::query($sql);
1025 1025
 				}
1026 1026
 			}
@@ -1090,13 +1090,13 @@  discard block
 block discarded – undo
1090 1090
 		$table = Database :: get_course_table(TABLE_FORUM_THREAD);
1091 1091
 		$topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id];
1092 1092
 
1093
-        $params = (array)$topic->obj;
1093
+        $params = (array) $topic->obj;
1094 1094
         $params = self::DBUTF8_array($params);
1095 1095
         $params['c_id'] = $this->destination_course_id;
1096 1096
         $params['forum_id'] = $forum_id;
1097 1097
         $params['thread_poster_id'] = $this->first_teacher_id;
1098 1098
         $params['thread_date'] = api_get_utc_datetime();
1099
-        $params['thread_close_date']  = '0000-00-00 00:00:00';
1099
+        $params['thread_close_date'] = '0000-00-00 00:00:00';
1100 1100
         $params['thread_last_post'] = 0;
1101 1101
         $params['thread_replies'] = 0;
1102 1102
         $params['thread_views'] = 0;
@@ -1202,7 +1202,7 @@  discard block
 block discarded – undo
1202 1202
 				        FROM $link_table
1203 1203
 				        WHERE
1204 1204
 				            c_id = ".$this->destination_course_id." AND
1205
-				            category_id='" . intval($cat_id). "'";
1205
+				            category_id='" . intval($cat_id)."'";
1206 1206
 				$result = Database::query($sql);
1207 1207
     			list($max_order) = Database::fetch_array($result);
1208 1208
 
@@ -1217,7 +1217,7 @@  discard block
 block discarded – undo
1217 1217
                 $params['description'] = self::DBUTF8($link->description);
1218 1218
                 $params['category_id'] = $cat_id;
1219 1219
                 $params['on_homepage'] = $link->on_homepage;
1220
-                $params['display_order'] = $max_order+1;
1220
+                $params['display_order'] = $max_order + 1;
1221 1221
 
1222 1222
                 $id = Database::insert($link_table, $params);
1223 1223
 
@@ -1261,9 +1261,9 @@  discard block
 block discarded – undo
1261 1261
         if (is_object($link_cat) && !$link_cat->is_restored()) {
1262 1262
             $sql = "SELECT MAX(display_order) FROM  $link_cat_table
1263 1263
 			        WHERE c_id = ".$this->destination_course_id." ";
1264
-            $result=Database::query($sql);
1265
-            list($orderMax)=Database::fetch_array($result,'NUM');
1266
-            $display_order=$orderMax+1;
1264
+            $result = Database::query($sql);
1265
+            list($orderMax) = Database::fetch_array($result, 'NUM');
1266
+            $display_order = $orderMax + 1;
1267 1267
 
1268 1268
             $params['c_id'] = $this->destination_course_id;
1269 1269
             $params['category_title'] = self::DBUTF8($link_cat->title);
@@ -1639,9 +1639,9 @@  discard block
 block discarded – undo
1639 1639
                 if (!empty($quiz->sound)) {
1640 1640
                     if (isset($this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]) &&
1641 1641
                         $this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]->is_restored()) {
1642
-                        $sql = "SELECT path FROM " . $table_doc . "
1642
+                        $sql = "SELECT path FROM ".$table_doc."
1643 1643
                                 WHERE
1644
-                                    c_id = " . $this->destination_course_id . "  AND
1644
+                                    c_id = " . $this->destination_course_id."  AND
1645 1645
                                     id = " . $resources[RESOURCE_DOCUMENT][$quiz->sound]->destination_id;
1646 1646
 						$doc = Database::query($sql);
1647 1647
 						$doc = Database::fetch_object($doc);
@@ -1675,19 +1675,19 @@  discard block
 block discarded – undo
1675 1675
                         'random' => $quiz->random,
1676 1676
                         'active' => $quiz->active,
1677 1677
                         'sound' => self::DBUTF8($doc),
1678
-                        'max_attempt' => (int)$quiz->max_attempt,
1679
-                        'results_disabled' => (int)$quiz->results_disabled,
1678
+                        'max_attempt' => (int) $quiz->max_attempt,
1679
+                        'results_disabled' => (int) $quiz->results_disabled,
1680 1680
                         'access_condition' => $quiz->access_condition,
1681 1681
                         'start_time' => $quiz->start_time,
1682 1682
                         'pass_percentage' => $quiz->pass_percentage,
1683 1683
                         'end_time' => $quiz->end_time,
1684
-                        'feedback_type' => (int)$quiz->feedback_type,
1685
-                        'random_answers' => (int)$quiz->random_answers,
1684
+                        'feedback_type' => (int) $quiz->feedback_type,
1685
+                        'random_answers' => (int) $quiz->random_answers,
1686 1686
                         'random_by_category' => $quiz->random_by_category,
1687 1687
                         'review_answers' => $quiz->review_answers,
1688 1688
                         'propagate_neg' => $quiz->propagate_neg,
1689 1689
                         'text_when_finished' => $quiz->text_when_finished,
1690
-                        'expired_time' => (int)$quiz->expired_time,
1690
+                        'expired_time' => (int) $quiz->expired_time,
1691 1691
                     );
1692 1692
 
1693 1693
                     if ($respect_base_content) {
@@ -1723,9 +1723,9 @@  discard block
 block discarded – undo
1723 1723
                         $qid = $this->restore_quiz_question($question_id);
1724 1724
                         $question_order = $quiz->question_orders[$index] ? $quiz->question_orders[$index] : ++$order;
1725 1725
                         $sql = "INSERT IGNORE INTO $table_rel SET
1726
-                                c_id = " . $this->destination_course_id . ",
1727
-                                question_id = " . $qid . ",
1728
-                                exercice_id = " . $new_id . ",
1726
+                                c_id = ".$this->destination_course_id.",
1727
+                                question_id = " . $qid.",
1728
+                                exercice_id = " . $new_id.",
1729 1729
                                 question_order = " . $question_order;
1730 1730
                         Database::query($sql);
1731 1731
                     }
@@ -1800,7 +1800,7 @@  discard block
 block discarded – undo
1800 1800
                             $sql = "UPDATE $table_que SET
1801 1801
                                         picture = '$picture_name'
1802 1802
                                     WHERE
1803
-                                        c_id = " . $this->destination_course_id . " AND
1803
+                                        c_id = ".$this->destination_course_id." AND
1804 1804
                                         id = $new_id ";
1805 1805
                             Database::query($sql);
1806 1806
                         }
@@ -1955,7 +1955,7 @@  discard block
 block discarded – undo
1955 1955
                             }
1956 1956
                         }
1957 1957
 
1958
-                        foreach($correct_answers as $answer_id => $correct_answer) {
1958
+                        foreach ($correct_answers as $answer_id => $correct_answer) {
1959 1959
                             $params = array();
1960 1960
                             $params['correct'] = $new_options[$correct_answer];
1961 1961
                             Database::update(
@@ -1989,7 +1989,7 @@  discard block
 block discarded – undo
1989 1989
         $tab_test_category_id_old_new = array(); // used to build the quiz_question_rel_category table
1990 1990
         if ($this->course->has_resources(RESOURCE_TEST_CATEGORY)) {
1991 1991
             $resources = $this->course->resources;
1992
-            foreach ($resources[RESOURCE_TEST_CATEGORY] as $id => $CourseCopyTestcategory ) {
1992
+            foreach ($resources[RESOURCE_TEST_CATEGORY] as $id => $CourseCopyTestcategory) {
1993 1993
                 $tab_test_category_id_old_new[$CourseCopyTestcategory->source_id] = $id;
1994 1994
                 // check if this test_category already exist in the destination BDD
1995 1995
                 // do not Database::escape_string $title and $description, it will be done later
@@ -2135,7 +2135,7 @@  discard block
 block discarded – undo
2135 2135
 							break;
2136 2136
 						case FILE_RENAME:
2137 2137
 							$survey_code = $survey->code.'_';
2138
-							$i=1;
2138
+							$i = 1;
2139 2139
 							$temp_survey_code = $survey_code.$i;
2140 2140
 							while (!$this->is_survey_code_available($temp_survey_code)) {
2141 2141
 								$temp_survey_code = $survey_code.++$i;
@@ -2167,15 +2167,15 @@  discard block
 block discarded – undo
2167 2167
 							$sql = "SELECT * FROM $table_sur
2168 2168
 							        WHERE
2169 2169
 							            c_id = ".$this->destination_course_id." AND
2170
-							            survey_id='".self::DBUTF8escapestring(Database::result($result_check,0,0))."'";
2170
+							            survey_id='".self::DBUTF8escapestring(Database::result($result_check, 0, 0))."'";
2171 2171
 							$result = Database::query($sql);
2172
-							$survey_data = Database::fetch_array($result,'ASSOC');
2172
+							$survey_data = Database::fetch_array($result, 'ASSOC');
2173 2173
 
2174 2174
 							// if the survey is shared => also delete the shared content
2175 2175
 							if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) {
2176
-                                SurveyManager::delete_survey($survey_data['survey_share'], true,$this->destination_course_id);
2176
+                                SurveyManager::delete_survey($survey_data['survey_share'], true, $this->destination_course_id);
2177 2177
 							}
2178
-							SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id);
2178
+							SurveyManager :: delete_survey($survey_data['survey_id'], false, $this->destination_course_id);
2179 2179
 
2180 2180
 							// Insert the new source survey
2181 2181
                             $new_id = Database::insert($table_sur, $params);
@@ -2251,7 +2251,7 @@  discard block
 block discarded – undo
2251 2251
 		$resources = $this->course->resources;
2252 2252
 		$question = $resources[RESOURCE_SURVEYQUESTION][$id];
2253 2253
 
2254
-		$new_id=0;
2254
+		$new_id = 0;
2255 2255
 
2256 2256
 		if (is_object($question)) {
2257 2257
 			if ($question->is_restored()) {
@@ -2356,14 +2356,14 @@  discard block
 block discarded – undo
2356 2356
 
2357 2357
 				// Adding the author's image
2358 2358
 				if (!empty($lp->preview_image)) {
2359
-					$new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image));
2359
+					$new_filename = uniqid('').substr($lp->preview_image, strlen($lp->preview_image) - 7, strlen($lp->preview_image));
2360 2360
 					if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) {
2361 2361
 						$copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename);
2362 2362
 						//$copy_result = true;
2363 2363
 						if ($copy_result) {
2364 2364
 							$lp->preview_image = $new_filename;
2365 2365
 						} else {
2366
-							$lp->preview_image ='';
2366
+							$lp->preview_image = '';
2367 2367
 						}
2368 2368
 					}
2369 2369
 				}
@@ -2524,20 +2524,20 @@  discard block
 block discarded – undo
2524 2524
 					$next_item_ids[$new_item_id] = $item['next_item_id'];
2525 2525
 
2526 2526
 					if (!empty($item['prerequisite'])) {
2527
-						if ($lp->lp_type =='2') {
2527
+						if ($lp->lp_type == '2') {
2528 2528
 							// if is an sco
2529
-							$old_prerequisite[$new_item_id]= $item['prerequisite'];
2529
+							$old_prerequisite[$new_item_id] = $item['prerequisite'];
2530 2530
 						} else {
2531
-							$old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']];
2531
+							$old_prerequisite[$new_item_id] = $new_item_ids[$item['prerequisite']];
2532 2532
 						}
2533 2533
 					}
2534 2534
 
2535 2535
 					if (!empty($ref)) {
2536
-						if ($lp->lp_type =='2') {
2536
+						if ($lp->lp_type == '2') {
2537 2537
 							// if is an sco
2538
-							$old_refs[$new_item_id]= $ref;
2538
+							$old_refs[$new_item_id] = $ref;
2539 2539
 						} else {
2540
-                            $old_refs[$new_item_id]= $new_item_ids[$ref];
2540
+                            $old_refs[$new_item_id] = $new_item_ids[$ref];
2541 2541
 						}
2542 2542
 					}
2543 2543
 
@@ -2546,7 +2546,7 @@  discard block
 block discarded – undo
2546 2546
 
2547 2547
 				// Updating prerequisites
2548 2548
 				foreach ($old_prerequisite  as $key=>$my_old_prerequisite) {
2549
-					if($my_old_prerequisite != ''){
2549
+					if ($my_old_prerequisite != '') {
2550 2550
 						$sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."'
2551 2551
 						        WHERE c_id = ".$this->destination_course_id." AND id = '".$key."'  ";
2552 2552
 						Database::query($sql);
@@ -2564,7 +2564,7 @@  discard block
 block discarded – undo
2564 2564
 
2565 2565
 				foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) {
2566 2566
 					$parent_new_id = 0;
2567
-					if($parent_item_old_id != 0){
2567
+					if ($parent_item_old_id != 0) {
2568 2568
 						$parent_new_id = $new_item_ids[$parent_item_old_id];
2569 2569
 					}
2570 2570
 					$sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."'
@@ -2573,7 +2573,7 @@  discard block
 block discarded – undo
2573 2573
 				}
2574 2574
 				foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) {
2575 2575
 					$previous_new_id = 0;
2576
-					if($previous_item_old_id != 0){
2576
+					if ($previous_item_old_id != 0) {
2577 2577
 						$previous_new_id = $new_item_ids[$previous_item_old_id];
2578 2578
 					}
2579 2579
 					$sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."'
@@ -2583,7 +2583,7 @@  discard block
 block discarded – undo
2583 2583
 
2584 2584
 				foreach ($next_item_ids as $new_item_id => $next_item_old_id) {
2585 2585
 					$next_new_id = 0;
2586
-					if($next_item_old_id != 0){
2586
+					if ($next_item_old_id != 0) {
2587 2587
 						$next_new_id = $new_item_ids[$next_item_old_id];
2588 2588
 					}
2589 2589
 					$sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."'
@@ -2593,7 +2593,7 @@  discard block
 block discarded – undo
2593 2593
 
2594 2594
 				foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) {
2595 2595
 					$prerequisite_new_id = 0;
2596
-					if($prerequisite_old_id != 0){
2596
+					if ($prerequisite_old_id != 0) {
2597 2597
 						$prerequisite_new_id = $new_item_ids[$prerequisite_old_id];
2598 2598
 					}
2599 2599
 					$sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."'
@@ -2613,9 +2613,9 @@  discard block
 block discarded – undo
2613 2613
 	public function restore_student_publication($sessionId = 0)
2614 2614
     {
2615 2615
         $sessionId = intval($sessionId);
2616
-		$work_assignment_table  = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
2616
+		$work_assignment_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
2617 2617
 		$work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
2618
-		$item_property_table  	= Database :: get_course_table(TABLE_ITEM_PROPERTY);
2618
+		$item_property_table = Database :: get_course_table(TABLE_ITEM_PROPERTY);
2619 2619
 
2620 2620
 		// Query in student publication
2621 2621
 		$sql = 'SELECT * FROM '.$work_table.'
@@ -2693,7 +2693,7 @@  discard block
 block discarded – undo
2693 2693
 
2694 2694
 		$destination = '../../courses/'.$this->course->destination_path.'/work/';
2695 2695
 		$origin = '../../courses/'.$this->course->info['path'].'/work/';
2696
-		self::allow_create_all_directory($origin,$destination,false);
2696
+		self::allow_create_all_directory($origin, $destination, false);
2697 2697
 	}
2698 2698
 
2699 2699
     /**
@@ -2712,16 +2712,16 @@  discard block
 block discarded – undo
2712 2712
         if ($handle = opendir($source)) {        // if the folder exploration is sucsessful, continue
2713 2713
             while (false !== ($file = readdir($handle))) { // as long as storing the next file to $file is successful, continue
2714 2714
                 if ($file != '.' && $file != '..') {
2715
-                    $path = $source . '/' . $file;
2715
+                    $path = $source.'/'.$file;
2716 2716
                     if (is_file($path)) {
2717 2717
                        /* if (!is_file($dest . '/' . $file) || $overwrite)
2718 2718
                         if (!@copy($path, $dest . '/' . $file)) {
2719 2719
                             echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>';
2720 2720
                         }*/
2721
-                    } elseif(is_dir($path)) {
2722
-                        if (!is_dir($dest . '/' . $file))
2723
-                        mkdir($dest . '/' . $file);
2724
-                       self:: allow_create_all_directory($path, $dest . '/' . $file, $overwrite);
2721
+                    } elseif (is_dir($path)) {
2722
+                        if (!is_dir($dest.'/'.$file))
2723
+                        mkdir($dest.'/'.$file);
2724
+                       self:: allow_create_all_directory($path, $dest.'/'.$file, $overwrite);
2725 2725
                     }
2726 2726
                 }
2727 2727
             }
@@ -2908,7 +2908,7 @@  discard block
 block discarded – undo
2908 2908
                     $this->course->backup_path,
2909 2909
                     $this->course->info['path']
2910 2910
                 );
2911
-				$thematic->params['c_id']  = $this->destination_course_id;
2911
+				$thematic->params['c_id'] = $this->destination_course_id;
2912 2912
 				unset($thematic->params['id']);
2913 2913
                 unset($thematic->params['iid']);
2914 2914
 
@@ -2932,7 +2932,7 @@  discard block
 block discarded – undo
2932 2932
                         unset($thematic_advance['iid']);
2933 2933
 						$thematic_advance['attendance_id'] = 0;
2934 2934
 						$thematic_advance['thematic_id'] = $last_id;
2935
-						$thematic_advance['c_id']  = $this->destination_course_id;
2935
+						$thematic_advance['c_id'] = $this->destination_course_id;
2936 2936
                         $my_id = Database::insert(
2937 2937
                             $table_thematic_advance,
2938 2938
                             $thematic_advance,
@@ -2954,7 +2954,7 @@  discard block
 block discarded – undo
2954 2954
 						}
2955 2955
 					}
2956 2956
 
2957
-					foreach($thematic->thematic_plan_list as $thematic_plan) {
2957
+					foreach ($thematic->thematic_plan_list as $thematic_plan) {
2958 2958
 						unset($thematic_plan['id']);
2959 2959
                         unset($thematic_plan['iid']);
2960 2960
 						$thematic_plan['thematic_id'] = $last_id;
@@ -3070,7 +3070,7 @@  discard block
 block discarded – undo
3070 3070
                 // re-create dir
3071 3071
                 // @todo check security against injection of dir in crafted course backup here!
3072 3072
                 $path = $obj->params['url'];
3073
-                $path = '/'.str_replace('/','',substr($path,1));
3073
+                $path = '/'.str_replace('/', '', substr($path, 1));
3074 3074
 
3075 3075
                 $workData = array();
3076 3076
                 switch ($this->file_option) {
@@ -3092,9 +3092,9 @@  discard block
 block discarded – undo
3092 3092
                         $obj->params['new_dir'] = $obj->params['title'];
3093 3093
 
3094 3094
                         if (!empty($this->course_origin_id)) {
3095
-                            $sql = 'SELECT * FROM ' . $table_work_assignment . '
3095
+                            $sql = 'SELECT * FROM '.$table_work_assignment.'
3096 3096
                                     WHERE
3097
-                                        c_id = ' . $this->course_origin_id . ' AND
3097
+                                        c_id = ' . $this->course_origin_id.' AND
3098 3098
                                         publication_id = ' . $id_work;
3099 3099
 
3100 3100
                             $result = Database::query($sql);
@@ -3206,7 +3206,7 @@  discard block
 block discarded – undo
3206 3206
     public function DBUTF8_array($array)
3207 3207
     {
3208 3208
         if (UTF8_CONVERT) {
3209
-            foreach ($array as &$item)  {
3209
+            foreach ($array as &$item) {
3210 3210
                 $item = utf8_encode($item);
3211 3211
             }
3212 3212
             return $array;
Please login to merge, or discard this patch.
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -512,7 +512,9 @@  discard block
 block discarded – undo
512 512
 
513 513
                                     if (in_array($file_info['extension'], array('html', 'htm'))) {
514 514
                                         $content = file_get_contents($path.$document->path);
515
-                                        if (UTF8_CONVERT) $content = utf8_encode($content);
515
+                                        if (UTF8_CONVERT) {
516
+                                            $content = utf8_encode($content);
517
+                                        }
516 518
                                         $content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
517 519
                                             $content,
518 520
                                             $this->course->code,
@@ -2240,7 +2242,11 @@  discard block
 block discarded – undo
2240 2242
 		            c_id = ".$this->destination_course_id." AND
2241 2243
 		            code='".self::DBUTF8escapestring($survey_code)."'";
2242 2244
 		$result = Database::query($sql);
2243
-		if (Database::num_rows($result) > 0) return false; else return true;
2245
+		if (Database::num_rows($result) > 0) {
2246
+		    return false;
2247
+		} else {
2248
+		    return true;
2249
+		}
2244 2250
 	}
2245 2251
 
2246 2252
 	/**
@@ -2719,8 +2725,9 @@  discard block
 block discarded – undo
2719 2725
                             echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>';
2720 2726
                         }*/
2721 2727
                     } elseif(is_dir($path)) {
2722
-                        if (!is_dir($dest . '/' . $file))
2723
-                        mkdir($dest . '/' . $file);
2728
+                        if (!is_dir($dest . '/' . $file)) {
2729
+                                                mkdir($dest . '/' . $file);
2730
+                        }
2724 2731
                        self:: allow_create_all_directory($path, $dest . '/' . $file, $overwrite);
2725 2732
                     }
2726 2733
                 }
Please login to merge, or discard this patch.
Doc Comments   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 
85 85
     /**
86 86
      * CourseRestorer constructor.
87
-     * @param array $course
87
+     * @param Course $course
88 88
      */
89 89
     public function __construct($course)
90 90
     {
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 * @param int	    $session_id
134 134
 	 * @param bool	    $update_course_settings Course settings are going to be restore?
135 135
      * @param bool      $respect_base_content
136
-     * @return bool
136
+     * @return false|null
137 137
 	 */
138 138
     public function restore(
139 139
         $destination_course_code = '',
@@ -1154,6 +1154,7 @@  discard block
 block discarded – undo
1154 1154
 
1155 1155
 	/**
1156 1156
 	 * Restore a forum-topic
1157
+	 * @param false|string $forum_id
1157 1158
 	 */
1158 1159
     public function restore_topic($thread_id, $forum_id, $sessionId = 0)
1159 1160
     {
@@ -1210,6 +1211,7 @@  discard block
 block discarded – undo
1210 1211
 	/**
1211 1212
 	 * Restore a forum-post
1212 1213
 	 * @TODO Restore tree-structure of posts. For example: attachments to posts.
1214
+	 * @param false|string $topic_id
1213 1215
 	 */
1214 1216
     public function restore_post($id, $topic_id, $forum_id, $sessionId = 0)
1215 1217
     {
@@ -2307,6 +2309,7 @@  discard block
 block discarded – undo
2307 2309
 
2308 2310
 	/**
2309 2311
 	 * Check availability of a survey code
2312
+	 * @param string $survey_code
2310 2313
 	 */
2311 2314
     public function is_survey_code_available($survey_code)
2312 2315
     {
@@ -2321,6 +2324,7 @@  discard block
 block discarded – undo
2321 2324
 
2322 2325
 	/**
2323 2326
 	 * Restore survey-questions
2327
+	 * @param string $survey_id
2324 2328
 	 */
2325 2329
     public function restore_survey_question($id, $survey_id)
2326 2330
     {
@@ -2777,6 +2781,8 @@  discard block
 block discarded – undo
2777 2781
     * @param string The path origin
2778 2782
     * @param string The path destination
2779 2783
     * @param boolean Option Overwrite
2784
+    * @param string $source
2785
+    * @param string $dest
2780 2786
     * @return void()
2781 2787
     * @deprecated
2782 2788
     */
Please login to merge, or discard this patch.
Indentation   +710 added lines, -710 removed lines patch added patch discarded remove patch
@@ -36,16 +36,16 @@  discard block
 block discarded – undo
36 36
  */
37 37
 class CourseRestorer
38 38
 {
39
-	/**
40
-	 * The course-object
41
-	 */
39
+    /**
40
+     * The course-object
41
+     */
42 42
     public $course;
43 43
     public $destination_course_info;
44 44
 
45
-	/**
46
-	 * What to do with files with same name (FILE_SKIP, FILE_RENAME or
47
-	 * FILE_OVERWRITE)
48
-	 */
45
+    /**
46
+     * What to do with files with same name (FILE_SKIP, FILE_RENAME or
47
+     * FILE_OVERWRITE)
48
+     */
49 49
     public $file_option;
50 50
     public $set_tools_invisible_by_default;
51 51
     public $skip_content;
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
         'events',
58 58
         'forum_category',
59 59
         'forums',
60
-       // 'forum_topics',
60
+        // 'forum_topics',
61 61
         'glossary',
62 62
         'quizzes',
63 63
         'test_category',
@@ -126,15 +126,15 @@  discard block
 block discarded – undo
126 126
         $this->tool_copy_settings = $array;
127 127
     }
128 128
 
129
-	/**
130
-	 * Restore a course.
129
+    /**
130
+     * Restore a course.
131 131
      *
132
-	 * @param string    $destination_course_code code of the Chamilo-course in
133
-	 * @param int	    $session_id
134
-	 * @param bool	    $update_course_settings Course settings are going to be restore?
132
+     * @param string    $destination_course_code code of the Chamilo-course in
133
+     * @param int	    $session_id
134
+     * @param bool	    $update_course_settings Course settings are going to be restore?
135 135
      * @param bool      $respect_base_content
136 136
      * @return bool
137
-	 */
137
+     */
138 138
     public function restore(
139 139
         $destination_course_code = '',
140 140
         $session_id = 0,
@@ -277,17 +277,17 @@  discard block
 block discarded – undo
277 277
         }
278 278
     }
279 279
 
280
-	/**
281
-	 * Restore only harmless course settings:
280
+    /**
281
+     * Restore only harmless course settings:
282 282
      * course_language, visibility, department_name,department_url,
283 283
      * subscribe, unsubscribe ,category_code
284
-	 *
285
-	 * @param string $destination_course_code
286
-	 */
284
+     *
285
+     * @param string $destination_course_code
286
+     */
287 287
     public function restore_course_settings($destination_course_code)
288 288
     {
289
-	    $origin_course_info = api_get_course_info($destination_course_code);
290
-	    $course_info = $this->course->info;
289
+        $origin_course_info = api_get_course_info($destination_course_code);
290
+        $course_info = $this->course->info;
291 291
         $params['course_language'] = $course_info['language'];
292 292
         $params['visibility'] = $course_info['visibility'];
293 293
         $params['department_name'] = $course_info['department_name'];
@@ -296,8 +296,8 @@  discard block
 block discarded – undo
296 296
         $params['category_code'] = $course_info['categoryCode'];
297 297
         $params['subscribe'] = $course_info['subscribe_allowed'];
298 298
         $params['unsubscribe'] = $course_info['unsubscribe'];
299
-	    CourseManager::update_attributes($origin_course_info['real_id'], $params);
300
-	}
299
+        CourseManager::update_attributes($origin_course_info['real_id'], $params);
300
+    }
301 301
 
302 302
     /**
303 303
      * Restore documents
@@ -311,11 +311,11 @@  discard block
 block discarded – undo
311 311
         $course_info = api_get_course_info($destination_course_code);
312 312
 
313 313
         if ($this->course->has_resources(RESOURCE_DOCUMENT)) {
314
-			$table = Database :: get_course_table(TABLE_DOCUMENT);
315
-			$resources = $this->course->resources;
314
+            $table = Database :: get_course_table(TABLE_DOCUMENT);
315
+            $resources = $this->course->resources;
316 316
             $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/';
317 317
 
318
-			foreach ($resources[RESOURCE_DOCUMENT] as $id => $document) {
318
+            foreach ($resources[RESOURCE_DOCUMENT] as $id => $document) {
319 319
 
320 320
                 if (empty($document->item_properties[0]['id_session'])) {
321 321
                     $my_session_id = 0;
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
                             }
386 386
                         }
387 387
                     }
388
-		    	} elseif ($document->file_type == DOCUMENT) {
388
+                } elseif ($document->file_type == DOCUMENT) {
389 389
                     //Checking if folder exists in the database otherwise we created it
390 390
                     $dir_to_create = dirname($document->path);
391 391
 
@@ -441,19 +441,19 @@  discard block
 block discarded – undo
441 441
                         }
442 442
                     }
443 443
 
444
-					if (file_exists($path.$document->path)) {
445
-						switch ($this->file_option) {
446
-							case FILE_OVERWRITE:
444
+                    if (file_exists($path.$document->path)) {
445
+                        switch ($this->file_option) {
446
+                            case FILE_OVERWRITE:
447 447
                                 $origin_path = $this->course->backup_path.'/'.$document->path;
448 448
 
449
-								if (file_exists($origin_path)) {
450
-        						    copy($origin_path, $path.$document->path);
449
+                                if (file_exists($origin_path)) {
450
+                                    copy($origin_path, $path.$document->path);
451 451
                                     $sql = "SELECT id FROM $table
452 452
                                             WHERE
453 453
                                                 c_id = ".$this->destination_course_id." AND
454 454
                                                 path = '/".self::DBUTF8escapestring(substr($document->path, 9))."'";
455 455
 
456
-        						    $res = Database::query($sql);
456
+                                    $res = Database::query($sql);
457 457
                                     $count = Database::num_rows($res);
458 458
 
459 459
                                     if ($count == 0) {
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
                                             'session_id' => $my_session_id,
468 468
                                         ];
469 469
 
470
-    									$document_id = Database::insert($table, $params);
470
+                                        $document_id = Database::insert($table, $params);
471 471
 
472 472
                                         if ($document_id) {
473 473
                                             $sql = "UPDATE $table SET id = iid WHERE iid = $document_id";
@@ -575,83 +575,83 @@  discard block
 block discarded – undo
575 575
                                             ],
576 576
                                         ]
577 577
                                     );
578
-								}
578
+                                }
579 579
 
580
-								break;
581
-							case FILE_SKIP:
582
-								$sql = "SELECT id FROM $table
580
+                                break;
581
+                            case FILE_SKIP:
582
+                                $sql = "SELECT id FROM $table
583 583
 								        WHERE
584 584
 								            c_id = ".$this->destination_course_id." AND
585 585
 								            path='/".self::DBUTF8escapestring(substr($document->path, 9))."'";
586
-								$res = Database::query($sql);
587
-								$obj = Database::fetch_object($res);
588
-								$this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $obj->id;
589
-								break;
590
-							case FILE_RENAME:
591
-								$i = 1;
592
-								$ext = explode('.', basename($document->path));
593
-								if (count($ext) > 1) {
594
-									$ext = array_pop($ext);
595
-									$file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1));
596
-									$ext = '.'.$ext;
597
-								} else {
598
-									$ext = '';
599
-									$file_name_no_ext = $document->path;
600
-								}
601
-								$new_file_name = $file_name_no_ext.'_'.$i.$ext;
602
-								$file_exists = file_exists($path.$new_file_name);
603
-								while ($file_exists) {
604
-									$i ++;
605
-									$new_file_name = $file_name_no_ext.'_'.$i.$ext;
606
-									$file_exists = file_exists($path.$new_file_name);
607
-								}
608
-
609
-								if (!empty($session_id)) {
610
-
611
-									$document_path = explode('/',$document->path,3);
612
-									$course_path = $path;
613
-									$orig_base_folder = $document_path[1];
614
-									$orig_base_path   = $course_path.$document_path[0].'/'.$document_path[1];
615
-
616
-									if (is_dir($orig_base_path)) {
617
-
618
-										$new_base_foldername = $orig_base_folder;
619
-										$new_base_path = $orig_base_path;
620
-
621
-										if ($_SESSION['orig_base_foldername'] != $new_base_foldername) {
622
-											unset($_SESSION['new_base_foldername']);
623
-											unset($_SESSION['orig_base_foldername']);
624
-											unset($_SESSION['new_base_path']);
625
-										}
626
-
627
-										$folder_exists = file_exists($new_base_path);
628
-										if ($folder_exists) {
629
-											$_SESSION['orig_base_foldername'] = $new_base_foldername; 		// e.g: carpeta1 in session
630
-											$x = '';
631
-											while ($folder_exists) {
632
-												$x = $x + 1;
633
-												$new_base_foldername = $document_path[1].'_'.$x;
634
-												$new_base_path = $orig_base_path.'_'.$x;
586
+                                $res = Database::query($sql);
587
+                                $obj = Database::fetch_object($res);
588
+                                $this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $obj->id;
589
+                                break;
590
+                            case FILE_RENAME:
591
+                                $i = 1;
592
+                                $ext = explode('.', basename($document->path));
593
+                                if (count($ext) > 1) {
594
+                                    $ext = array_pop($ext);
595
+                                    $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1));
596
+                                    $ext = '.'.$ext;
597
+                                } else {
598
+                                    $ext = '';
599
+                                    $file_name_no_ext = $document->path;
600
+                                }
601
+                                $new_file_name = $file_name_no_ext.'_'.$i.$ext;
602
+                                $file_exists = file_exists($path.$new_file_name);
603
+                                while ($file_exists) {
604
+                                    $i ++;
605
+                                    $new_file_name = $file_name_no_ext.'_'.$i.$ext;
606
+                                    $file_exists = file_exists($path.$new_file_name);
607
+                                }
608
+
609
+                                if (!empty($session_id)) {
610
+
611
+                                    $document_path = explode('/',$document->path,3);
612
+                                    $course_path = $path;
613
+                                    $orig_base_folder = $document_path[1];
614
+                                    $orig_base_path   = $course_path.$document_path[0].'/'.$document_path[1];
615
+
616
+                                    if (is_dir($orig_base_path)) {
617
+
618
+                                        $new_base_foldername = $orig_base_folder;
619
+                                        $new_base_path = $orig_base_path;
620
+
621
+                                        if ($_SESSION['orig_base_foldername'] != $new_base_foldername) {
622
+                                            unset($_SESSION['new_base_foldername']);
623
+                                            unset($_SESSION['orig_base_foldername']);
624
+                                            unset($_SESSION['new_base_path']);
625
+                                        }
626
+
627
+                                        $folder_exists = file_exists($new_base_path);
628
+                                        if ($folder_exists) {
629
+                                            $_SESSION['orig_base_foldername'] = $new_base_foldername; 		// e.g: carpeta1 in session
630
+                                            $x = '';
631
+                                            while ($folder_exists) {
632
+                                                $x = $x + 1;
633
+                                                $new_base_foldername = $document_path[1].'_'.$x;
634
+                                                $new_base_path = $orig_base_path.'_'.$x;
635 635
                                                 if ($_SESSION['new_base_foldername'] == $new_base_foldername) {
636 636
                                                     break;
637 637
                                                 }
638
-												$folder_exists = file_exists($new_base_path);
639
-											}
640
-											$_SESSION['new_base_foldername'] = $new_base_foldername;
641
-											$_SESSION['new_base_path'] = $new_base_path;
642
-										}
643
-
644
-										if (isset($_SESSION['new_base_foldername']) && isset($_SESSION['new_base_path'])) {
645
-											$new_base_foldername = $_SESSION['new_base_foldername'];
646
-											$new_base_path = $_SESSION['new_base_path'];
647
-										}
648
-
649
-										$dest_document_path = $new_base_path.'/'.$document_path[2];		// e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png"
650
-										$basedir_dest_path 	= dirname($dest_document_path);				// e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1"
651
-										$base_path_document = $course_path.$document_path[0];			// e.g: "/var/www/wiener/courses/CURSO4/document"
652
-										$path_title = '/'.$new_base_foldername.'/'.$document_path[2];
653
-
654
-										copy_folder_course_session(
638
+                                                $folder_exists = file_exists($new_base_path);
639
+                                            }
640
+                                            $_SESSION['new_base_foldername'] = $new_base_foldername;
641
+                                            $_SESSION['new_base_path'] = $new_base_path;
642
+                                        }
643
+
644
+                                        if (isset($_SESSION['new_base_foldername']) && isset($_SESSION['new_base_path'])) {
645
+                                            $new_base_foldername = $_SESSION['new_base_foldername'];
646
+                                            $new_base_path = $_SESSION['new_base_path'];
647
+                                        }
648
+
649
+                                        $dest_document_path = $new_base_path.'/'.$document_path[2];		// e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png"
650
+                                        $basedir_dest_path 	= dirname($dest_document_path);				// e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1"
651
+                                        $base_path_document = $course_path.$document_path[0];			// e.g: "/var/www/wiener/courses/CURSO4/document"
652
+                                        $path_title = '/'.$new_base_foldername.'/'.$document_path[2];
653
+
654
+                                        copy_folder_course_session(
655 655
                                             $basedir_dest_path,
656 656
                                             $base_path_document,
657 657
                                             $session_id,
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
                                             'session_id' => $my_session_id,
694 694
                                         ];
695 695
 
696
-										$document_id = Database::insert($table, $params);
696
+                                        $document_id = Database::insert($table, $params);
697 697
 
698 698
                                         if ($document_id) {
699 699
                                             $sql = "UPDATE $table SET id = iid WHERE iid = $document_id";
@@ -722,10 +722,10 @@  discard block
 block discarded – undo
722 722
                                             null,
723 723
                                             $my_session_id
724 724
                                         );
725
-									} else {
726
-									    if (file_exists($path.$document->path)) {
725
+                                    } else {
726
+                                        if (file_exists($path.$document->path)) {
727 727
                                             copy($path.$document->path, $path.$new_file_name);
728
-									    }
728
+                                        }
729 729
                                         //Replace old course code with the new destination code see BT#1985
730 730
                                         if (file_exists($path.$new_file_name)) {
731 731
                                             $file_info = pathinfo($path.$new_file_name);
@@ -784,10 +784,10 @@  discard block
 block discarded – undo
784 784
                                                 $my_session_id
785 785
                                             );
786 786
                                         }
787
-									}
788
-								} else {
787
+                                    }
788
+                                } else {
789 789
 
790
-									copy($this->course->backup_path.'/'.$document->path, $path.$new_file_name);
790
+                                    copy($this->course->backup_path.'/'.$document->path, $path.$new_file_name);
791 791
 
792 792
                                     //Replace old course code with the new destination code see BT#1985
793 793
                                     if (file_exists($path.$new_file_name)) {
@@ -847,20 +847,20 @@  discard block
 block discarded – undo
847 847
                                         null,
848 848
                                         $my_session_id
849 849
                                     );
850
-								}
851
-								break;
852
-
853
-						} // end switch
854
-					} else {
855
-					    // end if file exists
856
-						//make sure the source file actually exists
857
-						if (is_file($this->course->backup_path.'/'.$document->path) &&
850
+                                }
851
+                                break;
852
+
853
+                        } // end switch
854
+                    } else {
855
+                        // end if file exists
856
+                        //make sure the source file actually exists
857
+                        if (is_file($this->course->backup_path.'/'.$document->path) &&
858 858
                             is_readable($this->course->backup_path.'/'.$document->path) &&
859 859
                             is_dir(dirname($path.$document->path)) &&
860 860
                             is_writeable(dirname($path.$document->path))
861 861
                         ) {
862
-						    //echo 'Copying';
863
-							copy($this->course->backup_path.'/'.$document->path, $path.$document->path);
862
+                            //echo 'Copying';
863
+                            copy($this->course->backup_path.'/'.$document->path, $path.$document->path);
864 864
 
865 865
                             //Replace old course code with the new destination code see BT#1985
866 866
                             if (file_exists($path.$document->path)) {
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
                                 Database::query($sql);
899 899
                             }
900 900
 
901
-							$this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $document_id;
901
+                            $this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $document_id;
902 902
 
903 903
                             $itemProperty = isset($document->item_properties[0]) ? $document->item_properties[0] : '';
904 904
                             $insertUserId = isset($itemProperty['insert_user_id']) ? $itemProperty['insert_user_id'] : api_get_user_id();
@@ -920,79 +920,79 @@  discard block
 block discarded – undo
920 920
                                 null,
921 921
                                 $my_session_id
922 922
                             );
923
-						} else {
924
-							if (is_file($this->course->backup_path.'/'.$document->path) &&
923
+                        } else {
924
+                            if (is_file($this->course->backup_path.'/'.$document->path) &&
925 925
                                 is_readable($this->course->backup_path.'/'.$document->path)
926 926
                             ) {
927
-								error_log('Course copy generated an ignoreable error while trying to copy '.$this->course->backup_path.'/'.$document->path.': file not found');
928
-							}
929
-							if (!is_dir(dirname($path.$document->path))) {
930
-								error_log('Course copy generated an ignoreable error while trying to copy to '.dirname($path.$document->path).': directory not found');
931
-							}
932
-							if (!is_writeable(dirname($path.$document->path))) {
933
-								error_log('Course copy generated an ignoreable error while trying to copy to '.dirname($path.$document->path).': directory not writeable');
934
-							}
935
-						}
936
-					} // end file doesn't exist
937
-				}
938
-			} // end for each
939
-
940
-    		// Delete sessions for the copy the new folder in session
941
-    		unset($_SESSION['new_base_foldername']);
942
-    		unset($_SESSION['orig_base_foldername']);
943
-    		unset($_SESSION['new_base_path']);
944
-		}
945
-	}
946
-
947
-	/**
948
-	 * Restore scorm documents
949
-	 * TODO @TODO check that the restore function with renaming doesn't break the scorm structure!
927
+                                error_log('Course copy generated an ignoreable error while trying to copy '.$this->course->backup_path.'/'.$document->path.': file not found');
928
+                            }
929
+                            if (!is_dir(dirname($path.$document->path))) {
930
+                                error_log('Course copy generated an ignoreable error while trying to copy to '.dirname($path.$document->path).': directory not found');
931
+                            }
932
+                            if (!is_writeable(dirname($path.$document->path))) {
933
+                                error_log('Course copy generated an ignoreable error while trying to copy to '.dirname($path.$document->path).': directory not writeable');
934
+                            }
935
+                        }
936
+                    } // end file doesn't exist
937
+                }
938
+            } // end for each
939
+
940
+            // Delete sessions for the copy the new folder in session
941
+            unset($_SESSION['new_base_foldername']);
942
+            unset($_SESSION['orig_base_foldername']);
943
+            unset($_SESSION['new_base_path']);
944
+        }
945
+    }
946
+
947
+    /**
948
+     * Restore scorm documents
949
+     * TODO @TODO check that the restore function with renaming doesn't break the scorm structure!
950 950
      * see #7029
951
-	 */
952
-	public function restore_scorm_documents()
951
+     */
952
+    public function restore_scorm_documents()
953 953
     {
954
-		$perm = api_get_permissions_for_new_directories();
954
+        $perm = api_get_permissions_for_new_directories();
955 955
 
956
-		if ($this->course->has_resources(RESOURCE_SCORM)) {
957
-			$resources = $this->course->resources;
956
+        if ($this->course->has_resources(RESOURCE_SCORM)) {
957
+            $resources = $this->course->resources;
958 958
 
959
-			foreach ($resources[RESOURCE_SCORM] as $document) {
960
-				$path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/';
959
+            foreach ($resources[RESOURCE_SCORM] as $document) {
960
+                $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/';
961 961
 
962
-				@mkdir(dirname($path.$document->path), $perm, true);
962
+                @mkdir(dirname($path.$document->path), $perm, true);
963 963
 
964
-				if (file_exists($path.$document->path)) {
965
-					switch ($this->file_option) {
966
-						case FILE_OVERWRITE:
967
-							rmdirr($path.$document->path);
964
+                if (file_exists($path.$document->path)) {
965
+                    switch ($this->file_option) {
966
+                        case FILE_OVERWRITE:
967
+                            rmdirr($path.$document->path);
968 968
                             copyDirTo(
969 969
                                 $this->course->backup_path . '/' . $document->path,
970 970
                                 $path . dirname($document->path),
971 971
                                 false
972 972
                             );
973
-							break;
974
-						case FILE_SKIP:
975
-							break;
973
+                            break;
974
+                        case FILE_SKIP:
975
+                            break;
976 976
                         case FILE_RENAME:
977
-							$i = 1;
978
-							$ext = explode('.', basename($document->path));
979
-							if (count($ext) > 1) {
980
-								$ext = array_pop($ext);
981
-								$file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1));
982
-								$ext = '.'.$ext;
983
-							} else {
984
-								$ext = '';
985
-								$file_name_no_ext = $document->path;
986
-							}
987
-
988
-							$new_file_name = $file_name_no_ext.'_'.$i.$ext;
989
-							$file_exists = file_exists($path.$new_file_name);
990
-
991
-							while ($file_exists) {
992
-								$i ++;
993
-								$new_file_name = $file_name_no_ext.'_'.$i.$ext;
994
-								$file_exists = file_exists($path.$new_file_name);
995
-							}
977
+                            $i = 1;
978
+                            $ext = explode('.', basename($document->path));
979
+                            if (count($ext) > 1) {
980
+                                $ext = array_pop($ext);
981
+                                $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1));
982
+                                $ext = '.'.$ext;
983
+                            } else {
984
+                                $ext = '';
985
+                                $file_name_no_ext = $document->path;
986
+                            }
987
+
988
+                            $new_file_name = $file_name_no_ext.'_'.$i.$ext;
989
+                            $file_exists = file_exists($path.$new_file_name);
990
+
991
+                            while ($file_exists) {
992
+                                $i ++;
993
+                                $new_file_name = $file_name_no_ext.'_'.$i.$ext;
994
+                                $file_exists = file_exists($path.$new_file_name);
995
+                            }
996 996
 
997 997
                             rename(
998 998
                                 $this->course->backup_path . '/' . $document->path,
@@ -1008,30 +1008,30 @@  discard block
 block discarded – undo
1008 1008
                                 $this->course->backup_path . '/' . $document->path
1009 1009
                             );
1010 1010
 
1011
-							break;
1012
-					} // end switch
1013
-				} else {
1011
+                            break;
1012
+                    } // end switch
1013
+                } else {
1014 1014
                     // end if file exists
1015 1015
                     copyDirTo(
1016 1016
                         $this->course->backup_path . '/' . $document->path,
1017 1017
                         $path . dirname($document->path),
1018 1018
                         false
1019 1019
                     );
1020
-				}
1021
-			} // end for each
1022
-		}
1023
-	}
1024
-
1025
-	/**
1026
-	 * Restore forums
1027
-	 */
1028
-	public function restore_forums($sessionId = 0)
1020
+                }
1021
+            } // end for each
1022
+        }
1023
+    }
1024
+
1025
+    /**
1026
+     * Restore forums
1027
+     */
1028
+    public function restore_forums($sessionId = 0)
1029 1029
     {
1030
-		if ($this->course->has_resources(RESOURCE_FORUM)) {
1030
+        if ($this->course->has_resources(RESOURCE_FORUM)) {
1031 1031
             $sessionId = intval($sessionId);
1032
-			$table_forum = Database::get_course_table(TABLE_FORUM);
1033
-			$resources = $this->course->resources;
1034
-			foreach ($resources[RESOURCE_FORUM] as $id => $forum) {
1032
+            $table_forum = Database::get_course_table(TABLE_FORUM);
1033
+            $resources = $this->course->resources;
1034
+            foreach ($resources[RESOURCE_FORUM] as $id => $forum) {
1035 1035
                 $params = (array)$forum->obj;
1036 1036
                 $cat_id = '';
1037 1037
                 if (isset($this->course->resources[RESOURCE_FORUMCATEGORY]) &&
@@ -1077,33 +1077,33 @@  discard block
 block discarded – undo
1077 1077
                     Database::query($sql);
1078 1078
                 }
1079 1079
 
1080
-				$this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id;
1081
-
1082
-				$forum_topics = 0;
1083
-				if (is_array($this->course->resources[RESOURCE_FORUMTOPIC])) {
1084
-					foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) {
1085
-						if ($topic->obj->forum_id == $id) {
1086
-							$this->restore_topic($topic_id, $new_id, $sessionId);
1087
-							$forum_topics ++;
1088
-						}
1089
-					}
1090
-				}
1091
-				if ($forum_topics > 0) {
1092
-					$sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics."
1080
+                $this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id;
1081
+
1082
+                $forum_topics = 0;
1083
+                if (is_array($this->course->resources[RESOURCE_FORUMTOPIC])) {
1084
+                    foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) {
1085
+                        if ($topic->obj->forum_id == $id) {
1086
+                            $this->restore_topic($topic_id, $new_id, $sessionId);
1087
+                            $forum_topics ++;
1088
+                        }
1089
+                    }
1090
+                }
1091
+                if ($forum_topics > 0) {
1092
+                    $sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics."
1093 1093
                             WHERE c_id = {$this->destination_course_id} AND forum_id = ".(int)$new_id;
1094
-					Database::query($sql);
1095
-				}
1096
-			}
1097
-		}
1098
-	}
1099
-
1100
-	/**
1101
-	 * Restore forum-categories
1102
-	 */
1094
+                    Database::query($sql);
1095
+                }
1096
+            }
1097
+        }
1098
+    }
1099
+
1100
+    /**
1101
+     * Restore forum-categories
1102
+     */
1103 1103
     public function restore_forum_category($my_id = null, $sessionId = 0)
1104 1104
     {
1105
-		$forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY);
1106
-		$resources = $this->course->resources;
1105
+        $forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY);
1106
+        $resources = $this->course->resources;
1107 1107
         if (!empty($resources[RESOURCE_FORUMCATEGORY])) {
1108 1108
             foreach ($resources[RESOURCE_FORUMCATEGORY] as $id => $forum_cat) {
1109 1109
                 if (!empty($my_id)) {
@@ -1150,15 +1150,15 @@  discard block
 block discarded – undo
1150 1150
                 }
1151 1151
             }
1152 1152
         }
1153
-	}
1153
+    }
1154 1154
 
1155
-	/**
1156
-	 * Restore a forum-topic
1157
-	 */
1155
+    /**
1156
+     * Restore a forum-topic
1157
+     */
1158 1158
     public function restore_topic($thread_id, $forum_id, $sessionId = 0)
1159 1159
     {
1160
-		$table = Database :: get_course_table(TABLE_FORUM_THREAD);
1161
-		$topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id];
1160
+        $table = Database :: get_course_table(TABLE_FORUM_THREAD);
1161
+        $topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id];
1162 1162
 
1163 1163
         $params = (array)$topic->obj;
1164 1164
         $params = self::DBUTF8_array($params);
@@ -1194,27 +1194,27 @@  discard block
 block discarded – undo
1194 1194
             $sessionId
1195 1195
         );
1196 1196
 
1197
-		$this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id;
1197
+        $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id;
1198 1198
 
1199
-		$topic_replies = -1;
1199
+        $topic_replies = -1;
1200 1200
 
1201
-		foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) {
1202
-			if ($post->obj->thread_id == $thread_id) {
1203
-				$topic_replies++;
1204
-				$this->restore_post($post_id, $new_id, $forum_id, $sessionId);
1205
-			}
1206
-		}
1207
-		return $new_id;
1208
-	}
1201
+        foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) {
1202
+            if ($post->obj->thread_id == $thread_id) {
1203
+                $topic_replies++;
1204
+                $this->restore_post($post_id, $new_id, $forum_id, $sessionId);
1205
+            }
1206
+        }
1207
+        return $new_id;
1208
+    }
1209 1209
 
1210
-	/**
1211
-	 * Restore a forum-post
1212
-	 * @TODO Restore tree-structure of posts. For example: attachments to posts.
1213
-	 */
1210
+    /**
1211
+     * Restore a forum-post
1212
+     * @TODO Restore tree-structure of posts. For example: attachments to posts.
1213
+     */
1214 1214
     public function restore_post($id, $topic_id, $forum_id, $sessionId = 0)
1215 1215
     {
1216
-		$table_post = Database :: get_course_table(TABLE_FORUM_POST);
1217
-		$post = $this->course->resources[RESOURCE_FORUMPOST][$id];
1216
+        $table_post = Database :: get_course_table(TABLE_FORUM_POST);
1217
+        $post = $this->course->resources[RESOURCE_FORUMPOST][$id];
1218 1218
         $params = (array) $post->obj;
1219 1219
         $params['c_id'] = $this->destination_course_id;
1220 1220
         $params['forum_id'] = $forum_id;
@@ -1249,37 +1249,37 @@  discard block
 block discarded – undo
1249 1249
             null,
1250 1250
             $sessionId
1251 1251
         );
1252
-		$this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id;
1252
+        $this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id;
1253 1253
 
1254
-		return $new_id;
1255
-	}
1254
+        return $new_id;
1255
+    }
1256 1256
 
1257
-	/**
1258
-	 * Restore links
1259
-	 */
1257
+    /**
1258
+     * Restore links
1259
+     */
1260 1260
     public function restore_links($session_id = 0)
1261 1261
     {
1262
-		if ($this->course->has_resources(RESOURCE_LINK)) {
1263
-			$link_table = Database :: get_course_table(TABLE_LINK);
1264
-			$resources = $this->course->resources;
1262
+        if ($this->course->has_resources(RESOURCE_LINK)) {
1263
+            $link_table = Database :: get_course_table(TABLE_LINK);
1264
+            $resources = $this->course->resources;
1265 1265
 
1266
-			foreach ($resources[RESOURCE_LINK] as $id => $link) {
1266
+            foreach ($resources[RESOURCE_LINK] as $id => $link) {
1267 1267
                 $cat_id = $this->restore_link_category(
1268 1268
                     $link->category_id,
1269 1269
                     $session_id
1270 1270
                 );
1271
-				$sql = "SELECT MAX(display_order)
1271
+                $sql = "SELECT MAX(display_order)
1272 1272
 				        FROM $link_table
1273 1273
 				        WHERE
1274 1274
 				            c_id = ".$this->destination_course_id." AND
1275 1275
 				            category_id='" . intval($cat_id). "'";
1276
-				$result = Database::query($sql);
1277
-    			list($max_order) = Database::fetch_array($result);
1276
+                $result = Database::query($sql);
1277
+                list($max_order) = Database::fetch_array($result);
1278 1278
 
1279 1279
                 $params = [];
1280
-    			if (!empty($session_id)) {
1280
+                if (!empty($session_id)) {
1281 1281
                     $params['session_id'] = $session_id;
1282
-    			}
1282
+                }
1283 1283
 
1284 1284
                 $params['c_id'] = $this->destination_course_id;
1285 1285
                 $params['url'] = self::DBUTF8($link->url);
@@ -1308,9 +1308,9 @@  discard block
 block discarded – undo
1308 1308
                     }
1309 1309
                     $this->course->resources[RESOURCE_LINK][$id]->destination_id = $id;
1310 1310
                 }
1311
-			}
1312
-		}
1313
-	}
1311
+            }
1312
+        }
1313
+    }
1314 1314
 
1315 1315
     /**
1316 1316
      * Restore a link-category
@@ -1354,21 +1354,21 @@  discard block
 block discarded – undo
1354 1354
         return $this->course->resources[RESOURCE_LINKCATEGORY][$id]->destination_id;
1355 1355
     }
1356 1356
 
1357
-	/**
1358
-	 * Restore tool intro
1359
-	 */
1357
+    /**
1358
+     * Restore tool intro
1359
+     */
1360 1360
     public function restore_tool_intro($sessionId = 0)
1361 1361
     {
1362
-		if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) {
1362
+        if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) {
1363 1363
             $sessionId = intval($sessionId);
1364
-			$tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO);
1365
-			$resources = $this->course->resources;
1366
-			foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) {
1367
-				$sql = "DELETE FROM ".$tool_intro_table."
1364
+            $tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO);
1365
+            $resources = $this->course->resources;
1366
+            foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) {
1367
+                $sql = "DELETE FROM ".$tool_intro_table."
1368 1368
 				        WHERE
1369 1369
 				            c_id = ".$this->destination_course_id." AND
1370 1370
 				            id='".self::DBUTF8escapestring($tool_intro->id)."'";
1371
-				Database::query($sql);
1371
+                Database::query($sql);
1372 1372
 
1373 1373
                 $tool_intro->intro_text = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1374 1374
                     $tool_intro->intro_text,
@@ -1396,21 +1396,21 @@  discard block
 block discarded – undo
1396 1396
 
1397 1397
                     $this->course->resources[RESOURCE_TOOL_INTRO][$id]->destination_id = $id;
1398 1398
                 }
1399
-			}
1400
-		}
1401
-	}
1399
+            }
1400
+        }
1401
+    }
1402 1402
 
1403
-	/**
1404
-	 * Restore events
1405
-	 */
1403
+    /**
1404
+     * Restore events
1405
+     */
1406 1406
     public function restore_events($sessionId = 0)
1407 1407
     {
1408
-		if ($this->course->has_resources(RESOURCE_EVENT)) {
1408
+        if ($this->course->has_resources(RESOURCE_EVENT)) {
1409 1409
             $sessionId = intval($sessionId);
1410
-			$table = Database :: get_course_table(TABLE_AGENDA);
1411
-			$resources = $this->course->resources;
1412
-			foreach ($resources[RESOURCE_EVENT] as $id => $event) {
1413
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
1410
+            $table = Database :: get_course_table(TABLE_AGENDA);
1411
+            $resources = $this->course->resources;
1412
+            foreach ($resources[RESOURCE_EVENT] as $id => $event) {
1413
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
1414 1414
                 $event->content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1415 1415
                     $event->content,
1416 1416
                     $this->course->code,
@@ -1428,7 +1428,7 @@  discard block
 block discarded – undo
1428 1428
                     'end_date' => $event->end_date,
1429 1429
                     'session_id' => $sessionId,
1430 1430
                 ];
1431
-				$new_event_id = Database::insert($table, $params);
1431
+                $new_event_id = Database::insert($table, $params);
1432 1432
 
1433 1433
                 if ($new_event_id) {
1434 1434
                     $sql = "UPDATE $table SET id = iid WHERE iid = $new_event_id";
@@ -1441,30 +1441,30 @@  discard block
 block discarded – undo
1441 1441
                     $this->course->resources[RESOURCE_EVENT][$id]->destination_id = $new_event_id;
1442 1442
                 }
1443 1443
 
1444
-				// Copy event attachment
1444
+                // Copy event attachment
1445 1445
 
1446
-				$origin_path = $this->course->backup_path.'/upload/calendar/';
1447
-				$destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/';
1446
+                $origin_path = $this->course->backup_path.'/upload/calendar/';
1447
+                $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/';
1448 1448
 
1449
-				if (!empty($this->course->orig)) {
1449
+                if (!empty($this->course->orig)) {
1450 1450
 
1451
-					$table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1452
-					$sql = 'SELECT path, comment, size, filename
1451
+                    $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1452
+                    $sql = 'SELECT path, comment, size, filename
1453 1453
 					        FROM '.$table_attachment.'
1454 1454
 					        WHERE c_id = '.$this->destination_course_id.' AND agenda_id = '.$id;
1455
-					$attachment_event = Database::query($sql);
1456
-					$attachment_event = Database::fetch_object($attachment_event);
1455
+                    $attachment_event = Database::query($sql);
1456
+                    $attachment_event = Database::fetch_object($attachment_event);
1457 1457
 
1458
-					if (file_exists($origin_path.$attachment_event->path) &&
1458
+                    if (file_exists($origin_path.$attachment_event->path) &&
1459 1459
                         !is_dir($origin_path.$attachment_event->path)
1460 1460
                     ) {
1461
-						$new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1462
-						$copy_result = copy($origin_path.$attachment_event->path, $destination_path.$new_filename);
1463
-						//$copy_result = true;
1464
-						if ($copy_result) {
1465
-							$table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1461
+                        $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1462
+                        $copy_result = copy($origin_path.$attachment_event->path, $destination_path.$new_filename);
1463
+                        //$copy_result = true;
1464
+                        if ($copy_result) {
1465
+                            $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1466 1466
 
1467
-							$params = [
1467
+                            $params = [
1468 1468
                                 'c_id' => $this->destination_course_id,
1469 1469
                                 'path' => self::DBUTF8($new_filename),
1470 1470
                                 'comment' => self::DBUTF8($attachment_event->comment),
@@ -1478,17 +1478,17 @@  discard block
 block discarded – undo
1478 1478
                                 Database::query($sql);
1479 1479
                             }
1480 1480
                         }
1481
-					}
1482
-				} else {
1483
-					// get the info of the file
1484
-					if (!empty($event->attachment_path) &&
1481
+                    }
1482
+                } else {
1483
+                    // get the info of the file
1484
+                    if (!empty($event->attachment_path) &&
1485 1485
                         is_file($origin_path.$event->attachment_path) &&
1486 1486
                         is_readable($origin_path.$event->attachment_path)
1487 1487
                     ) {
1488
-						$new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1489
-						$copy_result = copy($origin_path.$event->attachment_path, $destination_path.$new_filename);
1490
-						if ($copy_result) {
1491
-							$table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1488
+                        $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1489
+                        $copy_result = copy($origin_path.$event->attachment_path, $destination_path.$new_filename);
1490
+                        if ($copy_result) {
1491
+                            $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1492 1492
 
1493 1493
                             $params = [
1494 1494
                                 'c_id' => $this->destination_course_id,
@@ -1504,29 +1504,29 @@  discard block
 block discarded – undo
1504 1504
                                 $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $id";
1505 1505
                                 Database::query($sql);
1506 1506
                             }
1507
-						}
1508
-					}
1509
-				}
1510
-			}
1511
-		}
1512
-	}
1513
-
1514
-	/**
1515
-	 * Restore course-description
1516
-	 */
1507
+                        }
1508
+                    }
1509
+                }
1510
+            }
1511
+        }
1512
+    }
1513
+
1514
+    /**
1515
+     * Restore course-description
1516
+     */
1517 1517
     public function restore_course_descriptions($session_id = 0)
1518 1518
     {
1519
-		if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) {
1520
-			$table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION);
1521
-			$resources = $this->course->resources;
1522
-			foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) {
1519
+        if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) {
1520
+            $table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION);
1521
+            $resources = $this->course->resources;
1522
+            foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) {
1523 1523
                 $courseDescription = (array) $cd;
1524 1524
 
1525 1525
                 $content = isset($courseDescription['content']) ? $courseDescription['content'] : '';
1526 1526
                 $descriptionType = isset($courseDescription['description_type']) ? $courseDescription['description_type'] : '';
1527 1527
                 $title = isset($courseDescription['title']) ? $courseDescription['title'] : '';
1528 1528
 
1529
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
1529
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
1530 1530
                 $description_content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1531 1531
                     $content,
1532 1532
                     $this->course->code,
@@ -1554,22 +1554,22 @@  discard block
 block discarded – undo
1554 1554
                     }
1555 1555
                     $this->course->resources[RESOURCE_COURSEDESCRIPTION][$id]->destination_id = $id;
1556 1556
                 }
1557
-			}
1558
-		}
1559
-	}
1557
+            }
1558
+        }
1559
+    }
1560 1560
 
1561
-	/**
1562
-	 * Restore announcements
1563
-	 */
1561
+    /**
1562
+     * Restore announcements
1563
+     */
1564 1564
     public function restore_announcements($sessionId = 0)
1565 1565
     {
1566
-		if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) {
1566
+        if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) {
1567 1567
             $sessionId = intval($sessionId);
1568
-			$table = Database :: get_course_table(TABLE_ANNOUNCEMENT);
1569
-			$resources = $this->course->resources;
1570
-			foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) {
1568
+            $table = Database :: get_course_table(TABLE_ANNOUNCEMENT);
1569
+            $resources = $this->course->resources;
1570
+            foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) {
1571 1571
 
1572
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
1572
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
1573 1573
                 $announcement->content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1574 1574
                     $announcement->content,
1575 1575
                     $this->course->code,
@@ -1588,7 +1588,7 @@  discard block
 block discarded – undo
1588 1588
                     'session_id' => $sessionId,
1589 1589
                 ];
1590 1590
 
1591
-				$new_announcement_id = Database::insert($table, $params);
1591
+                $new_announcement_id = Database::insert($table, $params);
1592 1592
 
1593 1593
                 if ($new_announcement_id) {
1594 1594
                     $sql = "UPDATE $table SET id = iid WHERE iid = $new_announcement_id";
@@ -1600,32 +1600,32 @@  discard block
 block discarded – undo
1600 1600
                     $this->course->resources[RESOURCE_ANNOUNCEMENT][$id]->destination_id = $new_announcement_id;
1601 1601
                 }
1602 1602
 
1603
-				$origin_path = $this->course->backup_path.'/upload/announcements/';
1604
-				$destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/';
1603
+                $origin_path = $this->course->backup_path.'/upload/announcements/';
1604
+                $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/';
1605 1605
 
1606
-				// Copy announcement attachment file
1607
-				if (!empty($this->course->orig)) {
1606
+                // Copy announcement attachment file
1607
+                if (!empty($this->course->orig)) {
1608 1608
 
1609
-					$table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1610
-					$sql = 'SELECT path, comment, size, filename
1609
+                    $table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1610
+                    $sql = 'SELECT path, comment, size, filename
1611 1611
 					        FROM '.$table_attachment.'
1612 1612
 					        WHERE
1613 1613
 					            c_id = '.$this->destination_course_id.' AND
1614 1614
 					            announcement_id = '.$id;
1615
-					$attachment_event = Database::query($sql);
1616
-					$attachment_event = Database::fetch_object($attachment_event);
1615
+                    $attachment_event = Database::query($sql);
1616
+                    $attachment_event = Database::fetch_object($attachment_event);
1617 1617
 
1618
-					if (file_exists($origin_path.$attachment_event->path) &&
1618
+                    if (file_exists($origin_path.$attachment_event->path) &&
1619 1619
                         !is_dir($origin_path.$attachment_event->path)
1620 1620
                     ) {
1621
-						$new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1621
+                        $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1622 1622
                         $copy_result = copy(
1623 1623
                             $origin_path.$attachment_event->path,
1624 1624
                             $destination_path.$new_filename
1625 1625
                         );
1626 1626
 
1627
-						if ($copy_result) {
1628
-							$table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1627
+                        if ($copy_result) {
1628
+                            $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1629 1629
 
1630 1630
                             $params = [
1631 1631
                                 'c_id' => $this->destination_course_id,
@@ -1642,20 +1642,20 @@  discard block
 block discarded – undo
1642 1642
                                 $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId";
1643 1643
                                 Database::query($sql);
1644 1644
                             }
1645
-						}
1646
-					}
1647
-				} else {
1648
-					// get the info of the file
1649
-					if (!empty($announcement->attachment_path) &&
1645
+                        }
1646
+                    }
1647
+                } else {
1648
+                    // get the info of the file
1649
+                    if (!empty($announcement->attachment_path) &&
1650 1650
                         is_file($origin_path.$announcement->attachment_path) &&
1651 1651
                         is_readable($origin_path.$announcement->attachment_path)
1652 1652
                     ) {
1653
-						$new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1654
-						$copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename);
1653
+                        $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1654
+                        $copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename);
1655 1655
 
1656
-						if ($copy_result) {
1657
-							$table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1658
-							/*$sql = "INSERT INTO ".$table_attachment." SET
1656
+                        if ($copy_result) {
1657
+                            $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1658
+                            /*$sql = "INSERT INTO ".$table_attachment." SET
1659 1659
 							        c_id = ".$this->destination_course_id." ,
1660 1660
 							        path = '".self::DBUTF8escapestring($new_filename)."',
1661 1661
 							        comment = '".self::DBUTF8escapestring($announcement->attachment_comment)."',
@@ -1678,12 +1678,12 @@  discard block
 block discarded – undo
1678 1678
                                 $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId";
1679 1679
                                 Database::query($sql);
1680 1680
                             }
1681
-						}
1682
-					}
1683
-				}
1684
-			}
1685
-		}
1686
-	}
1681
+                        }
1682
+                    }
1683
+                }
1684
+            }
1685
+        }
1686
+    }
1687 1687
 
1688 1688
     /**
1689 1689
      * Restore Quiz
@@ -1694,13 +1694,13 @@  discard block
 block discarded – undo
1694 1694
         $session_id = 0,
1695 1695
         $respect_base_content = false
1696 1696
     ) {
1697
-		if ($this->course->has_resources(RESOURCE_QUIZ)) {
1698
-			$table_qui = Database :: get_course_table(TABLE_QUIZ_TEST);
1699
-			$table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION);
1700
-			$table_doc = Database :: get_course_table(TABLE_DOCUMENT);
1701
-			$resources = $this->course->resources;
1697
+        if ($this->course->has_resources(RESOURCE_QUIZ)) {
1698
+            $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST);
1699
+            $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION);
1700
+            $table_doc = Database :: get_course_table(TABLE_DOCUMENT);
1701
+            $resources = $this->course->resources;
1702 1702
 
1703
-			foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) {
1703
+            foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) {
1704 1704
 
1705 1705
                 if (isset($quiz->obj)) {
1706 1706
                     //For new imports
@@ -1710,7 +1710,7 @@  discard block
 block discarded – undo
1710 1710
                     $quiz->obj = $quiz;
1711 1711
                 }
1712 1712
 
1713
-				$doc = '';
1713
+                $doc = '';
1714 1714
                 if (!empty($quiz->sound)) {
1715 1715
                     if (isset($this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]) &&
1716 1716
                         $this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]->is_restored()) {
@@ -1718,14 +1718,14 @@  discard block
 block discarded – undo
1718 1718
                                 WHERE
1719 1719
                                     c_id = " . $this->destination_course_id . "  AND
1720 1720
                                     id = " . $resources[RESOURCE_DOCUMENT][$quiz->sound]->destination_id;
1721
-						$doc = Database::query($sql);
1722
-						$doc = Database::fetch_object($doc);
1723
-						$doc = str_replace('/audio/', '', $doc->path);
1724
-					}
1725
-				}
1726
-
1727
-				if ($id != -1) {
1728
-					// check resources inside html from ckeditor tool and copy correct urls into recipient course
1721
+                        $doc = Database::query($sql);
1722
+                        $doc = Database::fetch_object($doc);
1723
+                        $doc = str_replace('/audio/', '', $doc->path);
1724
+                    }
1725
+                }
1726
+
1727
+                if ($id != -1) {
1728
+                    // check resources inside html from ckeditor tool and copy correct urls into recipient course
1729 1729
                     $quiz->description = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1730 1730
                         $quiz->description,
1731 1731
                         $this->course->code,
@@ -1734,13 +1734,13 @@  discard block
 block discarded – undo
1734 1734
                         $this->course->info['path']
1735 1735
                     );
1736 1736
 
1737
-					global $_custom;
1738
-					if (isset($_custom['exercises_clean_dates_when_restoring']) &&
1737
+                    global $_custom;
1738
+                    if (isset($_custom['exercises_clean_dates_when_restoring']) &&
1739 1739
                         $_custom['exercises_clean_dates_when_restoring']
1740 1740
                     ) {
1741
-						$quiz->start_time = null;
1742
-						$quiz->end_time   = null;
1743
-					}
1741
+                        $quiz->start_time = null;
1742
+                        $quiz->end_time   = null;
1743
+                    }
1744 1744
 
1745 1745
                     $params = array(
1746 1746
                         'c_id' => $this->destination_course_id,
@@ -1772,10 +1772,10 @@  discard block
 block discarded – undo
1772 1772
                         }
1773 1773
                         $params['session_id'] = $my_session_id;
1774 1774
                     } else {
1775
-        				if (!empty($session_id)) {
1776
-        					$session_id = intval($session_id);
1775
+                        if (!empty($session_id)) {
1776
+                            $session_id = intval($session_id);
1777 1777
                             $params['session_id'] = $session_id;
1778
-    				    }
1778
+                        }
1779 1779
                     }
1780 1780
                     $new_id = Database::insert($table_qui, $params);
1781 1781
 
@@ -1784,15 +1784,15 @@  discard block
 block discarded – undo
1784 1784
                         Database::query($sql);
1785 1785
                     }
1786 1786
 
1787
-				} else {
1788
-					// $id = -1 identifies the fictionary test for collecting
1789
-					// orphan questions. We do not store it in the database.
1790
-					$new_id = -1;
1791
-				}
1787
+                } else {
1788
+                    // $id = -1 identifies the fictionary test for collecting
1789
+                    // orphan questions. We do not store it in the database.
1790
+                    $new_id = -1;
1791
+                }
1792 1792
 
1793
-				$this->course->resources[RESOURCE_QUIZ][$id]->destination_id = $new_id;
1793
+                $this->course->resources[RESOURCE_QUIZ][$id]->destination_id = $new_id;
1794 1794
 
1795
-				$order = 0;
1795
+                $order = 0;
1796 1796
                 if (!empty($quiz->question_ids)) {
1797 1797
                     foreach ($quiz->question_ids as $index => $question_id) {
1798 1798
                         $qid = $this->restore_quiz_question($question_id);
@@ -1805,30 +1805,30 @@  discard block
 block discarded – undo
1805 1805
                         Database::query($sql);
1806 1806
                     }
1807 1807
                 }
1808
-			}
1809
-		}
1810
-	}
1808
+            }
1809
+        }
1810
+    }
1811 1811
 
1812
-	/**
1813
-	 * Restore quiz-questions
1812
+    /**
1813
+     * Restore quiz-questions
1814 1814
      * @params int question id
1815
-	 */
1815
+     */
1816 1816
     public function restore_quiz_question($id)
1817 1817
     {
1818
-		$resources = $this->course->resources;
1818
+        $resources = $this->course->resources;
1819 1819
         $question = isset($resources[RESOURCE_QUIZQUESTION][$id]) ? $resources[RESOURCE_QUIZQUESTION][$id] : null;
1820 1820
 
1821
-		$new_id = 0;
1821
+        $new_id = 0;
1822 1822
 
1823
-		if (is_object($question)) {
1824
-			if ($question->is_restored()) {
1825
-				return $question->destination_id;
1826
-			}
1827
-			$table_que = Database::get_course_table(TABLE_QUIZ_QUESTION);
1828
-			$table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER);
1823
+        if (is_object($question)) {
1824
+            if ($question->is_restored()) {
1825
+                return $question->destination_id;
1826
+            }
1827
+            $table_que = Database::get_course_table(TABLE_QUIZ_QUESTION);
1828
+            $table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER);
1829 1829
             $table_options = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION);
1830 1830
 
1831
-			// check resources inside html from ckeditor tool and copy correct urls into recipient course
1831
+            // check resources inside html from ckeditor tool and copy correct urls into recipient course
1832 1832
             $question->description = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1833 1833
                 $question->description,
1834 1834
                 $this->course->code,
@@ -1849,7 +1849,7 @@  discard block
 block discarded – undo
1849 1849
                 'extra' => self::DBUTF8($question->extra),
1850 1850
             ];
1851 1851
 
1852
-			$new_id = Database::insert($table_que, $params);
1852
+            $new_id = Database::insert($table_que, $params);
1853 1853
 
1854 1854
             if ($new_id) {
1855 1855
 
@@ -1890,7 +1890,7 @@  discard block
 block discarded – undo
1890 1890
 
1891 1891
                 foreach ($temp as $index => $answer) {
1892 1892
                     //id = '".$index."',
1893
-					$params = [
1893
+                    $params = [
1894 1894
                         'c_id' => $this->destination_course_id,
1895 1895
                         'question_id' => $new_id,
1896 1896
                         'answer' => self::DBUTF8($answer['answer']),
@@ -1907,12 +1907,12 @@  discard block
 block discarded – undo
1907 1907
                         $sql = "UPDATE $table_ans SET id = iid, id_auto = iid WHERE iid = $answerId";
1908 1908
                         Database::query($sql);
1909 1909
                     }
1910
-				}
1911
-			} else {
1910
+                }
1911
+            } else {
1912 1912
                 $correct_answers = array();
1913
-				foreach ($question->answers as $index => $answer) {
1913
+                foreach ($question->answers as $index => $answer) {
1914 1914
 
1915
-					// check resources inside html from ckeditor tool and copy correct urls into recipient course
1915
+                    // check resources inside html from ckeditor tool and copy correct urls into recipient course
1916 1916
                     $answer['answer'] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1917 1917
                         $answer['answer'],
1918 1918
                         $this->course->code,
@@ -1951,8 +1951,8 @@  discard block
 block discarded – undo
1951 1951
                     }
1952 1952
 
1953 1953
                     $correct_answers[$answerId] = $answer['correct'];
1954
-				}
1955
-			}
1954
+                }
1955
+            }
1956 1956
 
1957 1957
             //Current course id
1958 1958
             $course_id = api_get_course_int_id();
@@ -2049,12 +2049,12 @@  discard block
 block discarded – undo
2049 2049
                     }
2050 2050
                 }
2051 2051
             }
2052
-			$this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id;
2053
-		}
2054
-		return $new_id;
2055
-	}
2052
+            $this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id;
2053
+        }
2054
+        return $new_id;
2055
+    }
2056 2056
 
2057
-	/**
2057
+    /**
2058 2058
      * @todo : add session id when used for session
2059 2059
      */
2060 2060
     public function restore_test_category($session_id, $respect_base_content, $destination_course_code)
@@ -2134,21 +2134,21 @@  discard block
 block discarded – undo
2134 2134
         $sessionId = intval($sessionId);
2135 2135
 
2136 2136
         if ($this->course->has_resources(RESOURCE_SURVEY)) {
2137
-			$table_sur = Database :: get_course_table(TABLE_SURVEY);
2138
-			$table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2139
-			$table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2140
-			$resources = $this->course->resources;
2141
-			foreach ($resources[RESOURCE_SURVEY] as $id => $survey) {
2137
+            $table_sur = Database :: get_course_table(TABLE_SURVEY);
2138
+            $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2139
+            $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2140
+            $resources = $this->course->resources;
2141
+            foreach ($resources[RESOURCE_SURVEY] as $id => $survey) {
2142 2142
 
2143
-				$sql = 'SELECT survey_id FROM '.$table_sur.'
2143
+                $sql = 'SELECT survey_id FROM '.$table_sur.'
2144 2144
                         WHERE
2145 2145
                             c_id = '.$this->destination_course_id.' AND
2146 2146
                             code = "'.self::DBUTF8escapestring($survey->code).'" AND
2147 2147
                             lang = "'.self::DBUTF8escapestring($survey->lang).'" ';
2148 2148
 
2149
-				$result_check = Database::query($sql);
2149
+                $result_check = Database::query($sql);
2150 2150
 
2151
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
2151
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
2152 2152
                 $survey->title = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2153 2153
                     $survey->title,
2154 2154
                     $this->course->code,
@@ -2202,20 +2202,20 @@  discard block
 block discarded – undo
2202 2202
                     'session_id' => $sessionId,
2203 2203
                 ];
2204 2204
 
2205
-				//An existing survey exists with the same code and the same language
2206
-				if (Database::num_rows($result_check) == 1) {
2207
-					switch ($this->file_option) {
2208
-						case FILE_SKIP:
2209
-							//Do nothing
2210
-							break;
2211
-						case FILE_RENAME:
2212
-							$survey_code = $survey->code.'_';
2213
-							$i=1;
2214
-							$temp_survey_code = $survey_code.$i;
2215
-							while (!$this->is_survey_code_available($temp_survey_code)) {
2216
-								$temp_survey_code = $survey_code.++$i;
2217
-							}
2218
-							$survey_code = $temp_survey_code;
2205
+                //An existing survey exists with the same code and the same language
2206
+                if (Database::num_rows($result_check) == 1) {
2207
+                    switch ($this->file_option) {
2208
+                        case FILE_SKIP:
2209
+                            //Do nothing
2210
+                            break;
2211
+                        case FILE_RENAME:
2212
+                            $survey_code = $survey->code.'_';
2213
+                            $i=1;
2214
+                            $temp_survey_code = $survey_code.$i;
2215
+                            while (!$this->is_survey_code_available($temp_survey_code)) {
2216
+                                $temp_survey_code = $survey_code.++$i;
2217
+                            }
2218
+                            $survey_code = $temp_survey_code;
2219 2219
 
2220 2220
                             $params['code'] = $survey_code;
2221 2221
                             $new_id = Database::insert($table_sur, $params);
@@ -2234,25 +2234,25 @@  discard block
 block discarded – undo
2234 2234
                                     Database::query($sql);
2235 2235
                                 }
2236 2236
                             }
2237
-							break;
2238
-						case FILE_OVERWRITE:
2239
-							// Delete the existing survey with the same code and language and import the one of the source course
2240
-							// getting the information of the survey (used for when the survey is shared)
2237
+                            break;
2238
+                        case FILE_OVERWRITE:
2239
+                            // Delete the existing survey with the same code and language and import the one of the source course
2240
+                            // getting the information of the survey (used for when the survey is shared)
2241 2241
 
2242
-							$sql = "SELECT * FROM $table_sur
2242
+                            $sql = "SELECT * FROM $table_sur
2243 2243
 							        WHERE
2244 2244
 							            c_id = ".$this->destination_course_id." AND
2245 2245
 							            survey_id='".self::DBUTF8escapestring(Database::result($result_check,0,0))."'";
2246
-							$result = Database::query($sql);
2247
-							$survey_data = Database::fetch_array($result,'ASSOC');
2246
+                            $result = Database::query($sql);
2247
+                            $survey_data = Database::fetch_array($result,'ASSOC');
2248 2248
 
2249
-							// if the survey is shared => also delete the shared content
2250
-							if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) {
2249
+                            // if the survey is shared => also delete the shared content
2250
+                            if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) {
2251 2251
                                 SurveyManager::delete_survey($survey_data['survey_share'], true,$this->destination_course_id);
2252
-							}
2253
-							SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id);
2252
+                            }
2253
+                            SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id);
2254 2254
 
2255
-							// Insert the new source survey
2255
+                            // Insert the new source survey
2256 2256
                             $new_id = Database::insert($table_sur, $params);
2257 2257
 
2258 2258
                             if ($new_id) {
@@ -2273,11 +2273,11 @@  discard block
 block discarded – undo
2273 2273
                                     Database::query($sql);
2274 2274
                                 }
2275 2275
                             }
2276
-							break;
2277
-						default:
2278
-							break;
2279
-					}
2280
-				} else {
2276
+                            break;
2277
+                        default:
2278
+                            break;
2279
+                    }
2280
+                } else {
2281 2281
                     // No existing survey with the same language and the same code, we just copy the survey
2282 2282
                     $new_id = Database::insert($table_sur, $params);
2283 2283
 
@@ -2299,43 +2299,43 @@  discard block
 block discarded – undo
2299 2299
                             Database::query($sql);
2300 2300
                         }
2301 2301
                     }
2302
-				}
2303
-			}
2304
-		}
2305
-	}
2306
-
2307
-	/**
2308
-	 * Check availability of a survey code
2309
-	 */
2302
+                }
2303
+            }
2304
+        }
2305
+    }
2306
+
2307
+    /**
2308
+     * Check availability of a survey code
2309
+     */
2310 2310
     public function is_survey_code_available($survey_code)
2311 2311
     {
2312
-		$table_sur = Database :: get_course_table(TABLE_SURVEY);
2313
-		$sql = "SELECT * FROM $table_sur
2312
+        $table_sur = Database :: get_course_table(TABLE_SURVEY);
2313
+        $sql = "SELECT * FROM $table_sur
2314 2314
 		        WHERE
2315 2315
 		            c_id = ".$this->destination_course_id." AND
2316 2316
 		            code='".self::DBUTF8escapestring($survey_code)."'";
2317
-		$result = Database::query($sql);
2318
-		if (Database::num_rows($result) > 0) return false; else return true;
2319
-	}
2317
+        $result = Database::query($sql);
2318
+        if (Database::num_rows($result) > 0) return false; else return true;
2319
+    }
2320 2320
 
2321
-	/**
2322
-	 * Restore survey-questions
2323
-	 */
2321
+    /**
2322
+     * Restore survey-questions
2323
+     */
2324 2324
     public function restore_survey_question($id, $survey_id)
2325 2325
     {
2326
-		$resources = $this->course->resources;
2327
-		$question = $resources[RESOURCE_SURVEYQUESTION][$id];
2326
+        $resources = $this->course->resources;
2327
+        $question = $resources[RESOURCE_SURVEYQUESTION][$id];
2328 2328
 
2329
-		$new_id=0;
2329
+        $new_id=0;
2330 2330
 
2331
-		if (is_object($question)) {
2332
-			if ($question->is_restored()) {
2333
-				return $question->destination_id;
2334
-			}
2335
-			$table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2336
-			$table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2331
+        if (is_object($question)) {
2332
+            if ($question->is_restored()) {
2333
+                return $question->destination_id;
2334
+            }
2335
+            $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2336
+            $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2337 2337
 
2338
-			// check resources inside html from ckeditor tool and copy correct urls into recipient course
2338
+            // check resources inside html from ckeditor tool and copy correct urls into recipient course
2339 2339
             $question->survey_question = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2340 2340
                 $question->survey_question,
2341 2341
                 $this->course->code,
@@ -2389,10 +2389,10 @@  discard block
 block discarded – undo
2389 2389
                 }
2390 2390
                 $this->course->resources[RESOURCE_SURVEYQUESTION][$id]->destination_id = $new_id;
2391 2391
             }
2392
-		}
2392
+        }
2393 2393
 
2394
-		return $new_id;
2395
-	}
2394
+        return $new_id;
2395
+    }
2396 2396
 
2397 2397
     /**
2398 2398
      * Restoring learning paths
@@ -2403,20 +2403,20 @@  discard block
 block discarded – undo
2403 2403
     {
2404 2404
         $session_id = intval($session_id);
2405 2405
 
2406
-		if ($this->course->has_resources(RESOURCE_LEARNPATH)) {
2406
+        if ($this->course->has_resources(RESOURCE_LEARNPATH)) {
2407 2407
             $table_main = Database::get_course_table(TABLE_LP_MAIN);
2408 2408
             $table_item = Database::get_course_table(TABLE_LP_ITEM);
2409 2409
             $table_tool = Database::get_course_table(TABLE_TOOL_LIST);
2410 2410
 
2411
-			$resources = $this->course->resources;
2411
+            $resources = $this->course->resources;
2412 2412
 
2413
-			$origin_path = $this->course->backup_path.'/upload/learning_path/images/';
2414
-			$destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/';
2413
+            $origin_path = $this->course->backup_path.'/upload/learning_path/images/';
2414
+            $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/';
2415 2415
 
2416
-			foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) {
2416
+            foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) {
2417 2417
 
2418
-				$condition_session = "";
2419
-				if (!empty($session_id)) {
2418
+                $condition_session = "";
2419
+                if (!empty($session_id)) {
2420 2420
                     if ($respect_base_content) {
2421 2421
                         $my_session_id = $lp->session_id;
2422 2422
                         if (!empty($lp->session_id)) {
@@ -2427,21 +2427,21 @@  discard block
 block discarded – undo
2427 2427
                         $session_id = intval($session_id);
2428 2428
                         $condition_session = $session_id;
2429 2429
                     }
2430
-				}
2431
-
2432
-				// Adding the author's image
2433
-				if (!empty($lp->preview_image)) {
2434
-					$new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image));
2435
-					if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) {
2436
-						$copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename);
2437
-						//$copy_result = true;
2438
-						if ($copy_result) {
2439
-							$lp->preview_image = $new_filename;
2440
-						} else {
2441
-							$lp->preview_image ='';
2442
-						}
2443
-					}
2444
-				}
2430
+                }
2431
+
2432
+                // Adding the author's image
2433
+                if (!empty($lp->preview_image)) {
2434
+                    $new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image));
2435
+                    if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) {
2436
+                        $copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename);
2437
+                        //$copy_result = true;
2438
+                        if ($copy_result) {
2439
+                            $lp->preview_image = $new_filename;
2440
+                        } else {
2441
+                            $lp->preview_image ='';
2442
+                        }
2443
+                    }
2444
+                }
2445 2445
 
2446 2446
                 if ($this->add_text_in_items) {
2447 2447
                     $lp->name = $lp->name.' '.get_lang('CopyLabelSuffix');
@@ -2488,7 +2488,7 @@  discard block
 block discarded – undo
2488 2488
                     $params['session_id'] = $condition_session;
2489 2489
                 }
2490 2490
 
2491
-				$new_lp_id = Database::insert($table_main, $params);
2491
+                $new_lp_id = Database::insert($table_main, $params);
2492 2492
 
2493 2493
                 if ($new_lp_id) {
2494 2494
 
@@ -2549,13 +2549,13 @@  discard block
 block discarded – undo
2549 2549
                 $old_refs = array();
2550 2550
                 $prerequisite_ids = array();
2551 2551
 
2552
-				foreach ($lp->get_items() as $index => $item) {
2553
-					// we set the ref code here and then we update in a for loop
2554
-					$ref = $item['ref'];
2552
+                foreach ($lp->get_items() as $index => $item) {
2553
+                    // we set the ref code here and then we update in a for loop
2554
+                    $ref = $item['ref'];
2555 2555
 
2556
-					// Dealing with path the same way as ref as some data has
2556
+                    // Dealing with path the same way as ref as some data has
2557 2557
                     // been put into path when it's a local resource
2558
-					// Only fix the path for no scos
2558
+                    // Only fix the path for no scos
2559 2559
                     if ($item['item_type'] == 'sco') {
2560 2560
                         $path = $item['path'];
2561 2561
                     } else {
@@ -2584,128 +2584,128 @@  discard block
 block discarded – undo
2584 2584
                         'launch_data' => self::DBUTF8($item['launch_data']),
2585 2585
                     ];
2586 2586
 
2587
-					$new_item_id = Database::insert($table_item, $params);
2587
+                    $new_item_id = Database::insert($table_item, $params);
2588 2588
 
2589 2589
                     $sql = "UPDATE $table_item SET id = iid WHERE iid = $new_item_id";
2590 2590
                     Database::query($sql);
2591 2591
 
2592
-					//save a link between old and new item IDs
2593
-					$new_item_ids[$item['id']] = $new_item_id;
2594
-					//save a reference of items that need a parent_item_id refresh
2595
-					$parent_item_ids[$new_item_id] = $item['parent_item_id'];
2596
-					//save a reference of items that need a previous_item_id refresh
2597
-					$previous_item_ids[$new_item_id] = $item['previous_item_id'];
2598
-					//save a reference of items that need a next_item_id refresh
2599
-					$next_item_ids[$new_item_id] = $item['next_item_id'];
2600
-
2601
-					if (!empty($item['prerequisite'])) {
2602
-						if ($lp->lp_type =='2') {
2603
-							// if is an sco
2604
-							$old_prerequisite[$new_item_id]= $item['prerequisite'];
2605
-						} else {
2606
-							$old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']];
2607
-						}
2608
-					}
2609
-
2610
-					if (!empty($ref)) {
2611
-						if ($lp->lp_type =='2') {
2612
-							// if is an sco
2613
-							$old_refs[$new_item_id]= $ref;
2614
-						} else {
2592
+                    //save a link between old and new item IDs
2593
+                    $new_item_ids[$item['id']] = $new_item_id;
2594
+                    //save a reference of items that need a parent_item_id refresh
2595
+                    $parent_item_ids[$new_item_id] = $item['parent_item_id'];
2596
+                    //save a reference of items that need a previous_item_id refresh
2597
+                    $previous_item_ids[$new_item_id] = $item['previous_item_id'];
2598
+                    //save a reference of items that need a next_item_id refresh
2599
+                    $next_item_ids[$new_item_id] = $item['next_item_id'];
2600
+
2601
+                    if (!empty($item['prerequisite'])) {
2602
+                        if ($lp->lp_type =='2') {
2603
+                            // if is an sco
2604
+                            $old_prerequisite[$new_item_id]= $item['prerequisite'];
2605
+                        } else {
2606
+                            $old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']];
2607
+                        }
2608
+                    }
2609
+
2610
+                    if (!empty($ref)) {
2611
+                        if ($lp->lp_type =='2') {
2612
+                            // if is an sco
2613
+                            $old_refs[$new_item_id]= $ref;
2614
+                        } else {
2615 2615
                             $old_refs[$new_item_id]= $new_item_ids[$ref];
2616
-						}
2617
-					}
2616
+                        }
2617
+                    }
2618 2618
 
2619
-					$prerequisite_ids[$new_item_id] = $item['prerequisite'];
2620
-				}
2619
+                    $prerequisite_ids[$new_item_id] = $item['prerequisite'];
2620
+                }
2621 2621
 
2622
-				// Updating prerequisites
2623
-				foreach ($old_prerequisite  as $key=>$my_old_prerequisite) {
2624
-					if($my_old_prerequisite != ''){
2625
-						$sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."'
2622
+                // Updating prerequisites
2623
+                foreach ($old_prerequisite  as $key=>$my_old_prerequisite) {
2624
+                    if($my_old_prerequisite != ''){
2625
+                        $sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."'
2626 2626
 						        WHERE c_id = ".$this->destination_course_id." AND id = '".$key."'  ";
2627
-						Database::query($sql);
2628
-					}
2629
-				}
2630
-
2631
-				// Updating refs
2632
-				foreach ($old_refs  as $key=>$my_old_ref) {
2633
-					if ($my_old_ref != '') {
2634
-						$sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."'
2627
+                        Database::query($sql);
2628
+                    }
2629
+                }
2630
+
2631
+                // Updating refs
2632
+                foreach ($old_refs  as $key=>$my_old_ref) {
2633
+                    if ($my_old_ref != '') {
2634
+                        $sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."'
2635 2635
 						        WHERE c_id = ".$this->destination_course_id." AND id = '".$key."'  ";
2636
-						Database::query($sql);
2637
-					}
2638
-				}
2639
-
2640
-				foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) {
2641
-					$parent_new_id = 0;
2642
-					if($parent_item_old_id != 0){
2643
-						$parent_new_id = $new_item_ids[$parent_item_old_id];
2644
-					}
2645
-					$sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."'
2636
+                        Database::query($sql);
2637
+                    }
2638
+                }
2639
+
2640
+                foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) {
2641
+                    $parent_new_id = 0;
2642
+                    if($parent_item_old_id != 0){
2643
+                        $parent_new_id = $new_item_ids[$parent_item_old_id];
2644
+                    }
2645
+                    $sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."'
2646 2646
 					        WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'";
2647
-					Database::query($sql);
2648
-				}
2649
-				foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) {
2650
-					$previous_new_id = 0;
2651
-					if($previous_item_old_id != 0){
2652
-						$previous_new_id = $new_item_ids[$previous_item_old_id];
2653
-					}
2654
-					$sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."'
2647
+                    Database::query($sql);
2648
+                }
2649
+                foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) {
2650
+                    $previous_new_id = 0;
2651
+                    if($previous_item_old_id != 0){
2652
+                        $previous_new_id = $new_item_ids[$previous_item_old_id];
2653
+                    }
2654
+                    $sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."'
2655 2655
 					        WHERE  c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'";
2656
-					Database::query($sql);
2657
-				}
2658
-
2659
-				foreach ($next_item_ids as $new_item_id => $next_item_old_id) {
2660
-					$next_new_id = 0;
2661
-					if($next_item_old_id != 0){
2662
-						$next_new_id = $new_item_ids[$next_item_old_id];
2663
-					}
2664
-					$sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."'
2656
+                    Database::query($sql);
2657
+                }
2658
+
2659
+                foreach ($next_item_ids as $new_item_id => $next_item_old_id) {
2660
+                    $next_new_id = 0;
2661
+                    if($next_item_old_id != 0){
2662
+                        $next_new_id = $new_item_ids[$next_item_old_id];
2663
+                    }
2664
+                    $sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."'
2665 2665
 					        WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'";
2666
-					Database::query($sql);
2667
-				}
2668
-
2669
-				foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) {
2670
-					$prerequisite_new_id = 0;
2671
-					if($prerequisite_old_id != 0){
2672
-						$prerequisite_new_id = $new_item_ids[$prerequisite_old_id];
2673
-					}
2674
-					$sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."'
2666
+                    Database::query($sql);
2667
+                }
2668
+
2669
+                foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) {
2670
+                    $prerequisite_new_id = 0;
2671
+                    if($prerequisite_old_id != 0){
2672
+                        $prerequisite_new_id = $new_item_ids[$prerequisite_old_id];
2673
+                    }
2674
+                    $sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."'
2675 2675
 					        WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'";
2676
-					Database::query($sql);
2677
-				}
2678
-				$this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id;
2679
-			}
2680
-		}
2681
-	}
2682
-
2683
-	/**
2684
-	 * Restore works
2676
+                    Database::query($sql);
2677
+                }
2678
+                $this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id;
2679
+            }
2680
+        }
2681
+    }
2682
+
2683
+    /**
2684
+     * Restore works
2685 2685
      * @deprecated use restore_works
2686 2686
      *
2687
-	 */
2688
-	public function restore_student_publication($sessionId = 0)
2687
+     */
2688
+    public function restore_student_publication($sessionId = 0)
2689 2689
     {
2690 2690
         $sessionId = intval($sessionId);
2691
-		$work_assignment_table  = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
2692
-		$work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
2693
-		$item_property_table  	= Database :: get_course_table(TABLE_ITEM_PROPERTY);
2691
+        $work_assignment_table  = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
2692
+        $work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
2693
+        $item_property_table  	= Database :: get_course_table(TABLE_ITEM_PROPERTY);
2694 2694
 
2695
-		// Query in student publication
2696
-		$sql = 'SELECT * FROM '.$work_table.'
2695
+        // Query in student publication
2696
+        $sql = 'SELECT * FROM '.$work_table.'
2697 2697
 		        WHERE c_id = '.$this->course_origin_id.' AND filetype = "folder" AND active IN (0, 1) ';
2698 2698
 
2699
-		$result = Database::query($sql);
2700
-		$folders = Database::store_result($result, 'ASSOC');
2699
+        $result = Database::query($sql);
2700
+        $folders = Database::store_result($result, 'ASSOC');
2701 2701
 
2702
-		foreach ($folders  as $folder) {
2703
-		    $old_id = $folder['id'];
2702
+        foreach ($folders  as $folder) {
2703
+            $old_id = $folder['id'];
2704 2704
             unset($folder['id']);
2705
-			$folder['c_id'] = $this->destination_course_id;
2705
+            $folder['c_id'] = $this->destination_course_id;
2706 2706
             $folder['parent_id'] = 0;
2707 2707
             $folder['session_id'] = $sessionId;
2708
-			$new_id = Database::insert($work_table, $folder);
2708
+            $new_id = Database::insert($work_table, $folder);
2709 2709
 
2710 2710
             if ($new_id) {
2711 2711
                 //query in item property
@@ -2764,21 +2764,21 @@  discard block
 block discarded – undo
2764 2764
                     }
2765 2765
                 }
2766 2766
             }
2767
-		}
2767
+        }
2768 2768
 
2769
-		$destination = '../../courses/'.$this->course->destination_path.'/work/';
2770
-		$origin = '../../courses/'.$this->course->info['path'].'/work/';
2771
-		self::allow_create_all_directory($origin,$destination,false);
2772
-	}
2769
+        $destination = '../../courses/'.$this->course->destination_path.'/work/';
2770
+        $origin = '../../courses/'.$this->course->info['path'].'/work/';
2771
+        self::allow_create_all_directory($origin,$destination,false);
2772
+    }
2773 2773
 
2774 2774
     /**
2775
-    * copy all directory and sub directory
2776
-    * @param string The path origin
2777
-    * @param string The path destination
2778
-    * @param boolean Option Overwrite
2779
-    * @return void()
2780
-    * @deprecated
2781
-    */
2775
+     * copy all directory and sub directory
2776
+     * @param string The path origin
2777
+     * @param string The path destination
2778
+     * @param boolean Option Overwrite
2779
+     * @return void()
2780
+     * @deprecated
2781
+     */
2782 2782
     public function allow_create_all_directory($source, $dest, $overwrite = false)
2783 2783
     {
2784 2784
         if (!is_dir($dest)) {
@@ -2789,14 +2789,14 @@  discard block
 block discarded – undo
2789 2789
                 if ($file != '.' && $file != '..') {
2790 2790
                     $path = $source . '/' . $file;
2791 2791
                     if (is_file($path)) {
2792
-                       /* if (!is_file($dest . '/' . $file) || $overwrite)
2792
+                        /* if (!is_file($dest . '/' . $file) || $overwrite)
2793 2793
                         if (!@copy($path, $dest . '/' . $file)) {
2794 2794
                             echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>';
2795 2795
                         }*/
2796 2796
                     } elseif(is_dir($path)) {
2797 2797
                         if (!is_dir($dest . '/' . $file))
2798 2798
                         mkdir($dest . '/' . $file);
2799
-                       self:: allow_create_all_directory($path, $dest . '/' . $file, $overwrite);
2799
+                        self:: allow_create_all_directory($path, $dest . '/' . $file, $overwrite);
2800 2800
                     }
2801 2801
                 }
2802 2802
             }
@@ -2804,12 +2804,12 @@  discard block
 block discarded – undo
2804 2804
         }
2805 2805
     }
2806 2806
 
2807
-	/**
2808
-	 * Gets the new ID of one specific tool item from the tool name and the old ID
2809
-	 * @param	string	Tool name
2810
-	 * @param	integer	Old ID
2811
-	 * @return	integer	New ID
2812
-	 */
2807
+    /**
2808
+     * Gets the new ID of one specific tool item from the tool name and the old ID
2809
+     * @param	string	Tool name
2810
+     * @param	integer	Old ID
2811
+     * @return	integer	New ID
2812
+     */
2813 2813
     public function get_new_id($tool, $ref)
2814 2814
     {
2815 2815
         // Check if the value exist in the current array.
@@ -2831,25 +2831,25 @@  discard block
 block discarded – undo
2831 2831
         }
2832 2832
 
2833 2833
         return '';
2834
-	}
2834
+    }
2835 2835
 
2836
-	/**
2837
-	 * Restore glossary
2838
-	 */
2836
+    /**
2837
+     * Restore glossary
2838
+     */
2839 2839
     public function restore_glossary($session_id = 0)
2840 2840
     {
2841
-		if ($this->course->has_resources(RESOURCE_GLOSSARY)) {
2842
-			$table_glossary = Database :: get_course_table(TABLE_GLOSSARY);
2843
-			$resources = $this->course->resources;
2844
-			foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) {
2841
+        if ($this->course->has_resources(RESOURCE_GLOSSARY)) {
2842
+            $table_glossary = Database :: get_course_table(TABLE_GLOSSARY);
2843
+            $resources = $this->course->resources;
2844
+            foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) {
2845 2845
 
2846 2846
                 $params = [];
2847
-    			if (!empty($session_id)) {
2848
-    				$session_id = intval($session_id);
2847
+                if (!empty($session_id)) {
2848
+                    $session_id = intval($session_id);
2849 2849
                     $params['session_id'] = $session_id;
2850
-    			}
2850
+                }
2851 2851
 
2852
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
2852
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
2853 2853
                 $glossary->description = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2854 2854
                     $glossary->description,
2855 2855
                     $this->course->code,
@@ -2883,27 +2883,27 @@  discard block
 block discarded – undo
2883 2883
 
2884 2884
                     $this->course->resources[RESOURCE_GLOSSARY][$id]->destination_id = $my_id;
2885 2885
                 }
2886
-			}
2887
-		}
2888
-	}
2886
+            }
2887
+        }
2888
+    }
2889 2889
 
2890 2890
     /**
2891 2891
      * @param int $session_id
2892 2892
      */
2893 2893
     public function restore_wiki($session_id = 0)
2894 2894
     {
2895
-		if ($this->course->has_resources(RESOURCE_WIKI)) {
2896
-			// wiki table of the target course
2897
-			$table_wiki = Database :: get_course_table(TABLE_WIKI);
2898
-			$table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF);
2895
+        if ($this->course->has_resources(RESOURCE_WIKI)) {
2896
+            // wiki table of the target course
2897
+            $table_wiki = Database :: get_course_table(TABLE_WIKI);
2898
+            $table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF);
2899 2899
 
2900
-			// storing all the resources that have to be copied in an array
2901
-			$resources = $this->course->resources;
2900
+            // storing all the resources that have to be copied in an array
2901
+            $resources = $this->course->resources;
2902 2902
 
2903
-			foreach ($resources[RESOURCE_WIKI] as $id => $wiki) {
2904
-				// the sql statement to insert the groups from the old course to the new course
2903
+            foreach ($resources[RESOURCE_WIKI] as $id => $wiki) {
2904
+                // the sql statement to insert the groups from the old course to the new course
2905 2905
 
2906
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
2906
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
2907 2907
                 $wiki->content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2908 2908
                     $wiki->content,
2909 2909
                     $this->course->code,
@@ -2926,7 +2926,7 @@  discard block
 block discarded – undo
2926 2926
                     'session_id' => !empty($session_id) ? intval($session_id) : 0,
2927 2927
                 ];
2928 2928
 
2929
-				$new_id = Database::insert($table_wiki, $params);
2929
+                $new_id = Database::insert($table_wiki, $params);
2930 2930
 
2931 2931
                 if ($new_id) {
2932 2932
 
@@ -2957,9 +2957,9 @@  discard block
 block discarded – undo
2957 2957
 
2958 2958
                     Database::insert($table_wiki_conf, $params);
2959 2959
                 }
2960
-			}
2961
-		}
2962
-	}
2960
+            }
2961
+        }
2962
+    }
2963 2963
 
2964 2964
     /**
2965 2965
      * Restore Thematics
@@ -2967,15 +2967,15 @@  discard block
 block discarded – undo
2967 2967
      */
2968 2968
     public function restore_thematic($session_id = 0)
2969 2969
     {
2970
-		if ($this->course->has_resources(RESOURCE_THEMATIC)) {
2970
+        if ($this->course->has_resources(RESOURCE_THEMATIC)) {
2971 2971
             $table_thematic = Database:: get_course_table(TABLE_THEMATIC);
2972 2972
             $table_thematic_advance = Database:: get_course_table(TABLE_THEMATIC_ADVANCE);
2973 2973
             $table_thematic_plan = Database:: get_course_table(TABLE_THEMATIC_PLAN);
2974 2974
 
2975
-			$resources = $this->course->resources;
2976
-			foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) {
2975
+            $resources = $this->course->resources;
2976
+            foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) {
2977 2977
 
2978
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
2978
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
2979 2979
                 $thematic->params['content'] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2980 2980
                     $thematic->params['content'],
2981 2981
                     $this->course->code,
@@ -2983,13 +2983,13 @@  discard block
 block discarded – undo
2983 2983
                     $this->course->backup_path,
2984 2984
                     $this->course->info['path']
2985 2985
                 );
2986
-				$thematic->params['c_id']  = $this->destination_course_id;
2987
-				unset($thematic->params['id']);
2986
+                $thematic->params['c_id']  = $this->destination_course_id;
2987
+                unset($thematic->params['id']);
2988 2988
                 unset($thematic->params['iid']);
2989 2989
 
2990
-				$last_id = Database::insert($table_thematic, $thematic->params, false);
2990
+                $last_id = Database::insert($table_thematic, $thematic->params, false);
2991 2991
 
2992
-				if ($last_id) {
2992
+                if ($last_id) {
2993 2993
 
2994 2994
                     $sql = "UPDATE $table_thematic SET id = iid WHERE iid = $last_id";
2995 2995
                     Database::query($sql);
@@ -3002,19 +3002,19 @@  discard block
 block discarded – undo
3002 3002
                         api_get_user_id()
3003 3003
                     );
3004 3004
 
3005
-					foreach ($thematic->thematic_advance_list as $thematic_advance) {
3006
-						unset($thematic_advance['id']);
3005
+                    foreach ($thematic->thematic_advance_list as $thematic_advance) {
3006
+                        unset($thematic_advance['id']);
3007 3007
                         unset($thematic_advance['iid']);
3008
-						$thematic_advance['attendance_id'] = 0;
3009
-						$thematic_advance['thematic_id'] = $last_id;
3010
-						$thematic_advance['c_id']  = $this->destination_course_id;
3008
+                        $thematic_advance['attendance_id'] = 0;
3009
+                        $thematic_advance['thematic_id'] = $last_id;
3010
+                        $thematic_advance['c_id']  = $this->destination_course_id;
3011 3011
                         $my_id = Database::insert(
3012 3012
                             $table_thematic_advance,
3013 3013
                             $thematic_advance,
3014 3014
                             false
3015 3015
                         );
3016 3016
 
3017
-						if ($my_id) {
3017
+                        if ($my_id) {
3018 3018
 
3019 3019
                             $sql = "UPDATE $table_thematic_advance SET id = iid WHERE iid = $my_id";
3020 3020
                             Database::query($sql);
@@ -3026,17 +3026,17 @@  discard block
 block discarded – undo
3026 3026
                                 "ThematicAdvanceAdded",
3027 3027
                                 api_get_user_id()
3028 3028
                             );
3029
-						}
3030
-					}
3029
+                        }
3030
+                    }
3031 3031
 
3032
-					foreach($thematic->thematic_plan_list as $thematic_plan) {
3033
-						unset($thematic_plan['id']);
3032
+                    foreach($thematic->thematic_plan_list as $thematic_plan) {
3033
+                        unset($thematic_plan['id']);
3034 3034
                         unset($thematic_plan['iid']);
3035
-						$thematic_plan['thematic_id'] = $last_id;
3036
-						$thematic_plan['c_id'] = $this->destination_course_id;
3037
-						$my_id = Database::insert($table_thematic_plan, $thematic_plan, false);
3035
+                        $thematic_plan['thematic_id'] = $last_id;
3036
+                        $thematic_plan['c_id'] = $this->destination_course_id;
3037
+                        $my_id = Database::insert($table_thematic_plan, $thematic_plan, false);
3038 3038
 
3039
-						if ($my_id) {
3039
+                        if ($my_id) {
3040 3040
 
3041 3041
                             $sql = "UPDATE $table_thematic_plan SET id = iid WHERE iid = $my_id";
3042 3042
                             Database::query($sql);
@@ -3048,12 +3048,12 @@  discard block
 block discarded – undo
3048 3048
                                 "ThematicPlanAdded",
3049 3049
                                 api_get_user_id()
3050 3050
                             );
3051
-						}
3052
-					}
3053
-				}
3054
-			}
3055
-		}
3056
-	}
3051
+                        }
3052
+                    }
3053
+                }
3054
+            }
3055
+        }
3056
+    }
3057 3057
 
3058 3058
     /**
3059 3059
      * Restore Attendance
@@ -3061,14 +3061,14 @@  discard block
 block discarded – undo
3061 3061
      */
3062 3062
     public function restore_attendance($session_id = 0)
3063 3063
     {
3064
-		if ($this->course->has_resources(RESOURCE_ATTENDANCE)) {
3065
-			$table_attendance = Database :: get_course_table(TABLE_ATTENDANCE);
3066
-			$table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR);
3064
+        if ($this->course->has_resources(RESOURCE_ATTENDANCE)) {
3065
+            $table_attendance = Database :: get_course_table(TABLE_ATTENDANCE);
3066
+            $table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR);
3067 3067
 
3068
-			$resources = $this->course->resources;
3069
-			foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) {
3068
+            $resources = $this->course->resources;
3069
+            foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) {
3070 3070
 
3071
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
3071
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
3072 3072
                 $obj->params['description'] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
3073 3073
                     $obj->params['description'],
3074 3074
                     $this->course->code,
@@ -3080,11 +3080,11 @@  discard block
 block discarded – undo
3080 3080
                 unset($obj->params['id']);
3081 3081
                 unset($obj->params['iid']);
3082 3082
 
3083
-				$obj->params['c_id'] = $this->destination_course_id;
3083
+                $obj->params['c_id'] = $this->destination_course_id;
3084 3084
 
3085
-				$last_id = Database::insert($table_attendance, $obj->params);
3085
+                $last_id = Database::insert($table_attendance, $obj->params);
3086 3086
 
3087
-				if (is_numeric($last_id)) {
3087
+                if (is_numeric($last_id)) {
3088 3088
 
3089 3089
                     $sql = "UPDATE $table_attendance SET id = iid WHERE iid = $last_id";
3090 3090
                     Database::query($sql);
@@ -3098,11 +3098,11 @@  discard block
 block discarded – undo
3098 3098
                     );
3099 3099
 
3100 3100
                     foreach ($obj->attendance_calendar as $attendance_calendar) {
3101
-						unset($attendance_calendar['id']);
3101
+                        unset($attendance_calendar['id']);
3102 3102
                         unset($attendance_calendar['iid']);
3103 3103
 
3104
-						$attendance_calendar['attendance_id'] = $last_id;
3105
-						$attendance_calendar['c_id'] = $this->destination_course_id;
3104
+                        $attendance_calendar['attendance_id'] = $last_id;
3105
+                        $attendance_calendar['c_id'] = $this->destination_course_id;
3106 3106
                         $attendanceCalendarId = Database::insert(
3107 3107
                             $table_attendance_calendar,
3108 3108
                             $attendance_calendar
@@ -3110,11 +3110,11 @@  discard block
 block discarded – undo
3110 3110
 
3111 3111
                         $sql = "UPDATE $table_attendance_calendar SET id = iid WHERE iid = $attendanceCalendarId";
3112 3112
                         Database::query($sql);
3113
-					}
3114
-				}
3115
-			}
3116
-		}
3117
-	}
3113
+                    }
3114
+                }
3115
+            }
3116
+        }
3117
+    }
3118 3118
 
3119 3119
     /**
3120 3120
      * Restore Works
@@ -3256,11 +3256,11 @@  discard block
 block discarded – undo
3256 3256
      */
3257 3257
     public function DBUTF8($str)
3258 3258
     {
3259
-		if (UTF8_CONVERT) {
3259
+        if (UTF8_CONVERT) {
3260 3260
             $str = utf8_encode($str);
3261 3261
         }
3262
-		return $str;
3263
-	}
3262
+        return $str;
3263
+    }
3264 3264
 
3265 3265
     /**
3266 3266
      * @param string $str
@@ -3271,8 +3271,8 @@  discard block
 block discarded – undo
3271 3271
         if (UTF8_CONVERT) {
3272 3272
             $str = utf8_encode($str);
3273 3273
         }
3274
-		return Database::escape_string($str);
3275
-	}
3274
+        return Database::escape_string($str);
3275
+    }
3276 3276
 
3277 3277
     /**
3278 3278
      * @param array $array
Please login to merge, or discard this patch.
main/coursecopy/copy_course_session.php 2 patches
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 $cidReset = true;
13 13
 require_once '../inc/global.inc.php';
14
-$current_course_tool  = TOOL_COURSE_MAINTENANCE;
14
+$current_course_tool = TOOL_COURSE_MAINTENANCE;
15 15
 
16 16
 api_protect_global_admin_script();
17 17
 api_protect_limit_for_session_admin();
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 
83 83
 function display_form()
84 84
 {
85
-    $html  = '';
85
+    $html = '';
86 86
     $sessions = SessionManager::get_sessions_list(array(), array('name', 'ASC'));
87 87
 
88 88
     // Actions
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 
110 110
     //destination
111 111
     $html .= '<div class="form-group">';
112
-    $html .= '<label class="col-sm-2 control-label">' . get_lang('DestinationCoursesFromSession') . ': </label>';
112
+    $html .= '<label class="col-sm-2 control-label">'.get_lang('DestinationCoursesFromSession').': </label>';
113 113
     $html .= '<div class="col-sm-5" id="ajax_sessions_list_destination">';
114 114
     $html .= '<select class="form-control" name="sessions_list_destination" onchange="javascript: xajax_search_courses(this.value,\'destination\');">';
115 115
     $html .= '<option value = "0">'.get_lang('ThereIsNotStillASession').'</option></select ></div>';
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     $html .= '<button class="btn btn-success" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;"><em class="fa fa-files-o"></em> '.get_lang('CopyCourse').'</button>';
132 132
 
133 133
     // Add Security token
134
-    $html .= '<input type="hidden" value="' . Security::get_token() . '" name="sec_token">';
134
+    $html .= '<input type="hidden" value="'.Security::get_token().'" name="sec_token">';
135 135
     $html .= '</div></div>';
136 136
 
137 137
     $html .= '</form>';
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 
230 230
 /* HTML head extra */
231 231
 
232
-$htmlHeadXtra[] = $xajax->getJavascript( api_get_path(WEB_LIBRARY_PATH).'xajax/');
232
+$htmlHeadXtra[] = $xajax->getJavascript(api_get_path(WEB_LIBRARY_PATH).'xajax/');
233 233
 $htmlHeadXtra[] = '<script type="text/javascript">
234 234
 function checkSelected(id_select,id_radio,id_title,id_destination) {
235 235
    var num=0;
@@ -299,22 +299,22 @@  discard block
 block discarded – undo
299 299
         display_form();
300 300
     } else {
301 301
 
302
-        $arr_course_origin 		= array();
302
+        $arr_course_origin = array();
303 303
         $arr_course_destination = array();
304
-        $destination_session 	= '';
305
-        $origin_session 		= '';
304
+        $destination_session = '';
305
+        $origin_session = '';
306 306
 
307 307
         if (isset($_POST['SessionCoursesListOrigin'])) {
308
-            $arr_course_origin 		= $_POST['SessionCoursesListOrigin'];
308
+            $arr_course_origin = $_POST['SessionCoursesListOrigin'];
309 309
         }
310 310
         if (isset($_POST['SessionCoursesListDestination'])) {
311 311
             $arr_course_destination = $_POST['SessionCoursesListDestination'];
312 312
         }
313 313
         if (isset($_POST['sessions_list_destination'])) {
314
-            $destination_session 	= $_POST['sessions_list_destination'];
314
+            $destination_session = $_POST['sessions_list_destination'];
315 315
         }
316 316
         if (isset($_POST['sessions_list_origin'])) {
317
-            $origin_session 		= $_POST['sessions_list_origin'];
317
+            $origin_session = $_POST['sessions_list_origin'];
318 318
         }
319 319
 
320 320
         if ((is_array($arr_course_origin) && count($arr_course_origin) > 0) && !empty($destination_session)) {
@@ -354,22 +354,22 @@  discard block
 block discarded – undo
354 354
         Display::display_normal_message(get_lang('ToExportDocumentsWithGlossaryYouHaveToSelectGlossary'));
355 355
     }
356 356
 
357
-    $arr_course_origin 		= array();
357
+    $arr_course_origin = array();
358 358
     $arr_course_destination = array();
359
-    $destination_session 	= '';
360
-    $origin_session 		= '';
359
+    $destination_session = '';
360
+    $origin_session = '';
361 361
 
362 362
     if (isset($_POST['SessionCoursesListOrigin'])) {
363
-        $arr_course_origin 		= $_POST['SessionCoursesListOrigin'];
363
+        $arr_course_origin = $_POST['SessionCoursesListOrigin'];
364 364
     }
365 365
     if (isset($_POST['SessionCoursesListDestination'])) {
366 366
         $arr_course_destination = $_POST['SessionCoursesListDestination'];
367 367
     }
368 368
     if (isset($_POST['sessions_list_destination'])) {
369
-        $destination_session 	= $_POST['sessions_list_destination'];
369
+        $destination_session = $_POST['sessions_list_destination'];
370 370
     }
371 371
     if (isset($_POST['sessions_list_origin'])) {
372
-        $origin_session 		= $_POST['sessions_list_origin'];
372
+        $origin_session = $_POST['sessions_list_origin'];
373 373
     }
374 374
 
375 375
     if ((is_array($arr_course_origin) && count($arr_course_origin) > 0) && !empty($destination_session)) {
@@ -378,10 +378,10 @@  discard block
 block discarded – undo
378 378
         $cb = new CourseBuilder('', $course_origin);
379 379
         $course = $cb->build($origin_session, $arr_course_origin[0], $with_base_content);
380 380
         //$hiddenFields['same_file_name_option'] = $_POST['same_file_name_option'];
381
-        $hiddenFields['destination_course'] 	= $arr_course_destination[0];
382
-        $hiddenFields['origin_course'] 		= $arr_course_origin[0];
383
-        $hiddenFields['destination_session'] 	= $destination_session;
384
-        $hiddenFields['origin_session'] 		= $origin_session;
381
+        $hiddenFields['destination_course'] = $arr_course_destination[0];
382
+        $hiddenFields['origin_course'] = $arr_course_origin[0];
383
+        $hiddenFields['destination_session'] = $destination_session;
384
+        $hiddenFields['origin_session'] = $origin_session;
385 385
         // Add token to Course select form
386 386
         $hiddenFields['sec_token'] = Security::get_token();
387 387
 
Please login to merge, or discard this patch.
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -65,6 +65,9 @@
 block discarded – undo
65 65
 
66 66
 /* FUNCTIONS */
67 67
 
68
+/**
69
+ * @param string $name
70
+ */
68 71
 function make_select_session_list($name, $sessions, $attr = array())
69 72
 {
70 73
 
Please login to merge, or discard this patch.
main/coursecopy/import_backup.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -98,21 +98,21 @@  discard block
 block discarded – undo
98 98
         $cr->set_file_option($_POST['same_file_name_option']);
99 99
         $cr->restore();
100 100
         Display::display_normal_message(get_lang('ImportFinished'));
101
-        echo '<a class="btn btn-default" href="' . api_get_path(WEB_COURSE_PATH) . api_get_course_path() . '/index.php">' . get_lang('CourseHomepage') . '</a>';
101
+        echo '<a class="btn btn-default" href="'.api_get_path(WEB_COURSE_PATH).api_get_course_path().'/index.php">'.get_lang('CourseHomepage').'</a>';
102 102
     } else {
103 103
         if (!$error) {
104 104
             Display::display_warning_message(get_lang('NoResourcesInBackupFile'));
105
-            echo '<a class="btn btn-default" href="import_backup.php?' . api_get_cidreq() . '">' . get_lang('TryAgain') . '</a>';
105
+            echo '<a class="btn btn-default" href="import_backup.php?'.api_get_cidreq().'">'.get_lang('TryAgain').'</a>';
106 106
         } elseif ($filename === false) {
107 107
             Display::display_error_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'));
108
-            echo '<a class="btn btn-default" href="import_backup.php?' . api_get_cidreq() . '">' . get_lang('TryAgain') . '</a>';
108
+            echo '<a class="btn btn-default" href="import_backup.php?'.api_get_cidreq().'">'.get_lang('TryAgain').'</a>';
109 109
         } else {
110 110
             if ($filename == '') {
111 111
                 Display::display_error_message(get_lang('SelectBackupFile'));
112
-                echo '<a class="btn btn-default" href="import_backup.php?' . api_get_cidreq() . '">' . get_lang('TryAgain') . '</a>';
112
+                echo '<a class="btn btn-default" href="import_backup.php?'.api_get_cidreq().'">'.get_lang('TryAgain').'</a>';
113 113
             } else {
114 114
                 Display::display_error_message(get_lang('UploadError'));
115
-                echo '<a class="btn btn-default" href="import_backup.php?' . api_get_cidreq() . '">' . get_lang('TryAgain') . '</a>';
115
+                echo '<a class="btn btn-default" href="import_backup.php?'.api_get_cidreq().'">'.get_lang('TryAgain').'</a>';
116 116
             }
117 117
         }
118 118
     }
@@ -142,10 +142,10 @@  discard block
 block discarded – undo
142 142
         CourseSelectForm::display_form($course, $hiddenFields);
143 143
     } elseif ($filename === false) {
144 144
         Display::display_error_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'));
145
-        echo '<a class="btn btn-default" href="import_backup.php?' . api_get_cidreq() . '">' . get_lang('TryAgain') . '</a>';
145
+        echo '<a class="btn btn-default" href="import_backup.php?'.api_get_cidreq().'">'.get_lang('TryAgain').'</a>';
146 146
     } else {
147 147
         Display::display_warning_message(get_lang('NoResourcesInBackupFile'));
148
-        echo '<a class="btn btn-default" href="import_backup.php?' . api_get_cidreq() . '">' . get_lang('TryAgain') . '</a>';
148
+        echo '<a class="btn btn-default" href="import_backup.php?'.api_get_cidreq().'">'.get_lang('TryAgain').'</a>';
149 149
     }
150 150
 } else {
151 151
     $user = api_get_user_info();
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
     $form = new FormValidator(
158 158
         'import_backup_form',
159 159
         'post',
160
-        api_get_path(WEB_CODE_PATH) . 'coursecopy/import_backup.php?' . api_get_cidreq(),
160
+        api_get_path(WEB_CODE_PATH).'coursecopy/import_backup.php?'.api_get_cidreq(),
161 161
         '',
162 162
         array('enctype' => 'multipart/form-data')
163 163
     );
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
         );
190 190
         $options['null'] = '-';
191 191
         foreach ($backups as $index => $backup) {
192
-            $options[$backup['file']] = $backup['course_code'] . ' (' . $backup['date'] . ')';
192
+            $options[$backup['file']] = $backup['course_code'].' ('.$backup['date'].')';
193 193
         }
194 194
         $form->addElement(
195 195
             'select',
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
             'radio',
208 208
             '',
209 209
             '',
210
-            '<i>' . get_lang('NoBackupsAvailable') . '</i>',
210
+            '<i>'.get_lang('NoBackupsAvailable').'</i>',
211 211
             '',
212 212
             'disabled="true"'
213 213
         );
Please login to merge, or discard this patch.
main/search/index.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 $this_section =  SECTION_COURSES;
11 11
 
12 12
 if (extension_loaded('xapian')) {
13
-	require '../newscorm/lp_list_search.php';
13
+    require '../newscorm/lp_list_search.php';
14 14
 } else {
15 15
     Display::display_header(get_lang('Search'));
16 16
     Display::display_error_message(get_lang('SearchXapianModuleNotInstalled'));
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
  */
8 8
 
9 9
 require_once '../inc/global.inc.php';
10
-$this_section =  SECTION_COURSES;
10
+$this_section = SECTION_COURSES;
11 11
 
12 12
 if (extension_loaded('xapian')) {
13 13
 	require '../newscorm/lp_list_search.php';
Please login to merge, or discard this patch.
main/search/search_suggestions.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -104,6 +104,8 @@
 block discarded – undo
104 104
 }
105 105
 
106 106
 $q = strtolower($_GET["q"]);
107
-if (!$q) return;
107
+if (!$q) {
108
+    return;
109
+}
108 110
 //echo $q . "| value\n";
109 111
 get_suggestions_from_search_engine($q);
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package chamilo.search
7 7
  */
8 8
 
9
-require_once dirname(__FILE__) . '/../inc/global.inc.php';
9
+require_once dirname(__FILE__).'/../inc/global.inc.php';
10 10
 
11 11
 function get_suggestions_from_search_engine($q)
12 12
 {
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
     global $charset;
15 15
 
16 16
     $json = [];
17
-    $table_sfv     = Database :: get_main_table(TABLE_MAIN_SPECIFIC_FIELD_VALUES);
17
+    $table_sfv = Database :: get_main_table(TABLE_MAIN_SPECIFIC_FIELD_VALUES);
18 18
     $q = Database::escape_string($q);
19 19
     $cid = api_get_course_id();
20 20
     $sql_add = '';
@@ -28,13 +28,13 @@  discard block
 block discarded – undo
28 28
     $i = 0;
29 29
     while ($row = Database::fetch_array($sql_result)) {
30 30
         $json[] = [
31
-            'id' => api_convert_encoding($row['value'],'UTF-8',$charset),
32
-            'value' => api_convert_encoding($row['value'],'UTF-8',$charset),
33
-            'label' => api_convert_encoding($row['value'],'UTF-8',$charset)
31
+            'id' => api_convert_encoding($row['value'], 'UTF-8', $charset),
32
+            'value' => api_convert_encoding($row['value'], 'UTF-8', $charset),
33
+            'label' => api_convert_encoding($row['value'], 'UTF-8', $charset)
34 34
         ];
35 35
 
36
-        if ($i<20) {
37
-            $data[ $row['course_code'] ] [ $row['tool_id'] ] [ $row['ref_id'] ] = 1;
36
+        if ($i < 20) {
37
+            $data[$row['course_code']] [$row['tool_id']] [$row['ref_id']] = 1;
38 38
         }
39 39
         $i++;
40 40
     }
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
                         // will create a copy as Yannick - Car - Speed
79 79
                         // in $output[3]
80 80
                         $c = count($output);
81
-                        for ($i=0;$i<$c; $i++) {
82
-                            $output[($c+$i)] = $current_field_val;
81
+                        for ($i = 0; $i < $c; $i++) {
82
+                            $output[($c + $i)] = $current_field_val;
83 83
                         }
84 84
                     } else {
85 85
                         //no identical field id, continue as usual
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
                     }
97 97
                 }
98 98
                 foreach ($output as $i=>$out) {
99
-                    if (api_stristr($out,$q) === false) {continue;}
99
+                    if (api_stristr($out, $q) === false) {continue; }
100 100
                     $s = api_convert_encoding(substr($out, 0, -3), 'UTF-8', $charset);
101
-                    if (!in_array($s,$more_sugg)) {
101
+                    if (!in_array($s, $more_sugg)) {
102 102
                         $more_sugg[] = $s;
103 103
                         $json[] = [
104 104
                             'id' => $s,
Please login to merge, or discard this patch.
main/social/home.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -101,8 +101,8 @@
 block discarded – undo
101 101
         $group_url = "group_view.php?id=$id";
102 102
 
103 103
         $result['name'] = '<div class="group-name">'.Display::url(
104
-                          api_ucwords(cut($result['name'], 40, true)), $group_url)
105
-                          .'</div><div class="count-username">'.
104
+                            api_ucwords(cut($result['name'], 40, true)), $group_url)
105
+                            .'</div><div class="count-username">'.
106 106
                             Display::returnFontAwesomeIcon('user').$result['count'].'</div>';
107 107
 
108 108
         $picture = $userGroup->get_picture_group(
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 api_block_anonymous_users();
21 21
 
22 22
 if (api_get_setting('allow_social_tool') != 'true') {
23
-    $url = api_get_path(WEB_CODE_PATH) . 'auth/profile.php';
24
-    header('Location: ' . $url);
23
+    $url = api_get_path(WEB_CODE_PATH).'auth/profile.php';
24
+    header('Location: '.$url);
25 25
     exit;
26 26
 }
27 27
 
@@ -45,10 +45,10 @@  discard block
 block discarded – undo
45 45
     $allowed_picture_types = api_get_supported_image_extensions();
46 46
     $form->addRule(
47 47
         'picture',
48
-        get_lang('OnlyImagesAllowed') . ' (' . implode(
48
+        get_lang('OnlyImagesAllowed').' ('.implode(
49 49
             ',',
50 50
             $allowed_picture_types
51
-        ) . ')',
51
+        ).')',
52 52
         'filetype',
53 53
         $allowed_picture_types
54 54
     );
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
                 $table_user = Database :: get_main_table(TABLE_MAIN_USER);
68 68
 
69 69
                 $sql = "UPDATE $table_user
70
-                    SET picture_uri = '$new_picture' WHERE user_id =  " . api_get_user_id();
70
+                    SET picture_uri = '$new_picture' WHERE user_id =  ".api_get_user_id();
71 71
 
72 72
                 $result = Database::query($sql);
73 73
             }
@@ -93,9 +93,9 @@  discard block
 block discarded – undo
93 93
         $result['name'] = Security::remove_XSS($result['name'], STUDENT, true);
94 94
 
95 95
         if ($result['count'] == 1) {
96
-            $result['count'] = '1 ' . get_lang('Member');
96
+            $result['count'] = '1 '.get_lang('Member');
97 97
         } else {
98
-            $result['count'] = $result['count'] . ' ' . get_lang('Members');
98
+            $result['count'] = $result['count'].' '.get_lang('Members');
99 99
         }
100 100
 
101 101
         $group_url = "group_view.php?id=$id";
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
             80
112 112
         );
113 113
 
114
-        $result['picture'] = '<img class="group-image" src="' . $picture['file'] . '" />';
115
-        $group_actions = '<div class="group-more"><a href="groups.php?#tab_browse-2">' . get_lang('SeeMore') . '</a></div>';
116
-        $group_info= '<div class="description"><p>' . cut($result['description'], 120, true) . "</p></div>";
114
+        $result['picture'] = '<img class="group-image" src="'.$picture['file'].'" />';
115
+        $group_actions = '<div class="group-more"><a href="groups.php?#tab_browse-2">'.get_lang('SeeMore').'</a></div>';
116
+        $group_info = '<div class="description"><p>'.cut($result['description'], 120, true)."</p></div>";
117 117
         $groups_newest[] = array(
118 118
             Display::url(
119 119
                 $result['picture'],
@@ -140,12 +140,12 @@  discard block
 block discarded – undo
140 140
     $group_url = "group_view.php?id=$id";
141 141
 
142 142
     if ($result['count'] == 1) {
143
-        $result['count'] = '1 ' . get_lang('Member');
143
+        $result['count'] = '1 '.get_lang('Member');
144 144
     } else {
145
-        $result['count'] = $result['count'] . ' ' . get_lang('Members');
145
+        $result['count'] = $result['count'].' '.get_lang('Members');
146 146
     }
147 147
     $result['name'] = '<div class="group-name">'.Display::url(
148
-            api_ucwords(cut($result['name'], 40, true)),$group_url)
148
+            api_ucwords(cut($result['name'], 40, true)), $group_url)
149 149
         .'</div><div class="count-username">'.Display::returnFontAwesomeIcon('user').$result['count'].'</div>';
150 150
 
151 151
     $picture = $userGroup->get_picture_group(
@@ -153,42 +153,42 @@  discard block
 block discarded – undo
153 153
         $result['picture'],
154 154
         80
155 155
     );
156
-    $result['picture_uri'] = '<img class="group-image" src="' . $picture['file'] . '" />';
157
-    $group_actions = '<div class="group-more" ><a href="groups.php?#tab_browse-3">' . get_lang('SeeMore') . '</a></div>';
158
-    $group_info= '<div class="description"><p>' . cut($result['description'], 120, true) . "</p></div>";
156
+    $result['picture_uri'] = '<img class="group-image" src="'.$picture['file'].'" />';
157
+    $group_actions = '<div class="group-more" ><a href="groups.php?#tab_browse-3">'.get_lang('SeeMore').'</a></div>';
158
+    $group_info = '<div class="description"><p>'.cut($result['description'], 120, true)."</p></div>";
159 159
     $groups_pop[] = array(
160 160
         Display::url($result['picture_uri'], $group_url),
161
-        $result['name'],$group_info. $group_actions
161
+        $result['name'], $group_info.$group_actions
162 162
     );
163 163
 }
164 164
 
165
-$list=count($groups_newest);
165
+$list = count($groups_newest);
166 166
 $social_group_block = null;
167 167
 if ($list > 0) {
168 168
     $social_group_block .= '<div class="list-group-newest">';
169
-    $social_group_block .= '<div class="group-title">' . get_lang('Newest') . '</div>';
170
-    for($i = 0;$i < $list; $i++){
171
-        $social_group_block.='<div class="row">';
172
-        $social_group_block.='<div class="col-md-2">' . $groups_newest[$i][0] . '</div>';
173
-        $social_group_block.='<div class="col-md-10">' . $groups_newest[$i][1];
174
-        $social_group_block.= $groups_newest[$i][2] . '</div>';
175
-        $social_group_block.="</div>";
169
+    $social_group_block .= '<div class="group-title">'.get_lang('Newest').'</div>';
170
+    for ($i = 0; $i < $list; $i++) {
171
+        $social_group_block .= '<div class="row">';
172
+        $social_group_block .= '<div class="col-md-2">'.$groups_newest[$i][0].'</div>';
173
+        $social_group_block .= '<div class="col-md-10">'.$groups_newest[$i][1];
174
+        $social_group_block .= $groups_newest[$i][2].'</div>';
175
+        $social_group_block .= "</div>";
176 176
     }
177
-    $social_group_block.= "</div>";
177
+    $social_group_block .= "</div>";
178 178
 }
179
-$list=count($groups_pop);
179
+$list = count($groups_pop);
180 180
 if ($list > 0) {
181 181
     $social_group_block .= '<div class="list-group-newest">';
182
-    $social_group_block .= '<div class="group-title">' . get_lang('Popular') . '</div>';
183
-
184
-    for($i = 0;$i < $list; $i++){
185
-        $social_group_block.='<div class="row">';
186
-        $social_group_block.='<div class="col-md-2">' . $groups_pop[$i][0] . '</div>';
187
-        $social_group_block.='<div class="col-md-10">' . $groups_pop[$i][1];
188
-        $social_group_block.= $groups_pop[$i][2] . '</div>';
189
-        $social_group_block.="</div>";
182
+    $social_group_block .= '<div class="group-title">'.get_lang('Popular').'</div>';
183
+
184
+    for ($i = 0; $i < $list; $i++) {
185
+        $social_group_block .= '<div class="row">';
186
+        $social_group_block .= '<div class="col-md-2">'.$groups_pop[$i][0].'</div>';
187
+        $social_group_block .= '<div class="col-md-10">'.$groups_pop[$i][1];
188
+        $social_group_block .= $groups_pop[$i][2].'</div>';
189
+        $social_group_block .= "</div>";
190 190
     }
191
-    $social_group_block.= "</div>";
191
+    $social_group_block .= "</div>";
192 192
 }
193 193
 // My friends
194 194
 $friend_html = SocialManager::listMyFriendsBlock(
Please login to merge, or discard this patch.
main/social/my_skills_report.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 $isDRH = api_is_drh();
13 13
 
14 14
 if (!$isStudent && !$isStudentBoss && !$isDRH) {
15
-    header('Location: ' . api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php');
15
+    header('Location: '.api_get_path(WEB_CODE_PATH).'social/skills_wheel.php');
16 16
     exit;
17 17
 }
18 18
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 
192 192
 $tpl->assign('rows', $tableRows);
193 193
 
194
-$contentTemplate = $tpl->fetch("default/" . $tplPath);
194
+$contentTemplate = $tpl->fetch("default/".$tplPath);
195 195
 
196 196
 $tpl->assign('content', $contentTemplate);
197 197
 $tpl->display_one_col_template();
Please login to merge, or discard this patch.