Completed
Pull Request — 1.11.x (#1458)
by José
138:44 queued 104:05
created
src/Chamilo/CourseBundle/Component/CourseCopy/CourseArchiver.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -173,7 +173,7 @@
 block discarded – undo
173 173
 
174 174
     /**
175 175
      * @param array $file
176
-     * @return bool|string
176
+     * @return string|false
177 177
      */
178 178
     public static function import_uploaded_file($file)
179 179
     {
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
             while (($file = readdir($handle)) !== false) {
24 24
                 if ($file != "." && $file != ".." &&
25 25
                     strpos($file, 'CourseArchiver_') === 0 &&
26
-                    is_dir($dir . '/' . $file)
26
+                    is_dir($dir.'/'.$file)
27 27
                 ) {
28
-                    rmdirr($dir . '/' . $file);
28
+                    rmdirr($dir.'/'.$file);
29 29
                 }
30 30
             }
31 31
             closedir($handle);
@@ -43,48 +43,48 @@  discard block
 block discarded – undo
43 43
         CourseArchiver::clean_backup_dir();
44 44
 
45 45
         // Create a temp directory
46
-        $tmp_dir_name = 'CourseArchiver_' . api_get_unique_id();
47
-        $backup_dir = api_get_path(SYS_ARCHIVE_PATH) . $tmp_dir_name . '/';
46
+        $tmp_dir_name = 'CourseArchiver_'.api_get_unique_id();
47
+        $backup_dir = api_get_path(SYS_ARCHIVE_PATH).$tmp_dir_name.'/';
48 48
 
49 49
         // All course-information will be stored in course_info.dat
50
-        $course_info_file = $backup_dir . 'course_info.dat';
50
+        $course_info_file = $backup_dir.'course_info.dat';
51 51
         $zip_dir = api_get_path(SYS_ARCHIVE_PATH);
52 52
         $user = api_get_user_info();
53 53
         $date = new \DateTime(api_get_local_time());
54
-        $zip_file = $user['user_id'] . '_' . $course->code . '_' . $date->format('Ymd-His') . '.zip';
54
+        $zip_file = $user['user_id'].'_'.$course->code.'_'.$date->format('Ymd-His').'.zip';
55 55
         $php_errormsg = '';
56 56
         $res = @mkdir($backup_dir, $perm_dirs);
57 57
         if ($res === false) {
58 58
             //TODO set and handle an error message telling the user to review the permissions on the archive directory
59
-            error_log(__FILE__ . ' line ' . __LINE__ . ': ' . (ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini') . ' - This error, occuring because your archive directory will not let this script write data into it, will prevent courses backups to be created', 0);
59
+            error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini').' - This error, occuring because your archive directory will not let this script write data into it, will prevent courses backups to be created', 0);
60 60
         }
61 61
         // Write the course-object to the file
62 62
         $fp = @fopen($course_info_file, 'w');
63 63
         if ($fp === false) {
64
-            error_log(__FILE__ . ' line ' . __LINE__ . ': ' . (ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
64
+            error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
65 65
         }
66 66
 
67 67
         $res = @fwrite($fp, base64_encode(serialize($course)));
68 68
         if ($res === false) {
69
-            error_log(__FILE__ . ' line ' . __LINE__ . ': ' . (ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
69
+            error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
70 70
         }
71 71
 
72 72
         $res = @fclose($fp);
73 73
         if ($res === false) {
74
-            error_log(__FILE__ . ' line ' . __LINE__ . ': ' . (ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
74
+            error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
75 75
         }
76 76
 
77 77
         // Copy all documents to the temp-dir
78 78
         if (isset($course->resources[RESOURCE_DOCUMENT]) && is_array($course->resources[RESOURCE_DOCUMENT])) {
79 79
             foreach ($course->resources[RESOURCE_DOCUMENT] as $document) {
80 80
                 if ($document->file_type == DOCUMENT) {
81
-                    $doc_dir = $backup_dir . $document->path;
81
+                    $doc_dir = $backup_dir.$document->path;
82 82
                     @mkdir(dirname($doc_dir), $perm_dirs, true);
83
-                    if (file_exists($course->path . $document->path)) {
84
-                        copy($course->path . $document->path, $doc_dir);
83
+                    if (file_exists($course->path.$document->path)) {
84
+                        copy($course->path.$document->path, $doc_dir);
85 85
                     }
86 86
                 } else {
87
-                    @mkdir($backup_dir . $document->path, $perm_dirs, true);
87
+                    @mkdir($backup_dir.$document->path, $perm_dirs, true);
88 88
                 }
89 89
             }
90 90
         }
@@ -92,49 +92,49 @@  discard block
 block discarded – undo
92 92
         // Copy all scorm documents to the temp-dir
93 93
         if (isset($course->resources[RESOURCE_SCORM]) && is_array($course->resources[RESOURCE_SCORM])) {
94 94
             foreach ($course->resources[RESOURCE_SCORM] as $document) {
95
-                $doc_dir = dirname($backup_dir . $document->path);
95
+                $doc_dir = dirname($backup_dir.$document->path);
96 96
                 @mkdir($doc_dir, $perm_dirs, true);
97
-                copyDirTo($course->path . $document->path, $doc_dir, false);
97
+                copyDirTo($course->path.$document->path, $doc_dir, false);
98 98
             }
99 99
         }
100 100
 
101 101
         // Copy calendar attachments.
102 102
 
103 103
         if (isset($course->resources[RESOURCE_EVENT]) && is_array($course->resources[RESOURCE_EVENT])) {
104
-            $doc_dir = dirname($backup_dir . '/upload/calendar/');
104
+            $doc_dir = dirname($backup_dir.'/upload/calendar/');
105 105
             @mkdir($doc_dir, $perm_dirs, true);
106
-            copyDirTo($course->path . 'upload/calendar/', $doc_dir, false);
106
+            copyDirTo($course->path.'upload/calendar/', $doc_dir, false);
107 107
         }
108 108
 
109 109
         // Copy Learning path author image.
110 110
         if (isset($course->resources[RESOURCE_LEARNPATH]) && is_array($course->resources[RESOURCE_LEARNPATH])) {
111
-            $doc_dir = dirname($backup_dir . '/upload/learning_path/');
111
+            $doc_dir = dirname($backup_dir.'/upload/learning_path/');
112 112
             @mkdir($doc_dir, $perm_dirs, true);
113
-            copyDirTo($course->path . 'upload/learning_path/', $doc_dir, false);
113
+            copyDirTo($course->path.'upload/learning_path/', $doc_dir, false);
114 114
         }
115 115
 
116 116
         // Copy announcements attachments.
117 117
         if (isset($course->resources[RESOURCE_ANNOUNCEMENT]) && is_array($course->resources[RESOURCE_ANNOUNCEMENT])) {
118
-            $doc_dir = dirname($backup_dir . '/upload/announcements/');
118
+            $doc_dir = dirname($backup_dir.'/upload/announcements/');
119 119
             @mkdir($doc_dir, $perm_dirs, true);
120
-            copyDirTo($course->path . 'upload/announcements/', $doc_dir, false);
120
+            copyDirTo($course->path.'upload/announcements/', $doc_dir, false);
121 121
         }
122 122
 
123 123
         // Copy work folders (only folders)
124 124
         if (isset($course->resources[RESOURCE_WORK]) && is_array($course->resources[RESOURCE_WORK])) {
125
-            $doc_dir = dirname($backup_dir . '/upload/work/');
125
+            $doc_dir = dirname($backup_dir.'/upload/work/');
126 126
             @mkdir($doc_dir, $perm_dirs, true);
127 127
             // @todo: adjust to only create subdirs, but not copy files
128
-            copyDirTo($course->path . 'upload/work/', $doc_dir, false);
128
+            copyDirTo($course->path.'upload/work/', $doc_dir, false);
129 129
         }
130 130
 
131 131
         // Zip the course-contents
132
-        $zip = new \PclZip($zip_dir . $zip_file);
133
-        $zip->create($zip_dir . $tmp_dir_name, PCLZIP_OPT_REMOVE_PATH, $zip_dir . $tmp_dir_name . '/');
132
+        $zip = new \PclZip($zip_dir.$zip_file);
133
+        $zip->create($zip_dir.$tmp_dir_name, PCLZIP_OPT_REMOVE_PATH, $zip_dir.$tmp_dir_name.'/');
134 134
         //$zip->deleteByIndex(0);
135 135
         // Remove the temp-dir.
136 136
         rmdirr($backup_dir);
137
-        return '' . $zip_file;
137
+        return ''.$zip_file;
138 138
     }
139 139
 
140 140
     /**
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
     public static function get_available_backups($user_id = null)
145 145
     {
146 146
         $backup_files = array();
147
-        $dirname = api_get_path(SYS_ARCHIVE_PATH) . '';
147
+        $dirname = api_get_path(SYS_ARCHIVE_PATH).'';
148 148
         if ($dir = opendir($dirname)) {
149 149
             while (($file = readdir($dir)) !== false) {
150 150
                 $file_parts = explode('_', $file);
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
                     $date = $file_parts[0];
156 156
                     $ext = isset($file_parts[1]) ? $file_parts[1] : null;
157 157
                     if ($ext == 'zip' && ($user_id != null && $owner_id == $user_id || $user_id == null)) {
158
-                        $date = substr($date, 0, 4) . '-' . substr($date, 4, 2) . '-' . substr($date, 6, 2) . ' ' . substr($date, 9, 2) . ':' . substr($date, 11, 2) . ':' . substr($date, 13, 2);
158
+                        $date = substr($date, 0, 4).'-'.substr($date, 4, 2).'-'.substr($date, 6, 2).' '.substr($date, 9, 2).':'.substr($date, 11, 2).':'.substr($date, 13, 2);
159 159
                         $backup_files[] = array(
160 160
                             'file' => $file,
161 161
                             'date' => $date,
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
      */
177 177
     public static function import_uploaded_file($file)
178 178
     {
179
-        $new_filename = uniqid('') . '.zip';
179
+        $new_filename = uniqid('').'.zip';
180 180
         $new_dir = api_get_path(SYS_ARCHIVE_PATH);
181 181
         if (is_dir($new_dir) && is_writable($new_dir)) {
182 182
             move_uploaded_file($file, api_get_path(SYS_ARCHIVE_PATH).$new_filename);
@@ -199,17 +199,17 @@  discard block
 block discarded – undo
199 199
     {
200 200
         CourseArchiver::clean_backup_dir();
201 201
         // Create a temp directory
202
-        $tmp_dir_name = 'CourseArchiver_' . uniqid('');
203
-        $unzip_dir = api_get_path(SYS_ARCHIVE_PATH) . '' . $tmp_dir_name;
202
+        $tmp_dir_name = 'CourseArchiver_'.uniqid('');
203
+        $unzip_dir = api_get_path(SYS_ARCHIVE_PATH).''.$tmp_dir_name;
204 204
         @mkdir($unzip_dir, api_get_permissions_for_new_directories(), true);
205
-        @copy(api_get_path(SYS_ARCHIVE_PATH) . '' . $filename, $unzip_dir . '/backup.zip');
205
+        @copy(api_get_path(SYS_ARCHIVE_PATH).''.$filename, $unzip_dir.'/backup.zip');
206 206
         // unzip the archive
207
-        $zip = new \PclZip($unzip_dir . '/backup.zip');
207
+        $zip = new \PclZip($unzip_dir.'/backup.zip');
208 208
         @chdir($unzip_dir);
209 209
         $zip->extract(PCLZIP_OPT_TEMP_FILE_ON);
210 210
         // remove the archive-file
211 211
         if ($delete) {
212
-            @unlink(api_get_path(SYS_ARCHIVE_PATH) . '' . $filename);
212
+            @unlink(api_get_path(SYS_ARCHIVE_PATH).''.$filename);
213 213
         }
214 214
         // read the course
215 215
         if (!is_file('course_info.dat')) {
Please login to merge, or discard this patch.
src/Chamilo/CourseBundle/Component/CourseCopy/CourseRecycler.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
     }
39 39
 
40 40
     /**
41
-     * @return bool
41
+     * @return false|null
42 42
      */
43 43
     public function create_user_folder()
44 44
     {
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -619,8 +619,8 @@  discard block
 block discarded – undo
619 619
     }
620 620
 
621 621
     /**
622
-    * Recycle Thematics
623
-    */
622
+     * Recycle Thematics
623
+     */
624 624
     public function recycle_thematic($session_id = 0)
625 625
     {
626 626
         if ($this->course->has_resources(RESOURCE_THEMATIC)) {
@@ -685,8 +685,8 @@  discard block
 block discarded – undo
685 685
     }
686 686
 
687 687
     /**
688
-    * Recycle Attendances
689
-    */
688
+     * Recycle Attendances
689
+     */
690 690
     public function recycle_attendance($session_id = 0)
691 691
     {
692 692
         if ($this->course->has_resources(RESOURCE_ATTENDANCE)) {
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
     public function recycle_glossary()
161 161
     {
162 162
         if ($this->course->has_resources(RESOURCE_GLOSSARY)) {
163
-            $table_glossary	= Database::get_course_table(TABLE_GLOSSARY);
163
+            $table_glossary = Database::get_course_table(TABLE_GLOSSARY);
164 164
             $ids = implode(',', array_filter(array_keys($this->course->resources[RESOURCE_GLOSSARY])));
165 165
             if (!empty($ids)) {
166 166
                 $sql = "DELETE FROM ".$table_glossary."
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
                     if (trim($learnpath->path) != '') {
557 557
                         // when $learnpath->path value is incorrect for some reason.
558 558
                         // The directory trat contains files of the SCORM package is to be deleted.
559
-                        $scorm_package_dir = realpath($this->course->path . 'scorm/' . $learnpath->path);
559
+                        $scorm_package_dir = realpath($this->course->path.'scorm/'.$learnpath->path);
560 560
                         rmdirr($scorm_package_dir);
561 561
                     }
562 562
                 }
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
             foreach ($resources[RESOURCE_THEMATIC] as $last_id => $thematic) {
633 633
                 if (is_numeric($last_id)) {
634 634
 
635
-                    foreach($thematic->thematic_advance_list as $thematic_advance) {
635
+                    foreach ($thematic->thematic_advance_list as $thematic_advance) {
636 636
                         $cond = array(
637 637
                             'id = ? AND  c_id = ?' => array(
638 638
                                 $thematic_advance['id'],
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
                         Database::delete($table_thematic_advance, $cond);
650 650
                     }
651 651
 
652
-                    foreach($thematic->thematic_plan_list as $thematic_plan) {
652
+                    foreach ($thematic->thematic_plan_list as $thematic_plan) {
653 653
                         $cond = array(
654 654
                             'id = ? AND  c_id = ?' => array(
655 655
                                 $thematic_plan['id'],
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
                         'ThematicDeleted',
679 679
                         api_get_user_id()
680 680
                     );
681
-                    Database::delete($table_thematic,$cond);
681
+                    Database::delete($table_thematic, $cond);
682 682
                 }
683 683
             }
684 684
         }
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
             $resources = $this->course->resources;
697 697
             foreach ($resources[RESOURCE_ATTENDANCE] as $last_id => $obj) {
698 698
                 if (is_numeric($last_id)) {
699
-                    foreach($obj->attendance_calendar as $attendance_calendar) {
699
+                    foreach ($obj->attendance_calendar as $attendance_calendar) {
700 700
                         $cond = array('id = ? AND c_id = ? '=>array($attendance_calendar['id'], $this->course_id));
701 701
                         Database::delete($table_attendance_calendar, $cond);
702 702
                     }
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
     public function recycle_work($session_id = 0)
721 721
     {
722 722
         if ($this->course->has_resources(RESOURCE_WORK)) {
723
-            $table_work          = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
723
+            $table_work = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
724 724
             $table_work_assignment = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
725 725
 
726 726
             $resources = $this->course->resources;
Please login to merge, or discard this patch.
src/Chamilo/CourseBundle/Component/CourseCopy/CourseRestorer.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -1212,6 +1212,7 @@
 block discarded – undo
1212 1212
 	 * Restore a forum-post
1213 1213
 	 * @TODO Restore tree-structure of posts. For example: attachments to posts.
1214 1214
 	 * @param false|string $topic_id
1215
+	 * @param false|string $forum_id
1215 1216
 	 */
1216 1217
     public function restore_post($id, $topic_id, $forum_id, $sessionId = 0)
1217 1218
     {
Please login to merge, or discard this patch.
Indentation   +579 added lines, -579 removed lines patch added patch discarded remove patch
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
 class CourseRestorer
25 25
 {
26 26
     /**
27
-    * The course-object
28
-    */
27
+     * The course-object
28
+     */
29 29
     public $course;
30 30
     public $destination_course_info;
31 31
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
         'events',
45 45
         'forum_category',
46 46
         'forums',
47
-       // 'forum_topics',
47
+        // 'forum_topics',
48 48
         'glossary',
49 49
         'quizzes',
50 50
         'test_category',
@@ -112,15 +112,15 @@  discard block
 block discarded – undo
112 112
         $this->tool_copy_settings = $array;
113 113
     }
114 114
 
115
-	/**
116
-	 * Restore a course.
115
+    /**
116
+     * Restore a course.
117 117
      *
118
-	 * @param string    $destination_course_code code of the Chamilo-course in
119
-	 * @param int	    $session_id
120
-	 * @param bool	    $update_course_settings Course settings are going to be restore?
118
+     * @param string    $destination_course_code code of the Chamilo-course in
119
+     * @param int	    $session_id
120
+     * @param bool	    $update_course_settings Course settings are going to be restore?
121 121
      * @param bool      $respect_base_content
122 122
      * @return false|null
123
-	 */
123
+     */
124 124
     public function restore(
125 125
         $destination_course_code = '',
126 126
         $session_id = 0,
@@ -256,17 +256,17 @@  discard block
 block discarded – undo
256 256
         }
257 257
     }
258 258
 
259
-	/**
260
-	 * Restore only harmless course settings:
259
+    /**
260
+     * Restore only harmless course settings:
261 261
      * course_language, visibility, department_name,department_url,
262 262
      * subscribe, unsubscribe ,category_code
263
-	 *
264
-	 * @param string $destination_course_code
265
-	 */
263
+     *
264
+     * @param string $destination_course_code
265
+     */
266 266
     public function restore_course_settings($destination_course_code)
267 267
     {
268
-	    $origin_course_info = api_get_course_info($destination_course_code);
269
-	    $course_info = $this->course->info;
268
+        $origin_course_info = api_get_course_info($destination_course_code);
269
+        $course_info = $this->course->info;
270 270
         $params['course_language'] = $course_info['language'];
271 271
         $params['visibility'] = $course_info['visibility'];
272 272
         $params['department_name'] = $course_info['department_name'];
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
         $params['subscribe'] = $course_info['subscribe_allowed'];
277 277
         $params['unsubscribe'] = $course_info['unsubscribe'];
278 278
         CourseManager::update_attributes($origin_course_info['real_id'], $params);
279
-	}
279
+    }
280 280
 
281 281
     /**
282 282
      * Restore documents
@@ -922,56 +922,56 @@  discard block
 block discarded – undo
922 922
         unset($_SESSION['new_base_foldername']);
923 923
         unset($_SESSION['orig_base_foldername']);
924 924
         unset($_SESSION['new_base_path']);
925
-	}
925
+    }
926 926
 
927
-	/**
928
-	 * Restore scorm documents
929
-	 * TODO @TODO check that the restore function with renaming doesn't break the scorm structure!
927
+    /**
928
+     * Restore scorm documents
929
+     * TODO @TODO check that the restore function with renaming doesn't break the scorm structure!
930 930
      * see #7029
931
-	 */
932
-	public function restore_scorm_documents()
931
+     */
932
+    public function restore_scorm_documents()
933 933
     {
934
-		$perm = api_get_permissions_for_new_directories();
934
+        $perm = api_get_permissions_for_new_directories();
935 935
 
936
-		if ($this->course->has_resources(RESOURCE_SCORM)) {
937
-			$resources = $this->course->resources;
936
+        if ($this->course->has_resources(RESOURCE_SCORM)) {
937
+            $resources = $this->course->resources;
938 938
 
939
-			foreach ($resources[RESOURCE_SCORM] as $document) {
940
-				$path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/';
941
-				@mkdir(dirname($path.$document->path), $perm, true);
939
+            foreach ($resources[RESOURCE_SCORM] as $document) {
940
+                $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/';
941
+                @mkdir(dirname($path.$document->path), $perm, true);
942 942
 
943
-				if (file_exists($path.$document->path)) {
944
-					switch ($this->file_option) {
945
-						case FILE_OVERWRITE:
946
-							rmdirr($path.$document->path);
943
+                if (file_exists($path.$document->path)) {
944
+                    switch ($this->file_option) {
945
+                        case FILE_OVERWRITE:
946
+                            rmdirr($path.$document->path);
947 947
                             copyDirTo(
948 948
                                 $this->course->backup_path . '/' . $document->path,
949 949
                                 $path . dirname($document->path),
950 950
                                 false
951 951
                             );
952
-							break;
953
-						case FILE_SKIP:
954
-							break;
952
+                            break;
953
+                        case FILE_SKIP:
954
+                            break;
955 955
                         case FILE_RENAME:
956
-							$i = 1;
957
-							$ext = explode('.', basename($document->path));
958
-							if (count($ext) > 1) {
959
-								$ext = array_pop($ext);
960
-								$file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1));
961
-								$ext = '.'.$ext;
962
-							} else {
963
-								$ext = '';
964
-								$file_name_no_ext = $document->path;
965
-							}
966
-
967
-							$new_file_name = $file_name_no_ext.'_'.$i.$ext;
968
-							$file_exists = file_exists($path.$new_file_name);
969
-
970
-							while ($file_exists) {
971
-								$i ++;
972
-								$new_file_name = $file_name_no_ext.'_'.$i.$ext;
973
-								$file_exists = file_exists($path.$new_file_name);
974
-							}
956
+                            $i = 1;
957
+                            $ext = explode('.', basename($document->path));
958
+                            if (count($ext) > 1) {
959
+                                $ext = array_pop($ext);
960
+                                $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1));
961
+                                $ext = '.'.$ext;
962
+                            } else {
963
+                                $ext = '';
964
+                                $file_name_no_ext = $document->path;
965
+                            }
966
+
967
+                            $new_file_name = $file_name_no_ext.'_'.$i.$ext;
968
+                            $file_exists = file_exists($path.$new_file_name);
969
+
970
+                            while ($file_exists) {
971
+                                $i ++;
972
+                                $new_file_name = $file_name_no_ext.'_'.$i.$ext;
973
+                                $file_exists = file_exists($path.$new_file_name);
974
+                            }
975 975
 
976 976
                             rename(
977 977
                                 $this->course->backup_path . '/' . $document->path,
@@ -987,30 +987,30 @@  discard block
 block discarded – undo
987 987
                                 $this->course->backup_path . '/' . $document->path
988 988
                             );
989 989
 
990
-							break;
991
-					} // end switch
992
-				} else {
990
+                            break;
991
+                    } // end switch
992
+                } else {
993 993
                     // end if file exists
994 994
                     copyDirTo(
995 995
                         $this->course->backup_path . '/' . $document->path,
996 996
                         $path . dirname($document->path),
997 997
                         false
998 998
                     );
999
-				}
1000
-			} // end for each
1001
-		}
1002
-	}
1003
-
1004
-	/**
1005
-	 * Restore forums
1006
-	 */
1007
-	public function restore_forums($sessionId = 0)
999
+                }
1000
+            } // end for each
1001
+        }
1002
+    }
1003
+
1004
+    /**
1005
+     * Restore forums
1006
+     */
1007
+    public function restore_forums($sessionId = 0)
1008 1008
     {
1009
-		if ($this->course->has_resources(RESOURCE_FORUM)) {
1009
+        if ($this->course->has_resources(RESOURCE_FORUM)) {
1010 1010
             $sessionId = intval($sessionId);
1011
-			$table_forum = Database::get_course_table(TABLE_FORUM);
1012
-			$resources = $this->course->resources;
1013
-			foreach ($resources[RESOURCE_FORUM] as $id => $forum) {
1011
+            $table_forum = Database::get_course_table(TABLE_FORUM);
1012
+            $resources = $this->course->resources;
1013
+            foreach ($resources[RESOURCE_FORUM] as $id => $forum) {
1014 1014
                 $params = (array)$forum->obj;
1015 1015
                 $cat_id = '';
1016 1016
                 if (isset($this->course->resources[RESOURCE_FORUMCATEGORY]) &&
@@ -1057,33 +1057,33 @@  discard block
 block discarded – undo
1057 1057
                     Database::query($sql);
1058 1058
                 }
1059 1059
 
1060
-				$this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id;
1061
-
1062
-				$forum_topics = 0;
1063
-				if (is_array($this->course->resources[RESOURCE_FORUMTOPIC])) {
1064
-					foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) {
1065
-						if ($topic->obj->forum_id == $id) {
1066
-							$this->restore_topic($topic_id, $new_id, $sessionId);
1067
-							$forum_topics ++;
1068
-						}
1069
-					}
1070
-				}
1071
-				if ($forum_topics > 0) {
1072
-					$sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics."
1060
+                $this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id;
1061
+
1062
+                $forum_topics = 0;
1063
+                if (is_array($this->course->resources[RESOURCE_FORUMTOPIC])) {
1064
+                    foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) {
1065
+                        if ($topic->obj->forum_id == $id) {
1066
+                            $this->restore_topic($topic_id, $new_id, $sessionId);
1067
+                            $forum_topics ++;
1068
+                        }
1069
+                    }
1070
+                }
1071
+                if ($forum_topics > 0) {
1072
+                    $sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics."
1073 1073
                             WHERE c_id = {$this->destination_course_id} AND forum_id = ".(int)$new_id;
1074
-					Database::query($sql);
1075
-				}
1076
-			}
1077
-		}
1078
-	}
1079
-
1080
-	/**
1081
-	 * Restore forum-categories
1082
-	 */
1074
+                    Database::query($sql);
1075
+                }
1076
+            }
1077
+        }
1078
+    }
1079
+
1080
+    /**
1081
+     * Restore forum-categories
1082
+     */
1083 1083
     public function restore_forum_category($my_id = null, $sessionId = 0)
1084 1084
     {
1085
-		$forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY);
1086
-		$resources = $this->course->resources;
1085
+        $forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY);
1086
+        $resources = $this->course->resources;
1087 1087
         if (!empty($resources[RESOURCE_FORUMCATEGORY])) {
1088 1088
             foreach ($resources[RESOURCE_FORUMCATEGORY] as $id => $forum_cat) {
1089 1089
                 if (!empty($my_id)) {
@@ -1121,16 +1121,16 @@  discard block
 block discarded – undo
1121 1121
                 }
1122 1122
             }
1123 1123
         }
1124
-	}
1124
+    }
1125 1125
 
1126
-	/**
1127
-	 * Restore a forum-topic
1128
-	 * @param false|string $forum_id
1129
-	 */
1126
+    /**
1127
+     * Restore a forum-topic
1128
+     * @param false|string $forum_id
1129
+     */
1130 1130
     public function restore_topic($thread_id, $forum_id, $sessionId = 0)
1131 1131
     {
1132
-		$table = Database :: get_course_table(TABLE_FORUM_THREAD);
1133
-		$topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id];
1132
+        $table = Database :: get_course_table(TABLE_FORUM_THREAD);
1133
+        $topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id];
1134 1134
 
1135 1135
         $params = (array)$topic->obj;
1136 1136
         $params = self::DBUTF8_array($params);
@@ -1167,27 +1167,27 @@  discard block
 block discarded – undo
1167 1167
             $sessionId
1168 1168
         );
1169 1169
 
1170
-		$this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id;
1171
-		$topic_replies = -1;
1172
-
1173
-		foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) {
1174
-			if ($post->obj->thread_id == $thread_id) {
1175
-				$topic_replies++;
1176
-				$this->restore_post($post_id, $new_id, $forum_id, $sessionId);
1177
-			}
1178
-		}
1179
-		return $new_id;
1180
-	}
1181
-
1182
-	/**
1183
-	 * Restore a forum-post
1184
-	 * @TODO Restore tree-structure of posts. For example: attachments to posts.
1185
-	 * @param false|string $topic_id
1186
-	 */
1170
+        $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id;
1171
+        $topic_replies = -1;
1172
+
1173
+        foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) {
1174
+            if ($post->obj->thread_id == $thread_id) {
1175
+                $topic_replies++;
1176
+                $this->restore_post($post_id, $new_id, $forum_id, $sessionId);
1177
+            }
1178
+        }
1179
+        return $new_id;
1180
+    }
1181
+
1182
+    /**
1183
+     * Restore a forum-post
1184
+     * @TODO Restore tree-structure of posts. For example: attachments to posts.
1185
+     * @param false|string $topic_id
1186
+     */
1187 1187
     public function restore_post($id, $topic_id, $forum_id, $sessionId = 0)
1188 1188
     {
1189
-		$table_post = Database :: get_course_table(TABLE_FORUM_POST);
1190
-		$post = $this->course->resources[RESOURCE_FORUMPOST][$id];
1189
+        $table_post = Database :: get_course_table(TABLE_FORUM_POST);
1190
+        $post = $this->course->resources[RESOURCE_FORUMPOST][$id];
1191 1191
         $params = (array) $post->obj;
1192 1192
         $params['c_id'] = $this->destination_course_id;
1193 1193
         $params['forum_id'] = $forum_id;
@@ -1223,37 +1223,37 @@  discard block
 block discarded – undo
1223 1223
             null,
1224 1224
             $sessionId
1225 1225
         );
1226
-		$this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id;
1226
+        $this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id;
1227 1227
 
1228
-		return $new_id;
1229
-	}
1228
+        return $new_id;
1229
+    }
1230 1230
 
1231
-	/**
1232
-	 * Restore links
1233
-	 */
1231
+    /**
1232
+     * Restore links
1233
+     */
1234 1234
     public function restore_links($session_id = 0)
1235 1235
     {
1236
-		if ($this->course->has_resources(RESOURCE_LINK)) {
1237
-			$link_table = Database :: get_course_table(TABLE_LINK);
1238
-			$resources = $this->course->resources;
1236
+        if ($this->course->has_resources(RESOURCE_LINK)) {
1237
+            $link_table = Database :: get_course_table(TABLE_LINK);
1238
+            $resources = $this->course->resources;
1239 1239
 
1240
-			foreach ($resources[RESOURCE_LINK] as $id => $link) {
1240
+            foreach ($resources[RESOURCE_LINK] as $id => $link) {
1241 1241
                 $cat_id = $this->restore_link_category(
1242 1242
                     $link->category_id,
1243 1243
                     $session_id
1244 1244
                 );
1245
-				$sql = "SELECT MAX(display_order)
1245
+                $sql = "SELECT MAX(display_order)
1246 1246
 				        FROM $link_table
1247 1247
 				        WHERE
1248 1248
 				            c_id = ".$this->destination_course_id." AND
1249 1249
 				            category_id='" . intval($cat_id). "'";
1250
-				$result = Database::query($sql);
1251
-    			list($max_order) = Database::fetch_array($result);
1250
+                $result = Database::query($sql);
1251
+                list($max_order) = Database::fetch_array($result);
1252 1252
 
1253 1253
                 $params = [];
1254
-    			if (!empty($session_id)) {
1254
+                if (!empty($session_id)) {
1255 1255
                     $params['session_id'] = $session_id;
1256
-    			}
1256
+                }
1257 1257
 
1258 1258
                 $params['c_id'] = $this->destination_course_id;
1259 1259
                 $params['url'] = self::DBUTF8($link->url);
@@ -1282,9 +1282,9 @@  discard block
 block discarded – undo
1282 1282
                     }
1283 1283
                     $this->course->resources[RESOURCE_LINK][$id]->destination_id = $id;
1284 1284
                 }
1285
-			}
1286
-		}
1287
-	}
1285
+            }
1286
+        }
1287
+    }
1288 1288
 
1289 1289
     /**
1290 1290
      * Restore a link-category
@@ -1328,21 +1328,21 @@  discard block
 block discarded – undo
1328 1328
         return $this->course->resources[RESOURCE_LINKCATEGORY][$id]->destination_id;
1329 1329
     }
1330 1330
 
1331
-	/**
1332
-	 * Restore tool intro
1333
-	 */
1331
+    /**
1332
+     * Restore tool intro
1333
+     */
1334 1334
     public function restore_tool_intro($sessionId = 0)
1335 1335
     {
1336
-		if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) {
1336
+        if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) {
1337 1337
             $sessionId = intval($sessionId);
1338
-			$tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO);
1339
-			$resources = $this->course->resources;
1340
-			foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) {
1341
-				$sql = "DELETE FROM $tool_intro_table
1338
+            $tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO);
1339
+            $resources = $this->course->resources;
1340
+            foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) {
1341
+                $sql = "DELETE FROM $tool_intro_table
1342 1342
 				        WHERE
1343 1343
 				            c_id = ".$this->destination_course_id." AND
1344 1344
 				            id='".self::DBUTF8escapestring($tool_intro->id)."'";
1345
-				Database::query($sql);
1345
+                Database::query($sql);
1346 1346
 
1347 1347
                 $tool_intro->intro_text = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1348 1348
                     $tool_intro->intro_text,
@@ -1372,21 +1372,21 @@  discard block
 block discarded – undo
1372 1372
 
1373 1373
                     $this->course->resources[RESOURCE_TOOL_INTRO][$id]->destination_id = $id;
1374 1374
                 }
1375
-			}
1376
-		}
1377
-	}
1375
+            }
1376
+        }
1377
+    }
1378 1378
 
1379
-	/**
1380
-	 * Restore events
1381
-	 */
1379
+    /**
1380
+     * Restore events
1381
+     */
1382 1382
     public function restore_events($sessionId = 0)
1383 1383
     {
1384
-		if ($this->course->has_resources(RESOURCE_EVENT)) {
1384
+        if ($this->course->has_resources(RESOURCE_EVENT)) {
1385 1385
             $sessionId = intval($sessionId);
1386
-			$table = Database :: get_course_table(TABLE_AGENDA);
1387
-			$resources = $this->course->resources;
1388
-			foreach ($resources[RESOURCE_EVENT] as $id => $event) {
1389
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
1386
+            $table = Database :: get_course_table(TABLE_AGENDA);
1387
+            $resources = $this->course->resources;
1388
+            foreach ($resources[RESOURCE_EVENT] as $id => $event) {
1389
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
1390 1390
                 $event->content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1391 1391
                     $event->content,
1392 1392
                     $this->course->code,
@@ -1404,7 +1404,7 @@  discard block
 block discarded – undo
1404 1404
                     'end_date' => $event->end_date,
1405 1405
                     'session_id' => $sessionId
1406 1406
                 ];
1407
-				$new_event_id = Database::insert($table, $params);
1407
+                $new_event_id = Database::insert($table, $params);
1408 1408
 
1409 1409
                 if ($new_event_id) {
1410 1410
                     $sql = "UPDATE $table SET id = iid WHERE iid = $new_event_id";
@@ -1417,30 +1417,30 @@  discard block
 block discarded – undo
1417 1417
                     $this->course->resources[RESOURCE_EVENT][$id]->destination_id = $new_event_id;
1418 1418
                 }
1419 1419
 
1420
-				// Copy event attachment
1420
+                // Copy event attachment
1421 1421
 
1422
-				$origin_path = $this->course->backup_path.'/upload/calendar/';
1423
-				$destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/';
1422
+                $origin_path = $this->course->backup_path.'/upload/calendar/';
1423
+                $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/';
1424 1424
 
1425
-				if (!empty($this->course->orig)) {
1425
+                if (!empty($this->course->orig)) {
1426 1426
 
1427
-					$table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1428
-					$sql = 'SELECT path, comment, size, filename
1427
+                    $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1428
+                    $sql = 'SELECT path, comment, size, filename
1429 1429
 					        FROM '.$table_attachment.'
1430 1430
 					        WHERE c_id = '.$this->destination_course_id.' AND agenda_id = '.$id;
1431
-					$attachment_event = Database::query($sql);
1432
-					$attachment_event = Database::fetch_object($attachment_event);
1431
+                    $attachment_event = Database::query($sql);
1432
+                    $attachment_event = Database::fetch_object($attachment_event);
1433 1433
 
1434
-					if (file_exists($origin_path.$attachment_event->path) &&
1434
+                    if (file_exists($origin_path.$attachment_event->path) &&
1435 1435
                         !is_dir($origin_path.$attachment_event->path)
1436 1436
                     ) {
1437
-						$new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1438
-						$copy_result = copy($origin_path.$attachment_event->path, $destination_path.$new_filename);
1439
-						//$copy_result = true;
1440
-						if ($copy_result) {
1441
-							$table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1437
+                        $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1438
+                        $copy_result = copy($origin_path.$attachment_event->path, $destination_path.$new_filename);
1439
+                        //$copy_result = true;
1440
+                        if ($copy_result) {
1441
+                            $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1442 1442
 
1443
-							$params = [
1443
+                            $params = [
1444 1444
                                 'c_id' => $this->destination_course_id,
1445 1445
                                 'path' => self::DBUTF8($new_filename),
1446 1446
                                 'comment' => self::DBUTF8($attachment_event->comment),
@@ -1454,17 +1454,17 @@  discard block
 block discarded – undo
1454 1454
                                 Database::query($sql);
1455 1455
                             }
1456 1456
                         }
1457
-					}
1458
-				} else {
1459
-					// get the info of the file
1460
-					if (!empty($event->attachment_path) &&
1457
+                    }
1458
+                } else {
1459
+                    // get the info of the file
1460
+                    if (!empty($event->attachment_path) &&
1461 1461
                         is_file($origin_path.$event->attachment_path) &&
1462 1462
                         is_readable($origin_path.$event->attachment_path)
1463 1463
                     ) {
1464
-						$new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1465
-						$copy_result = copy($origin_path.$event->attachment_path, $destination_path.$new_filename);
1466
-						if ($copy_result) {
1467
-							$table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1464
+                        $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1465
+                        $copy_result = copy($origin_path.$event->attachment_path, $destination_path.$new_filename);
1466
+                        if ($copy_result) {
1467
+                            $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1468 1468
 
1469 1469
                             $params = [
1470 1470
                                 'c_id' => $this->destination_course_id,
@@ -1480,29 +1480,29 @@  discard block
 block discarded – undo
1480 1480
                                 $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $id";
1481 1481
                                 Database::query($sql);
1482 1482
                             }
1483
-						}
1484
-					}
1485
-				}
1486
-			}
1487
-		}
1488
-	}
1489
-
1490
-	/**
1491
-	 * Restore course-description
1492
-	 */
1483
+                        }
1484
+                    }
1485
+                }
1486
+            }
1487
+        }
1488
+    }
1489
+
1490
+    /**
1491
+     * Restore course-description
1492
+     */
1493 1493
     public function restore_course_descriptions($session_id = 0)
1494 1494
     {
1495
-		if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) {
1496
-			$table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION);
1497
-			$resources = $this->course->resources;
1498
-			foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) {
1495
+        if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) {
1496
+            $table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION);
1497
+            $resources = $this->course->resources;
1498
+            foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) {
1499 1499
                 $courseDescription = (array) $cd;
1500 1500
 
1501 1501
                 $content = isset($courseDescription['content']) ? $courseDescription['content'] : '';
1502 1502
                 $descriptionType = isset($courseDescription['description_type']) ? $courseDescription['description_type'] : '';
1503 1503
                 $title = isset($courseDescription['title']) ? $courseDescription['title'] : '';
1504 1504
 
1505
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
1505
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
1506 1506
                 $description_content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1507 1507
                     $content,
1508 1508
                     $this->course->code,
@@ -1531,22 +1531,22 @@  discard block
 block discarded – undo
1531 1531
                     }
1532 1532
                     $this->course->resources[RESOURCE_COURSEDESCRIPTION][$id]->destination_id = $id;
1533 1533
                 }
1534
-			}
1535
-		}
1536
-	}
1534
+            }
1535
+        }
1536
+    }
1537 1537
 
1538
-	/**
1539
-	 * Restore announcements
1540
-	 */
1538
+    /**
1539
+     * Restore announcements
1540
+     */
1541 1541
     public function restore_announcements($sessionId = 0)
1542 1542
     {
1543
-		if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) {
1543
+        if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) {
1544 1544
             $sessionId = intval($sessionId);
1545
-			$table = Database :: get_course_table(TABLE_ANNOUNCEMENT);
1546
-			$resources = $this->course->resources;
1547
-			foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) {
1545
+            $table = Database :: get_course_table(TABLE_ANNOUNCEMENT);
1546
+            $resources = $this->course->resources;
1547
+            foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) {
1548 1548
 
1549
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
1549
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
1550 1550
                 $announcement->content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1551 1551
                     $announcement->content,
1552 1552
                     $this->course->code,
@@ -1565,7 +1565,7 @@  discard block
 block discarded – undo
1565 1565
                     'session_id' => $sessionId,
1566 1566
                 ];
1567 1567
 
1568
-				$new_announcement_id = Database::insert($table, $params);
1568
+                $new_announcement_id = Database::insert($table, $params);
1569 1569
 
1570 1570
                 if ($new_announcement_id) {
1571 1571
                     $sql = "UPDATE $table SET id = iid WHERE iid = $new_announcement_id";
@@ -1577,32 +1577,32 @@  discard block
 block discarded – undo
1577 1577
                     $this->course->resources[RESOURCE_ANNOUNCEMENT][$id]->destination_id = $new_announcement_id;
1578 1578
                 }
1579 1579
 
1580
-				$origin_path = $this->course->backup_path.'/upload/announcements/';
1581
-				$destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/';
1580
+                $origin_path = $this->course->backup_path.'/upload/announcements/';
1581
+                $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/';
1582 1582
 
1583
-				// Copy announcement attachment file
1584
-				if (!empty($this->course->orig)) {
1583
+                // Copy announcement attachment file
1584
+                if (!empty($this->course->orig)) {
1585 1585
 
1586
-					$table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1587
-					$sql = 'SELECT path, comment, size, filename
1586
+                    $table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1587
+                    $sql = 'SELECT path, comment, size, filename
1588 1588
 					        FROM '.$table_attachment.'
1589 1589
 					        WHERE
1590 1590
 					            c_id = '.$this->destination_course_id.' AND
1591 1591
 					            announcement_id = '.$id;
1592
-					$attachment_event = Database::query($sql);
1593
-					$attachment_event = Database::fetch_object($attachment_event);
1592
+                    $attachment_event = Database::query($sql);
1593
+                    $attachment_event = Database::fetch_object($attachment_event);
1594 1594
 
1595
-					if (file_exists($origin_path.$attachment_event->path) &&
1595
+                    if (file_exists($origin_path.$attachment_event->path) &&
1596 1596
                         !is_dir($origin_path.$attachment_event->path)
1597 1597
                     ) {
1598
-						$new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1598
+                        $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1599 1599
                         $copy_result = copy(
1600 1600
                             $origin_path.$attachment_event->path,
1601 1601
                             $destination_path.$new_filename
1602 1602
                         );
1603 1603
 
1604
-						if ($copy_result) {
1605
-							$table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1604
+                        if ($copy_result) {
1605
+                            $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1606 1606
 
1607 1607
                             $params = [
1608 1608
                                 'c_id' => $this->destination_course_id,
@@ -1619,19 +1619,19 @@  discard block
 block discarded – undo
1619 1619
                                 $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId";
1620 1620
                                 Database::query($sql);
1621 1621
                             }
1622
-						}
1623
-					}
1624
-				} else {
1625
-					// get the info of the file
1626
-					if (!empty($announcement->attachment_path) &&
1622
+                        }
1623
+                    }
1624
+                } else {
1625
+                    // get the info of the file
1626
+                    if (!empty($announcement->attachment_path) &&
1627 1627
                         is_file($origin_path.$announcement->attachment_path) &&
1628 1628
                         is_readable($origin_path.$announcement->attachment_path)
1629 1629
                     ) {
1630
-						$new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1631
-						$copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename);
1630
+                        $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1631
+                        $copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename);
1632 1632
 
1633
-						if ($copy_result) {
1634
-							$table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1633
+                        if ($copy_result) {
1634
+                            $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1635 1635
 
1636 1636
                             $params = [
1637 1637
                                 'c_id' => $this->destination_course_id,
@@ -1648,12 +1648,12 @@  discard block
 block discarded – undo
1648 1648
                                 $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId";
1649 1649
                                 Database::query($sql);
1650 1650
                             }
1651
-						}
1652
-					}
1653
-				}
1654
-			}
1655
-		}
1656
-	}
1651
+                        }
1652
+                    }
1653
+                }
1654
+            }
1655
+        }
1656
+    }
1657 1657
 
1658 1658
     /**
1659 1659
      * Restore Quiz
@@ -1664,13 +1664,13 @@  discard block
 block discarded – undo
1664 1664
         $session_id = 0,
1665 1665
         $respect_base_content = false
1666 1666
     ) {
1667
-		if ($this->course->has_resources(RESOURCE_QUIZ)) {
1668
-			$table_qui = Database :: get_course_table(TABLE_QUIZ_TEST);
1669
-			$table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION);
1670
-			$table_doc = Database :: get_course_table(TABLE_DOCUMENT);
1671
-			$resources = $this->course->resources;
1667
+        if ($this->course->has_resources(RESOURCE_QUIZ)) {
1668
+            $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST);
1669
+            $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION);
1670
+            $table_doc = Database :: get_course_table(TABLE_DOCUMENT);
1671
+            $resources = $this->course->resources;
1672 1672
 
1673
-			foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) {
1673
+            foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) {
1674 1674
 
1675 1675
                 if (isset($quiz->obj)) {
1676 1676
                     //For new imports
@@ -1680,7 +1680,7 @@  discard block
 block discarded – undo
1680 1680
                     $quiz->obj = $quiz;
1681 1681
                 }
1682 1682
 
1683
-				$doc = '';
1683
+                $doc = '';
1684 1684
                 if (!empty($quiz->sound)) {
1685 1685
                     if (isset($this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]) &&
1686 1686
                         $this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]->is_restored()) {
@@ -1688,14 +1688,14 @@  discard block
 block discarded – undo
1688 1688
                                 WHERE
1689 1689
                                     c_id = " . $this->destination_course_id . "  AND
1690 1690
                                     id = " . $resources[RESOURCE_DOCUMENT][$quiz->sound]->destination_id;
1691
-						$doc = Database::query($sql);
1692
-						$doc = Database::fetch_object($doc);
1693
-						$doc = str_replace('/audio/', '', $doc->path);
1694
-					}
1695
-				}
1696
-
1697
-				if ($id != -1) {
1698
-					// check resources inside html from ckeditor tool and copy correct urls into recipient course
1691
+                        $doc = Database::query($sql);
1692
+                        $doc = Database::fetch_object($doc);
1693
+                        $doc = str_replace('/audio/', '', $doc->path);
1694
+                    }
1695
+                }
1696
+
1697
+                if ($id != -1) {
1698
+                    // check resources inside html from ckeditor tool and copy correct urls into recipient course
1699 1699
                     $quiz->description = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1700 1700
                         $quiz->description,
1701 1701
                         $this->course->code,
@@ -1707,13 +1707,13 @@  discard block
 block discarded – undo
1707 1707
                     $quiz->start_time = $quiz->start_time == '0000-00-00 00:00:00' ? null : $quiz->start_time;
1708 1708
                     $quiz->end_time = $quiz->end_time == '0000-00-00 00:00:00' ? null : $quiz->end_time;
1709 1709
 
1710
-					global $_custom;
1711
-					if (isset($_custom['exercises_clean_dates_when_restoring']) &&
1710
+                    global $_custom;
1711
+                    if (isset($_custom['exercises_clean_dates_when_restoring']) &&
1712 1712
                         $_custom['exercises_clean_dates_when_restoring']
1713 1713
                     ) {
1714
-						$quiz->start_time = null;
1715
-						$quiz->end_time   = null;
1716
-					}
1714
+                        $quiz->start_time = null;
1715
+                        $quiz->end_time   = null;
1716
+                    }
1717 1717
 
1718 1718
                     $params = array(
1719 1719
                         'c_id' => $this->destination_course_id,
@@ -1747,10 +1747,10 @@  discard block
 block discarded – undo
1747 1747
                         }
1748 1748
                         $params['session_id'] = $my_session_id;
1749 1749
                     } else {
1750
-        				if (!empty($session_id)) {
1751
-        					$session_id = intval($session_id);
1750
+                        if (!empty($session_id)) {
1751
+                            $session_id = intval($session_id);
1752 1752
                             $params['session_id'] = $session_id;
1753
-    				    }
1753
+                        }
1754 1754
                     }
1755 1755
                     $new_id = Database::insert($table_qui, $params);
1756 1756
 
@@ -1759,15 +1759,15 @@  discard block
 block discarded – undo
1759 1759
                         Database::query($sql);
1760 1760
                     }
1761 1761
 
1762
-				} else {
1763
-					// $id = -1 identifies the fictionary test for collecting
1764
-					// orphan questions. We do not store it in the database.
1765
-					$new_id = -1;
1766
-				}
1762
+                } else {
1763
+                    // $id = -1 identifies the fictionary test for collecting
1764
+                    // orphan questions. We do not store it in the database.
1765
+                    $new_id = -1;
1766
+                }
1767 1767
 
1768
-				$this->course->resources[RESOURCE_QUIZ][$id]->destination_id = $new_id;
1768
+                $this->course->resources[RESOURCE_QUIZ][$id]->destination_id = $new_id;
1769 1769
 
1770
-				$order = 0;
1770
+                $order = 0;
1771 1771
                 if (!empty($quiz->question_ids)) {
1772 1772
                     foreach ($quiz->question_ids as $index => $question_id) {
1773 1773
                         $qid = $this->restore_quiz_question($question_id);
@@ -1780,31 +1780,31 @@  discard block
 block discarded – undo
1780 1780
                         Database::query($sql);
1781 1781
                     }
1782 1782
                 }
1783
-			}
1784
-		}
1785
-	}
1783
+            }
1784
+        }
1785
+    }
1786 1786
 
1787
-	/**
1788
-	 * Restore quiz-questions
1787
+    /**
1788
+     * Restore quiz-questions
1789 1789
      * @params int question id
1790
-	 */
1790
+     */
1791 1791
     public function restore_quiz_question($id)
1792 1792
     {
1793 1793
         $em = Database::getManager();
1794
-		$resources = $this->course->resources;
1794
+        $resources = $this->course->resources;
1795 1795
         $question = isset($resources[RESOURCE_QUIZQUESTION][$id]) ? $resources[RESOURCE_QUIZQUESTION][$id] : null;
1796 1796
 
1797
-		$new_id = 0;
1797
+        $new_id = 0;
1798 1798
 
1799
-		if (is_object($question)) {
1800
-			if ($question->is_restored()) {
1801
-				return $question->destination_id;
1802
-			}
1803
-			$table_que = Database::get_course_table(TABLE_QUIZ_QUESTION);
1804
-			$table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER);
1799
+        if (is_object($question)) {
1800
+            if ($question->is_restored()) {
1801
+                return $question->destination_id;
1802
+            }
1803
+            $table_que = Database::get_course_table(TABLE_QUIZ_QUESTION);
1804
+            $table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER);
1805 1805
             $table_options = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION);
1806 1806
 
1807
-			// check resources inside html from ckeditor tool and copy correct urls into recipient course
1807
+            // check resources inside html from ckeditor tool and copy correct urls into recipient course
1808 1808
             $question->description = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1809 1809
                 $question->description,
1810 1810
                 $this->course->code,
@@ -1825,7 +1825,7 @@  discard block
 block discarded – undo
1825 1825
                 'extra' => self::DBUTF8($question->extra)
1826 1826
             ];
1827 1827
 
1828
-			$new_id = Database::insert($table_que, $params);
1828
+            $new_id = Database::insert($table_que, $params);
1829 1829
 
1830 1830
             if ($new_id) {
1831 1831
 
@@ -1891,12 +1891,12 @@  discard block
 block discarded – undo
1891 1891
                         $em->merge($quizAnswer);
1892 1892
                         $em->flush();
1893 1893
                     }
1894
-				}
1895
-			} else {
1894
+                }
1895
+            } else {
1896 1896
                 $correct_answers = array();
1897
-				foreach ($question->answers as $index => $answer) {
1897
+                foreach ($question->answers as $index => $answer) {
1898 1898
 
1899
-					// check resources inside html from ckeditor tool and copy correct urls into recipient course
1899
+                    // check resources inside html from ckeditor tool and copy correct urls into recipient course
1900 1900
                     $answer['answer'] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1901 1901
                         $answer['answer'],
1902 1902
                         $this->course->code,
@@ -1935,8 +1935,8 @@  discard block
 block discarded – undo
1935 1935
                     }
1936 1936
 
1937 1937
                     $correct_answers[$answerId] = $answer['correct'];
1938
-				}
1939
-			}
1938
+                }
1939
+            }
1940 1940
 
1941 1941
             //Current course id
1942 1942
             $course_id = api_get_course_int_id();
@@ -2033,12 +2033,12 @@  discard block
 block discarded – undo
2033 2033
                     }
2034 2034
                 }
2035 2035
             }
2036
-			$this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id;
2037
-		}
2038
-		return $new_id;
2039
-	}
2036
+            $this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id;
2037
+        }
2038
+        return $new_id;
2039
+    }
2040 2040
 
2041
-	/**
2041
+    /**
2042 2042
      * @todo : add session id when used for session
2043 2043
      */
2044 2044
     public function restore_test_category($session_id, $respect_base_content, $destination_course_code)
@@ -2123,21 +2123,21 @@  discard block
 block discarded – undo
2123 2123
         $sessionId = intval($sessionId);
2124 2124
 
2125 2125
         if ($this->course->has_resources(RESOURCE_SURVEY)) {
2126
-			$table_sur = Database :: get_course_table(TABLE_SURVEY);
2127
-			$table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2128
-			$table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2129
-			$resources = $this->course->resources;
2130
-			foreach ($resources[RESOURCE_SURVEY] as $id => $survey) {
2126
+            $table_sur = Database :: get_course_table(TABLE_SURVEY);
2127
+            $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2128
+            $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2129
+            $resources = $this->course->resources;
2130
+            foreach ($resources[RESOURCE_SURVEY] as $id => $survey) {
2131 2131
 
2132
-				$sql = 'SELECT survey_id FROM '.$table_sur.'
2132
+                $sql = 'SELECT survey_id FROM '.$table_sur.'
2133 2133
                         WHERE
2134 2134
                             c_id = '.$this->destination_course_id.' AND
2135 2135
                             code = "'.self::DBUTF8escapestring($survey->code).'" AND
2136 2136
                             lang = "'.self::DBUTF8escapestring($survey->lang).'" ';
2137 2137
 
2138
-				$result_check = Database::query($sql);
2138
+                $result_check = Database::query($sql);
2139 2139
 
2140
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
2140
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
2141 2141
                 $survey->title = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2142 2142
                     $survey->title,
2143 2143
                     $this->course->code,
@@ -2191,20 +2191,20 @@  discard block
 block discarded – undo
2191 2191
                     'session_id' => $sessionId
2192 2192
                 ];
2193 2193
 
2194
-				//An existing survey exists with the same code and the same language
2195
-				if (Database::num_rows($result_check) == 1) {
2196
-					switch ($this->file_option) {
2197
-						case FILE_SKIP:
2198
-							//Do nothing
2199
-							break;
2200
-						case FILE_RENAME:
2201
-							$survey_code = $survey->code.'_';
2202
-							$i=1;
2203
-							$temp_survey_code = $survey_code.$i;
2204
-							while (!$this->is_survey_code_available($temp_survey_code)) {
2205
-								$temp_survey_code = $survey_code.++$i;
2206
-							}
2207
-							$survey_code = $temp_survey_code;
2194
+                //An existing survey exists with the same code and the same language
2195
+                if (Database::num_rows($result_check) == 1) {
2196
+                    switch ($this->file_option) {
2197
+                        case FILE_SKIP:
2198
+                            //Do nothing
2199
+                            break;
2200
+                        case FILE_RENAME:
2201
+                            $survey_code = $survey->code.'_';
2202
+                            $i=1;
2203
+                            $temp_survey_code = $survey_code.$i;
2204
+                            while (!$this->is_survey_code_available($temp_survey_code)) {
2205
+                                $temp_survey_code = $survey_code.++$i;
2206
+                            }
2207
+                            $survey_code = $temp_survey_code;
2208 2208
 
2209 2209
                             $params['code'] = $survey_code;
2210 2210
                             $new_id = Database::insert($table_sur, $params);
@@ -2223,25 +2223,25 @@  discard block
 block discarded – undo
2223 2223
                                     Database::query($sql);
2224 2224
                                 }
2225 2225
                             }
2226
-							break;
2227
-						case FILE_OVERWRITE:
2228
-							// Delete the existing survey with the same code and language and import the one of the source course
2229
-							// getting the information of the survey (used for when the survey is shared)
2226
+                            break;
2227
+                        case FILE_OVERWRITE:
2228
+                            // Delete the existing survey with the same code and language and import the one of the source course
2229
+                            // getting the information of the survey (used for when the survey is shared)
2230 2230
 
2231
-							$sql = "SELECT * FROM $table_sur
2231
+                            $sql = "SELECT * FROM $table_sur
2232 2232
 							        WHERE
2233 2233
 							            c_id = ".$this->destination_course_id." AND
2234 2234
 							            survey_id='".self::DBUTF8escapestring(Database::result($result_check,0,0))."'";
2235
-							$result = Database::query($sql);
2236
-							$survey_data = Database::fetch_array($result,'ASSOC');
2235
+                            $result = Database::query($sql);
2236
+                            $survey_data = Database::fetch_array($result,'ASSOC');
2237 2237
 
2238
-							// if the survey is shared => also delete the shared content
2239
-							if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) {
2238
+                            // if the survey is shared => also delete the shared content
2239
+                            if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) {
2240 2240
                                 SurveyManager::delete_survey($survey_data['survey_share'], true,$this->destination_course_id);
2241
-							}
2242
-							SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id);
2241
+                            }
2242
+                            SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id);
2243 2243
 
2244
-							// Insert the new source survey
2244
+                            // Insert the new source survey
2245 2245
                             $new_id = Database::insert($table_sur, $params);
2246 2246
 
2247 2247
                             if ($new_id) {
@@ -2262,11 +2262,11 @@  discard block
 block discarded – undo
2262 2262
                                     Database::query($sql);
2263 2263
                                 }
2264 2264
                             }
2265
-							break;
2266
-						default:
2267
-							break;
2268
-					}
2269
-				} else {
2265
+                            break;
2266
+                        default:
2267
+                            break;
2268
+                    }
2269
+                } else {
2270 2270
                     // No existing survey with the same language and the same code, we just copy the survey
2271 2271
                     $new_id = Database::insert($table_sur, $params);
2272 2272
 
@@ -2288,48 +2288,48 @@  discard block
 block discarded – undo
2288 2288
                             Database::query($sql);
2289 2289
                         }
2290 2290
                     }
2291
-				}
2292
-			}
2293
-		}
2294
-	}
2295
-
2296
-	/**
2297
-	 * Check availability of a survey code
2298
-	 * @param string $survey_code
2299
-	 */
2291
+                }
2292
+            }
2293
+        }
2294
+    }
2295
+
2296
+    /**
2297
+     * Check availability of a survey code
2298
+     * @param string $survey_code
2299
+     */
2300 2300
     public function is_survey_code_available($survey_code)
2301 2301
     {
2302
-		$table_sur = Database :: get_course_table(TABLE_SURVEY);
2303
-		$sql = "SELECT * FROM $table_sur
2302
+        $table_sur = Database :: get_course_table(TABLE_SURVEY);
2303
+        $sql = "SELECT * FROM $table_sur
2304 2304
 		        WHERE
2305 2305
 		            c_id = ".$this->destination_course_id." AND
2306 2306
 		            code = '".self::DBUTF8escapestring($survey_code)."'";
2307
-		$result = Database::query($sql);
2307
+        $result = Database::query($sql);
2308 2308
         if (Database::num_rows($result) > 0) {
2309 2309
             return false;
2310 2310
         } else {
2311 2311
             return true;
2312 2312
         }
2313
-	}
2313
+    }
2314 2314
 
2315
-	/**
2316
-	 * Restore survey-questions
2317
-	 * @param string $survey_id
2318
-	 */
2315
+    /**
2316
+     * Restore survey-questions
2317
+     * @param string $survey_id
2318
+     */
2319 2319
     public function restore_survey_question($id, $survey_id)
2320 2320
     {
2321
-		$resources = $this->course->resources;
2322
-		$question = $resources[RESOURCE_SURVEYQUESTION][$id];
2321
+        $resources = $this->course->resources;
2322
+        $question = $resources[RESOURCE_SURVEYQUESTION][$id];
2323 2323
         $new_id = 0;
2324 2324
 
2325
-		if (is_object($question)) {
2326
-			if ($question->is_restored()) {
2327
-				return $question->destination_id;
2328
-			}
2329
-			$table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2330
-			$table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2325
+        if (is_object($question)) {
2326
+            if ($question->is_restored()) {
2327
+                return $question->destination_id;
2328
+            }
2329
+            $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2330
+            $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2331 2331
 
2332
-			// check resources inside html from ckeditor tool and copy correct urls into recipient course
2332
+            // check resources inside html from ckeditor tool and copy correct urls into recipient course
2333 2333
             $question->survey_question = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2334 2334
                 $question->survey_question,
2335 2335
                 $this->course->code,
@@ -2383,10 +2383,10 @@  discard block
 block discarded – undo
2383 2383
                 }
2384 2384
                 $this->course->resources[RESOURCE_SURVEYQUESTION][$id]->destination_id = $new_id;
2385 2385
             }
2386
-		}
2386
+        }
2387 2387
 
2388
-		return $new_id;
2389
-	}
2388
+        return $new_id;
2389
+    }
2390 2390
 
2391 2391
     /**
2392 2392
      * Restoring learning paths
@@ -2397,19 +2397,19 @@  discard block
 block discarded – undo
2397 2397
     {
2398 2398
         $session_id = intval($session_id);
2399 2399
 
2400
-		if ($this->course->has_resources(RESOURCE_LEARNPATH)) {
2400
+        if ($this->course->has_resources(RESOURCE_LEARNPATH)) {
2401 2401
             $table_main = Database::get_course_table(TABLE_LP_MAIN);
2402 2402
             $table_item = Database::get_course_table(TABLE_LP_ITEM);
2403 2403
             $table_tool = Database::get_course_table(TABLE_TOOL_LIST);
2404 2404
 
2405
-			$resources = $this->course->resources;
2405
+            $resources = $this->course->resources;
2406 2406
 
2407
-			$origin_path = $this->course->backup_path.'/upload/learning_path/images/';
2408
-			$destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/';
2407
+            $origin_path = $this->course->backup_path.'/upload/learning_path/images/';
2408
+            $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/';
2409 2409
 
2410
-			foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) {
2411
-				$condition_session = '';
2412
-				if (!empty($session_id)) {
2410
+            foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) {
2411
+                $condition_session = '';
2412
+                if (!empty($session_id)) {
2413 2413
                     if ($respect_base_content) {
2414 2414
                         $my_session_id = $lp->session_id;
2415 2415
                         if (!empty($lp->session_id)) {
@@ -2420,20 +2420,20 @@  discard block
 block discarded – undo
2420 2420
                         $session_id = intval($session_id);
2421 2421
                         $condition_session = $session_id;
2422 2422
                     }
2423
-				}
2424
-
2425
-				// Adding the author's image
2426
-				if (!empty($lp->preview_image)) {
2427
-					$new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image));
2428
-					if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) {
2429
-						$copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename);
2430
-						if ($copy_result) {
2431
-							$lp->preview_image = $new_filename;
2432
-						} else {
2433
-							$lp->preview_image ='';
2434
-						}
2435
-					}
2436
-				}
2423
+                }
2424
+
2425
+                // Adding the author's image
2426
+                if (!empty($lp->preview_image)) {
2427
+                    $new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image));
2428
+                    if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) {
2429
+                        $copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename);
2430
+                        if ($copy_result) {
2431
+                            $lp->preview_image = $new_filename;
2432
+                        } else {
2433
+                            $lp->preview_image ='';
2434
+                        }
2435
+                    }
2436
+                }
2437 2437
 
2438 2438
                 if ($this->add_text_in_items) {
2439 2439
                     $lp->name = $lp->name.' '.get_lang('CopyLabelSuffix');
@@ -2491,7 +2491,7 @@  discard block
 block discarded – undo
2491 2491
                     $params['session_id'] = $condition_session;
2492 2492
                 }
2493 2493
 
2494
-				$new_lp_id = Database::insert($table_main, $params);
2494
+                $new_lp_id = Database::insert($table_main, $params);
2495 2495
 
2496 2496
                 if ($new_lp_id) {
2497 2497
 
@@ -2552,13 +2552,13 @@  discard block
 block discarded – undo
2552 2552
                 $old_refs = array();
2553 2553
                 $prerequisite_ids = array();
2554 2554
 
2555
-				foreach ($lp->get_items() as $index => $item) {
2556
-					// we set the ref code here and then we update in a for loop
2557
-					$ref = $item['ref'];
2555
+                foreach ($lp->get_items() as $index => $item) {
2556
+                    // we set the ref code here and then we update in a for loop
2557
+                    $ref = $item['ref'];
2558 2558
 
2559
-					// Dealing with path the same way as ref as some data has
2559
+                    // Dealing with path the same way as ref as some data has
2560 2560
                     // been put into path when it's a local resource
2561
-					// Only fix the path for no scos
2561
+                    // Only fix the path for no scos
2562 2562
                     if ($item['item_type'] == 'sco') {
2563 2563
                         $path = $item['path'];
2564 2564
                     } else {
@@ -2589,128 +2589,128 @@  discard block
 block discarded – undo
2589 2589
                         'launch_data' => self::DBUTF8($item['launch_data']),
2590 2590
                     ];
2591 2591
 
2592
-					$new_item_id = Database::insert($table_item, $params);
2592
+                    $new_item_id = Database::insert($table_item, $params);
2593 2593
 
2594 2594
                     $sql = "UPDATE $table_item SET id = iid WHERE iid = $new_item_id";
2595 2595
                     Database::query($sql);
2596 2596
 
2597
-					//save a link between old and new item IDs
2598
-					$new_item_ids[$item['id']] = $new_item_id;
2599
-					//save a reference of items that need a parent_item_id refresh
2600
-					$parent_item_ids[$new_item_id] = $item['parent_item_id'];
2601
-					//save a reference of items that need a previous_item_id refresh
2602
-					$previous_item_ids[$new_item_id] = $item['previous_item_id'];
2603
-					//save a reference of items that need a next_item_id refresh
2604
-					$next_item_ids[$new_item_id] = $item['next_item_id'];
2605
-
2606
-					if (!empty($item['prerequisite'])) {
2607
-						if ($lp->lp_type =='2') {
2608
-							// if is an sco
2609
-							$old_prerequisite[$new_item_id]= $item['prerequisite'];
2610
-						} else {
2611
-							$old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']];
2612
-						}
2613
-					}
2614
-
2615
-					if (!empty($ref)) {
2616
-						if ($lp->lp_type =='2') {
2617
-							// if is an sco
2618
-							$old_refs[$new_item_id]= $ref;
2619
-						} elseif (isset($new_item_ids[$ref])) {
2597
+                    //save a link between old and new item IDs
2598
+                    $new_item_ids[$item['id']] = $new_item_id;
2599
+                    //save a reference of items that need a parent_item_id refresh
2600
+                    $parent_item_ids[$new_item_id] = $item['parent_item_id'];
2601
+                    //save a reference of items that need a previous_item_id refresh
2602
+                    $previous_item_ids[$new_item_id] = $item['previous_item_id'];
2603
+                    //save a reference of items that need a next_item_id refresh
2604
+                    $next_item_ids[$new_item_id] = $item['next_item_id'];
2605
+
2606
+                    if (!empty($item['prerequisite'])) {
2607
+                        if ($lp->lp_type =='2') {
2608
+                            // if is an sco
2609
+                            $old_prerequisite[$new_item_id]= $item['prerequisite'];
2610
+                        } else {
2611
+                            $old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']];
2612
+                        }
2613
+                    }
2614
+
2615
+                    if (!empty($ref)) {
2616
+                        if ($lp->lp_type =='2') {
2617
+                            // if is an sco
2618
+                            $old_refs[$new_item_id]= $ref;
2619
+                        } elseif (isset($new_item_ids[$ref])) {
2620 2620
                             $old_refs[$new_item_id]= $new_item_ids[$ref];
2621 2621
                         }
2622
-					}
2622
+                    }
2623 2623
 
2624
-					$prerequisite_ids[$new_item_id] = $item['prerequisite'];
2625
-				}
2624
+                    $prerequisite_ids[$new_item_id] = $item['prerequisite'];
2625
+                }
2626 2626
 
2627
-				// Updating prerequisites
2628
-				foreach ($old_prerequisite  as $key=>$my_old_prerequisite) {
2629
-					if ($my_old_prerequisite != ''){
2630
-						$sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."'
2627
+                // Updating prerequisites
2628
+                foreach ($old_prerequisite  as $key=>$my_old_prerequisite) {
2629
+                    if ($my_old_prerequisite != ''){
2630
+                        $sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."'
2631 2631
 						        WHERE c_id = ".$this->destination_course_id." AND id = '".$key."'  ";
2632
-						Database::query($sql);
2633
-					}
2634
-				}
2635
-
2636
-				// Updating refs
2637
-				foreach ($old_refs  as $key=>$my_old_ref) {
2638
-					if ($my_old_ref != '') {
2639
-						$sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."'
2632
+                        Database::query($sql);
2633
+                    }
2634
+                }
2635
+
2636
+                // Updating refs
2637
+                foreach ($old_refs  as $key=>$my_old_ref) {
2638
+                    if ($my_old_ref != '') {
2639
+                        $sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."'
2640 2640
 						        WHERE c_id = ".$this->destination_course_id." AND id = '".$key."'  ";
2641
-						Database::query($sql);
2642
-					}
2643
-				}
2644
-
2645
-				foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) {
2646
-					$parent_new_id = 0;
2647
-					if($parent_item_old_id != 0){
2648
-						$parent_new_id = $new_item_ids[$parent_item_old_id];
2649
-					}
2650
-					$sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."'
2641
+                        Database::query($sql);
2642
+                    }
2643
+                }
2644
+
2645
+                foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) {
2646
+                    $parent_new_id = 0;
2647
+                    if($parent_item_old_id != 0){
2648
+                        $parent_new_id = $new_item_ids[$parent_item_old_id];
2649
+                    }
2650
+                    $sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."'
2651 2651
 					        WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'";
2652
-					Database::query($sql);
2653
-				}
2654
-				foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) {
2655
-					$previous_new_id = 0;
2656
-					if ($previous_item_old_id != 0){
2657
-						$previous_new_id = $new_item_ids[$previous_item_old_id];
2658
-					}
2659
-					$sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."'
2652
+                    Database::query($sql);
2653
+                }
2654
+                foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) {
2655
+                    $previous_new_id = 0;
2656
+                    if ($previous_item_old_id != 0){
2657
+                        $previous_new_id = $new_item_ids[$previous_item_old_id];
2658
+                    }
2659
+                    $sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."'
2660 2660
 					        WHERE  c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'";
2661
-					Database::query($sql);
2662
-				}
2663
-
2664
-				foreach ($next_item_ids as $new_item_id => $next_item_old_id) {
2665
-					$next_new_id = 0;
2666
-					if ($next_item_old_id != 0){
2667
-						$next_new_id = $new_item_ids[$next_item_old_id];
2668
-					}
2669
-					$sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."'
2661
+                    Database::query($sql);
2662
+                }
2663
+
2664
+                foreach ($next_item_ids as $new_item_id => $next_item_old_id) {
2665
+                    $next_new_id = 0;
2666
+                    if ($next_item_old_id != 0){
2667
+                        $next_new_id = $new_item_ids[$next_item_old_id];
2668
+                    }
2669
+                    $sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."'
2670 2670
 					        WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'";
2671
-					Database::query($sql);
2672
-				}
2673
-
2674
-				foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) {
2675
-					$prerequisite_new_id = 0;
2676
-					if ($prerequisite_old_id != 0){
2677
-						$prerequisite_new_id = $new_item_ids[$prerequisite_old_id];
2678
-					}
2679
-					$sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."'
2671
+                    Database::query($sql);
2672
+                }
2673
+
2674
+                foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) {
2675
+                    $prerequisite_new_id = 0;
2676
+                    if ($prerequisite_old_id != 0){
2677
+                        $prerequisite_new_id = $new_item_ids[$prerequisite_old_id];
2678
+                    }
2679
+                    $sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."'
2680 2680
 					        WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'";
2681
-					Database::query($sql);
2682
-				}
2683
-				$this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id;
2684
-			}
2685
-		}
2686
-	}
2687
-
2688
-	/**
2689
-	 * Restore works
2681
+                    Database::query($sql);
2682
+                }
2683
+                $this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id;
2684
+            }
2685
+        }
2686
+    }
2687
+
2688
+    /**
2689
+     * Restore works
2690 2690
      * @deprecated use restore_works
2691 2691
      *
2692
-	 */
2693
-	public function restore_student_publication($sessionId = 0)
2692
+     */
2693
+    public function restore_student_publication($sessionId = 0)
2694 2694
     {
2695 2695
         $sessionId = intval($sessionId);
2696 2696
         $work_assignment_table = Database:: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
2697 2697
         $work_table = Database:: get_course_table(TABLE_STUDENT_PUBLICATION);
2698 2698
         $item_property_table = Database:: get_course_table(TABLE_ITEM_PROPERTY);
2699 2699
 
2700
-		// Query in student publication
2701
-		$sql = 'SELECT * FROM '.$work_table.'
2700
+        // Query in student publication
2701
+        $sql = 'SELECT * FROM '.$work_table.'
2702 2702
 		        WHERE c_id = '.$this->course_origin_id.' AND filetype = "folder" AND active IN (0, 1) ';
2703 2703
 
2704
-		$result = Database::query($sql);
2705
-		$folders = Database::store_result($result, 'ASSOC');
2704
+        $result = Database::query($sql);
2705
+        $folders = Database::store_result($result, 'ASSOC');
2706 2706
 
2707
-		foreach ($folders  as $folder) {
2708
-		    $old_id = $folder['id'];
2707
+        foreach ($folders  as $folder) {
2708
+            $old_id = $folder['id'];
2709 2709
             unset($folder['id']);
2710
-			$folder['c_id'] = $this->destination_course_id;
2710
+            $folder['c_id'] = $this->destination_course_id;
2711 2711
             $folder['parent_id'] = 0;
2712 2712
             $folder['session_id'] = $sessionId ? $sessionId : null;
2713
-			$new_id = Database::insert($work_table, $folder);
2713
+            $new_id = Database::insert($work_table, $folder);
2714 2714
 
2715 2715
             if ($new_id) {
2716 2716
                 // query in item property
@@ -2769,23 +2769,23 @@  discard block
 block discarded – undo
2769 2769
                     }
2770 2770
                 }
2771 2771
             }
2772
-		}
2772
+        }
2773 2773
 
2774 2774
         $destination = '../..'.api_get_path(REL_COURSE_PATH).$this->course->destination_path.'/work/';
2775 2775
         $origin = '../..'.api_get_path(REL_COURSE_PATH).$this->course->info['path'].'/work/';
2776 2776
         self::allow_create_all_directory($origin, $destination, false);
2777
-	}
2777
+    }
2778 2778
 
2779 2779
     /**
2780
-    * copy all directory and sub directory
2781
-    * @param string The path origin
2782
-    * @param string The path destination
2783
-    * @param boolean Option Overwrite
2784
-    * @param string $source
2785
-    * @param string $dest
2786
-    * @return void()
2787
-    * @deprecated
2788
-    */
2780
+     * copy all directory and sub directory
2781
+     * @param string The path origin
2782
+     * @param string The path destination
2783
+     * @param boolean Option Overwrite
2784
+     * @param string $source
2785
+     * @param string $dest
2786
+     * @return void()
2787
+     * @deprecated
2788
+     */
2789 2789
     public function allow_create_all_directory($source, $dest, $overwrite = false)
2790 2790
     {
2791 2791
         if (!is_dir($dest)) {
@@ -2796,7 +2796,7 @@  discard block
 block discarded – undo
2796 2796
                 if ($file != '.' && $file != '..') {
2797 2797
                     $path = $source . '/' . $file;
2798 2798
                     if (is_file($path)) {
2799
-                       /* if (!is_file($dest . '/' . $file) || $overwrite)
2799
+                        /* if (!is_file($dest . '/' . $file) || $overwrite)
2800 2800
                         if (!@copy($path, $dest . '/' . $file)) {
2801 2801
                             echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>';
2802 2802
                         }*/
@@ -2811,12 +2811,12 @@  discard block
 block discarded – undo
2811 2811
         }
2812 2812
     }
2813 2813
 
2814
-	/**
2815
-	 * Gets the new ID of one specific tool item from the tool name and the old ID
2816
-	 * @param	string	Tool name
2817
-	 * @param	integer	Old ID
2818
-	 * @return	integer	New ID
2819
-	 */
2814
+    /**
2815
+     * Gets the new ID of one specific tool item from the tool name and the old ID
2816
+     * @param	string	Tool name
2817
+     * @param	integer	Old ID
2818
+     * @return	integer	New ID
2819
+     */
2820 2820
     public function get_new_id($tool, $ref)
2821 2821
     {
2822 2822
         // Check if the value exist in the current array.
@@ -2838,25 +2838,25 @@  discard block
 block discarded – undo
2838 2838
         }
2839 2839
 
2840 2840
         return '';
2841
-	}
2841
+    }
2842 2842
 
2843
-	/**
2844
-	 * Restore glossary
2845
-	 */
2843
+    /**
2844
+     * Restore glossary
2845
+     */
2846 2846
     public function restore_glossary($session_id = 0)
2847 2847
     {
2848
-		if ($this->course->has_resources(RESOURCE_GLOSSARY)) {
2849
-			$table_glossary = Database :: get_course_table(TABLE_GLOSSARY);
2850
-			$resources = $this->course->resources;
2851
-			foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) {
2848
+        if ($this->course->has_resources(RESOURCE_GLOSSARY)) {
2849
+            $table_glossary = Database :: get_course_table(TABLE_GLOSSARY);
2850
+            $resources = $this->course->resources;
2851
+            foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) {
2852 2852
 
2853 2853
                 $params = [];
2854
-    			if (!empty($session_id)) {
2855
-    				$session_id = intval($session_id);
2854
+                if (!empty($session_id)) {
2855
+                    $session_id = intval($session_id);
2856 2856
                     $params['session_id'] = $session_id;
2857
-    			}
2857
+                }
2858 2858
 
2859
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
2859
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
2860 2860
                 $glossary->description = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2861 2861
                     $glossary->description,
2862 2862
                     $this->course->code,
@@ -2890,27 +2890,27 @@  discard block
 block discarded – undo
2890 2890
 
2891 2891
                     $this->course->resources[RESOURCE_GLOSSARY][$id]->destination_id = $my_id;
2892 2892
                 }
2893
-			}
2894
-		}
2895
-	}
2893
+            }
2894
+        }
2895
+    }
2896 2896
 
2897 2897
     /**
2898 2898
      * @param int $session_id
2899 2899
      */
2900 2900
     public function restore_wiki($session_id = 0)
2901 2901
     {
2902
-		if ($this->course->has_resources(RESOURCE_WIKI)) {
2903
-			// wiki table of the target course
2904
-			$table_wiki = Database :: get_course_table(TABLE_WIKI);
2905
-			$table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF);
2902
+        if ($this->course->has_resources(RESOURCE_WIKI)) {
2903
+            // wiki table of the target course
2904
+            $table_wiki = Database :: get_course_table(TABLE_WIKI);
2905
+            $table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF);
2906 2906
 
2907
-			// storing all the resources that have to be copied in an array
2908
-			$resources = $this->course->resources;
2907
+            // storing all the resources that have to be copied in an array
2908
+            $resources = $this->course->resources;
2909 2909
 
2910
-			foreach ($resources[RESOURCE_WIKI] as $id => $wiki) {
2911
-				// the sql statement to insert the groups from the old course to the new course
2910
+            foreach ($resources[RESOURCE_WIKI] as $id => $wiki) {
2911
+                // the sql statement to insert the groups from the old course to the new course
2912 2912
 
2913
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
2913
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
2914 2914
                 $wiki->content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2915 2915
                     $wiki->content,
2916 2916
                     $this->course->code,
@@ -2945,7 +2945,7 @@  discard block
 block discarded – undo
2945 2945
                     'user_ip' => ''
2946 2946
                 ];
2947 2947
 
2948
-				$new_id = Database::insert($table_wiki, $params);
2948
+                $new_id = Database::insert($table_wiki, $params);
2949 2949
 
2950 2950
                 if ($new_id) {
2951 2951
                     $sql = "UPDATE $table_wiki SET page_id = '$new_id', id = iid
@@ -2975,9 +2975,9 @@  discard block
 block discarded – undo
2975 2975
 
2976 2976
                     Database::insert($table_wiki_conf, $params);
2977 2977
                 }
2978
-			}
2979
-		}
2980
-	}
2978
+            }
2979
+        }
2980
+    }
2981 2981
 
2982 2982
     /**
2983 2983
      * Restore Thematics
@@ -2985,15 +2985,15 @@  discard block
 block discarded – undo
2985 2985
      */
2986 2986
     public function restore_thematic($session_id = 0)
2987 2987
     {
2988
-		if ($this->course->has_resources(RESOURCE_THEMATIC)) {
2988
+        if ($this->course->has_resources(RESOURCE_THEMATIC)) {
2989 2989
             $table_thematic = Database::get_course_table(TABLE_THEMATIC);
2990 2990
             $table_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
2991 2991
             $table_thematic_plan = Database::get_course_table(TABLE_THEMATIC_PLAN);
2992 2992
 
2993
-			$resources = $this->course->resources;
2994
-			foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) {
2993
+            $resources = $this->course->resources;
2994
+            foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) {
2995 2995
 
2996
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
2996
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
2997 2997
                 $thematic->params['content'] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2998 2998
                     $thematic->params['content'],
2999 2999
                     $this->course->code,
@@ -3001,13 +3001,13 @@  discard block
 block discarded – undo
3001 3001
                     $this->course->backup_path,
3002 3002
                     $this->course->info['path']
3003 3003
                 );
3004
-				$thematic->params['c_id']  = $this->destination_course_id;
3005
-				unset($thematic->params['id']);
3004
+                $thematic->params['c_id']  = $this->destination_course_id;
3005
+                unset($thematic->params['id']);
3006 3006
                 unset($thematic->params['iid']);
3007 3007
 
3008
-				$last_id = Database::insert($table_thematic, $thematic->params, false);
3008
+                $last_id = Database::insert($table_thematic, $thematic->params, false);
3009 3009
 
3010
-				if ($last_id) {
3010
+                if ($last_id) {
3011 3011
 
3012 3012
                     $sql = "UPDATE $table_thematic SET id = iid WHERE iid = $last_id";
3013 3013
                     Database::query($sql);
@@ -3020,12 +3020,12 @@  discard block
 block discarded – undo
3020 3020
                         api_get_user_id()
3021 3021
                     );
3022 3022
 
3023
-					foreach ($thematic->thematic_advance_list as $thematic_advance) {
3024
-						unset($thematic_advance['id']);
3023
+                    foreach ($thematic->thematic_advance_list as $thematic_advance) {
3024
+                        unset($thematic_advance['id']);
3025 3025
                         unset($thematic_advance['iid']);
3026
-						$thematic_advance['attendance_id'] = 0;
3027
-						$thematic_advance['thematic_id'] = $last_id;
3028
-						$thematic_advance['c_id']  = $this->destination_course_id;
3026
+                        $thematic_advance['attendance_id'] = 0;
3027
+                        $thematic_advance['thematic_id'] = $last_id;
3028
+                        $thematic_advance['c_id']  = $this->destination_course_id;
3029 3029
 
3030 3030
                         $my_id = Database::insert(
3031 3031
                             $table_thematic_advance,
@@ -3033,7 +3033,7 @@  discard block
 block discarded – undo
3033 3033
                             false
3034 3034
                         );
3035 3035
 
3036
-						if ($my_id) {
3036
+                        if ($my_id) {
3037 3037
 
3038 3038
                             $sql = "UPDATE $table_thematic_advance SET id = iid WHERE iid = $my_id";
3039 3039
                             Database::query($sql);
@@ -3045,17 +3045,17 @@  discard block
 block discarded – undo
3045 3045
                                 'ThematicAdvanceAdded',
3046 3046
                                 api_get_user_id()
3047 3047
                             );
3048
-						}
3049
-					}
3048
+                        }
3049
+                    }
3050 3050
 
3051
-					foreach($thematic->thematic_plan_list as $thematic_plan) {
3052
-						unset($thematic_plan['id']);
3051
+                    foreach($thematic->thematic_plan_list as $thematic_plan) {
3052
+                        unset($thematic_plan['id']);
3053 3053
                         unset($thematic_plan['iid']);
3054
-						$thematic_plan['thematic_id'] = $last_id;
3055
-						$thematic_plan['c_id'] = $this->destination_course_id;
3056
-						$my_id = Database::insert($table_thematic_plan, $thematic_plan, false);
3054
+                        $thematic_plan['thematic_id'] = $last_id;
3055
+                        $thematic_plan['c_id'] = $this->destination_course_id;
3056
+                        $my_id = Database::insert($table_thematic_plan, $thematic_plan, false);
3057 3057
 
3058
-						if ($my_id) {
3058
+                        if ($my_id) {
3059 3059
 
3060 3060
                             $sql = "UPDATE $table_thematic_plan SET id = iid WHERE iid = $my_id";
3061 3061
                             Database::query($sql);
@@ -3067,12 +3067,12 @@  discard block
 block discarded – undo
3067 3067
                                 'ThematicPlanAdded',
3068 3068
                                 api_get_user_id()
3069 3069
                             );
3070
-						}
3071
-					}
3072
-				}
3073
-			}
3074
-		}
3075
-	}
3070
+                        }
3071
+                    }
3072
+                }
3073
+            }
3074
+        }
3075
+    }
3076 3076
 
3077 3077
     /**
3078 3078
      * Restore Attendance
@@ -3080,14 +3080,14 @@  discard block
 block discarded – undo
3080 3080
      */
3081 3081
     public function restore_attendance($session_id = 0)
3082 3082
     {
3083
-		if ($this->course->has_resources(RESOURCE_ATTENDANCE)) {
3084
-			$table_attendance = Database :: get_course_table(TABLE_ATTENDANCE);
3085
-			$table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR);
3083
+        if ($this->course->has_resources(RESOURCE_ATTENDANCE)) {
3084
+            $table_attendance = Database :: get_course_table(TABLE_ATTENDANCE);
3085
+            $table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR);
3086 3086
 
3087
-			$resources = $this->course->resources;
3088
-			foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) {
3087
+            $resources = $this->course->resources;
3088
+            foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) {
3089 3089
 
3090
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
3090
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
3091 3091
                 $obj->params['description'] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
3092 3092
                     $obj->params['description'],
3093 3093
                     $this->course->code,
@@ -3099,11 +3099,11 @@  discard block
 block discarded – undo
3099 3099
                 unset($obj->params['id']);
3100 3100
                 unset($obj->params['iid']);
3101 3101
 
3102
-				$obj->params['c_id'] = $this->destination_course_id;
3102
+                $obj->params['c_id'] = $this->destination_course_id;
3103 3103
 
3104
-				$last_id = Database::insert($table_attendance, $obj->params);
3104
+                $last_id = Database::insert($table_attendance, $obj->params);
3105 3105
 
3106
-				if (is_numeric($last_id)) {
3106
+                if (is_numeric($last_id)) {
3107 3107
 
3108 3108
                     $sql = "UPDATE $table_attendance SET id = iid WHERE iid = $last_id";
3109 3109
                     Database::query($sql);
@@ -3117,11 +3117,11 @@  discard block
 block discarded – undo
3117 3117
                     );
3118 3118
 
3119 3119
                     foreach ($obj->attendance_calendar as $attendance_calendar) {
3120
-						unset($attendance_calendar['id']);
3120
+                        unset($attendance_calendar['id']);
3121 3121
                         unset($attendance_calendar['iid']);
3122 3122
 
3123
-						$attendance_calendar['attendance_id'] = $last_id;
3124
-						$attendance_calendar['c_id'] = $this->destination_course_id;
3123
+                        $attendance_calendar['attendance_id'] = $last_id;
3124
+                        $attendance_calendar['c_id'] = $this->destination_course_id;
3125 3125
                         $attendanceCalendarId = Database::insert(
3126 3126
                             $table_attendance_calendar,
3127 3127
                             $attendance_calendar
@@ -3129,11 +3129,11 @@  discard block
 block discarded – undo
3129 3129
 
3130 3130
                         $sql = "UPDATE $table_attendance_calendar SET id = iid WHERE iid = $attendanceCalendarId";
3131 3131
                         Database::query($sql);
3132
-					}
3133
-				}
3134
-			}
3135
-		}
3136
-	}
3132
+                    }
3133
+                }
3134
+            }
3135
+        }
3136
+    }
3137 3137
 
3138 3138
     /**
3139 3139
      * Restore Works
@@ -3274,11 +3274,11 @@  discard block
 block discarded – undo
3274 3274
      */
3275 3275
     public function DBUTF8($str)
3276 3276
     {
3277
-		if (UTF8_CONVERT) {
3277
+        if (UTF8_CONVERT) {
3278 3278
             $str = utf8_encode($str);
3279 3279
         }
3280
-		return $str;
3281
-	}
3280
+        return $str;
3281
+    }
3282 3282
 
3283 3283
     /**
3284 3284
      * @param string $str
@@ -3289,8 +3289,8 @@  discard block
 block discarded – undo
3289 3289
         if (UTF8_CONVERT) {
3290 3290
             $str = utf8_encode($str);
3291 3291
         }
3292
-		return Database::escape_string($str);
3293
-	}
3292
+        return Database::escape_string($str);
3293
+    }
3294 3294
 
3295 3295
     /**
3296 3296
      * @param array $array
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2801,8 +2801,9 @@
 block discarded – undo
2801 2801
                             echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>';
2802 2802
                         }*/
2803 2803
                     } elseif(is_dir($path)) {
2804
-                        if (!is_dir($dest . '/' . $file))
2805
-                        mkdir($dest . '/' . $file);
2804
+                        if (!is_dir($dest . '/' . $file)) {
2805
+                                                mkdir($dest . '/' . $file);
2806
+                        }
2806 2807
                         self:: allow_create_all_directory($path, $dest . '/' . $file, $overwrite);
2807 2808
                     }
2808 2809
                 }
Please login to merge, or discard this patch.
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
                                 $params['lastedit_date'] = self::DBUTF8($property['lastedit_date']);
219 219
                                 $params['ref'] = $resource->destination_id;
220 220
                                 $params['lastedit_type'] = self::DBUTF8($property['lastedit_type']);
221
-                                $params['lastedit_user_id'] =  $this->checkUserId($property['lastedit_user_id']);
221
+                                $params['lastedit_user_id'] = $this->checkUserId($property['lastedit_user_id']);
222 222
                                 $params['visibility'] = self::DBUTF8($property['visibility']);
223 223
                                 $params['start_visible'] = self::DBUTF8($property['start_visible']);
224 224
                                 $params['end_visible'] = self::DBUTF8($property['end_visible']);
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
                             $new_file_name = $file_name_no_ext.'_'.$i.$ext;
563 563
                             $file_exists = file_exists($path.$new_file_name);
564 564
                             while ($file_exists) {
565
-                                $i ++;
565
+                                $i++;
566 566
                                 $new_file_name = $file_name_no_ext.'_'.$i.$ext;
567 567
                                 $file_exists = file_exists($path.$new_file_name);
568 568
                             }
@@ -607,9 +607,9 @@  discard block
 block discarded – undo
607 607
                                         $new_base_path = $_SESSION['new_base_path'];
608 608
                                     }
609 609
 
610
-                                    $dest_document_path = $new_base_path.'/'.$document_path[2];		// e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png"
611
-                                    $basedir_dest_path 	= dirname($dest_document_path);				// e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1"
612
-                                    $base_path_document = $course_path.$document_path[0];			// e.g: "/var/www/wiener/courses/CURSO4/document"
610
+                                    $dest_document_path = $new_base_path.'/'.$document_path[2]; // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png"
611
+                                    $basedir_dest_path 	= dirname($dest_document_path); // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1"
612
+                                    $base_path_document = $course_path.$document_path[0]; // e.g: "/var/www/wiener/courses/CURSO4/document"
613 613
                                     $path_title = '/'.$new_base_foldername.'/'.$document_path[2];
614 614
 
615 615
                                     copy_folder_course_session(
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
                                     //Replace old course code with the new destination code see BT#1985
629 629
                                     if (file_exists($dest_document_path)) {
630 630
                                         $file_info = pathinfo($dest_document_path);
631
-                                        if (in_array($file_info['extension'], array('html','htm'))) {
631
+                                        if (in_array($file_info['extension'], array('html', 'htm'))) {
632 632
                                             $content = file_get_contents($dest_document_path);
633 633
                                             if (UTF8_CONVERT) {
634 634
                                                 $content = utf8_encode($content);
@@ -690,8 +690,8 @@  discard block
 block discarded – undo
690 690
                                     //Replace old course code with the new destination code see BT#1985
691 691
                                     if (file_exists($path.$new_file_name)) {
692 692
                                         $file_info = pathinfo($path.$new_file_name);
693
-                                        if (in_array($file_info['extension'], array('html','htm'))) {
694
-                                            $content    = file_get_contents($path.$new_file_name);
693
+                                        if (in_array($file_info['extension'], array('html', 'htm'))) {
694
+                                            $content = file_get_contents($path.$new_file_name);
695 695
                                             if (UTF8_CONVERT) {
696 696
                                                 $content = utf8_encode($content);
697 697
                                             }
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
                                 //Replace old course code with the new destination code see BT#1985
754 754
                                 if (file_exists($path.$new_file_name)) {
755 755
                                     $file_info = pathinfo($path.$new_file_name);
756
-                                    if (in_array($file_info['extension'], array('html','htm'))) {
756
+                                    if (in_array($file_info['extension'], array('html', 'htm'))) {
757 757
                                         $content = file_get_contents($path.$new_file_name);
758 758
                                         if (UTF8_CONVERT) {
759 759
                                             $content = utf8_encode($content);
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
                         //Replace old course code with the new destination code see BT#1985
827 827
                         if (file_exists($path.$document->path)) {
828 828
                             $file_info = pathinfo($path.$document->path);
829
-                            if (isset($file_info['extension']) && in_array($file_info['extension'], array('html','htm'))) {
829
+                            if (isset($file_info['extension']) && in_array($file_info['extension'], array('html', 'htm'))) {
830 830
                                 $content = file_get_contents($path.$document->path);
831 831
                                 if (UTF8_CONVERT) {
832 832
                                     $content = utf8_encode($content);
@@ -926,8 +926,8 @@  discard block
 block discarded – undo
926 926
 						case FILE_OVERWRITE:
927 927
 							rmdirr($path.$document->path);
928 928
                             copyDirTo(
929
-                                $this->course->backup_path . '/' . $document->path,
930
-                                $path . dirname($document->path),
929
+                                $this->course->backup_path.'/'.$document->path,
930
+                                $path.dirname($document->path),
931 931
                                 false
932 932
                             );
933 933
 							break;
@@ -949,23 +949,23 @@  discard block
 block discarded – undo
949 949
 							$file_exists = file_exists($path.$new_file_name);
950 950
 
951 951
 							while ($file_exists) {
952
-								$i ++;
952
+								$i++;
953 953
 								$new_file_name = $file_name_no_ext.'_'.$i.$ext;
954 954
 								$file_exists = file_exists($path.$new_file_name);
955 955
 							}
956 956
 
957 957
                             rename(
958
-                                $this->course->backup_path . '/' . $document->path,
959
-                                $this->course->backup_path . '/' . $new_file_name
958
+                                $this->course->backup_path.'/'.$document->path,
959
+                                $this->course->backup_path.'/'.$new_file_name
960 960
                             );
961 961
                             copyDirTo(
962
-                                $this->course->backup_path . '/' . $new_file_name,
963
-                                $path . dirname($new_file_name),
962
+                                $this->course->backup_path.'/'.$new_file_name,
963
+                                $path.dirname($new_file_name),
964 964
                                 false
965 965
                             );
966 966
                             rename(
967
-                                $this->course->backup_path . '/' . $new_file_name,
968
-                                $this->course->backup_path . '/' . $document->path
967
+                                $this->course->backup_path.'/'.$new_file_name,
968
+                                $this->course->backup_path.'/'.$document->path
969 969
                             );
970 970
 
971 971
 							break;
@@ -973,8 +973,8 @@  discard block
 block discarded – undo
973 973
 				} else {
974 974
                     // end if file exists
975 975
                     copyDirTo(
976
-                        $this->course->backup_path . '/' . $document->path,
977
-                        $path . dirname($document->path),
976
+                        $this->course->backup_path.'/'.$document->path,
977
+                        $path.dirname($document->path),
978 978
                         false
979 979
                     );
980 980
 				}
@@ -992,7 +992,7 @@  discard block
 block discarded – undo
992 992
 			$table_forum = Database::get_course_table(TABLE_FORUM);
993 993
 			$resources = $this->course->resources;
994 994
 			foreach ($resources[RESOURCE_FORUM] as $id => $forum) {
995
-                $params = (array)$forum->obj;
995
+                $params = (array) $forum->obj;
996 996
                 $cat_id = '';
997 997
                 if (isset($this->course->resources[RESOURCE_FORUMCATEGORY]) &&
998 998
                     isset($this->course->resources[RESOURCE_FORUMCATEGORY][$params['forum_category']])) {
@@ -1045,13 +1045,13 @@  discard block
 block discarded – undo
1045 1045
 					foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) {
1046 1046
 						if ($topic->obj->forum_id == $id) {
1047 1047
 							$this->restore_topic($topic_id, $new_id, $sessionId);
1048
-							$forum_topics ++;
1048
+							$forum_topics++;
1049 1049
 						}
1050 1050
 					}
1051 1051
 				}
1052 1052
 				if ($forum_topics > 0) {
1053 1053
 					$sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics."
1054
-                            WHERE c_id = {$this->destination_course_id} AND forum_id = ".(int)$new_id;
1054
+                            WHERE c_id = {$this->destination_course_id} AND forum_id = ".(int) $new_id;
1055 1055
 					Database::query($sql);
1056 1056
 				}
1057 1057
 			}
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
 		$table = Database :: get_course_table(TABLE_FORUM_THREAD);
1114 1114
 		$topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id];
1115 1115
 
1116
-        $params = (array)$topic->obj;
1116
+        $params = (array) $topic->obj;
1117 1117
         $params = self::DBUTF8_array($params);
1118 1118
         $params['c_id'] = $this->destination_course_id;
1119 1119
         $params['forum_id'] = $forum_id;
@@ -1227,7 +1227,7 @@  discard block
 block discarded – undo
1227 1227
 				        FROM $link_table
1228 1228
 				        WHERE
1229 1229
 				            c_id = ".$this->destination_course_id." AND
1230
-				            category_id='" . intval($cat_id). "'";
1230
+				            category_id='" . intval($cat_id)."'";
1231 1231
 				$result = Database::query($sql);
1232 1232
     			list($max_order) = Database::fetch_array($result);
1233 1233
 
@@ -1242,7 +1242,7 @@  discard block
 block discarded – undo
1242 1242
                 $params['description'] = self::DBUTF8($link->description);
1243 1243
                 $params['category_id'] = $cat_id;
1244 1244
                 $params['on_homepage'] = $link->on_homepage;
1245
-                $params['display_order'] = $max_order+1;
1245
+                $params['display_order'] = $max_order + 1;
1246 1246
 
1247 1247
                 $id = Database::insert($link_table, $params);
1248 1248
 
@@ -1286,9 +1286,9 @@  discard block
 block discarded – undo
1286 1286
         if (is_object($link_cat) && !$link_cat->is_restored()) {
1287 1287
             $sql = "SELECT MAX(display_order) FROM  $link_cat_table
1288 1288
 			        WHERE c_id = ".$this->destination_course_id;
1289
-            $result=Database::query($sql);
1290
-            list($orderMax)=Database::fetch_array($result,'NUM');
1291
-            $display_order=$orderMax+1;
1289
+            $result = Database::query($sql);
1290
+            list($orderMax) = Database::fetch_array($result, 'NUM');
1291
+            $display_order = $orderMax + 1;
1292 1292
 
1293 1293
             $params['c_id'] = $this->destination_course_id;
1294 1294
             $params['category_title'] = self::DBUTF8($link_cat->title);
@@ -1667,7 +1667,7 @@  discard block
 block discarded – undo
1667 1667
                         $this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]->is_restored()) {
1668 1668
                         $sql = "SELECT path FROM $table_doc
1669 1669
                                 WHERE
1670
-                                    c_id = " . $this->destination_course_id . "  AND
1670
+                                    c_id = ".$this->destination_course_id."  AND
1671 1671
                                     id = " . $resources[RESOURCE_DOCUMENT][$quiz->sound]->destination_id;
1672 1672
 						$doc = Database::query($sql);
1673 1673
 						$doc = Database::fetch_object($doc);
@@ -1704,17 +1704,17 @@  discard block
 block discarded – undo
1704 1704
                         'random' => $quiz->random,
1705 1705
                         'active' => $quiz->active,
1706 1706
                         'sound' => self::DBUTF8($doc),
1707
-                        'max_attempt' => (int)$quiz->max_attempt,
1708
-                        'results_disabled' => (int)$quiz->results_disabled,
1707
+                        'max_attempt' => (int) $quiz->max_attempt,
1708
+                        'results_disabled' => (int) $quiz->results_disabled,
1709 1709
                         'access_condition' => $quiz->access_condition,
1710 1710
                         'pass_percentage' => $quiz->pass_percentage,
1711
-                        'feedback_type' => (int)$quiz->feedback_type,
1712
-                        'random_answers' => (int)$quiz->random_answers,
1711
+                        'feedback_type' => (int) $quiz->feedback_type,
1712
+                        'random_answers' => (int) $quiz->random_answers,
1713 1713
                         'random_by_category' => $quiz->random_by_category,
1714 1714
                         'review_answers' => $quiz->review_answers,
1715 1715
                         'propagate_neg' => $quiz->propagate_neg,
1716 1716
                         'text_when_finished' => $quiz->text_when_finished,
1717
-                        'expired_time' => (int)$quiz->expired_time,
1717
+                        'expired_time' => (int) $quiz->expired_time,
1718 1718
                         'start_time' => $quiz->start_time,
1719 1719
                         'end_time' => $quiz->end_time,
1720 1720
                         'save_correct_answers' => 0,
@@ -1754,10 +1754,10 @@  discard block
 block discarded – undo
1754 1754
                         $qid = $this->restore_quiz_question($question_id);
1755 1755
                         $question_order = $quiz->question_orders[$index] ? $quiz->question_orders[$index] : ++$order;
1756 1756
                         $sql = "INSERT IGNORE INTO $table_rel SET
1757
-                                c_id = " . $this->destination_course_id . ",
1757
+                                c_id = ".$this->destination_course_id.",
1758 1758
                                 question_id = $qid ,
1759 1759
                                 exercice_id = $new_id ,
1760
-                                question_order = " . $question_order;
1760
+                                question_order = ".$question_order;
1761 1761
                         Database::query($sql);
1762 1762
                     }
1763 1763
                 }
@@ -1832,7 +1832,7 @@  discard block
 block discarded – undo
1832 1832
                             $sql = "UPDATE $table_que SET
1833 1833
                                         picture = '$picture_name'
1834 1834
                                     WHERE
1835
-                                        c_id = " . $this->destination_course_id . " AND
1835
+                                        c_id = ".$this->destination_course_id." AND
1836 1836
                                         id = $new_id ";
1837 1837
                             Database::query($sql);
1838 1838
                         }
@@ -1995,7 +1995,7 @@  discard block
 block discarded – undo
1995 1995
                             }
1996 1996
                         }
1997 1997
 
1998
-                        foreach($correct_answers as $answer_id => $correct_answer) {
1998
+                        foreach ($correct_answers as $answer_id => $correct_answer) {
1999 1999
                             $params = array();
2000 2000
                             $params['correct'] = $new_options[$correct_answer];
2001 2001
                             Database::update(
@@ -2029,7 +2029,7 @@  discard block
 block discarded – undo
2029 2029
         $tab_test_category_id_old_new = array(); // used to build the quiz_question_rel_category table
2030 2030
         if ($this->course->has_resources(RESOURCE_TEST_CATEGORY)) {
2031 2031
             $resources = $this->course->resources;
2032
-            foreach ($resources[RESOURCE_TEST_CATEGORY] as $id => $CourseCopyTestCategory ) {
2032
+            foreach ($resources[RESOURCE_TEST_CATEGORY] as $id => $CourseCopyTestCategory) {
2033 2033
                 $tab_test_category_id_old_new[$CourseCopyTestCategory->source_id] = $id;
2034 2034
                 // check if this test_category already exist in the destination BDD
2035 2035
                 // do not Database::escape_string $title and $description, it will be done later
@@ -2180,7 +2180,7 @@  discard block
 block discarded – undo
2180 2180
 							break;
2181 2181
 						case FILE_RENAME:
2182 2182
 							$survey_code = $survey->code.'_';
2183
-							$i=1;
2183
+							$i = 1;
2184 2184
 							$temp_survey_code = $survey_code.$i;
2185 2185
 							while (!$this->is_survey_code_available($temp_survey_code)) {
2186 2186
 								$temp_survey_code = $survey_code.++$i;
@@ -2212,15 +2212,15 @@  discard block
 block discarded – undo
2212 2212
 							$sql = "SELECT * FROM $table_sur
2213 2213
 							        WHERE
2214 2214
 							            c_id = ".$this->destination_course_id." AND
2215
-							            survey_id='".self::DBUTF8escapestring(Database::result($result_check,0,0))."'";
2215
+							            survey_id='".self::DBUTF8escapestring(Database::result($result_check, 0, 0))."'";
2216 2216
 							$result = Database::query($sql);
2217
-							$survey_data = Database::fetch_array($result,'ASSOC');
2217
+							$survey_data = Database::fetch_array($result, 'ASSOC');
2218 2218
 
2219 2219
 							// if the survey is shared => also delete the shared content
2220 2220
 							if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) {
2221
-                                SurveyManager::delete_survey($survey_data['survey_share'], true,$this->destination_course_id);
2221
+                                SurveyManager::delete_survey($survey_data['survey_share'], true, $this->destination_course_id);
2222 2222
 							}
2223
-							SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id);
2223
+							SurveyManager :: delete_survey($survey_data['survey_id'], false, $this->destination_course_id);
2224 2224
 
2225 2225
 							// Insert the new source survey
2226 2226
                             $new_id = Database::insert($table_sur, $params);
@@ -2405,13 +2405,13 @@  discard block
 block discarded – undo
2405 2405
 
2406 2406
 				// Adding the author's image
2407 2407
 				if (!empty($lp->preview_image)) {
2408
-					$new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image));
2408
+					$new_filename = uniqid('').substr($lp->preview_image, strlen($lp->preview_image) - 7, strlen($lp->preview_image));
2409 2409
 					if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) {
2410 2410
 						$copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename);
2411 2411
 						if ($copy_result) {
2412 2412
 							$lp->preview_image = $new_filename;
2413 2413
 						} else {
2414
-							$lp->preview_image ='';
2414
+							$lp->preview_image = '';
2415 2415
 						}
2416 2416
 					}
2417 2417
 				}
@@ -2585,20 +2585,20 @@  discard block
 block discarded – undo
2585 2585
 					$next_item_ids[$new_item_id] = $item['next_item_id'];
2586 2586
 
2587 2587
 					if (!empty($item['prerequisite'])) {
2588
-						if ($lp->lp_type =='2') {
2588
+						if ($lp->lp_type == '2') {
2589 2589
 							// if is an sco
2590
-							$old_prerequisite[$new_item_id]= $item['prerequisite'];
2590
+							$old_prerequisite[$new_item_id] = $item['prerequisite'];
2591 2591
 						} else {
2592
-							$old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']];
2592
+							$old_prerequisite[$new_item_id] = $new_item_ids[$item['prerequisite']];
2593 2593
 						}
2594 2594
 					}
2595 2595
 
2596 2596
 					if (!empty($ref)) {
2597
-						if ($lp->lp_type =='2') {
2597
+						if ($lp->lp_type == '2') {
2598 2598
 							// if is an sco
2599
-							$old_refs[$new_item_id]= $ref;
2599
+							$old_refs[$new_item_id] = $ref;
2600 2600
 						} elseif (isset($new_item_ids[$ref])) {
2601
-                            $old_refs[$new_item_id]= $new_item_ids[$ref];
2601
+                            $old_refs[$new_item_id] = $new_item_ids[$ref];
2602 2602
                         }
2603 2603
 					}
2604 2604
 
@@ -2607,7 +2607,7 @@  discard block
 block discarded – undo
2607 2607
 
2608 2608
 				// Updating prerequisites
2609 2609
 				foreach ($old_prerequisite  as $key=>$my_old_prerequisite) {
2610
-					if ($my_old_prerequisite != ''){
2610
+					if ($my_old_prerequisite != '') {
2611 2611
 						$sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."'
2612 2612
 						        WHERE c_id = ".$this->destination_course_id." AND id = '".$key."'  ";
2613 2613
 						Database::query($sql);
@@ -2625,7 +2625,7 @@  discard block
 block discarded – undo
2625 2625
 
2626 2626
 				foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) {
2627 2627
 					$parent_new_id = 0;
2628
-					if($parent_item_old_id != 0){
2628
+					if ($parent_item_old_id != 0) {
2629 2629
 						$parent_new_id = $new_item_ids[$parent_item_old_id];
2630 2630
 					}
2631 2631
 					$sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."'
@@ -2634,7 +2634,7 @@  discard block
 block discarded – undo
2634 2634
 				}
2635 2635
 				foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) {
2636 2636
 					$previous_new_id = 0;
2637
-					if ($previous_item_old_id != 0){
2637
+					if ($previous_item_old_id != 0) {
2638 2638
 						$previous_new_id = $new_item_ids[$previous_item_old_id];
2639 2639
 					}
2640 2640
 					$sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."'
@@ -2644,7 +2644,7 @@  discard block
 block discarded – undo
2644 2644
 
2645 2645
 				foreach ($next_item_ids as $new_item_id => $next_item_old_id) {
2646 2646
 					$next_new_id = 0;
2647
-					if ($next_item_old_id != 0){
2647
+					if ($next_item_old_id != 0) {
2648 2648
 						$next_new_id = $new_item_ids[$next_item_old_id];
2649 2649
 					}
2650 2650
 					$sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."'
@@ -2654,7 +2654,7 @@  discard block
 block discarded – undo
2654 2654
 
2655 2655
 				foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) {
2656 2656
 					$prerequisite_new_id = 0;
2657
-					if ($prerequisite_old_id != 0){
2657
+					if ($prerequisite_old_id != 0) {
2658 2658
 						$prerequisite_new_id = $new_item_ids[$prerequisite_old_id];
2659 2659
 					}
2660 2660
 					$sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."'
@@ -2775,16 +2775,16 @@  discard block
 block discarded – undo
2775 2775
         if ($handle = opendir($source)) {        // if the folder exploration is sucsessful, continue
2776 2776
             while (false !== ($file = readdir($handle))) { // as long as storing the next file to $file is successful, continue
2777 2777
                 if ($file != '.' && $file != '..') {
2778
-                    $path = $source . '/' . $file;
2778
+                    $path = $source.'/'.$file;
2779 2779
                     if (is_file($path)) {
2780 2780
                        /* if (!is_file($dest . '/' . $file) || $overwrite)
2781 2781
                         if (!@copy($path, $dest . '/' . $file)) {
2782 2782
                             echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>';
2783 2783
                         }*/
2784
-                    } elseif(is_dir($path)) {
2785
-                        if (!is_dir($dest . '/' . $file))
2786
-                        mkdir($dest . '/' . $file);
2787
-                        self:: allow_create_all_directory($path, $dest . '/' . $file, $overwrite);
2784
+                    } elseif (is_dir($path)) {
2785
+                        if (!is_dir($dest.'/'.$file))
2786
+                        mkdir($dest.'/'.$file);
2787
+                        self:: allow_create_all_directory($path, $dest.'/'.$file, $overwrite);
2788 2788
                     }
2789 2789
                 }
2790 2790
             }
@@ -2982,7 +2982,7 @@  discard block
 block discarded – undo
2982 2982
                     $this->course->backup_path,
2983 2983
                     $this->course->info['path']
2984 2984
                 );
2985
-				$thematic->params['c_id']  = $this->destination_course_id;
2985
+				$thematic->params['c_id'] = $this->destination_course_id;
2986 2986
 				unset($thematic->params['id']);
2987 2987
                 unset($thematic->params['iid']);
2988 2988
 
@@ -3006,7 +3006,7 @@  discard block
 block discarded – undo
3006 3006
                         unset($thematic_advance['iid']);
3007 3007
 						$thematic_advance['attendance_id'] = 0;
3008 3008
 						$thematic_advance['thematic_id'] = $last_id;
3009
-						$thematic_advance['c_id']  = $this->destination_course_id;
3009
+						$thematic_advance['c_id'] = $this->destination_course_id;
3010 3010
 
3011 3011
                         $my_id = Database::insert(
3012 3012
                             $table_thematic_advance,
@@ -3029,7 +3029,7 @@  discard block
 block discarded – undo
3029 3029
 						}
3030 3030
 					}
3031 3031
 
3032
-					foreach($thematic->thematic_plan_list as $thematic_plan) {
3032
+					foreach ($thematic->thematic_plan_list as $thematic_plan) {
3033 3033
 						unset($thematic_plan['id']);
3034 3034
                         unset($thematic_plan['iid']);
3035 3035
 						$thematic_plan['thematic_id'] = $last_id;
@@ -3145,7 +3145,7 @@  discard block
 block discarded – undo
3145 3145
                 // re-create dir
3146 3146
                 // @todo check security against injection of dir in crafted course backup here!
3147 3147
                 $path = $obj->params['url'];
3148
-                $path = '/'.str_replace('/','',substr($path,1));
3148
+                $path = '/'.str_replace('/', '', substr($path, 1));
3149 3149
 
3150 3150
                 $workData = array();
3151 3151
                 switch ($this->file_option) {
@@ -3167,9 +3167,9 @@  discard block
 block discarded – undo
3167 3167
                         $obj->params['new_dir'] = $obj->params['title'];
3168 3168
 
3169 3169
                         if (!empty($this->course_origin_id)) {
3170
-                            $sql = 'SELECT * FROM ' . $table_work_assignment . '
3170
+                            $sql = 'SELECT * FROM '.$table_work_assignment.'
3171 3171
                                     WHERE
3172
-                                        c_id = ' . $this->course_origin_id . ' AND
3172
+                                        c_id = ' . $this->course_origin_id.' AND
3173 3173
                                         publication_id = ' . $id_work;
3174 3174
 
3175 3175
                             $result = Database::query($sql);
@@ -3280,7 +3280,7 @@  discard block
 block discarded – undo
3280 3280
     public function DBUTF8_array($array)
3281 3281
     {
3282 3282
         if (UTF8_CONVERT) {
3283
-            foreach ($array as &$item)  {
3283
+            foreach ($array as &$item) {
3284 3284
                 $item = utf8_encode($item);
3285 3285
             }
3286 3286
             return $array;
Please login to merge, or discard this patch.
Chamilo/CourseBundle/Component/CourseCopy/Resources/DummyCourseCreator.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -25,6 +25,7 @@
 block discarded – undo
25 25
 
26 26
     /**
27 27
      * Useful finder - experimental akelos like only use in notification.lib.php send function
28
+     * @param string $type
28 29
      */
29 30
     public function find($type, $options = null)
30 31
     {
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -291,16 +291,16 @@
 block discarded – undo
291 291
         Duis bibendum elementum justo. Duis posuere. Fusce nulla odio, posuere eget, condimentum nec, venenatis eu, elit. In hac habitasse platea dictumst. Aenean ac sem in enim imperdiet feugiat. Integer tincidunt lectus at elit. Integer magna lacus, vehicula quis, eleifend eget, suscipit vitae, leo. Nunc porta augue nec enim. Curabitur vehicula volutpat enim. Aliquam consequat. Vestibulum rhoncus tellus vitae erat. Integer est. Quisque fermentum leo nec odio. Suspendisse lobortis sollicitudin augue. Nullam urna mi, suscipit eu, sagittis laoreet, ultrices ac, sem. Aliquam enim tortor, hendrerit non, cursus a, tristique sit amet, sapien. Suspendisse potenti. Aenean semper placerat neque.';
292 292
         switch($type)
293 293
         {
294
-         case 'description':
294
+            case 'description':
295 295
             $descriptions = explode(".",$dummy_text);
296 296
             return $descriptions[rand(0,count($descriptions)-1)];
297 297
             break;
298
-         case 'title':
298
+            case 'title':
299 299
             $dummy_text = str_replace(array("\n",'.',',',"\t"),array(' ','','',' '),$dummy_text);
300 300
             $titles = explode(" ",$dummy_text);
301 301
             return trim($titles[rand(0,count($titles)-1)]);
302 302
             break;
303
-         case 'text':
303
+            case 'text':
304 304
             $texts = explode("\n",$dummy_text);
305 305
             return $texts[rand(0,count($texts)-1)];
306 306
             break;
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         $this->default_property['to_user_id'] = null;
32 32
         $this->default_property['visibility'] = '1';
33 33
         $this->default_property['start_visible'] = null;
34
-        $this->default_property['end_visible'] =  null;
34
+        $this->default_property['end_visible'] = null;
35 35
 
36 36
         $course = api_get_course_info($course_code);
37 37
         $this->course = new Course();
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
         $course = api_get_course_info();
59 59
         $course_doc_path = $this->course->backup_path.'/document/';
60 60
         $number_of_documents = rand(10, 30);
61
-        $extensions = array ('html', 'doc');
61
+        $extensions = array('html', 'doc');
62 62
         $directories = array();
63 63
         $property = $this->default_property;
64 64
         $property['lastedit_type'] = 'DocumentAdded';
65 65
         $property['tool'] = TOOL_DOCUMENT;
66 66
         $doc_id = 0;
67
-        for ($doc_id = 1; $doc_id < $number_of_documents; $doc_id ++)
67
+        for ($doc_id = 1; $doc_id < $number_of_documents; $doc_id++)
68 68
         {
69 69
             $path = '';
70 70
             $doc_type = rand(0, count($extensions) - 1);
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
             $filename = $this->get_dummy_content('title').'_'.$doc_id.'.'.$extension;
73 73
             $content = $this->get_dummy_content('text');
74 74
             $dirs = rand(0, 3);
75
-            for ($i = 0; $i < $dirs; $i ++)
75
+            for ($i = 0; $i < $dirs; $i++)
76 76
             {
77 77
                 $path .= 'directory/';
78 78
                 $directories[$path] = 1;
@@ -87,14 +87,14 @@  discard block
 block discarded – undo
87 87
             fwrite($fp, $content);
88 88
             fclose($fp);
89 89
             $size = filesize($file);
90
-            $document = new Document($doc_id, '/'.$path.$filename,$this->get_dummy_content('description'),$this->get_dummy_content('title'), 'file', $size);
90
+            $document = new Document($doc_id, '/'.$path.$filename, $this->get_dummy_content('description'), $this->get_dummy_content('title'), 'file', $size);
91 91
             $document->item_properties[] = $property;
92 92
             $this->course->add_resource($document);
93 93
         }
94
-        foreach($directories as $path => $flag)
94
+        foreach ($directories as $path => $flag)
95 95
         {
96
-            $path = substr($path,0,strlen($path)-1);
97
-            $document = new Document($doc_id++,'/'.$path, $this->get_dummy_content('description'),$this->get_dummy_content('title'),'folder',0);
96
+            $path = substr($path, 0, strlen($path) - 1);
97
+            $document = new Document($doc_id++, '/'.$path, $this->get_dummy_content('description'), $this->get_dummy_content('title'), 'folder', 0);
98 98
             $property['lastedit_type'] = 'FolderCreated';
99 99
             $document->item_properties[] = $property;
100 100
             $this->course->add_resource($document);
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
         $property['lastedit_type'] = 'AnnouncementAdded';
110 110
         $property['tool'] = TOOL_ANNOUNCEMENT;
111 111
         $number_of_announcements = rand(10, 30);
112
-        for ($i = 0; $i < $number_of_announcements; $i ++)
112
+        for ($i = 0; $i < $number_of_announcements; $i++)
113 113
         {
114 114
             $time = mktime(rand(1, 24), rand(1, 60), 0, rand(1, 12), rand(1, 28), intval(date('Y')));
115 115
             $date = date('Y-m-d', $time);
116
-            $announcement = new Announcement($i,$this->get_dummy_content('title'),$this->get_dummy_content('text'), $date,0);
116
+            $announcement = new Announcement($i, $this->get_dummy_content('title'), $this->get_dummy_content('text'), $date, 0);
117 117
             $announcement->item_properties[] = $property;
118 118
             $this->course->add_resource($announcement);
119 119
         }
@@ -127,23 +127,23 @@  discard block
 block discarded – undo
127 127
         $property = $this->default_property;
128 128
         $property['lastedit_type'] = 'AgendaAdded';
129 129
         $property['tool'] = TOOL_CALENDAR_EVENT;
130
-        for ($i = 0; $i < $number_of_events; $i ++)
130
+        for ($i = 0; $i < $number_of_events; $i++)
131 131
         {
132
-            $hour = rand(1,24);
133
-            $minute = rand(1,60);
134
-            $second = rand(1,60);
135
-            $day = rand(1,28);
136
-            $month = rand(1,12);
132
+            $hour = rand(1, 24);
133
+            $minute = rand(1, 60);
134
+            $second = rand(1, 60);
135
+            $day = rand(1, 28);
136
+            $month = rand(1, 12);
137 137
             $year = intval(date('Y'));
138
-            $time = mktime($hour,$minute,$second,$month,$day,$year);
138
+            $time = mktime($hour, $minute, $second, $month, $day, $year);
139 139
             $start_date = date('Y-m-d H:m:s', $time);
140
-            $hour = rand($hour,24);
141
-            $minute = rand($minute,60);
142
-            $second = rand($second,60);
143
-            $day = rand($day,28);
144
-            $month = rand($month,12);
140
+            $hour = rand($hour, 24);
141
+            $minute = rand($minute, 60);
142
+            $second = rand($second, 60);
143
+            $day = rand($day, 28);
144
+            $month = rand($month, 12);
145 145
             $year = intval(date('Y'));
146
-            $time = mktime($hour,$minute,$second,$month,$day,$year);
146
+            $time = mktime($hour, $minute, $second, $month, $day, $year);
147 147
             $end_date = date('Y-m-d H:m:s', $time);
148 148
             $event = new CalendarEvent(
149 149
                 $i,
@@ -163,20 +163,20 @@  discard block
 block discarded – undo
163 163
     {
164 164
         // create categorys
165 165
         $number_of_categories = rand(5, 10);
166
-        for ($i = 0; $i < $number_of_categories; $i ++)
166
+        for ($i = 0; $i < $number_of_categories; $i++)
167 167
         {
168
-            $linkcat = new LinkCategory($i, $this->get_dummy_content('title'), $this->get_dummy_content('description'),$i);
168
+            $linkcat = new LinkCategory($i, $this->get_dummy_content('title'), $this->get_dummy_content('description'), $i);
169 169
             $this->course->add_resource($linkcat);
170 170
         }
171 171
         // create links
172 172
         $number_of_links = rand(5, 50);
173
-        $on_homepage = rand(0,20) == 0 ? 1 : 0;
173
+        $on_homepage = rand(0, 20) == 0 ? 1 : 0;
174 174
         $property = $this->default_property;
175 175
         $property['lastedit_type'] = 'LinkAdded';
176 176
         $property['tool'] = TOOL_LINK;
177
-        for ($i = 0; $i < $number_of_links; $i ++)
177
+        for ($i = 0; $i < $number_of_links; $i++)
178 178
         {
179
-            $link = new Link($i, $this->get_dummy_content('title'), 'http://www.google.com/search?q='.$this->get_dummy_content('title'), $this->get_dummy_content('description'), rand(0, $number_of_categories -1),$on_homepage);
179
+            $link = new Link($i, $this->get_dummy_content('title'), 'http://www.google.com/search?q='.$this->get_dummy_content('title'), $this->get_dummy_content('description'), rand(0, $number_of_categories - 1), $on_homepage);
180 180
             $link->item_properties[] = $property;
181 181
             $this->course->add_resource($link);
182 182
         }
@@ -190,18 +190,18 @@  discard block
 block discarded – undo
190 190
         $number_of_forums = rand(5, 50);
191 191
         $number_of_topics = rand(30, 100);
192 192
         $number_of_posts = rand(100, 1000);
193
-        $last_forum_post = array ();
194
-        $last_topic_post = array ();
193
+        $last_forum_post = array();
194
+        $last_topic_post = array();
195 195
         // create categorys
196 196
         $order = 1;
197
-        for ($i = 1; $i <= $number_of_categories; $i ++)
197
+        for ($i = 1; $i <= $number_of_categories; $i++)
198 198
         {
199 199
             $forumcat = new ForumCategory($i, $this->get_dummy_content('title'), $this->get_dummy_content('description'), $order, 0, 0);
200 200
             $this->course->add_resource($forumcat);
201 201
             $order++;
202 202
         }
203 203
         // create posts
204
-        for ($post_id = 1; $post_id <= $number_of_posts; $post_id ++)
204
+        for ($post_id = 1; $post_id <= $number_of_posts; $post_id++)
205 205
         {
206 206
             $topic_id = rand(1, $number_of_topics);
207 207
             $last_topic_post[$topic_id] = $post_id;
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
             $this->course->add_resource($post);
210 210
         }
211 211
         // create topics
212
-        for ($topic_id = 1; $topic_id <= $number_of_topics; $topic_id ++)
212
+        for ($topic_id = 1; $topic_id <= $number_of_topics; $topic_id++)
213 213
         {
214 214
             $forum_id = rand(1, $number_of_forums);
215 215
             $last_forum_post[$forum_id] = $last_topic_post[$topic_id];
@@ -217,9 +217,9 @@  discard block
 block discarded – undo
217 217
             $this->course->add_resource($topic);
218 218
         }
219 219
         // create forums
220
-        for ($forum_id = 1; $forum_id <= $number_of_forums; $forum_id ++)
220
+        for ($forum_id = 1; $forum_id <= $number_of_forums; $forum_id++)
221 221
         {
222
-            $forum = new Forum($forum_id, $this->get_dummy_content('title'),$this->get_dummy_content('description'), rand(1, $number_of_categories), $last_forum_post[$forum_id]);
222
+            $forum = new Forum($forum_id, $this->get_dummy_content('title'), $this->get_dummy_content('description'), rand(1, $number_of_categories), $last_forum_post[$forum_id]);
223 223
             $this->course->add_resource($forum);
224 224
         }
225 225
     }
@@ -228,25 +228,25 @@  discard block
 block discarded – undo
228 228
      */
229 229
     function create_dummy_learnpaths()
230 230
     {
231
-        $number_of_learnpaths = rand(3,5);
231
+        $number_of_learnpaths = rand(3, 5);
232 232
         $global_item_id = 1;
233
-        for($i=1; $i<=$number_of_learnpaths;$i++)
233
+        for ($i = 1; $i <= $number_of_learnpaths; $i++)
234 234
         {
235 235
         $chapters = array();
236
-        $number_of_chapters = rand(1,6);
237
-        for($chapter_id = 1; $chapter_id <= $number_of_chapters; $chapter_id++)
236
+        $number_of_chapters = rand(1, 6);
237
+        for ($chapter_id = 1; $chapter_id <= $number_of_chapters; $chapter_id++)
238 238
         {
239 239
             $chapter['name'] = $this->get_dummy_content('title');
240 240
             $chapter['description'] = $this->get_dummy_content('description');
241 241
             $chapter['display_order'] = $chapter_id;
242 242
             $chapter['items'] = array();
243
-            $number_of_items = rand(5,20);
244
-            for( $item_id = 1; $item_id<$number_of_items; $item_id++)
243
+            $number_of_items = rand(5, 20);
244
+            for ($item_id = 1; $item_id < $number_of_items; $item_id++)
245 245
             {
246
-                $types = array(RESOURCE_ANNOUNCEMENT, RESOURCE_EVENT, RESOURCE_DOCUMENT,RESOURCE_LINK,RESOURCE_FORUM,RESOURCE_FORUMPOST,RESOURCE_FORUMTOPIC);
247
-                $type = $types[rand(0,count($types)-1)];
246
+                $types = array(RESOURCE_ANNOUNCEMENT, RESOURCE_EVENT, RESOURCE_DOCUMENT, RESOURCE_LINK, RESOURCE_FORUM, RESOURCE_FORUMPOST, RESOURCE_FORUMTOPIC);
247
+                $type = $types[rand(0, count($types) - 1)];
248 248
                 $resources = $this->course->resources[$type];
249
-                $resource = $resources[rand(0,count($resources)-1)];
249
+                $resource = $resources[rand(0, count($resources) - 1)];
250 250
                 $item = array();
251 251
                 $item['type'] = $resource->type;
252 252
                 $item['id'] = $resource->source_id;
@@ -254,17 +254,17 @@  discard block
 block discarded – undo
254 254
                 $item['title'] = $this->get_dummy_content('title');
255 255
                 $item['description'] = $this->get_dummy_content('description');
256 256
                 $item['ref_id'] = $global_item_id;
257
-                if( rand(0,5) == 1 && $item_id > 1)
257
+                if (rand(0, 5) == 1 && $item_id > 1)
258 258
                 {
259 259
                     $item['prereq_type'] = 'i';
260
-                    $item['prereq'] = rand($global_item_id - $item_id,$global_item_id-1);
260
+                    $item['prereq'] = rand($global_item_id - $item_id, $global_item_id - 1);
261 261
                 }
262 262
                 $chapter['items'][] = $item;
263 263
                 $global_item_id++;
264 264
             }
265 265
             $chapters[] = $chapter;
266 266
         }
267
-        $lp = new CourseCopyLearnpath($i,$this->get_dummy_content('title'),$this->get_dummy_content('description'),1,$chapters);
267
+        $lp = new CourseCopyLearnpath($i, $this->get_dummy_content('title'), $this->get_dummy_content('description'), 1, $chapters);
268 268
         $this->course->add_resource($lp);
269 269
         }
270 270
     }
@@ -278,20 +278,20 @@  discard block
 block discarded – undo
278 278
         Aenean ac wisi non enim aliquam scelerisque. Praesent eget mi. Vestibulum volutpat pulvinar justo. Phasellus sapien ante, pharetra id, bibendum sed, porta non, purus. Maecenas leo velit, luctus quis, porta non, feugiat sit amet, sapien. Proin vitae augue ut massa adipiscing placerat. Morbi ac risus. Proin dapibus eros egestas quam. Fusce fermentum lobortis elit. Duis lectus tellus, convallis nec, lobortis vel, accumsan ut, nunc. Nunc est. Donec ullamcorper laoreet quam.
279 279
         Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Suspendisse potenti. Mauris mi. Vivamus risus lacus, faucibus sit amet, sollicitudin a, blandit et, justo. In hendrerit. Sed imperdiet, eros at fringilla tempor, turpis augue semper enim, quis rhoncus nibh enim quis dui. Sed massa sapien, mattis et, laoreet sit amet, dignissim nec, urna. Integer laoreet quam quis lectus. Curabitur convallis gravida dui. Nam metus. Ut sit amet augue in nibh interdum scelerisque. Donec venenatis, lacus et pulvinar euismod, libero massa condimentum pede, commodo tristique nunc massa eu quam. Donec vulputate. Aenean in nibh. Phasellus porttitor. Donec molestie, sem ac porttitor vulputate, mauris dui egestas libero, ac lobortis dolor sem vel ligula. Nam vulputate pretium libero. Cras accumsan. Vivamus lacinia sapien sit amet elit.
280 280
         Duis bibendum elementum justo. Duis posuere. Fusce nulla odio, posuere eget, condimentum nec, venenatis eu, elit. In hac habitasse platea dictumst. Aenean ac sem in enim imperdiet feugiat. Integer tincidunt lectus at elit. Integer magna lacus, vehicula quis, eleifend eget, suscipit vitae, leo. Nunc porta augue nec enim. Curabitur vehicula volutpat enim. Aliquam consequat. Vestibulum rhoncus tellus vitae erat. Integer est. Quisque fermentum leo nec odio. Suspendisse lobortis sollicitudin augue. Nullam urna mi, suscipit eu, sagittis laoreet, ultrices ac, sem. Aliquam enim tortor, hendrerit non, cursus a, tristique sit amet, sapien. Suspendisse potenti. Aenean semper placerat neque.';
281
-        switch($type)
281
+        switch ($type)
282 282
         {
283 283
          case 'description':
284
-            $descriptions = explode(".",$dummy_text);
285
-            return $descriptions[rand(0,count($descriptions)-1)];
284
+            $descriptions = explode(".", $dummy_text);
285
+            return $descriptions[rand(0, count($descriptions) - 1)];
286 286
             break;
287 287
          case 'title':
288
-            $dummy_text = str_replace(array("\n",'.',',',"\t"),array(' ','','',' '),$dummy_text);
289
-            $titles = explode(" ",$dummy_text);
290
-            return trim($titles[rand(0,count($titles)-1)]);
288
+            $dummy_text = str_replace(array("\n", '.', ',', "\t"), array(' ', '', '', ' '), $dummy_text);
289
+            $titles = explode(" ", $dummy_text);
290
+            return trim($titles[rand(0, count($titles) - 1)]);
291 291
             break;
292 292
          case 'text':
293
-            $texts = explode("\n",$dummy_text);
294
-            return $texts[rand(0,count($texts)-1)];
293
+            $texts = explode("\n", $dummy_text);
294
+            return $texts[rand(0, count($texts) - 1)];
295 295
             break;
296 296
         }
297 297
     }
Please login to merge, or discard this patch.
src/Chamilo/CourseBundle/Component/CourseCopy/CourseSelectForm.php 3 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -527,14 +527,15 @@
 block discarded – undo
527 527
 						// Mark folders to import which are not selected by the user to import,
528 528
 						// but in which a document was selected.
529 529
 						$documents = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null;
530
-						if (!empty($resources) && is_array($resources))
531
-							foreach ($resources as $id => $obj) {
530
+						if (!empty($resources) && is_array($resources)) {
531
+													foreach ($resources as $id => $obj) {
532 532
 								if (isset($obj->file_type) && $obj->file_type == 'folder' &&
533 533
                                     !isset($_POST['resource'][RESOURCE_DOCUMENT][$id]) &&
534 534
                                     is_array($documents)
535 535
                                 ) {
536 536
 									foreach ($documents as $id_to_check => $post_value) {
537 537
 										$obj_to_check = $resources[$id_to_check];
538
+						}
538 539
 										$shared_path_part = substr($obj_to_check->path,0,strlen($obj->path));
539 540
 										if ($id_to_check != $id && $obj->path == $shared_path_part) {
540 541
 											$_POST['resource'][RESOURCE_DOCUMENT][$id] = 1;
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -140,10 +140,10 @@  discard block
 block discarded – undo
140 140
 		<?php
141 141
 		// get destination course title
142 142
 		if (!empty($hidden_fields['destination_course'])) {
143
-            $sessionTitle = !empty($hidden_fields['destination_session']) ? ' (' . api_get_session_name($hidden_fields['destination_session']) . ')' : null;
143
+            $sessionTitle = !empty($hidden_fields['destination_session']) ? ' ('.api_get_session_name($hidden_fields['destination_session']).')' : null;
144 144
             $course_infos = CourseManager::get_course_information($hidden_fields['destination_course']);
145 145
 			echo '<h3>';
146
-			echo get_lang('DestinationCourse').' : '.$course_infos['title'] . ' ('.$course_infos['code'].') '.$sessionTitle;
146
+			echo get_lang('DestinationCourse').' : '.$course_infos['title'].' ('.$course_infos['code'].') '.$sessionTitle;
147 147
 			echo '</h3>';
148 148
 		}
149 149
         echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>';
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 			/*Documents are avoided due the huge amount of memory that the serialize php function "eats"
303 303
 			(when there are directories with hundred/thousand of files) */
304 304
 			// this is a known issue of serialize
305
-			$course->resources['document']= null;
305
+			$course->resources['document'] = null;
306 306
 		}
307 307
 
308 308
 		echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>';
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 		    Display::display_warning_message(get_lang('NoDataAvailable'));
320 320
 		} else {
321 321
     		if (!empty($hidden_fields['destination_session'])) {
322
-    			echo '<br /><button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES, $charset))."'".')) return false;" >'.
322
+    			echo '<br /><button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset))."'".')) return false;" >'.
323 323
                     get_lang('Ok').'</button>';
324 324
     		} else {
325 325
                 if ($recycleOption) {
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
      */
344 344
     public static function display_hidden_quiz_questions($course)
345 345
     {
346
-		if(is_array($course->resources)){
346
+		if (is_array($course->resources)) {
347 347
 			foreach ($course->resources as $type => $resources) {
348 348
 				if (count($resources) > 0) {
349 349
 					switch ($type) {
@@ -363,10 +363,10 @@  discard block
 block discarded – undo
363 363
      */
364 364
     public static function display_hidden_scorm_directories($course)
365 365
     {
366
-        if (is_array($course->resources)){
366
+        if (is_array($course->resources)) {
367 367
 			foreach ($course->resources as $type => $resources) {
368 368
 				if (count($resources) > 0) {
369
-					switch($type) {
369
+					switch ($type) {
370 370
 						case RESOURCE_SCORM:
371 371
 							foreach ($resources as $id => $resource) {
372 372
 								echo '<input type="hidden" name="resource['.RESOURCE_SCORM.']['.$id.']" id="resource['.RESOURCE_SCORM.']['.$id.']" value="On" />';
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 			if (is_array($resource)) {
413 413
 				$resource = array_keys($resource);
414 414
 
415
-				foreach	($resource as $resource_item) {
415
+				foreach ($resource as $resource_item) {
416 416
 
417 417
 					$condition_session = '';
418 418
 					if (!empty($session_id)) {
@@ -448,8 +448,8 @@  discard block
 block discarded – undo
448 448
                                         tool = '".RESOURCE_DOCUMENT."' AND
449 449
                                         ref = $resource_item ";
450 450
                             $res = Database::query($sql);
451
-                            $all_properties = array ();
452
-                            while ($item_property = Database::fetch_array($res,'ASSOC')) {
451
+                            $all_properties = array();
452
+                            while ($item_property = Database::fetch_array($res, 'ASSOC')) {
453 453
                                 $all_properties[] = $item_property;
454 454
                             }
455 455
                             $course->resources[RESOURCE_DOCUMENT][$resource_item]->item_properties = $all_properties;
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 
465 465
 				switch ($type) {
466 466
 					case RESOURCE_SURVEYQUESTION:
467
-						foreach($resources as $id => $obj) {
467
+						foreach ($resources as $id => $obj) {
468 468
 						    if (isset($_POST['resource'][RESOURCE_SURVEY]) &&
469 469
                                 is_array($_POST['resource'][RESOURCE_SURVEY]) &&
470 470
                                 !in_array($obj->survey_id, array_keys($_POST['resource'][RESOURCE_SURVEY]))
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
                                 ) {
540 540
 									foreach ($documents as $id_to_check => $post_value) {
541 541
 										$obj_to_check = $resources[$id_to_check];
542
-										$shared_path_part = substr($obj_to_check->path,0,strlen($obj->path));
542
+										$shared_path_part = substr($obj_to_check->path, 0, strlen($obj->path));
543 543
 										if ($id_to_check != $id && $obj->path == $shared_path_part) {
544 544
 											$_POST['resource'][RESOURCE_DOCUMENT][$id] = 1;
545 545
 											break;
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
 								$resource_is_used_elsewhere = $course->is_linked_resource($obj);
554 554
 								// check if document is in a quiz (audio/video)
555 555
 								if ($type == RESOURCE_DOCUMENT && $course->has_resources(RESOURCE_QUIZ)) {
556
-									foreach($course->resources[RESOURCE_QUIZ] as $quiz) {
556
+									foreach ($course->resources[RESOURCE_QUIZ] as $quiz) {
557 557
                                         $quiz = $quiz->obj;
558 558
 										if (isset($quiz->media) && $quiz->media == $id) {
559 559
 											$resource_is_used_elsewhere = true;
@@ -623,15 +623,15 @@  discard block
 block discarded – undo
623 623
 		<?php
624 624
 
625 625
 		//get destination course title
626
-		if(!empty($hidden_fields['destination_course'])) {
626
+		if (!empty($hidden_fields['destination_course'])) {
627 627
              if (!empty($hidden_fields['destination_session'])) {
628
-                 $sessionTitle = ' (' . api_get_session_name($hidden_fields['destination_session']) . ')';
628
+                 $sessionTitle = ' ('.api_get_session_name($hidden_fields['destination_session']).')';
629 629
              } else {
630 630
                  $sessionTitle = null;
631 631
              }
632 632
             $course_infos = CourseManager::get_course_information($hidden_fields['destination_course']);
633 633
 			echo '<h3>';
634
-				echo get_lang('DestinationCourse') . ' : ' . $course_infos['title'] . $sessionTitle;
634
+				echo get_lang('DestinationCourse').' : '.$course_infos['title'].$sessionTitle;
635 635
 			echo '</h3>';
636 636
 		}
637 637
 
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
 		if ($avoid_serialize) {
669 669
 			//Documents are avoided due the huge amount of memory that the serialize php function "eats" (when there are directories with hundred/thousand of files)
670 670
 			// this is a known issue of serialize
671
-			$course->resources['document']= null;
671
+			$course->resources['document'] = null;
672 672
 		}
673 673
 		echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>';
674 674
 		if (is_array($hidden_fields)) {
Please login to merge, or discard this patch.
Indentation   +243 added lines, -243 removed lines patch added patch discarded remove patch
@@ -17,13 +17,13 @@  discard block
 block discarded – undo
17 17
  */
18 18
 class CourseSelectForm
19 19
 {
20
-	/**
21
-	 * Display the form
20
+    /**
21
+     * Display the form
22 22
      * @param array $course
23
-	 * @param array $hidden_fields Hidden fields to add to the form.
24
-	 * @param boolean $avoid_serialize the document array will be serialize. This is used in the course_copy.php file
25
-	 */
26
-	public static function display_form($course, $hidden_fields = null, $avoid_serialize = false)
23
+     * @param array $hidden_fields Hidden fields to add to the form.
24
+     * @param boolean $avoid_serialize the document array will be serialize. This is used in the course_copy.php file
25
+     */
26
+    public static function display_form($course, $hidden_fields = null, $avoid_serialize = false)
27 27
     {
28 28
         global $charset;
29 29
         $resource_titles[RESOURCE_GRADEBOOK] = get_lang('Gradebook');
@@ -138,48 +138,48 @@  discard block
 block discarded – undo
138 138
             }
139 139
 		</script>
140 140
 		<?php
141
-		// get destination course title
142
-		if (!empty($hidden_fields['destination_course'])) {
141
+        // get destination course title
142
+        if (!empty($hidden_fields['destination_course'])) {
143 143
             $sessionTitle = !empty($hidden_fields['destination_session']) ? ' (' . api_get_session_name($hidden_fields['destination_session']) . ')' : null;
144 144
             $course_infos = CourseManager::get_course_information($hidden_fields['destination_course']);
145
-			echo '<h3>';
146
-			echo get_lang('DestinationCourse').' : '.$course_infos['title'] . ' ('.$course_infos['code'].') '.$sessionTitle;
147
-			echo '</h3>';
148
-		}
145
+            echo '<h3>';
146
+            echo get_lang('DestinationCourse').' : '.$course_infos['title'] . ' ('.$course_infos['code'].') '.$sessionTitle;
147
+            echo '</h3>';
148
+        }
149 149
         echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>';
150
-		echo '<script type="text/javascript">var myUpload = new upload(1000);</script>';
150
+        echo '<script type="text/javascript">var myUpload = new upload(1000);</script>';
151 151
         $icon = Display::returnIconPath('myprogress_bar.gif');
152 152
         echo '<div class="tool-backups-options">';
153
-		echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="javascript: myUpload.start(\'dynamic_div\',\''.$icon.',\''.get_lang('PleaseStandBy', '').'\',\'upload_form\')">';
154
-		echo '<input type="hidden" name="action" value="course_select_form"/>';
153
+        echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="javascript: myUpload.start(\'dynamic_div\',\''.$icon.',\''.get_lang('PleaseStandBy', '').'\',\'upload_form\')">';
154
+        echo '<input type="hidden" name="action" value="course_select_form"/>';
155 155
 
156
-		if (!empty($hidden_fields['destination_course']) &&
156
+        if (!empty($hidden_fields['destination_course']) &&
157 157
             !empty($hidden_fields['origin_course']) &&
158 158
             !empty($hidden_fields['destination_session']) &&
159 159
             !empty($hidden_fields['origin_session'])
160 160
         ) {
161
-			echo '<input type="hidden" name="destination_course" 	value="'.$hidden_fields['destination_course'].'"/>';
162
-			echo '<input type="hidden" name="origin_course" 		value="'.$hidden_fields['origin_course'].'"/>';
163
-			echo '<input type="hidden" name="destination_session" 	value="'.$hidden_fields['destination_session'].'"/>';
164
-			echo '<input type="hidden" name="origin_session" 		value="'.$hidden_fields['origin_session'].'"/>';
165
-		}
161
+            echo '<input type="hidden" name="destination_course" 	value="'.$hidden_fields['destination_course'].'"/>';
162
+            echo '<input type="hidden" name="origin_course" 		value="'.$hidden_fields['origin_course'].'"/>';
163
+            echo '<input type="hidden" name="destination_session" 	value="'.$hidden_fields['destination_session'].'"/>';
164
+            echo '<input type="hidden" name="origin_session" 		value="'.$hidden_fields['origin_session'].'"/>';
165
+        }
166 166
 
167
-		$element_count = 0;
167
+        $element_count = 0;
168 168
         $forum_categories = array();
169 169
         $forums = array();
170 170
         $forum_topics = array();
171 171
 
172 172
         echo '<p>';
173
-		echo get_lang('SelectResources');
174
-		echo '</p>';
173
+        echo get_lang('SelectResources');
174
+        echo '</p>';
175 175
 
176 176
         Display::display_normal_message(get_lang('DontForgetToSelectTheMediaFilesIfYourResourceNeedIt'));
177 177
 
178 178
         foreach ($course->resources as $type => $resources) {
179 179
             if (count($resources) > 0) {
180
-				switch ($type) {
181
-					//Resources to avoid
182
-					case RESOURCE_FORUMCATEGORY:
180
+                switch ($type) {
181
+                    //Resources to avoid
182
+                    case RESOURCE_FORUMCATEGORY:
183 183
                         foreach ($resources as $id => $resource) {
184 184
                             $forum_categories[$id] = $resource;
185 185
                         }
@@ -206,30 +206,30 @@  discard block
 block discarded – undo
206 206
                         break;
207 207
                     default:
208 208
                         echo '<div class="item-backup" onclick="javascript:exp('."'$type'".');">';
209
-						echo '<em id="img_'.$type.'" class="fa fa-minus-square-o fa-lg" ></em>';
210
-						echo '<span class="title">'.$resource_titles[$type].'</span></div>';
211
-						echo '<div class="item-content" id="div_'.$type.'">';
212
-						if ($type == RESOURCE_LEARNPATH) {
213
-    						Display::display_warning_message(get_lang('ToExportLearnpathWithQuizYouHaveToSelectQuiz'));
214
-    						Display::display_warning_message(get_lang('IfYourLPsHaveAudioFilesIncludedYouShouldSelectThemFromTheDocuments'));
215
-						}
216
-						if ($type == RESOURCE_DOCUMENT) {
209
+                        echo '<em id="img_'.$type.'" class="fa fa-minus-square-o fa-lg" ></em>';
210
+                        echo '<span class="title">'.$resource_titles[$type].'</span></div>';
211
+                        echo '<div class="item-content" id="div_'.$type.'">';
212
+                        if ($type == RESOURCE_LEARNPATH) {
213
+                            Display::display_warning_message(get_lang('ToExportLearnpathWithQuizYouHaveToSelectQuiz'));
214
+                            Display::display_warning_message(get_lang('IfYourLPsHaveAudioFilesIncludedYouShouldSelectThemFromTheDocuments'));
215
+                        }
216
+                        if ($type == RESOURCE_DOCUMENT) {
217 217
                             if (api_get_setting('show_glossary_in_documents') != 'none') {
218 218
                                 Display::display_warning_message(get_lang('ToExportDocumentsWithGlossaryYouHaveToSelectGlossary'));
219 219
                             }
220
-						}
220
+                        }
221 221
 
222
-						echo '<div class="well">';
222
+                        echo '<div class="well">';
223 223
 
224 224
                         echo '<div class="btn-group">';
225
-						echo "<a class=\"btn btn-default\" href=\"javascript: void(0);\" onclick=\"javascript: setCheckbox('$type',true);\" >".get_lang('All')."</a>";
225
+                        echo "<a class=\"btn btn-default\" href=\"javascript: void(0);\" onclick=\"javascript: setCheckbox('$type',true);\" >".get_lang('All')."</a>";
226 226
                         echo "<a class=\"btn btn-default\" href=\"javascript: void(0);\" onclick=\"javascript:setCheckbox('$type',false);\" >".get_lang('None')."</a>";
227
-						echo '</div>';
227
+                        echo '</div>';
228 228
                         echo '<ul class="list-backups-options">';
229
-						foreach ($resources as $id => $resource) {
229
+                        foreach ($resources as $id => $resource) {
230 230
                             if ($resource) {
231 231
                                 echo '<li>';
232
-								// Event obj in 1.9.x in 1.10.x the class is CalendarEvent
232
+                                // Event obj in 1.9.x in 1.10.x the class is CalendarEvent
233 233
                                 Resource::setClassType($resource);
234 234
                                 echo '<label class="checkbox">';
235 235
                                 echo '<input type="checkbox" name="resource['.$type.']['.$id.']"  id="resource['.$type.']['.$id.']" />';
@@ -237,15 +237,15 @@  discard block
 block discarded – undo
237 237
                                 echo '</label>';
238 238
                                 echo '</li>';
239 239
                             }
240
-						}
240
+                        }
241 241
                         echo '</ul>';
242
-						echo '</div>';
243
-						echo '</div>';
244
-						echo '<script language="javascript">exp('."'$type'".')</script>';
245
-						$element_count++;
242
+                        echo '</div>';
243
+                        echo '</div>';
244
+                        echo '<script language="javascript">exp('."'$type'".')</script>';
245
+                        $element_count++;
246 246
                 }
247
-			}
248
-		}
247
+            }
248
+        }
249 249
 
250 250
         //Fixes forum order
251 251
         if (!empty($forum_categories)) {
@@ -301,66 +301,66 @@  discard block
 block discarded – undo
301 301
             echo '<script language="javascript">exp('."'$type'".')</script>';
302 302
         }
303 303
 
304
-		if ($avoid_serialize) {
305
-			/*Documents are avoided due the huge amount of memory that the serialize php function "eats"
304
+        if ($avoid_serialize) {
305
+            /*Documents are avoided due the huge amount of memory that the serialize php function "eats"
306 306
 			(when there are directories with hundred/thousand of files) */
307
-			// this is a known issue of serialize
308
-			$course->resources['document']= null;
309
-		}
307
+            // this is a known issue of serialize
308
+            $course->resources['document']= null;
309
+        }
310 310
 
311
-		echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>';
311
+        echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>';
312 312
 
313
-		if (is_array($hidden_fields)) {
314
-			foreach ($hidden_fields as $key => $value) {
315
-				echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>';
316
-			}
317
-		}
313
+        if (is_array($hidden_fields)) {
314
+            foreach ($hidden_fields as $key => $value) {
315
+                echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>';
316
+            }
317
+        }
318 318
 
319 319
         $recycleOption = isset($_POST['recycle_option']) ? true : false;
320 320
 
321
-		if (empty($element_count)) {
322
-		    Display::display_warning_message(get_lang('NoDataAvailable'));
323
-		} else {
324
-    		if (!empty($hidden_fields['destination_session'])) {
325
-    			echo '<br /><button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES, $charset))."'".')) return false;" >'.
321
+        if (empty($element_count)) {
322
+            Display::display_warning_message(get_lang('NoDataAvailable'));
323
+        } else {
324
+            if (!empty($hidden_fields['destination_session'])) {
325
+                echo '<br /><button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES, $charset))."'".')) return false;" >'.
326 326
                     get_lang('Ok').'</button>';
327
-    		} else {
327
+            } else {
328 328
                 if ($recycleOption) {
329 329
                     echo '<br /><button class="save" type="submit">'.
330 330
                         get_lang('Ok').'</button>';
331 331
                 } else {
332
-    			    echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.
332
+                    echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.
333 333
                     get_lang('Ok').'</button>';
334 334
                 }
335
-    		}
336
-		}
335
+            }
336
+        }
337 337
 
338
-		CourseSelectForm::display_hidden_quiz_questions($course);
339
-		CourseSelectForm::display_hidden_scorm_directories($course);
340
-		echo '</form>';
338
+        CourseSelectForm::display_hidden_quiz_questions($course);
339
+        CourseSelectForm::display_hidden_scorm_directories($course);
340
+        echo '</form>';
341 341
         echo '</div>';
342
-		echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>';
343
-	}
342
+        echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>';
343
+    }
344 344
 
345 345
     /**
346 346
      * @param $course
347 347
      */
348 348
     public static function display_hidden_quiz_questions($course)
349 349
     {
350
-		if(is_array($course->resources)){
351
-			foreach ($course->resources as $type => $resources) {
352
-				if (count($resources) > 0) {
353
-					switch ($type) {
354
-						case RESOURCE_QUIZQUESTION:
355
-							foreach ($resources as $id => $resource) {
356
-								echo '<input type="hidden" name="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" id="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" value="On" />';
357
-							}
358
-							break;
359
-					}
360
-				}
361
-			}
362
-		}
363
-	}
350
+        if(is_array($course->resources)){
351
+            foreach ($course->resources as $type => $resources) {
352
+                if (count($resources) > 0) {
353
+                    switch ($type) {
354
+                        case RESOURCE_QUIZQUESTION:
355
+                            foreach ($resources as $id => $resource) {
356
+                                echo '<input type="hidden" name="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" id="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" value="On" />';
357
+                            }
358
+                            break;
359
+                    }
360
+                }
361
+            }
362
+        }
363
+    }
364 364
 
365 365
     /**
366 366
      * @param $course
@@ -368,30 +368,30 @@  discard block
 block discarded – undo
368 368
     public static function display_hidden_scorm_directories($course)
369 369
     {
370 370
         if (is_array($course->resources)){
371
-			foreach ($course->resources as $type => $resources) {
372
-				if (count($resources) > 0) {
373
-					switch($type) {
374
-						case RESOURCE_SCORM:
375
-							foreach ($resources as $id => $resource) {
376
-								echo '<input type="hidden" name="resource['.RESOURCE_SCORM.']['.$id.']" id="resource['.RESOURCE_SCORM.']['.$id.']" value="On" />';
377
-							}
378
-							break;
379
-					}
380
-				}
381
-			}
382
-		}
383
-	}
371
+            foreach ($course->resources as $type => $resources) {
372
+                if (count($resources) > 0) {
373
+                    switch($type) {
374
+                        case RESOURCE_SCORM:
375
+                            foreach ($resources as $id => $resource) {
376
+                                echo '<input type="hidden" name="resource['.RESOURCE_SCORM.']['.$id.']" id="resource['.RESOURCE_SCORM.']['.$id.']" value="On" />';
377
+                            }
378
+                            break;
379
+                    }
380
+                }
381
+            }
382
+        }
383
+    }
384 384
 
385
-	/**
386
-	 * Get the posted course
387
-	 * @param string $from who calls the function?
385
+    /**
386
+     * Get the posted course
387
+     * @param string $from who calls the function?
388 388
      * It can be copy_course, create_backup, import_backup or recycle_course
389 389
      * @param int $session_id
390 390
      * @param string $course_code
391
-	 * @return course The course-object with all resources selected by the user
392
-	 * in the form given by display_form(...)
393
-	 */
394
-	public static function get_posted_course($from = '', $session_id = 0, $course_code = '')
391
+     * @return course The course-object with all resources selected by the user
392
+     * in the form given by display_form(...)
393
+     */
394
+    public static function get_posted_course($from = '', $session_id = 0, $course_code = '')
395 395
     {
396 396
         $course = null;
397 397
 
@@ -401,30 +401,30 @@  discard block
 block discarded – undo
401 401
             return false;
402 402
         }
403 403
 
404
-		// Create the resource DOCUMENT objects
405
-		// Loading the results from the checkboxes of ethe javascript
406
-		$resource = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null;
404
+        // Create the resource DOCUMENT objects
405
+        // Loading the results from the checkboxes of ethe javascript
406
+        $resource = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null;
407 407
 
408
-		$course_info = api_get_course_info($course_code);
409
-		$table_doc = Database::get_course_table(TABLE_DOCUMENT);
410
-		$table_prop = Database::get_course_table(TABLE_ITEM_PROPERTY);
411
-		$course_id = $course_info['real_id'];
408
+        $course_info = api_get_course_info($course_code);
409
+        $table_doc = Database::get_course_table(TABLE_DOCUMENT);
410
+        $table_prop = Database::get_course_table(TABLE_ITEM_PROPERTY);
411
+        $course_id = $course_info['real_id'];
412 412
 
413
-		/* Searching the documents resource that have been set to null because
413
+        /* Searching the documents resource that have been set to null because
414 414
         $avoid_serialize is true in the display_form() function*/
415
-		if ($from === 'copy_course') {
416
-			if (is_array($resource)) {
417
-				$resource = array_keys($resource);
415
+        if ($from === 'copy_course') {
416
+            if (is_array($resource)) {
417
+                $resource = array_keys($resource);
418 418
 
419
-				foreach	($resource as $resource_item) {
419
+                foreach	($resource as $resource_item) {
420 420
 
421
-					$condition_session = '';
422
-					if (!empty($session_id)) {
423
-						$session_id = intval($session_id);
424
-						$condition_session = ' AND d.session_id ='.$session_id;
425
-					}
421
+                    $condition_session = '';
422
+                    if (!empty($session_id)) {
423
+                        $session_id = intval($session_id);
424
+                        $condition_session = ' AND d.session_id ='.$session_id;
425
+                    }
426 426
 
427
-					$sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size
427
+                    $sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size
428 428
 							FROM '.$table_doc.' d, '.$table_prop.' p
429 429
 							WHERE
430 430
 							    d.c_id = '.$course_id.' AND
@@ -433,8 +433,8 @@  discard block
 block discarded – undo
433 433
                                 p.ref = d.id AND p.visibility != 2 AND
434 434
                                 d.id = '.$resource_item.$condition_session.'
435 435
 							ORDER BY path';
436
-					$db_result = Database::query($sql);
437
-					while ($obj = Database::fetch_object($db_result)) {
436
+                    $db_result = Database::query($sql);
437
+                    while ($obj = Database::fetch_object($db_result)) {
438 438
                         $doc = new Document(
439 439
                             $obj->id,
440 440
                             $obj->path,
@@ -458,25 +458,25 @@  discard block
 block discarded – undo
458 458
                             }
459 459
                             $course->resources[RESOURCE_DOCUMENT][$resource_item]->item_properties = $all_properties;
460 460
                         }
461
-					}
462
-				}
463
-			}
464
-		}
461
+                    }
462
+                }
463
+            }
464
+        }
465 465
 
466
-		if (is_array($course->resources)) {
467
-			foreach ($course->resources as $type => $resources) {
466
+        if (is_array($course->resources)) {
467
+            foreach ($course->resources as $type => $resources) {
468 468
 
469
-				switch ($type) {
470
-					case RESOURCE_SURVEYQUESTION:
471
-						foreach($resources as $id => $obj) {
472
-						    if (isset($_POST['resource'][RESOURCE_SURVEY]) &&
469
+                switch ($type) {
470
+                    case RESOURCE_SURVEYQUESTION:
471
+                        foreach($resources as $id => $obj) {
472
+                            if (isset($_POST['resource'][RESOURCE_SURVEY]) &&
473 473
                                 is_array($_POST['resource'][RESOURCE_SURVEY]) &&
474 474
                                 !in_array($obj->survey_id, array_keys($_POST['resource'][RESOURCE_SURVEY]))
475 475
                             ) {
476
-								unset($course->resources[$type][$id]);
477
-							}
478
-						}
479
-						break;
476
+                                unset($course->resources[$type][$id]);
477
+                            }
478
+                        }
479
+                        break;
480 480
                     case RESOURCE_FORUMTOPIC:
481 481
                     case RESOURCE_FORUMPOST:
482 482
                        //Add post from topic
@@ -528,63 +528,63 @@  discard block
 block discarded – undo
528 528
                                 }
529 529
                             }
530 530
                         }
531
-					case RESOURCE_LINKCATEGORY:
532
-					case RESOURCE_FORUMCATEGORY:
533
-					case RESOURCE_QUIZQUESTION:
534
-					case RESOURCE_DOCUMENT:
535
-						// Mark folders to import which are not selected by the user to import,
536
-						// but in which a document was selected.
537
-						$documents = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null;
538
-						if (!empty($resources) && is_array($resources))
539
-							foreach ($resources as $id => $obj) {
540
-								if (isset($obj->file_type) && $obj->file_type == 'folder' &&
531
+                    case RESOURCE_LINKCATEGORY:
532
+                    case RESOURCE_FORUMCATEGORY:
533
+                    case RESOURCE_QUIZQUESTION:
534
+                    case RESOURCE_DOCUMENT:
535
+                        // Mark folders to import which are not selected by the user to import,
536
+                        // but in which a document was selected.
537
+                        $documents = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null;
538
+                        if (!empty($resources) && is_array($resources))
539
+                            foreach ($resources as $id => $obj) {
540
+                                if (isset($obj->file_type) && $obj->file_type == 'folder' &&
541 541
                                     !isset($_POST['resource'][RESOURCE_DOCUMENT][$id]) &&
542 542
                                     is_array($documents)
543 543
                                 ) {
544
-									foreach ($documents as $id_to_check => $post_value) {
545
-										$obj_to_check = $resources[$id_to_check];
546
-										$shared_path_part = substr($obj_to_check->path,0,strlen($obj->path));
547
-										if ($id_to_check != $id && $obj->path == $shared_path_part) {
548
-											$_POST['resource'][RESOURCE_DOCUMENT][$id] = 1;
549
-											break;
550
-										}
551
-									}
552
-								}
553
-							}
554
-					default :
555
-						if (!empty($resources) && is_array($resources)) {
556
-							foreach ($resources as $id => $obj) {
557
-								$resource_is_used_elsewhere = $course->is_linked_resource($obj);
558
-								// check if document is in a quiz (audio/video)
559
-								if ($type == RESOURCE_DOCUMENT && $course->has_resources(RESOURCE_QUIZ)) {
560
-									foreach($course->resources[RESOURCE_QUIZ] as $quiz) {
544
+                                    foreach ($documents as $id_to_check => $post_value) {
545
+                                        $obj_to_check = $resources[$id_to_check];
546
+                                        $shared_path_part = substr($obj_to_check->path,0,strlen($obj->path));
547
+                                        if ($id_to_check != $id && $obj->path == $shared_path_part) {
548
+                                            $_POST['resource'][RESOURCE_DOCUMENT][$id] = 1;
549
+                                            break;
550
+                                        }
551
+                                    }
552
+                                }
553
+                            }
554
+                    default :
555
+                        if (!empty($resources) && is_array($resources)) {
556
+                            foreach ($resources as $id => $obj) {
557
+                                $resource_is_used_elsewhere = $course->is_linked_resource($obj);
558
+                                // check if document is in a quiz (audio/video)
559
+                                if ($type == RESOURCE_DOCUMENT && $course->has_resources(RESOURCE_QUIZ)) {
560
+                                    foreach($course->resources[RESOURCE_QUIZ] as $quiz) {
561 561
                                         $quiz = $quiz->obj;
562
-										if (isset($quiz->media) && $quiz->media == $id) {
563
-											$resource_is_used_elsewhere = true;
564
-										}
565
-									}
566
-								}
567
-								if (!isset($_POST['resource'][$type][$id]) && !$resource_is_used_elsewhere) {
568
-									unset($course->resources[$type][$id]);
569
-								}
570
-							}
571
-						}
572
-				}
573
-			}
574
-		}
562
+                                        if (isset($quiz->media) && $quiz->media == $id) {
563
+                                            $resource_is_used_elsewhere = true;
564
+                                        }
565
+                                    }
566
+                                }
567
+                                if (!isset($_POST['resource'][$type][$id]) && !$resource_is_used_elsewhere) {
568
+                                    unset($course->resources[$type][$id]);
569
+                                }
570
+                            }
571
+                        }
572
+                }
573
+            }
574
+        }
575 575
 
576
-		return $course;
577
-	}
576
+        return $course;
577
+    }
578 578
 
579
-	/**
580
-	 * Display the form session export
579
+    /**
580
+     * Display the form session export
581 581
      * @param array $list_course
582
-	 * @param array $hidden_fields Hidden fields to add to the form.
582
+     * @param array $hidden_fields Hidden fields to add to the form.
583 583
      * @param boolean $avoid_serialize the document array will be serialize. This is used in the course_copy.php file
584
-	 */
585
-	 public static function display_form_session_export($list_course, $hidden_fields = null, $avoid_serialize = false)
586
-     {
587
-         ?>
584
+     */
585
+        public static function display_form_session_export($list_course, $hidden_fields = null, $avoid_serialize = false)
586
+        {
587
+            ?>
588 588
 		<script>
589 589
 			function exp(item) {
590 590
 				el = document.getElementById('div_'+item);
@@ -626,68 +626,68 @@  discard block
 block discarded – undo
626 626
 		</script>
627 627
 		<?php
628 628
 
629
-		//get destination course title
630
-		if(!empty($hidden_fields['destination_course'])) {
631
-             if (!empty($hidden_fields['destination_session'])) {
632
-                 $sessionTitle = ' (' . api_get_session_name($hidden_fields['destination_session']) . ')';
633
-             } else {
634
-                 $sessionTitle = null;
635
-             }
629
+        //get destination course title
630
+        if(!empty($hidden_fields['destination_course'])) {
631
+                if (!empty($hidden_fields['destination_session'])) {
632
+                    $sessionTitle = ' (' . api_get_session_name($hidden_fields['destination_session']) . ')';
633
+                } else {
634
+                    $sessionTitle = null;
635
+                }
636 636
             $course_infos = CourseManager::get_course_information($hidden_fields['destination_course']);
637
-			echo '<h3>';
638
-				echo get_lang('DestinationCourse') . ' : ' . $course_infos['title'] . $sessionTitle;
639
-			echo '</h3>';
640
-		}
637
+            echo '<h3>';
638
+                echo get_lang('DestinationCourse') . ' : ' . $course_infos['title'] . $sessionTitle;
639
+            echo '</h3>';
640
+        }
641 641
 
642
-		echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>';
643
-		echo '<script type="text/javascript">var myUpload = new upload(1000);</script>';
642
+        echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>';
643
+        echo '<script type="text/javascript">var myUpload = new upload(1000);</script>';
644 644
         $icon = Display::returnIconPath('progress_bar.gif');
645 645
         echo '<div class="tool-backups-options">';
646
-		echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="myUpload.start(\'dynamic_div\',\''.$icon.'\',\''.get_lang('PleaseStandBy').'\',\'upload_form\')">';
647
-		echo '<input type="hidden" name="action" value="course_select_form"/>';
648
-		foreach ($list_course as $course) {
649
-			foreach ($course->resources as $type => $resources) {
650
-				if (count($resources) > 0) {
646
+        echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="myUpload.start(\'dynamic_div\',\''.$icon.'\',\''.get_lang('PleaseStandBy').'\',\'upload_form\')">';
647
+        echo '<input type="hidden" name="action" value="course_select_form"/>';
648
+        foreach ($list_course as $course) {
649
+            foreach ($course->resources as $type => $resources) {
650
+                if (count($resources) > 0) {
651 651
                     echo '<div class="item-backup" onclick="javascript:exp('."'$course->code'".');">';
652
-					echo '<em id="img_'.$course->code.'" class="fa fa-minus-square-o fa-lg"></em>';
653
-					echo '<span class="title"> '.$course->code.'</span></div>';
654
-					echo '<div class="item-content" id="div_'.$course->code.'">';
655
-					echo '<blockquote>';
652
+                    echo '<em id="img_'.$course->code.'" class="fa fa-minus-square-o fa-lg"></em>';
653
+                    echo '<span class="title"> '.$course->code.'</span></div>';
654
+                    echo '<div class="item-content" id="div_'.$course->code.'">';
655
+                    echo '<blockquote>';
656 656
 
657 657
                     echo '<div class="btn-group">';
658
-					echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',true);\" >".get_lang('All')."</a>";
658
+                    echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',true);\" >".get_lang('All')."</a>";
659 659
                     echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',false);\" >".get_lang('None')."</a>";
660
-					echo '</div>';
660
+                    echo '</div>';
661 661
 
662
-					foreach ($resources as $id => $resource) {
663
-						echo '<label class="checkbox" for="resource['.$course->code.']['.$id.']">';
662
+                    foreach ($resources as $id => $resource) {
663
+                        echo '<label class="checkbox" for="resource['.$course->code.']['.$id.']">';
664 664
                         echo '<input type="checkbox" name="resource['.$course->code.']['.$id.']" id="resource['.$course->code.']['.$id.']"/>';
665
-						$resource->show();
666
-						echo '</label>';
667
-					}
668
-					echo '</blockquote>';
669
-					echo '</div>';
670
-					echo '<script type="text/javascript">exp('."'$course->code'".')</script>';
671
-				}
672
-			}
673
-		}
674
-		if ($avoid_serialize) {
675
-			//Documents are avoided due the huge amount of memory that the serialize php function "eats" (when there are directories with hundred/thousand of files)
676
-			// this is a known issue of serialize
677
-			$course->resources['document']= null;
678
-		}
679
-		echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>';
680
-		if (is_array($hidden_fields)) {
681
-			foreach ($hidden_fields as $key => $value) {
682
-				echo "\n";
683
-				echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>';
684
-			}
685
-		}
686
-		echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.get_lang('Ok').'</button>';
687
-		CourseSelectForm :: display_hidden_quiz_questions($course);
688
-		CourseSelectForm :: display_hidden_scorm_directories($course);
689
-		echo '</form>';
665
+                        $resource->show();
666
+                        echo '</label>';
667
+                    }
668
+                    echo '</blockquote>';
669
+                    echo '</div>';
670
+                    echo '<script type="text/javascript">exp('."'$course->code'".')</script>';
671
+                }
672
+            }
673
+        }
674
+        if ($avoid_serialize) {
675
+            //Documents are avoided due the huge amount of memory that the serialize php function "eats" (when there are directories with hundred/thousand of files)
676
+            // this is a known issue of serialize
677
+            $course->resources['document']= null;
678
+        }
679
+        echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>';
680
+        if (is_array($hidden_fields)) {
681
+            foreach ($hidden_fields as $key => $value) {
682
+                echo "\n";
683
+                echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>';
684
+            }
685
+        }
686
+        echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.get_lang('Ok').'</button>';
687
+        CourseSelectForm :: display_hidden_quiz_questions($course);
688
+        CourseSelectForm :: display_hidden_scorm_directories($course);
689
+        echo '</form>';
690 690
         echo '</div>';
691
-		echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>';
692
-	}
691
+        echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>';
692
+    }
693 693
 }
Please login to merge, or discard this patch.
src/Chamilo/CourseBundle/Component/CourseCopy/CourseBuilder.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -602,7 +602,7 @@
 block discarded – undo
602 602
         $table_doc = Database:: get_course_table(TABLE_DOCUMENT);
603 603
 
604 604
         if (!empty($courseId) && !empty($session_id)) {
605
-            $session_id  = intval($session_id);
605
+            $session_id = intval($session_id);
606 606
             if ($with_base_content) {
607 607
                 $session_condition = api_get_session_condition(
608 608
                     $session_id,
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@
 block discarded – undo
91 91
     }
92 92
 
93 93
     /**
94
-     * @param array $array
94
+     * @param string[] $array
95 95
      */
96 96
     public function set_tools_to_build($array)
97 97
     {
Please login to merge, or discard this patch.
src/Chamilo/CourseBundle/Component/CourseCopy/Course.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -326,9 +326,9 @@  discard block
 block discarded – undo
326 326
     }
327 327
 
328 328
     /**
329
-    * Serialize the course with the best serializer available
330
-    * @return string
331
-    */
329
+     * Serialize the course with the best serializer available
330
+     * @return string
331
+     */
332 332
     public static function serialize($course)
333 333
     {
334 334
         if (extension_loaded('igbinary')) {
@@ -339,9 +339,9 @@  discard block
 block discarded – undo
339 339
     }
340 340
 
341 341
     /**
342
-    * Unserialize the course with the best serializer available
343
-    * @param string $course
344
-    */
342
+     * Unserialize the course with the best serializer available
343
+     * @param string $course
344
+     */
345 345
     public static function unserialize($course)
346 346
     {
347 347
         if (extension_loaded('igbinary')) {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,10 +40,10 @@
 block discarded – undo
40 40
             if (is_array($resources)) {
41 41
                 foreach ($resources as $resource) {
42 42
                     Resource::setClassType($resource);
43
-                    if ($resource->links_to($resource_to_check) ) {
43
+                    if ($resource->links_to($resource_to_check)) {
44 44
                         return true;
45 45
                     }
46
-                    if ($type == RESOURCE_LEARNPATH && get_class($resource)=='CourseCopyLearnpath') {
46
+                    if ($type == RESOURCE_LEARNPATH && get_class($resource) == 'CourseCopyLearnpath') {
47 47
                         if ($resource->has_item($resource_to_check)) {
48 48
                             return true;
49 49
                         }
Please login to merge, or discard this patch.
src/Chamilo/CourseBundle/Component/CourseCopy/Resources/Glossary.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,9 +22,9 @@
 block discarded – undo
22 22
      * @param string $description
23 23
      * @param int $display_order
24 24
      */
25
-    public function __construct($id,$name,$description,$display_order)
25
+    public function __construct($id, $name, $description, $display_order)
26 26
     {
27
-        parent::__construct($id,RESOURCE_GLOSSARY);
27
+        parent::__construct($id, RESOURCE_GLOSSARY);
28 28
         $this->glossary_id = $id;
29 29
         $this->name = $name;
30 30
         $this->description = $description;
Please login to merge, or discard this patch.
src/Chamilo/CourseBundle/Component/CourseCopy/Resources/ForumPost.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,6 +25,6 @@
 block discarded – undo
25 25
     public function show()
26 26
     {
27 27
         parent::show();
28
-        echo $this->obj->title . ' (' . $this->obj->poster_name . ', ' . $this->obj->post_date . ')';
28
+        echo $this->obj->title.' ('.$this->obj->poster_name.', '.$this->obj->post_date.')';
29 29
     }
30 30
 }
Please login to merge, or discard this patch.