Completed
Push — 1.11.x ( 78f130...f6f5c2 )
by José
50:40 queued 24:26
created
main/admin/configure_inscription.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 $tool_name = get_lang('ConfigureInscription');
47 47
 if (!empty($action)) {
48 48
     $interbreadcrumb[] = array('url' => 'configure_inscription.php', 'name' => get_lang('ConfigureInscription'));
49
-    switch($action) {
49
+    switch ($action) {
50 50
         case 'edit_top':
51 51
             $tool_name = get_lang('EditTopRegister');
52 52
             break;
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
                 // This request is only the preparation for the update of the home_top
142 142
                 $home_top = '';
143 143
                 if (is_file($homep.$topf.'_'.$lang.$ext) && is_readable($homep.$topf.'_'.$lang.$ext)) {
144
-                    $home_top = @(string)file_get_contents($homep.$topf.'_'.$lang.$ext);
144
+                    $home_top = @(string) file_get_contents($homep.$topf.'_'.$lang.$ext);
145 145
                 } elseif (is_file($homep.$topf.$lang.$ext) && is_readable($homep.$topf.$lang.$ext)) {
146
-                    $home_top = @(string)file_get_contents($homep.$topf.$lang.$ext);
146
+                    $home_top = @(string) file_get_contents($homep.$topf.$lang.$ext);
147 147
                 } else {
148 148
                     $errorMsg = get_lang('HomePageFilesNotReadable');
149 149
                 }
@@ -184,15 +184,15 @@  discard block
 block discarded – undo
184 184
     if (api_is_western_name_order()) {
185 185
         //	FIRST NAME and LAST NAME
186 186
         $form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40, 'disabled' => 'disabled'));
187
-        $form->addElement('text', 'lastname',  get_lang('LastName'),  array('size' => 40, 'disabled' => 'disabled'));
187
+        $form->addElement('text', 'lastname', get_lang('LastName'), array('size' => 40, 'disabled' => 'disabled'));
188 188
     } else {
189 189
         //	LAST NAME and FIRST NAME
190
-        $form->addElement('text', 'lastname',  get_lang('LastName'),  array('size' => 40, 'disabled' => 'disabled'));
190
+        $form->addElement('text', 'lastname', get_lang('LastName'), array('size' => 40, 'disabled' => 'disabled'));
191 191
         $form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40, 'disabled' => 'disabled'));
192 192
     }
193 193
     $form->applyFilter('firstname', 'trim');
194 194
     $form->applyFilter('lastname', 'trim');
195
-    $form->addRule('lastname',  get_lang('ThisFieldIsRequired'), 'required');
195
+    $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
196 196
     $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
197 197
 
198 198
     //	EMAIL
@@ -210,10 +210,10 @@  discard block
 block discarded – undo
210 210
     $form->addRule('username', get_lang('ThisFieldIsRequired'), 'required');
211 211
     $form->addRule('username', get_lang('UsernameWrong'), 'username');
212 212
     $form->addRule('username', get_lang('UserTaken'), 'username_available');
213
-    $form->addRule('username', sprintf(get_lang('UsernameMaxXCharacters'), (string)USERNAME_MAX_LENGTH), 'maxlength', USERNAME_MAX_LENGTH);
213
+    $form->addRule('username', sprintf(get_lang('UsernameMaxXCharacters'), (string) USERNAME_MAX_LENGTH), 'maxlength', USERNAME_MAX_LENGTH);
214 214
 
215 215
     //	PASSWORD
216
-    $form->addElement('password', 'pass1', get_lang('Pass'),         array('size' => 40, 'disabled' => 'disabled'));
216
+    $form->addElement('password', 'pass1', get_lang('Pass'), array('size' => 40, 'disabled' => 'disabled'));
217 217
     $form->addElement('password', 'pass2', get_lang('Confirmation'), array('size' => 40, 'disabled' => 'disabled'));
218 218
     $form->addRule('pass1', get_lang('ThisFieldIsRequired'), 'required');
219 219
     $form->addRule('pass2', get_lang('ThisFieldIsRequired'), 'required');
@@ -241,25 +241,25 @@  discard block
 block discarded – undo
241 241
 
242 242
     //	EXTENDED FIELDS
243 243
     if (api_get_setting('extended_profile') == 'true' &&
244
-        api_get_setting('extendedprofile_registration','mycomptetences') == 'true'
244
+        api_get_setting('extendedprofile_registration', 'mycomptetences') == 'true'
245 245
     ) {
246 246
         $form->addHtmlEditor('competences', get_lang('MyCompetences'), false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
247 247
     }
248 248
 
249 249
     if (api_get_setting('extended_profile') == 'true' &&
250
-        api_get_setting('extendedprofile_registration','mydiplomas') == 'true'
250
+        api_get_setting('extendedprofile_registration', 'mydiplomas') == 'true'
251 251
     ) {
252 252
         $form->addHtmlEditor('diplomas', get_lang('MyDiplomas'), false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
253 253
     }
254 254
 
255 255
     if (api_get_setting('extended_profile') == 'true' &&
256
-        api_get_setting('extendedprofile_registration','myteach') == 'true'
256
+        api_get_setting('extendedprofile_registration', 'myteach') == 'true'
257 257
     ) {
258 258
         $form->addHtmlEditor('teach', get_lang('MyTeach'), false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
259 259
     }
260 260
 
261 261
     if (api_get_setting('extended_profile') == 'true' &&
262
-        api_get_setting('extendedprofile_registration','mypersonalopenarea') == 'true'
262
+        api_get_setting('extendedprofile_registration', 'mypersonalopenarea') == 'true'
263 263
     ) {
264 264
         $form->addHtmlEditor('openarea', get_lang('MyPersonalOpenArea'), false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
265 265
     }
@@ -349,14 +349,14 @@  discard block
 block discarded – undo
349 349
 
350 350
 $form->setDefaults($defaults);
351 351
 
352
-switch ($action){
352
+switch ($action) {
353 353
     case 'edit_top':
354 354
         if ($action == 'edit_top') {
355 355
             $name = $topf;
356 356
             $open = $home_top;
357 357
         } else {
358 358
             $name = $newsf;
359
-            $open = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext);
359
+            $open = @(string) file_get_contents($homep.$newsf.'_'.$lang.$ext);
360 360
             $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
361 361
         }
362 362
 
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 
367 367
         $default = array();
368 368
         $form = new FormValidator('configure_inscription_'.$action, 'post', api_get_self().'?action='.$action, '', array('style' => 'margin: 0px;'));
369
-        $renderer =& $form->defaultRenderer();
369
+        $renderer = & $form->defaultRenderer();
370 370
         $renderer->setHeaderTemplate('');
371 371
         $renderer->setFormTemplate('<form{attributes}><table border="0" cellpadding="5" cellspacing="0" width="100%">{content}</table></form>');
372 372
         $renderer->setCustomElementTemplate('<tr><td>{element}</td></tr>');
@@ -385,9 +385,9 @@  discard block
 block discarded – undo
385 385
 
386 386
         $open = '';
387 387
         if (file_exists($homep.$topf.'_'.$lang.$ext)) {
388
-            $open = @(string)file_get_contents($homep.$topf.'_'.$lang.$ext);
388
+            $open = @(string) file_get_contents($homep.$topf.'_'.$lang.$ext);
389 389
         } else {
390
-            $open = @(string)file_get_contents($homep.$topf.$ext);
390
+            $open = @(string) file_get_contents($homep.$topf.$ext);
391 391
         }
392 392
         $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
393 393
         if (!empty($open)) {
Please login to merge, or discard this patch.
main/admin/legal_list.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,10 +42,10 @@
 block discarded – undo
42 42
 // this 2 "mask" function are here just because the SortableTable
43 43
 function get_legal_data_mask($id, $params = null, $row = null)
44 44
 {
45
-	return LegalManager::get_legal_data($id, $params, $row);
45
+    return LegalManager::get_legal_data($id, $params, $row);
46 46
 }
47 47
 function count_mask()
48 48
 {
49
-	return LegalManager::count();
49
+    return LegalManager::count();
50 50
 }
51 51
 Display :: display_footer();
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 require_once '../inc/global.inc.php';
11 11
 $this_section = SECTION_PLATFORM_ADMIN;
12 12
 api_protect_admin_script();
13
-$interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
13
+$interbreadcrumb[] = array("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
14 14
 $tool_name = get_lang('TermsAndConditions');
15 15
 Display :: display_header($tool_name);
16 16
 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 // action menu
20 20
 echo '<div class="actions">';
21 21
 echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/legal_add.php">'.
22
-    Display::return_icon('edit.gif',get_lang('EditTermsAndConditions'), '').get_lang('EditTermsAndConditions').'</a>&nbsp;&nbsp;';
22
+    Display::return_icon('edit.gif', get_lang('EditTermsAndConditions'), '').get_lang('EditTermsAndConditions').'</a>&nbsp;&nbsp;';
23 23
 echo '</div>';
24 24
 
25 25
 $legal_count = LegalManager::count();
Please login to merge, or discard this patch.
main/admin/user_information.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 $interbreadcrumb[] = array("url" => 'user_list.php', "name" => get_lang('UserList'));
43 43
 
44 44
 $userId = $user['user_id'];
45
-$tool_name = $user['complete_name'].(empty($user['official_code'])?'':' ('.$user['official_code'].')');
45
+$tool_name = $user['complete_name'].(empty($user['official_code']) ? '' : ' ('.$user['official_code'].')');
46 46
 $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
47 47
 $table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
48 48
 
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
         $tools = '<a href="course_information.php?code='.$courseCode.'">'.
420 420
             Display::return_icon('synthese_view.gif', get_lang('Overview')).'</a>'.
421 421
             '<a href="'.$courseInfo['course_public_url'].'">'.
422
-            Display::return_icon('course_home.gif', get_lang('CourseHomepage')).'</a>' .
422
+            Display::return_icon('course_home.gif', get_lang('CourseHomepage')).'</a>'.
423 423
             '<a href="course_edit.php?id='.$course->c_id.'">'.
424 424
             Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
425 425
         if ($course->status == STUDENT) {
Please login to merge, or discard this patch.
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   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -70,49 +70,49 @@  discard block
 block discarded – undo
70 70
         $backupDirectory = self::getBackupDir();
71 71
 
72 72
         // Create a temp directory
73
-        $backup_dir = $backupDirectory . 'CourseArchiver_' . api_get_unique_id() . '/';
73
+        $backup_dir = $backupDirectory.'CourseArchiver_'.api_get_unique_id().'/';
74 74
 
75 75
         // All course-information will be stored in course_info.dat
76
-        $course_info_file = $backup_dir . 'course_info.dat';
76
+        $course_info_file = $backup_dir.'course_info.dat';
77 77
 
78 78
         $user = api_get_user_info();
79 79
         $date = new \DateTime(api_get_local_time());
80
-        $zipFileName = $user['user_id'] . '_' . $course->code . '_' . $date->format('Ymd-His') . '.zip';
81
-        $zipFilePath = $backupDirectory. $zipFileName;
80
+        $zipFileName = $user['user_id'].'_'.$course->code.'_'.$date->format('Ymd-His').'.zip';
81
+        $zipFilePath = $backupDirectory.$zipFileName;
82 82
 
83 83
         $php_errormsg = '';
84 84
         $res = @mkdir($backup_dir, $perm_dirs);
85 85
         if ($res === false) {
86 86
             //TODO set and handle an error message telling the user to review the permissions on the archive directory
87
-            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);
87
+            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);
88 88
         }
89 89
         // Write the course-object to the file
90 90
         $fp = @fopen($course_info_file, 'w');
91 91
         if ($fp === false) {
92
-            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);
92
+            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);
93 93
         }
94 94
 
95 95
         $res = @fwrite($fp, base64_encode(serialize($course)));
96 96
         if ($res === false) {
97
-            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);
97
+            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);
98 98
         }
99 99
 
100 100
         $res = @fclose($fp);
101 101
         if ($res === false) {
102
-            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);
102
+            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);
103 103
         }
104 104
 
105 105
         // Copy all documents to the temp-dir
106 106
         if (isset($course->resources[RESOURCE_DOCUMENT]) && is_array($course->resources[RESOURCE_DOCUMENT])) {
107 107
             foreach ($course->resources[RESOURCE_DOCUMENT] as $document) {
108 108
                 if ($document->file_type == DOCUMENT) {
109
-                    $doc_dir = $backup_dir . $document->path;
109
+                    $doc_dir = $backup_dir.$document->path;
110 110
                     @mkdir(dirname($doc_dir), $perm_dirs, true);
111
-                    if (file_exists($course->path . $document->path)) {
112
-                        copy($course->path . $document->path, $doc_dir);
111
+                    if (file_exists($course->path.$document->path)) {
112
+                        copy($course->path.$document->path, $doc_dir);
113 113
                     }
114 114
                 } else {
115
-                    @mkdir($backup_dir . $document->path, $perm_dirs, true);
115
+                    @mkdir($backup_dir.$document->path, $perm_dirs, true);
116 116
                 }
117 117
             }
118 118
         }
@@ -120,40 +120,40 @@  discard block
 block discarded – undo
120 120
         // Copy all scorm documents to the temp-dir
121 121
         if (isset($course->resources[RESOURCE_SCORM]) && is_array($course->resources[RESOURCE_SCORM])) {
122 122
             foreach ($course->resources[RESOURCE_SCORM] as $document) {
123
-                $doc_dir = dirname($backup_dir . $document->path);
123
+                $doc_dir = dirname($backup_dir.$document->path);
124 124
                 @mkdir($doc_dir, $perm_dirs, true);
125
-                copyDirTo($course->path . $document->path, $doc_dir, false);
125
+                copyDirTo($course->path.$document->path, $doc_dir, false);
126 126
             }
127 127
         }
128 128
 
129 129
         // Copy calendar attachments.
130 130
 
131 131
         if (isset($course->resources[RESOURCE_EVENT]) && is_array($course->resources[RESOURCE_EVENT])) {
132
-            $doc_dir = dirname($backup_dir . '/upload/calendar/');
132
+            $doc_dir = dirname($backup_dir.'/upload/calendar/');
133 133
             @mkdir($doc_dir, $perm_dirs, true);
134
-            copyDirTo($course->path . 'upload/calendar/', $doc_dir, false);
134
+            copyDirTo($course->path.'upload/calendar/', $doc_dir, false);
135 135
         }
136 136
 
137 137
         // Copy Learning path author image.
138 138
         if (isset($course->resources[RESOURCE_LEARNPATH]) && is_array($course->resources[RESOURCE_LEARNPATH])) {
139
-            $doc_dir = dirname($backup_dir . '/upload/learning_path/');
139
+            $doc_dir = dirname($backup_dir.'/upload/learning_path/');
140 140
             @mkdir($doc_dir, $perm_dirs, true);
141
-            copyDirTo($course->path . 'upload/learning_path/', $doc_dir, false);
141
+            copyDirTo($course->path.'upload/learning_path/', $doc_dir, false);
142 142
         }
143 143
 
144 144
         // Copy announcements attachments.
145 145
         if (isset($course->resources[RESOURCE_ANNOUNCEMENT]) && is_array($course->resources[RESOURCE_ANNOUNCEMENT])) {
146
-            $doc_dir = dirname($backup_dir . '/upload/announcements/');
146
+            $doc_dir = dirname($backup_dir.'/upload/announcements/');
147 147
             @mkdir($doc_dir, $perm_dirs, true);
148
-            copyDirTo($course->path . 'upload/announcements/', $doc_dir, false);
148
+            copyDirTo($course->path.'upload/announcements/', $doc_dir, false);
149 149
         }
150 150
 
151 151
         // Copy work folders (only folders)
152 152
         if (isset($course->resources[RESOURCE_WORK]) && is_array($course->resources[RESOURCE_WORK])) {
153
-            $doc_dir = dirname($backup_dir . '/upload/work/');
153
+            $doc_dir = dirname($backup_dir.'/upload/work/');
154 154
             @mkdir($doc_dir, $perm_dirs, true);
155 155
             // @todo: adjust to only create subdirs, but not copy files
156
-            copyDirTo($course->path . 'upload/work/', $doc_dir, false);
156
+            copyDirTo($course->path.'upload/work/', $doc_dir, false);
157 157
         }
158 158
 
159 159
         // Zip the course-contents
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
                     $date = $file_parts[0];
184 184
                     $ext = isset($file_parts[1]) ? $file_parts[1] : null;
185 185
                     if ($ext == 'zip' && ($user_id != null && $owner_id == $user_id || $user_id == null)) {
186
-                        $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);
186
+                        $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);
187 187
                         $backup_files[] = array(
188 188
                             'file' => $file,
189 189
                             'date' => $date,
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
      */
205 205
     public static function importUploadedFile($file)
206 206
     {
207
-        $new_filename = uniqid('') . '.zip';
207
+        $new_filename = uniqid('').'.zip';
208 208
         $new_dir = self::getBackupDir();
209 209
         if (is_dir($new_dir) && is_writable($new_dir)) {
210 210
             move_uploaded_file($file, $new_dir.$new_filename);
@@ -234,11 +234,11 @@  discard block
 block discarded – undo
234 234
         @mkdir($unzip_dir, api_get_permissions_for_new_directories(), true);
235 235
         @copy(
236 236
             $filePath,
237
-            $unzip_dir . '/backup.zip'
237
+            $unzip_dir.'/backup.zip'
238 238
         );
239 239
 
240 240
         // unzip the archive
241
-        $zip = new \PclZip($unzip_dir . '/backup.zip');
241
+        $zip = new \PclZip($unzip_dir.'/backup.zip');
242 242
         @chdir($unzip_dir);
243 243
         $zip->extract(PCLZIP_OPT_TEMP_FILE_ON);
244 244
         // remove the archive-file
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.
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.
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,
@@ -237,17 +237,17 @@  discard block
 block discarded – undo
237 237
         }
238 238
     }
239 239
 
240
-	/**
241
-	 * Restore only harmless course settings:
240
+    /**
241
+     * Restore only harmless course settings:
242 242
      * course_language, visibility, department_name,department_url,
243 243
      * subscribe, unsubscribe ,category_code
244
-	 *
245
-	 * @param string $destination_course_code
246
-	 */
244
+     *
245
+     * @param string $destination_course_code
246
+     */
247 247
     public function restore_course_settings($destination_course_code)
248 248
     {
249
-	    $origin_course_info = api_get_course_info($destination_course_code);
250
-	    $course_info = $this->course->info;
249
+        $origin_course_info = api_get_course_info($destination_course_code);
250
+        $course_info = $this->course->info;
251 251
         $params['course_language'] = $course_info['language'];
252 252
         $params['visibility'] = $course_info['visibility'];
253 253
         $params['department_name'] = $course_info['department_name'];
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
         $params['subscribe'] = $course_info['subscribe_allowed'];
258 258
         $params['unsubscribe'] = $course_info['unsubscribe'];
259 259
         CourseManager::update_attributes($origin_course_info['real_id'], $params);
260
-	}
260
+    }
261 261
 
262 262
     /**
263 263
      * Restore documents
@@ -903,56 +903,56 @@  discard block
 block discarded – undo
903 903
         unset($_SESSION['new_base_foldername']);
904 904
         unset($_SESSION['orig_base_foldername']);
905 905
         unset($_SESSION['new_base_path']);
906
-	}
906
+    }
907 907
 
908
-	/**
909
-	 * Restore scorm documents
910
-	 * TODO @TODO check that the restore function with renaming doesn't break the scorm structure!
908
+    /**
909
+     * Restore scorm documents
910
+     * TODO @TODO check that the restore function with renaming doesn't break the scorm structure!
911 911
      * see #7029
912
-	 */
913
-	public function restore_scorm_documents()
912
+     */
913
+    public function restore_scorm_documents()
914 914
     {
915
-		$perm = api_get_permissions_for_new_directories();
915
+        $perm = api_get_permissions_for_new_directories();
916 916
 
917
-		if ($this->course->has_resources(RESOURCE_SCORM)) {
918
-			$resources = $this->course->resources;
917
+        if ($this->course->has_resources(RESOURCE_SCORM)) {
918
+            $resources = $this->course->resources;
919 919
 
920
-			foreach ($resources[RESOURCE_SCORM] as $document) {
921
-				$path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/';
922
-				@mkdir(dirname($path.$document->path), $perm, true);
920
+            foreach ($resources[RESOURCE_SCORM] as $document) {
921
+                $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/';
922
+                @mkdir(dirname($path.$document->path), $perm, true);
923 923
 
924
-				if (file_exists($path.$document->path)) {
925
-					switch ($this->file_option) {
926
-						case FILE_OVERWRITE:
927
-							rmdirr($path.$document->path);
924
+                if (file_exists($path.$document->path)) {
925
+                    switch ($this->file_option) {
926
+                        case FILE_OVERWRITE:
927
+                            rmdirr($path.$document->path);
928 928
                             copyDirTo(
929 929
                                 $this->course->backup_path . '/' . $document->path,
930 930
                                 $path . dirname($document->path),
931 931
                                 false
932 932
                             );
933
-							break;
934
-						case FILE_SKIP:
935
-							break;
933
+                            break;
934
+                        case FILE_SKIP:
935
+                            break;
936 936
                         case FILE_RENAME:
937
-							$i = 1;
938
-							$ext = explode('.', basename($document->path));
939
-							if (count($ext) > 1) {
940
-								$ext = array_pop($ext);
941
-								$file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1));
942
-								$ext = '.'.$ext;
943
-							} else {
944
-								$ext = '';
945
-								$file_name_no_ext = $document->path;
946
-							}
947
-
948
-							$new_file_name = $file_name_no_ext.'_'.$i.$ext;
949
-							$file_exists = file_exists($path.$new_file_name);
950
-
951
-							while ($file_exists) {
952
-								$i ++;
953
-								$new_file_name = $file_name_no_ext.'_'.$i.$ext;
954
-								$file_exists = file_exists($path.$new_file_name);
955
-							}
937
+                            $i = 1;
938
+                            $ext = explode('.', basename($document->path));
939
+                            if (count($ext) > 1) {
940
+                                $ext = array_pop($ext);
941
+                                $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1));
942
+                                $ext = '.'.$ext;
943
+                            } else {
944
+                                $ext = '';
945
+                                $file_name_no_ext = $document->path;
946
+                            }
947
+
948
+                            $new_file_name = $file_name_no_ext.'_'.$i.$ext;
949
+                            $file_exists = file_exists($path.$new_file_name);
950
+
951
+                            while ($file_exists) {
952
+                                $i ++;
953
+                                $new_file_name = $file_name_no_ext.'_'.$i.$ext;
954
+                                $file_exists = file_exists($path.$new_file_name);
955
+                            }
956 956
 
957 957
                             rename(
958 958
                                 $this->course->backup_path . '/' . $document->path,
@@ -968,30 +968,30 @@  discard block
 block discarded – undo
968 968
                                 $this->course->backup_path . '/' . $document->path
969 969
                             );
970 970
 
971
-							break;
972
-					} // end switch
973
-				} else {
971
+                            break;
972
+                    } // end switch
973
+                } else {
974 974
                     // end if file exists
975 975
                     copyDirTo(
976 976
                         $this->course->backup_path . '/' . $document->path,
977 977
                         $path . dirname($document->path),
978 978
                         false
979 979
                     );
980
-				}
981
-			} // end for each
982
-		}
983
-	}
984
-
985
-	/**
986
-	 * Restore forums
987
-	 */
988
-	public function restore_forums($sessionId = 0)
980
+                }
981
+            } // end for each
982
+        }
983
+    }
984
+
985
+    /**
986
+     * Restore forums
987
+     */
988
+    public function restore_forums($sessionId = 0)
989 989
     {
990
-		if ($this->course->has_resources(RESOURCE_FORUM)) {
990
+        if ($this->course->has_resources(RESOURCE_FORUM)) {
991 991
             $sessionId = intval($sessionId);
992
-			$table_forum = Database::get_course_table(TABLE_FORUM);
993
-			$resources = $this->course->resources;
994
-			foreach ($resources[RESOURCE_FORUM] as $id => $forum) {
992
+            $table_forum = Database::get_course_table(TABLE_FORUM);
993
+            $resources = $this->course->resources;
994
+            foreach ($resources[RESOURCE_FORUM] as $id => $forum) {
995 995
                 $params = (array)$forum->obj;
996 996
                 $cat_id = '';
997 997
                 if (isset($this->course->resources[RESOURCE_FORUMCATEGORY]) &&
@@ -1038,33 +1038,33 @@  discard block
 block discarded – undo
1038 1038
                     Database::query($sql);
1039 1039
                 }
1040 1040
 
1041
-				$this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id;
1042
-
1043
-				$forum_topics = 0;
1044
-				if (is_array($this->course->resources[RESOURCE_FORUMTOPIC])) {
1045
-					foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) {
1046
-						if ($topic->obj->forum_id == $id) {
1047
-							$this->restore_topic($topic_id, $new_id, $sessionId);
1048
-							$forum_topics ++;
1049
-						}
1050
-					}
1051
-				}
1052
-				if ($forum_topics > 0) {
1053
-					$sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics."
1041
+                $this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id;
1042
+
1043
+                $forum_topics = 0;
1044
+                if (is_array($this->course->resources[RESOURCE_FORUMTOPIC])) {
1045
+                    foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) {
1046
+                        if ($topic->obj->forum_id == $id) {
1047
+                            $this->restore_topic($topic_id, $new_id, $sessionId);
1048
+                            $forum_topics ++;
1049
+                        }
1050
+                    }
1051
+                }
1052
+                if ($forum_topics > 0) {
1053
+                    $sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics."
1054 1054
                             WHERE c_id = {$this->destination_course_id} AND forum_id = ".(int)$new_id;
1055
-					Database::query($sql);
1056
-				}
1057
-			}
1058
-		}
1059
-	}
1060
-
1061
-	/**
1062
-	 * Restore forum-categories
1063
-	 */
1055
+                    Database::query($sql);
1056
+                }
1057
+            }
1058
+        }
1059
+    }
1060
+
1061
+    /**
1062
+     * Restore forum-categories
1063
+     */
1064 1064
     public function restore_forum_category($my_id = null, $sessionId = 0)
1065 1065
     {
1066
-		$forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY);
1067
-		$resources = $this->course->resources;
1066
+        $forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY);
1067
+        $resources = $this->course->resources;
1068 1068
         if (!empty($resources[RESOURCE_FORUMCATEGORY])) {
1069 1069
             foreach ($resources[RESOURCE_FORUMCATEGORY] as $id => $forum_cat) {
1070 1070
                 if (!empty($my_id)) {
@@ -1102,16 +1102,16 @@  discard block
 block discarded – undo
1102 1102
                 }
1103 1103
             }
1104 1104
         }
1105
-	}
1105
+    }
1106 1106
 
1107
-	/**
1108
-	 * Restore a forum-topic
1109
-	 * @param false|string $forum_id
1110
-	 */
1107
+    /**
1108
+     * Restore a forum-topic
1109
+     * @param false|string $forum_id
1110
+     */
1111 1111
     public function restore_topic($thread_id, $forum_id, $sessionId = 0)
1112 1112
     {
1113
-		$table = Database :: get_course_table(TABLE_FORUM_THREAD);
1114
-		$topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id];
1113
+        $table = Database :: get_course_table(TABLE_FORUM_THREAD);
1114
+        $topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id];
1115 1115
 
1116 1116
         $params = (array)$topic->obj;
1117 1117
         $params = self::DBUTF8_array($params);
@@ -1148,27 +1148,27 @@  discard block
 block discarded – undo
1148 1148
             $sessionId
1149 1149
         );
1150 1150
 
1151
-		$this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id;
1152
-		$topic_replies = -1;
1153
-
1154
-		foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) {
1155
-			if ($post->obj->thread_id == $thread_id) {
1156
-				$topic_replies++;
1157
-				$this->restore_post($post_id, $new_id, $forum_id, $sessionId);
1158
-			}
1159
-		}
1160
-		return $new_id;
1161
-	}
1162
-
1163
-	/**
1164
-	 * Restore a forum-post
1165
-	 * @TODO Restore tree-structure of posts. For example: attachments to posts.
1166
-	 * @param false|string $topic_id
1167
-	 */
1151
+        $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id;
1152
+        $topic_replies = -1;
1153
+
1154
+        foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) {
1155
+            if ($post->obj->thread_id == $thread_id) {
1156
+                $topic_replies++;
1157
+                $this->restore_post($post_id, $new_id, $forum_id, $sessionId);
1158
+            }
1159
+        }
1160
+        return $new_id;
1161
+    }
1162
+
1163
+    /**
1164
+     * Restore a forum-post
1165
+     * @TODO Restore tree-structure of posts. For example: attachments to posts.
1166
+     * @param false|string $topic_id
1167
+     */
1168 1168
     public function restore_post($id, $topic_id, $forum_id, $sessionId = 0)
1169 1169
     {
1170
-		$table_post = Database :: get_course_table(TABLE_FORUM_POST);
1171
-		$post = $this->course->resources[RESOURCE_FORUMPOST][$id];
1170
+        $table_post = Database :: get_course_table(TABLE_FORUM_POST);
1171
+        $post = $this->course->resources[RESOURCE_FORUMPOST][$id];
1172 1172
         $params = (array) $post->obj;
1173 1173
         $params['c_id'] = $this->destination_course_id;
1174 1174
         $params['forum_id'] = $forum_id;
@@ -1204,37 +1204,37 @@  discard block
 block discarded – undo
1204 1204
             null,
1205 1205
             $sessionId
1206 1206
         );
1207
-		$this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id;
1207
+        $this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id;
1208 1208
 
1209
-		return $new_id;
1210
-	}
1209
+        return $new_id;
1210
+    }
1211 1211
 
1212
-	/**
1213
-	 * Restore links
1214
-	 */
1212
+    /**
1213
+     * Restore links
1214
+     */
1215 1215
     public function restore_links($session_id = 0)
1216 1216
     {
1217
-		if ($this->course->has_resources(RESOURCE_LINK)) {
1218
-			$link_table = Database :: get_course_table(TABLE_LINK);
1219
-			$resources = $this->course->resources;
1217
+        if ($this->course->has_resources(RESOURCE_LINK)) {
1218
+            $link_table = Database :: get_course_table(TABLE_LINK);
1219
+            $resources = $this->course->resources;
1220 1220
 
1221
-			foreach ($resources[RESOURCE_LINK] as $id => $link) {
1221
+            foreach ($resources[RESOURCE_LINK] as $id => $link) {
1222 1222
                 $cat_id = $this->restore_link_category(
1223 1223
                     $link->category_id,
1224 1224
                     $session_id
1225 1225
                 );
1226
-				$sql = "SELECT MAX(display_order)
1226
+                $sql = "SELECT MAX(display_order)
1227 1227
 				        FROM $link_table
1228 1228
 				        WHERE
1229 1229
 				            c_id = ".$this->destination_course_id." AND
1230 1230
 				            category_id='" . intval($cat_id). "'";
1231
-				$result = Database::query($sql);
1232
-    			list($max_order) = Database::fetch_array($result);
1231
+                $result = Database::query($sql);
1232
+                list($max_order) = Database::fetch_array($result);
1233 1233
 
1234 1234
                 $params = [];
1235
-    			if (!empty($session_id)) {
1235
+                if (!empty($session_id)) {
1236 1236
                     $params['session_id'] = $session_id;
1237
-    			}
1237
+                }
1238 1238
 
1239 1239
                 $params['c_id'] = $this->destination_course_id;
1240 1240
                 $params['url'] = self::DBUTF8($link->url);
@@ -1263,9 +1263,9 @@  discard block
 block discarded – undo
1263 1263
                     }
1264 1264
                     $this->course->resources[RESOURCE_LINK][$id]->destination_id = $id;
1265 1265
                 }
1266
-			}
1267
-		}
1268
-	}
1266
+            }
1267
+        }
1268
+    }
1269 1269
 
1270 1270
     /**
1271 1271
      * Restore a link-category
@@ -1309,21 +1309,21 @@  discard block
 block discarded – undo
1309 1309
         return $this->course->resources[RESOURCE_LINKCATEGORY][$id]->destination_id;
1310 1310
     }
1311 1311
 
1312
-	/**
1313
-	 * Restore tool intro
1314
-	 */
1312
+    /**
1313
+     * Restore tool intro
1314
+     */
1315 1315
     public function restore_tool_intro($sessionId = 0)
1316 1316
     {
1317
-		if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) {
1317
+        if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) {
1318 1318
             $sessionId = intval($sessionId);
1319
-			$tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO);
1320
-			$resources = $this->course->resources;
1321
-			foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) {
1322
-				$sql = "DELETE FROM $tool_intro_table
1319
+            $tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO);
1320
+            $resources = $this->course->resources;
1321
+            foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) {
1322
+                $sql = "DELETE FROM $tool_intro_table
1323 1323
 				        WHERE
1324 1324
 				            c_id = ".$this->destination_course_id." AND
1325 1325
 				            id='".self::DBUTF8escapestring($tool_intro->id)."'";
1326
-				Database::query($sql);
1326
+                Database::query($sql);
1327 1327
 
1328 1328
                 $tool_intro->intro_text = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1329 1329
                     $tool_intro->intro_text,
@@ -1353,21 +1353,21 @@  discard block
 block discarded – undo
1353 1353
 
1354 1354
                     $this->course->resources[RESOURCE_TOOL_INTRO][$id]->destination_id = $id;
1355 1355
                 }
1356
-			}
1357
-		}
1358
-	}
1356
+            }
1357
+        }
1358
+    }
1359 1359
 
1360
-	/**
1361
-	 * Restore events
1362
-	 */
1360
+    /**
1361
+     * Restore events
1362
+     */
1363 1363
     public function restore_events($sessionId = 0)
1364 1364
     {
1365
-		if ($this->course->has_resources(RESOURCE_EVENT)) {
1365
+        if ($this->course->has_resources(RESOURCE_EVENT)) {
1366 1366
             $sessionId = intval($sessionId);
1367
-			$table = Database :: get_course_table(TABLE_AGENDA);
1368
-			$resources = $this->course->resources;
1369
-			foreach ($resources[RESOURCE_EVENT] as $id => $event) {
1370
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
1367
+            $table = Database :: get_course_table(TABLE_AGENDA);
1368
+            $resources = $this->course->resources;
1369
+            foreach ($resources[RESOURCE_EVENT] as $id => $event) {
1370
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
1371 1371
                 $event->content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1372 1372
                     $event->content,
1373 1373
                     $this->course->code,
@@ -1385,7 +1385,7 @@  discard block
 block discarded – undo
1385 1385
                     'end_date' => $event->end_date,
1386 1386
                     'session_id' => $sessionId
1387 1387
                 ];
1388
-				$new_event_id = Database::insert($table, $params);
1388
+                $new_event_id = Database::insert($table, $params);
1389 1389
 
1390 1390
                 if ($new_event_id) {
1391 1391
                     $sql = "UPDATE $table SET id = iid WHERE iid = $new_event_id";
@@ -1398,30 +1398,30 @@  discard block
 block discarded – undo
1398 1398
                     $this->course->resources[RESOURCE_EVENT][$id]->destination_id = $new_event_id;
1399 1399
                 }
1400 1400
 
1401
-				// Copy event attachment
1401
+                // Copy event attachment
1402 1402
 
1403
-				$origin_path = $this->course->backup_path.'/upload/calendar/';
1404
-				$destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/';
1403
+                $origin_path = $this->course->backup_path.'/upload/calendar/';
1404
+                $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/';
1405 1405
 
1406
-				if (!empty($this->course->orig)) {
1406
+                if (!empty($this->course->orig)) {
1407 1407
 
1408
-					$table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1409
-					$sql = 'SELECT path, comment, size, filename
1408
+                    $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1409
+                    $sql = 'SELECT path, comment, size, filename
1410 1410
 					        FROM '.$table_attachment.'
1411 1411
 					        WHERE c_id = '.$this->destination_course_id.' AND agenda_id = '.$id;
1412
-					$attachment_event = Database::query($sql);
1413
-					$attachment_event = Database::fetch_object($attachment_event);
1412
+                    $attachment_event = Database::query($sql);
1413
+                    $attachment_event = Database::fetch_object($attachment_event);
1414 1414
 
1415
-					if (file_exists($origin_path.$attachment_event->path) &&
1415
+                    if (file_exists($origin_path.$attachment_event->path) &&
1416 1416
                         !is_dir($origin_path.$attachment_event->path)
1417 1417
                     ) {
1418
-						$new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1419
-						$copy_result = copy($origin_path.$attachment_event->path, $destination_path.$new_filename);
1420
-						//$copy_result = true;
1421
-						if ($copy_result) {
1422
-							$table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1418
+                        $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1419
+                        $copy_result = copy($origin_path.$attachment_event->path, $destination_path.$new_filename);
1420
+                        //$copy_result = true;
1421
+                        if ($copy_result) {
1422
+                            $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1423 1423
 
1424
-							$params = [
1424
+                            $params = [
1425 1425
                                 'c_id' => $this->destination_course_id,
1426 1426
                                 'path' => self::DBUTF8($new_filename),
1427 1427
                                 'comment' => self::DBUTF8($attachment_event->comment),
@@ -1435,17 +1435,17 @@  discard block
 block discarded – undo
1435 1435
                                 Database::query($sql);
1436 1436
                             }
1437 1437
                         }
1438
-					}
1439
-				} else {
1440
-					// get the info of the file
1441
-					if (!empty($event->attachment_path) &&
1438
+                    }
1439
+                } else {
1440
+                    // get the info of the file
1441
+                    if (!empty($event->attachment_path) &&
1442 1442
                         is_file($origin_path.$event->attachment_path) &&
1443 1443
                         is_readable($origin_path.$event->attachment_path)
1444 1444
                     ) {
1445
-						$new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1446
-						$copy_result = copy($origin_path.$event->attachment_path, $destination_path.$new_filename);
1447
-						if ($copy_result) {
1448
-							$table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1445
+                        $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1446
+                        $copy_result = copy($origin_path.$event->attachment_path, $destination_path.$new_filename);
1447
+                        if ($copy_result) {
1448
+                            $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1449 1449
 
1450 1450
                             $params = [
1451 1451
                                 'c_id' => $this->destination_course_id,
@@ -1461,29 +1461,29 @@  discard block
 block discarded – undo
1461 1461
                                 $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $id";
1462 1462
                                 Database::query($sql);
1463 1463
                             }
1464
-						}
1465
-					}
1466
-				}
1467
-			}
1468
-		}
1469
-	}
1470
-
1471
-	/**
1472
-	 * Restore course-description
1473
-	 */
1464
+                        }
1465
+                    }
1466
+                }
1467
+            }
1468
+        }
1469
+    }
1470
+
1471
+    /**
1472
+     * Restore course-description
1473
+     */
1474 1474
     public function restore_course_descriptions($session_id = 0)
1475 1475
     {
1476
-		if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) {
1477
-			$table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION);
1478
-			$resources = $this->course->resources;
1479
-			foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) {
1476
+        if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) {
1477
+            $table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION);
1478
+            $resources = $this->course->resources;
1479
+            foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) {
1480 1480
                 $courseDescription = (array) $cd;
1481 1481
 
1482 1482
                 $content = isset($courseDescription['content']) ? $courseDescription['content'] : '';
1483 1483
                 $descriptionType = isset($courseDescription['description_type']) ? $courseDescription['description_type'] : '';
1484 1484
                 $title = isset($courseDescription['title']) ? $courseDescription['title'] : '';
1485 1485
 
1486
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
1486
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
1487 1487
                 $description_content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1488 1488
                     $content,
1489 1489
                     $this->course->code,
@@ -1512,22 +1512,22 @@  discard block
 block discarded – undo
1512 1512
                     }
1513 1513
                     $this->course->resources[RESOURCE_COURSEDESCRIPTION][$id]->destination_id = $id;
1514 1514
                 }
1515
-			}
1516
-		}
1517
-	}
1515
+            }
1516
+        }
1517
+    }
1518 1518
 
1519
-	/**
1520
-	 * Restore announcements
1521
-	 */
1519
+    /**
1520
+     * Restore announcements
1521
+     */
1522 1522
     public function restore_announcements($sessionId = 0)
1523 1523
     {
1524
-		if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) {
1524
+        if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) {
1525 1525
             $sessionId = intval($sessionId);
1526
-			$table = Database :: get_course_table(TABLE_ANNOUNCEMENT);
1527
-			$resources = $this->course->resources;
1528
-			foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) {
1526
+            $table = Database :: get_course_table(TABLE_ANNOUNCEMENT);
1527
+            $resources = $this->course->resources;
1528
+            foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) {
1529 1529
 
1530
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
1530
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
1531 1531
                 $announcement->content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1532 1532
                     $announcement->content,
1533 1533
                     $this->course->code,
@@ -1546,7 +1546,7 @@  discard block
 block discarded – undo
1546 1546
                     'session_id' => $sessionId,
1547 1547
                 ];
1548 1548
 
1549
-				$new_announcement_id = Database::insert($table, $params);
1549
+                $new_announcement_id = Database::insert($table, $params);
1550 1550
 
1551 1551
                 if ($new_announcement_id) {
1552 1552
                     $sql = "UPDATE $table SET id = iid WHERE iid = $new_announcement_id";
@@ -1558,32 +1558,32 @@  discard block
 block discarded – undo
1558 1558
                     $this->course->resources[RESOURCE_ANNOUNCEMENT][$id]->destination_id = $new_announcement_id;
1559 1559
                 }
1560 1560
 
1561
-				$origin_path = $this->course->backup_path.'/upload/announcements/';
1562
-				$destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/';
1561
+                $origin_path = $this->course->backup_path.'/upload/announcements/';
1562
+                $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/';
1563 1563
 
1564
-				// Copy announcement attachment file
1565
-				if (!empty($this->course->orig)) {
1564
+                // Copy announcement attachment file
1565
+                if (!empty($this->course->orig)) {
1566 1566
 
1567
-					$table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1568
-					$sql = 'SELECT path, comment, size, filename
1567
+                    $table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1568
+                    $sql = 'SELECT path, comment, size, filename
1569 1569
 					        FROM '.$table_attachment.'
1570 1570
 					        WHERE
1571 1571
 					            c_id = '.$this->destination_course_id.' AND
1572 1572
 					            announcement_id = '.$id;
1573
-					$attachment_event = Database::query($sql);
1574
-					$attachment_event = Database::fetch_object($attachment_event);
1573
+                    $attachment_event = Database::query($sql);
1574
+                    $attachment_event = Database::fetch_object($attachment_event);
1575 1575
 
1576
-					if (file_exists($origin_path.$attachment_event->path) &&
1576
+                    if (file_exists($origin_path.$attachment_event->path) &&
1577 1577
                         !is_dir($origin_path.$attachment_event->path)
1578 1578
                     ) {
1579
-						$new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1579
+                        $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1580 1580
                         $copy_result = copy(
1581 1581
                             $origin_path.$attachment_event->path,
1582 1582
                             $destination_path.$new_filename
1583 1583
                         );
1584 1584
 
1585
-						if ($copy_result) {
1586
-							$table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1585
+                        if ($copy_result) {
1586
+                            $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1587 1587
 
1588 1588
                             $params = [
1589 1589
                                 'c_id' => $this->destination_course_id,
@@ -1600,19 +1600,19 @@  discard block
 block discarded – undo
1600 1600
                                 $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId";
1601 1601
                                 Database::query($sql);
1602 1602
                             }
1603
-						}
1604
-					}
1605
-				} else {
1606
-					// get the info of the file
1607
-					if (!empty($announcement->attachment_path) &&
1603
+                        }
1604
+                    }
1605
+                } else {
1606
+                    // get the info of the file
1607
+                    if (!empty($announcement->attachment_path) &&
1608 1608
                         is_file($origin_path.$announcement->attachment_path) &&
1609 1609
                         is_readable($origin_path.$announcement->attachment_path)
1610 1610
                     ) {
1611
-						$new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1612
-						$copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename);
1611
+                        $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1612
+                        $copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename);
1613 1613
 
1614
-						if ($copy_result) {
1615
-							$table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1614
+                        if ($copy_result) {
1615
+                            $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1616 1616
 
1617 1617
                             $params = [
1618 1618
                                 'c_id' => $this->destination_course_id,
@@ -1629,12 +1629,12 @@  discard block
 block discarded – undo
1629 1629
                                 $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId";
1630 1630
                                 Database::query($sql);
1631 1631
                             }
1632
-						}
1633
-					}
1634
-				}
1635
-			}
1636
-		}
1637
-	}
1632
+                        }
1633
+                    }
1634
+                }
1635
+            }
1636
+        }
1637
+    }
1638 1638
 
1639 1639
     /**
1640 1640
      * Restore Quiz
@@ -1645,13 +1645,13 @@  discard block
 block discarded – undo
1645 1645
         $session_id = 0,
1646 1646
         $respect_base_content = false
1647 1647
     ) {
1648
-		if ($this->course->has_resources(RESOURCE_QUIZ)) {
1649
-			$table_qui = Database :: get_course_table(TABLE_QUIZ_TEST);
1650
-			$table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION);
1651
-			$table_doc = Database :: get_course_table(TABLE_DOCUMENT);
1652
-			$resources = $this->course->resources;
1648
+        if ($this->course->has_resources(RESOURCE_QUIZ)) {
1649
+            $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST);
1650
+            $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION);
1651
+            $table_doc = Database :: get_course_table(TABLE_DOCUMENT);
1652
+            $resources = $this->course->resources;
1653 1653
 
1654
-			foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) {
1654
+            foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) {
1655 1655
 
1656 1656
                 if (isset($quiz->obj)) {
1657 1657
                     //For new imports
@@ -1661,7 +1661,7 @@  discard block
 block discarded – undo
1661 1661
                     $quiz->obj = $quiz;
1662 1662
                 }
1663 1663
 
1664
-				$doc = '';
1664
+                $doc = '';
1665 1665
                 if (!empty($quiz->sound)) {
1666 1666
                     if (isset($this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]) &&
1667 1667
                         $this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]->is_restored()) {
@@ -1669,14 +1669,14 @@  discard block
 block discarded – undo
1669 1669
                                 WHERE
1670 1670
                                     c_id = " . $this->destination_course_id . "  AND
1671 1671
                                     id = " . $resources[RESOURCE_DOCUMENT][$quiz->sound]->destination_id;
1672
-						$doc = Database::query($sql);
1673
-						$doc = Database::fetch_object($doc);
1674
-						$doc = str_replace('/audio/', '', $doc->path);
1675
-					}
1676
-				}
1677
-
1678
-				if ($id != -1) {
1679
-					// check resources inside html from ckeditor tool and copy correct urls into recipient course
1672
+                        $doc = Database::query($sql);
1673
+                        $doc = Database::fetch_object($doc);
1674
+                        $doc = str_replace('/audio/', '', $doc->path);
1675
+                    }
1676
+                }
1677
+
1678
+                if ($id != -1) {
1679
+                    // check resources inside html from ckeditor tool and copy correct urls into recipient course
1680 1680
                     $quiz->description = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1681 1681
                         $quiz->description,
1682 1682
                         $this->course->code,
@@ -1688,13 +1688,13 @@  discard block
 block discarded – undo
1688 1688
                     $quiz->start_time = $quiz->start_time == '0000-00-00 00:00:00' ? null : $quiz->start_time;
1689 1689
                     $quiz->end_time = $quiz->end_time == '0000-00-00 00:00:00' ? null : $quiz->end_time;
1690 1690
 
1691
-					global $_custom;
1692
-					if (isset($_custom['exercises_clean_dates_when_restoring']) &&
1691
+                    global $_custom;
1692
+                    if (isset($_custom['exercises_clean_dates_when_restoring']) &&
1693 1693
                         $_custom['exercises_clean_dates_when_restoring']
1694 1694
                     ) {
1695
-						$quiz->start_time = null;
1696
-						$quiz->end_time   = null;
1697
-					}
1695
+                        $quiz->start_time = null;
1696
+                        $quiz->end_time   = null;
1697
+                    }
1698 1698
 
1699 1699
                     $params = array(
1700 1700
                         'c_id' => $this->destination_course_id,
@@ -1728,10 +1728,10 @@  discard block
 block discarded – undo
1728 1728
                         }
1729 1729
                         $params['session_id'] = $my_session_id;
1730 1730
                     } else {
1731
-        				if (!empty($session_id)) {
1732
-        					$session_id = intval($session_id);
1731
+                        if (!empty($session_id)) {
1732
+                            $session_id = intval($session_id);
1733 1733
                             $params['session_id'] = $session_id;
1734
-    				    }
1734
+                        }
1735 1735
                     }
1736 1736
                     $new_id = Database::insert($table_qui, $params);
1737 1737
 
@@ -1740,15 +1740,15 @@  discard block
 block discarded – undo
1740 1740
                         Database::query($sql);
1741 1741
                     }
1742 1742
 
1743
-				} else {
1744
-					// $id = -1 identifies the fictionary test for collecting
1745
-					// orphan questions. We do not store it in the database.
1746
-					$new_id = -1;
1747
-				}
1743
+                } else {
1744
+                    // $id = -1 identifies the fictionary test for collecting
1745
+                    // orphan questions. We do not store it in the database.
1746
+                    $new_id = -1;
1747
+                }
1748 1748
 
1749
-				$this->course->resources[RESOURCE_QUIZ][$id]->destination_id = $new_id;
1749
+                $this->course->resources[RESOURCE_QUIZ][$id]->destination_id = $new_id;
1750 1750
 
1751
-				$order = 0;
1751
+                $order = 0;
1752 1752
                 if (!empty($quiz->question_ids)) {
1753 1753
                     foreach ($quiz->question_ids as $index => $question_id) {
1754 1754
                         $qid = $this->restore_quiz_question($question_id);
@@ -1761,31 +1761,31 @@  discard block
 block discarded – undo
1761 1761
                         Database::query($sql);
1762 1762
                     }
1763 1763
                 }
1764
-			}
1765
-		}
1766
-	}
1764
+            }
1765
+        }
1766
+    }
1767 1767
 
1768
-	/**
1769
-	 * Restore quiz-questions
1768
+    /**
1769
+     * Restore quiz-questions
1770 1770
      * @params int question id
1771
-	 */
1771
+     */
1772 1772
     public function restore_quiz_question($id)
1773 1773
     {
1774 1774
         $em = Database::getManager();
1775
-		$resources = $this->course->resources;
1775
+        $resources = $this->course->resources;
1776 1776
         $question = isset($resources[RESOURCE_QUIZQUESTION][$id]) ? $resources[RESOURCE_QUIZQUESTION][$id] : null;
1777 1777
 
1778
-		$new_id = 0;
1778
+        $new_id = 0;
1779 1779
 
1780
-		if (is_object($question)) {
1781
-			if ($question->is_restored()) {
1782
-				return $question->destination_id;
1783
-			}
1784
-			$table_que = Database::get_course_table(TABLE_QUIZ_QUESTION);
1785
-			$table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER);
1780
+        if (is_object($question)) {
1781
+            if ($question->is_restored()) {
1782
+                return $question->destination_id;
1783
+            }
1784
+            $table_que = Database::get_course_table(TABLE_QUIZ_QUESTION);
1785
+            $table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER);
1786 1786
             $table_options = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION);
1787 1787
 
1788
-			// check resources inside html from ckeditor tool and copy correct urls into recipient course
1788
+            // check resources inside html from ckeditor tool and copy correct urls into recipient course
1789 1789
             $question->description = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1790 1790
                 $question->description,
1791 1791
                 $this->course->code,
@@ -1806,7 +1806,7 @@  discard block
 block discarded – undo
1806 1806
                 'extra' => self::DBUTF8($question->extra)
1807 1807
             ];
1808 1808
 
1809
-			$new_id = Database::insert($table_que, $params);
1809
+            $new_id = Database::insert($table_que, $params);
1810 1810
 
1811 1811
             if ($new_id) {
1812 1812
                 $sql = "UPDATE $table_que SET id = iid WHERE iid = $new_id";
@@ -1870,8 +1870,8 @@  discard block
 block discarded – undo
1870 1870
                         $em->merge($quizAnswer);
1871 1871
                         $em->flush();
1872 1872
                     }
1873
-				}
1874
-			} else {
1873
+                }
1874
+            } else {
1875 1875
                 $correct_answers = array();
1876 1876
                 $allAnswers = [];
1877 1877
                 if ($question->quiz_type == DRAGGABLE) {
@@ -1879,8 +1879,8 @@  discard block
 block discarded – undo
1879 1879
                 }
1880 1880
 
1881 1881
                 $onlyAnswers = [];
1882
-				foreach ($question->answers as $index => $answer) {
1883
-					// check resources inside html from ckeditor tool and copy correct urls into recipient course
1882
+                foreach ($question->answers as $index => $answer) {
1883
+                    // check resources inside html from ckeditor tool and copy correct urls into recipient course
1884 1884
                     $answer['answer'] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1885 1885
                         $answer['answer'],
1886 1886
                         $this->course->code,
@@ -1920,8 +1920,8 @@  discard block
 block discarded – undo
1920 1920
 
1921 1921
                     $correct_answers[$answerId] = $answer['correct'];
1922 1922
                     $onlyAnswers[$answerId] = $answer['answer'];
1923
-				}
1924
-			}
1923
+                }
1924
+            }
1925 1925
 
1926 1926
             // Current course id
1927 1927
             $course_id = api_get_course_int_id();
@@ -2041,13 +2041,13 @@  discard block
 block discarded – undo
2041 2041
                     }
2042 2042
                 }
2043 2043
             }
2044
-			$this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id;
2045
-		}
2044
+            $this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id;
2045
+        }
2046 2046
 
2047
-		return $new_id;
2048
-	}
2047
+        return $new_id;
2048
+    }
2049 2049
 
2050
-	/**
2050
+    /**
2051 2051
      * @todo : add session id when used for session
2052 2052
      */
2053 2053
     public function restore_test_category($session_id, $respect_base_content, $destination_course_code)
@@ -2132,21 +2132,21 @@  discard block
 block discarded – undo
2132 2132
         $sessionId = intval($sessionId);
2133 2133
 
2134 2134
         if ($this->course->has_resources(RESOURCE_SURVEY)) {
2135
-			$table_sur = Database :: get_course_table(TABLE_SURVEY);
2136
-			$table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2137
-			$table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2138
-			$resources = $this->course->resources;
2139
-			foreach ($resources[RESOURCE_SURVEY] as $id => $survey) {
2135
+            $table_sur = Database :: get_course_table(TABLE_SURVEY);
2136
+            $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2137
+            $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2138
+            $resources = $this->course->resources;
2139
+            foreach ($resources[RESOURCE_SURVEY] as $id => $survey) {
2140 2140
 
2141
-				$sql = 'SELECT survey_id FROM '.$table_sur.'
2141
+                $sql = 'SELECT survey_id FROM '.$table_sur.'
2142 2142
                         WHERE
2143 2143
                             c_id = '.$this->destination_course_id.' AND
2144 2144
                             code = "'.self::DBUTF8escapestring($survey->code).'" AND
2145 2145
                             lang = "'.self::DBUTF8escapestring($survey->lang).'" ';
2146 2146
 
2147
-				$result_check = Database::query($sql);
2147
+                $result_check = Database::query($sql);
2148 2148
 
2149
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
2149
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
2150 2150
                 $survey->title = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2151 2151
                     $survey->title,
2152 2152
                     $this->course->code,
@@ -2200,20 +2200,20 @@  discard block
 block discarded – undo
2200 2200
                     'session_id' => $sessionId
2201 2201
                 ];
2202 2202
 
2203
-				//An existing survey exists with the same code and the same language
2204
-				if (Database::num_rows($result_check) == 1) {
2205
-					switch ($this->file_option) {
2206
-						case FILE_SKIP:
2207
-							//Do nothing
2208
-							break;
2209
-						case FILE_RENAME:
2210
-							$survey_code = $survey->code.'_';
2211
-							$i=1;
2212
-							$temp_survey_code = $survey_code.$i;
2213
-							while (!$this->is_survey_code_available($temp_survey_code)) {
2214
-								$temp_survey_code = $survey_code.++$i;
2215
-							}
2216
-							$survey_code = $temp_survey_code;
2203
+                //An existing survey exists with the same code and the same language
2204
+                if (Database::num_rows($result_check) == 1) {
2205
+                    switch ($this->file_option) {
2206
+                        case FILE_SKIP:
2207
+                            //Do nothing
2208
+                            break;
2209
+                        case FILE_RENAME:
2210
+                            $survey_code = $survey->code.'_';
2211
+                            $i=1;
2212
+                            $temp_survey_code = $survey_code.$i;
2213
+                            while (!$this->is_survey_code_available($temp_survey_code)) {
2214
+                                $temp_survey_code = $survey_code.++$i;
2215
+                            }
2216
+                            $survey_code = $temp_survey_code;
2217 2217
 
2218 2218
                             $params['code'] = $survey_code;
2219 2219
                             $new_id = Database::insert($table_sur, $params);
@@ -2232,25 +2232,25 @@  discard block
 block discarded – undo
2232 2232
                                     Database::query($sql);
2233 2233
                                 }
2234 2234
                             }
2235
-							break;
2236
-						case FILE_OVERWRITE:
2237
-							// Delete the existing survey with the same code and language and import the one of the source course
2238
-							// getting the information of the survey (used for when the survey is shared)
2235
+                            break;
2236
+                        case FILE_OVERWRITE:
2237
+                            // Delete the existing survey with the same code and language and import the one of the source course
2238
+                            // getting the information of the survey (used for when the survey is shared)
2239 2239
 
2240
-							$sql = "SELECT * FROM $table_sur
2240
+                            $sql = "SELECT * FROM $table_sur
2241 2241
 							        WHERE
2242 2242
 							            c_id = ".$this->destination_course_id." AND
2243 2243
 							            survey_id='".self::DBUTF8escapestring(Database::result($result_check,0,0))."'";
2244
-							$result = Database::query($sql);
2245
-							$survey_data = Database::fetch_array($result,'ASSOC');
2244
+                            $result = Database::query($sql);
2245
+                            $survey_data = Database::fetch_array($result,'ASSOC');
2246 2246
 
2247
-							// if the survey is shared => also delete the shared content
2248
-							if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) {
2247
+                            // if the survey is shared => also delete the shared content
2248
+                            if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) {
2249 2249
                                 SurveyManager::delete_survey($survey_data['survey_share'], true,$this->destination_course_id);
2250
-							}
2251
-							SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id);
2250
+                            }
2251
+                            SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id);
2252 2252
 
2253
-							// Insert the new source survey
2253
+                            // Insert the new source survey
2254 2254
                             $new_id = Database::insert($table_sur, $params);
2255 2255
 
2256 2256
                             if ($new_id) {
@@ -2271,11 +2271,11 @@  discard block
 block discarded – undo
2271 2271
                                     Database::query($sql);
2272 2272
                                 }
2273 2273
                             }
2274
-							break;
2275
-						default:
2276
-							break;
2277
-					}
2278
-				} else {
2274
+                            break;
2275
+                        default:
2276
+                            break;
2277
+                    }
2278
+                } else {
2279 2279
                     // No existing survey with the same language and the same code, we just copy the survey
2280 2280
                     $new_id = Database::insert($table_sur, $params);
2281 2281
 
@@ -2297,48 +2297,48 @@  discard block
 block discarded – undo
2297 2297
                             Database::query($sql);
2298 2298
                         }
2299 2299
                     }
2300
-				}
2301
-			}
2302
-		}
2303
-	}
2304
-
2305
-	/**
2306
-	 * Check availability of a survey code
2307
-	 * @param string $survey_code
2308
-	 */
2300
+                }
2301
+            }
2302
+        }
2303
+    }
2304
+
2305
+    /**
2306
+     * Check availability of a survey code
2307
+     * @param string $survey_code
2308
+     */
2309 2309
     public function is_survey_code_available($survey_code)
2310 2310
     {
2311
-		$table_sur = Database :: get_course_table(TABLE_SURVEY);
2312
-		$sql = "SELECT * FROM $table_sur
2311
+        $table_sur = Database :: get_course_table(TABLE_SURVEY);
2312
+        $sql = "SELECT * FROM $table_sur
2313 2313
 		        WHERE
2314 2314
 		            c_id = ".$this->destination_course_id." AND
2315 2315
 		            code = '".self::DBUTF8escapestring($survey_code)."'";
2316
-		$result = Database::query($sql);
2316
+        $result = Database::query($sql);
2317 2317
         if (Database::num_rows($result) > 0) {
2318 2318
             return false;
2319 2319
         } else {
2320 2320
             return true;
2321 2321
         }
2322
-	}
2322
+    }
2323 2323
 
2324
-	/**
2325
-	 * Restore survey-questions
2326
-	 * @param string $survey_id
2327
-	 */
2324
+    /**
2325
+     * Restore survey-questions
2326
+     * @param string $survey_id
2327
+     */
2328 2328
     public function restore_survey_question($id, $survey_id)
2329 2329
     {
2330
-		$resources = $this->course->resources;
2331
-		$question = $resources[RESOURCE_SURVEYQUESTION][$id];
2330
+        $resources = $this->course->resources;
2331
+        $question = $resources[RESOURCE_SURVEYQUESTION][$id];
2332 2332
         $new_id = 0;
2333 2333
 
2334
-		if (is_object($question)) {
2335
-			if ($question->is_restored()) {
2336
-				return $question->destination_id;
2337
-			}
2338
-			$table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2339
-			$table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2334
+        if (is_object($question)) {
2335
+            if ($question->is_restored()) {
2336
+                return $question->destination_id;
2337
+            }
2338
+            $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2339
+            $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2340 2340
 
2341
-			// check resources inside html from ckeditor tool and copy correct urls into recipient course
2341
+            // check resources inside html from ckeditor tool and copy correct urls into recipient course
2342 2342
             $question->survey_question = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2343 2343
                 $question->survey_question,
2344 2344
                 $this->course->code,
@@ -2392,10 +2392,10 @@  discard block
 block discarded – undo
2392 2392
                 }
2393 2393
                 $this->course->resources[RESOURCE_SURVEYQUESTION][$id]->destination_id = $new_id;
2394 2394
             }
2395
-		}
2395
+        }
2396 2396
 
2397
-		return $new_id;
2398
-	}
2397
+        return $new_id;
2398
+    }
2399 2399
 
2400 2400
     /**
2401 2401
      * Restoring learning paths
@@ -2406,19 +2406,19 @@  discard block
 block discarded – undo
2406 2406
     {
2407 2407
         $session_id = intval($session_id);
2408 2408
 
2409
-		if ($this->course->has_resources(RESOURCE_LEARNPATH)) {
2409
+        if ($this->course->has_resources(RESOURCE_LEARNPATH)) {
2410 2410
             $table_main = Database::get_course_table(TABLE_LP_MAIN);
2411 2411
             $table_item = Database::get_course_table(TABLE_LP_ITEM);
2412 2412
             $table_tool = Database::get_course_table(TABLE_TOOL_LIST);
2413 2413
 
2414
-			$resources = $this->course->resources;
2414
+            $resources = $this->course->resources;
2415 2415
 
2416
-			$origin_path = $this->course->backup_path.'/upload/learning_path/images/';
2417
-			$destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/';
2416
+            $origin_path = $this->course->backup_path.'/upload/learning_path/images/';
2417
+            $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/';
2418 2418
 
2419
-			foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) {
2420
-				$condition_session = '';
2421
-				if (!empty($session_id)) {
2419
+            foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) {
2420
+                $condition_session = '';
2421
+                if (!empty($session_id)) {
2422 2422
                     if ($respect_base_content) {
2423 2423
                         $my_session_id = $lp->session_id;
2424 2424
                         if (!empty($lp->session_id)) {
@@ -2429,20 +2429,20 @@  discard block
 block discarded – undo
2429 2429
                         $session_id = intval($session_id);
2430 2430
                         $condition_session = $session_id;
2431 2431
                     }
2432
-				}
2433
-
2434
-				// Adding the author's image
2435
-				if (!empty($lp->preview_image)) {
2436
-					$new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image));
2437
-					if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) {
2438
-						$copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename);
2439
-						if ($copy_result) {
2440
-							$lp->preview_image = $new_filename;
2441
-						} else {
2442
-							$lp->preview_image ='';
2443
-						}
2444
-					}
2445
-				}
2432
+                }
2433
+
2434
+                // Adding the author's image
2435
+                if (!empty($lp->preview_image)) {
2436
+                    $new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image));
2437
+                    if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) {
2438
+                        $copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename);
2439
+                        if ($copy_result) {
2440
+                            $lp->preview_image = $new_filename;
2441
+                        } else {
2442
+                            $lp->preview_image ='';
2443
+                        }
2444
+                    }
2445
+                }
2446 2446
 
2447 2447
                 if ($this->add_text_in_items) {
2448 2448
                     $lp->name = $lp->name.' '.get_lang('CopyLabelSuffix');
@@ -2500,7 +2500,7 @@  discard block
 block discarded – undo
2500 2500
                     $params['session_id'] = $condition_session;
2501 2501
                 }
2502 2502
 
2503
-				$new_lp_id = Database::insert($table_main, $params);
2503
+                $new_lp_id = Database::insert($table_main, $params);
2504 2504
 
2505 2505
                 if ($new_lp_id) {
2506 2506
 
@@ -2561,13 +2561,13 @@  discard block
 block discarded – undo
2561 2561
                 $old_refs = array();
2562 2562
                 $prerequisite_ids = array();
2563 2563
 
2564
-				foreach ($lp->get_items() as $index => $item) {
2565
-					// we set the ref code here and then we update in a for loop
2566
-					$ref = $item['ref'];
2564
+                foreach ($lp->get_items() as $index => $item) {
2565
+                    // we set the ref code here and then we update in a for loop
2566
+                    $ref = $item['ref'];
2567 2567
 
2568
-					// Dealing with path the same way as ref as some data has
2568
+                    // Dealing with path the same way as ref as some data has
2569 2569
                     // been put into path when it's a local resource
2570
-					// Only fix the path for no scos
2570
+                    // Only fix the path for no scos
2571 2571
                     if ($item['item_type'] == 'sco') {
2572 2572
                         $path = $item['path'];
2573 2573
                     } else {
@@ -2598,128 +2598,128 @@  discard block
 block discarded – undo
2598 2598
                         'launch_data' => self::DBUTF8($item['launch_data']),
2599 2599
                     ];
2600 2600
 
2601
-					$new_item_id = Database::insert($table_item, $params);
2601
+                    $new_item_id = Database::insert($table_item, $params);
2602 2602
 
2603 2603
                     $sql = "UPDATE $table_item SET id = iid WHERE iid = $new_item_id";
2604 2604
                     Database::query($sql);
2605 2605
 
2606
-					//save a link between old and new item IDs
2607
-					$new_item_ids[$item['id']] = $new_item_id;
2608
-					//save a reference of items that need a parent_item_id refresh
2609
-					$parent_item_ids[$new_item_id] = $item['parent_item_id'];
2610
-					//save a reference of items that need a previous_item_id refresh
2611
-					$previous_item_ids[$new_item_id] = $item['previous_item_id'];
2612
-					//save a reference of items that need a next_item_id refresh
2613
-					$next_item_ids[$new_item_id] = $item['next_item_id'];
2614
-
2615
-					if (!empty($item['prerequisite'])) {
2616
-						if ($lp->lp_type =='2') {
2617
-							// if is an sco
2618
-							$old_prerequisite[$new_item_id]= $item['prerequisite'];
2619
-						} else {
2620
-							$old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']];
2621
-						}
2622
-					}
2623
-
2624
-					if (!empty($ref)) {
2625
-						if ($lp->lp_type =='2') {
2626
-							// if is an sco
2627
-							$old_refs[$new_item_id]= $ref;
2628
-						} elseif (isset($new_item_ids[$ref])) {
2606
+                    //save a link between old and new item IDs
2607
+                    $new_item_ids[$item['id']] = $new_item_id;
2608
+                    //save a reference of items that need a parent_item_id refresh
2609
+                    $parent_item_ids[$new_item_id] = $item['parent_item_id'];
2610
+                    //save a reference of items that need a previous_item_id refresh
2611
+                    $previous_item_ids[$new_item_id] = $item['previous_item_id'];
2612
+                    //save a reference of items that need a next_item_id refresh
2613
+                    $next_item_ids[$new_item_id] = $item['next_item_id'];
2614
+
2615
+                    if (!empty($item['prerequisite'])) {
2616
+                        if ($lp->lp_type =='2') {
2617
+                            // if is an sco
2618
+                            $old_prerequisite[$new_item_id]= $item['prerequisite'];
2619
+                        } else {
2620
+                            $old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']];
2621
+                        }
2622
+                    }
2623
+
2624
+                    if (!empty($ref)) {
2625
+                        if ($lp->lp_type =='2') {
2626
+                            // if is an sco
2627
+                            $old_refs[$new_item_id]= $ref;
2628
+                        } elseif (isset($new_item_ids[$ref])) {
2629 2629
                             $old_refs[$new_item_id]= $new_item_ids[$ref];
2630 2630
                         }
2631
-					}
2631
+                    }
2632 2632
 
2633
-					$prerequisite_ids[$new_item_id] = $item['prerequisite'];
2634
-				}
2633
+                    $prerequisite_ids[$new_item_id] = $item['prerequisite'];
2634
+                }
2635 2635
 
2636
-				// Updating prerequisites
2637
-				foreach ($old_prerequisite  as $key=>$my_old_prerequisite) {
2638
-					if ($my_old_prerequisite != ''){
2639
-						$sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."'
2636
+                // Updating prerequisites
2637
+                foreach ($old_prerequisite  as $key=>$my_old_prerequisite) {
2638
+                    if ($my_old_prerequisite != ''){
2639
+                        $sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."'
2640 2640
 						        WHERE c_id = ".$this->destination_course_id." AND id = '".$key."'  ";
2641
-						Database::query($sql);
2642
-					}
2643
-				}
2644
-
2645
-				// Updating refs
2646
-				foreach ($old_refs  as $key=>$my_old_ref) {
2647
-					if ($my_old_ref != '') {
2648
-						$sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."'
2641
+                        Database::query($sql);
2642
+                    }
2643
+                }
2644
+
2645
+                // Updating refs
2646
+                foreach ($old_refs  as $key=>$my_old_ref) {
2647
+                    if ($my_old_ref != '') {
2648
+                        $sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."'
2649 2649
 						        WHERE c_id = ".$this->destination_course_id." AND id = '".$key."'  ";
2650
-						Database::query($sql);
2651
-					}
2652
-				}
2653
-
2654
-				foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) {
2655
-					$parent_new_id = 0;
2656
-					if($parent_item_old_id != 0){
2657
-						$parent_new_id = $new_item_ids[$parent_item_old_id];
2658
-					}
2659
-					$sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."'
2650
+                        Database::query($sql);
2651
+                    }
2652
+                }
2653
+
2654
+                foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) {
2655
+                    $parent_new_id = 0;
2656
+                    if($parent_item_old_id != 0){
2657
+                        $parent_new_id = $new_item_ids[$parent_item_old_id];
2658
+                    }
2659
+                    $sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."'
2660 2660
 					        WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'";
2661
-					Database::query($sql);
2662
-				}
2663
-				foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) {
2664
-					$previous_new_id = 0;
2665
-					if ($previous_item_old_id != 0){
2666
-						$previous_new_id = $new_item_ids[$previous_item_old_id];
2667
-					}
2668
-					$sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."'
2661
+                    Database::query($sql);
2662
+                }
2663
+                foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) {
2664
+                    $previous_new_id = 0;
2665
+                    if ($previous_item_old_id != 0){
2666
+                        $previous_new_id = $new_item_ids[$previous_item_old_id];
2667
+                    }
2668
+                    $sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."'
2669 2669
 					        WHERE  c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'";
2670
-					Database::query($sql);
2671
-				}
2672
-
2673
-				foreach ($next_item_ids as $new_item_id => $next_item_old_id) {
2674
-					$next_new_id = 0;
2675
-					if ($next_item_old_id != 0){
2676
-						$next_new_id = $new_item_ids[$next_item_old_id];
2677
-					}
2678
-					$sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."'
2670
+                    Database::query($sql);
2671
+                }
2672
+
2673
+                foreach ($next_item_ids as $new_item_id => $next_item_old_id) {
2674
+                    $next_new_id = 0;
2675
+                    if ($next_item_old_id != 0){
2676
+                        $next_new_id = $new_item_ids[$next_item_old_id];
2677
+                    }
2678
+                    $sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."'
2679 2679
 					        WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'";
2680
-					Database::query($sql);
2681
-				}
2682
-
2683
-				foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) {
2684
-					$prerequisite_new_id = 0;
2685
-					if ($prerequisite_old_id != 0){
2686
-						$prerequisite_new_id = $new_item_ids[$prerequisite_old_id];
2687
-					}
2688
-					$sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."'
2680
+                    Database::query($sql);
2681
+                }
2682
+
2683
+                foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) {
2684
+                    $prerequisite_new_id = 0;
2685
+                    if ($prerequisite_old_id != 0){
2686
+                        $prerequisite_new_id = $new_item_ids[$prerequisite_old_id];
2687
+                    }
2688
+                    $sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."'
2689 2689
 					        WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'";
2690
-					Database::query($sql);
2691
-				}
2692
-				$this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id;
2693
-			}
2694
-		}
2695
-	}
2696
-
2697
-	/**
2698
-	 * Restore works
2690
+                    Database::query($sql);
2691
+                }
2692
+                $this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id;
2693
+            }
2694
+        }
2695
+    }
2696
+
2697
+    /**
2698
+     * Restore works
2699 2699
      * @deprecated use restore_works
2700 2700
      *
2701
-	 */
2702
-	public function restore_student_publication($sessionId = 0)
2701
+     */
2702
+    public function restore_student_publication($sessionId = 0)
2703 2703
     {
2704 2704
         $sessionId = intval($sessionId);
2705 2705
         $work_assignment_table = Database:: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
2706 2706
         $work_table = Database:: get_course_table(TABLE_STUDENT_PUBLICATION);
2707 2707
         $item_property_table = Database:: get_course_table(TABLE_ITEM_PROPERTY);
2708 2708
 
2709
-		// Query in student publication
2710
-		$sql = 'SELECT * FROM '.$work_table.'
2709
+        // Query in student publication
2710
+        $sql = 'SELECT * FROM '.$work_table.'
2711 2711
 		        WHERE c_id = '.$this->course_origin_id.' AND filetype = "folder" AND active IN (0, 1) ';
2712 2712
 
2713
-		$result = Database::query($sql);
2714
-		$folders = Database::store_result($result, 'ASSOC');
2713
+        $result = Database::query($sql);
2714
+        $folders = Database::store_result($result, 'ASSOC');
2715 2715
 
2716
-		foreach ($folders  as $folder) {
2717
-		    $old_id = $folder['id'];
2716
+        foreach ($folders  as $folder) {
2717
+            $old_id = $folder['id'];
2718 2718
             unset($folder['id']);
2719
-			$folder['c_id'] = $this->destination_course_id;
2719
+            $folder['c_id'] = $this->destination_course_id;
2720 2720
             $folder['parent_id'] = 0;
2721 2721
             $folder['session_id'] = $sessionId ? $sessionId : null;
2722
-			$new_id = Database::insert($work_table, $folder);
2722
+            $new_id = Database::insert($work_table, $folder);
2723 2723
 
2724 2724
             if ($new_id) {
2725 2725
                 // query in item property
@@ -2778,23 +2778,23 @@  discard block
 block discarded – undo
2778 2778
                     }
2779 2779
                 }
2780 2780
             }
2781
-		}
2781
+        }
2782 2782
 
2783 2783
         $destination = '../..'.api_get_path(REL_COURSE_PATH).$this->course->destination_path.'/work/';
2784 2784
         $origin = '../..'.api_get_path(REL_COURSE_PATH).$this->course->info['path'].'/work/';
2785 2785
         self::allow_create_all_directory($origin, $destination, false);
2786
-	}
2786
+    }
2787 2787
 
2788 2788
     /**
2789
-    * copy all directory and sub directory
2790
-    * @param string The path origin
2791
-    * @param string The path destination
2792
-    * @param boolean Option Overwrite
2793
-    * @param string $source
2794
-    * @param string $dest
2795
-    * @return void()
2796
-    * @deprecated
2797
-    */
2789
+     * copy all directory and sub directory
2790
+     * @param string The path origin
2791
+     * @param string The path destination
2792
+     * @param boolean Option Overwrite
2793
+     * @param string $source
2794
+     * @param string $dest
2795
+     * @return void()
2796
+     * @deprecated
2797
+     */
2798 2798
     public function allow_create_all_directory($source, $dest, $overwrite = false)
2799 2799
     {
2800 2800
         if (!is_dir($dest)) {
@@ -2805,7 +2805,7 @@  discard block
 block discarded – undo
2805 2805
                 if ($file != '.' && $file != '..') {
2806 2806
                     $path = $source . '/' . $file;
2807 2807
                     if (is_file($path)) {
2808
-                       /* if (!is_file($dest . '/' . $file) || $overwrite)
2808
+                        /* if (!is_file($dest . '/' . $file) || $overwrite)
2809 2809
                         if (!@copy($path, $dest . '/' . $file)) {
2810 2810
                             echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>';
2811 2811
                         }*/
@@ -2820,12 +2820,12 @@  discard block
 block discarded – undo
2820 2820
         }
2821 2821
     }
2822 2822
 
2823
-	/**
2824
-	 * Gets the new ID of one specific tool item from the tool name and the old ID
2825
-	 * @param	string	Tool name
2826
-	 * @param	integer	Old ID
2827
-	 * @return	integer	New ID
2828
-	 */
2823
+    /**
2824
+     * Gets the new ID of one specific tool item from the tool name and the old ID
2825
+     * @param	string	Tool name
2826
+     * @param	integer	Old ID
2827
+     * @return	integer	New ID
2828
+     */
2829 2829
     public function get_new_id($tool, $ref)
2830 2830
     {
2831 2831
         // Check if the value exist in the current array.
@@ -2847,25 +2847,25 @@  discard block
 block discarded – undo
2847 2847
         }
2848 2848
 
2849 2849
         return '';
2850
-	}
2850
+    }
2851 2851
 
2852
-	/**
2853
-	 * Restore glossary
2854
-	 */
2852
+    /**
2853
+     * Restore glossary
2854
+     */
2855 2855
     public function restore_glossary($session_id = 0)
2856 2856
     {
2857
-		if ($this->course->has_resources(RESOURCE_GLOSSARY)) {
2858
-			$table_glossary = Database :: get_course_table(TABLE_GLOSSARY);
2859
-			$resources = $this->course->resources;
2860
-			foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) {
2857
+        if ($this->course->has_resources(RESOURCE_GLOSSARY)) {
2858
+            $table_glossary = Database :: get_course_table(TABLE_GLOSSARY);
2859
+            $resources = $this->course->resources;
2860
+            foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) {
2861 2861
 
2862 2862
                 $params = [];
2863
-    			if (!empty($session_id)) {
2864
-    				$session_id = intval($session_id);
2863
+                if (!empty($session_id)) {
2864
+                    $session_id = intval($session_id);
2865 2865
                     $params['session_id'] = $session_id;
2866
-    			}
2866
+                }
2867 2867
 
2868
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
2868
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
2869 2869
                 $glossary->description = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2870 2870
                     $glossary->description,
2871 2871
                     $this->course->code,
@@ -2899,27 +2899,27 @@  discard block
 block discarded – undo
2899 2899
 
2900 2900
                     $this->course->resources[RESOURCE_GLOSSARY][$id]->destination_id = $my_id;
2901 2901
                 }
2902
-			}
2903
-		}
2904
-	}
2902
+            }
2903
+        }
2904
+    }
2905 2905
 
2906 2906
     /**
2907 2907
      * @param int $session_id
2908 2908
      */
2909 2909
     public function restore_wiki($session_id = 0)
2910 2910
     {
2911
-		if ($this->course->has_resources(RESOURCE_WIKI)) {
2912
-			// wiki table of the target course
2913
-			$table_wiki = Database :: get_course_table(TABLE_WIKI);
2914
-			$table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF);
2911
+        if ($this->course->has_resources(RESOURCE_WIKI)) {
2912
+            // wiki table of the target course
2913
+            $table_wiki = Database :: get_course_table(TABLE_WIKI);
2914
+            $table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF);
2915 2915
 
2916
-			// storing all the resources that have to be copied in an array
2917
-			$resources = $this->course->resources;
2916
+            // storing all the resources that have to be copied in an array
2917
+            $resources = $this->course->resources;
2918 2918
 
2919
-			foreach ($resources[RESOURCE_WIKI] as $id => $wiki) {
2920
-				// the sql statement to insert the groups from the old course to the new course
2919
+            foreach ($resources[RESOURCE_WIKI] as $id => $wiki) {
2920
+                // the sql statement to insert the groups from the old course to the new course
2921 2921
 
2922
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
2922
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
2923 2923
                 $wiki->content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2924 2924
                     $wiki->content,
2925 2925
                     $this->course->code,
@@ -2954,7 +2954,7 @@  discard block
 block discarded – undo
2954 2954
                     'user_ip' => ''
2955 2955
                 ];
2956 2956
 
2957
-				$new_id = Database::insert($table_wiki, $params);
2957
+                $new_id = Database::insert($table_wiki, $params);
2958 2958
 
2959 2959
                 if ($new_id) {
2960 2960
                     $sql = "UPDATE $table_wiki SET page_id = '$new_id', id = iid
@@ -2984,9 +2984,9 @@  discard block
 block discarded – undo
2984 2984
 
2985 2985
                     Database::insert($table_wiki_conf, $params);
2986 2986
                 }
2987
-			}
2988
-		}
2989
-	}
2987
+            }
2988
+        }
2989
+    }
2990 2990
 
2991 2991
     /**
2992 2992
      * Restore Thematics
@@ -2994,15 +2994,15 @@  discard block
 block discarded – undo
2994 2994
      */
2995 2995
     public function restore_thematic($session_id = 0)
2996 2996
     {
2997
-		if ($this->course->has_resources(RESOURCE_THEMATIC)) {
2997
+        if ($this->course->has_resources(RESOURCE_THEMATIC)) {
2998 2998
             $table_thematic = Database::get_course_table(TABLE_THEMATIC);
2999 2999
             $table_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
3000 3000
             $table_thematic_plan = Database::get_course_table(TABLE_THEMATIC_PLAN);
3001 3001
 
3002
-			$resources = $this->course->resources;
3003
-			foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) {
3002
+            $resources = $this->course->resources;
3003
+            foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) {
3004 3004
 
3005
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
3005
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
3006 3006
                 $thematic->params['content'] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
3007 3007
                     $thematic->params['content'],
3008 3008
                     $this->course->code,
@@ -3010,13 +3010,13 @@  discard block
 block discarded – undo
3010 3010
                     $this->course->backup_path,
3011 3011
                     $this->course->info['path']
3012 3012
                 );
3013
-				$thematic->params['c_id']  = $this->destination_course_id;
3014
-				unset($thematic->params['id']);
3013
+                $thematic->params['c_id']  = $this->destination_course_id;
3014
+                unset($thematic->params['id']);
3015 3015
                 unset($thematic->params['iid']);
3016 3016
 
3017
-				$last_id = Database::insert($table_thematic, $thematic->params, false);
3017
+                $last_id = Database::insert($table_thematic, $thematic->params, false);
3018 3018
 
3019
-				if ($last_id) {
3019
+                if ($last_id) {
3020 3020
 
3021 3021
                     $sql = "UPDATE $table_thematic SET id = iid WHERE iid = $last_id";
3022 3022
                     Database::query($sql);
@@ -3029,12 +3029,12 @@  discard block
 block discarded – undo
3029 3029
                         api_get_user_id()
3030 3030
                     );
3031 3031
 
3032
-					foreach ($thematic->thematic_advance_list as $thematic_advance) {
3033
-						unset($thematic_advance['id']);
3032
+                    foreach ($thematic->thematic_advance_list as $thematic_advance) {
3033
+                        unset($thematic_advance['id']);
3034 3034
                         unset($thematic_advance['iid']);
3035
-						$thematic_advance['attendance_id'] = 0;
3036
-						$thematic_advance['thematic_id'] = $last_id;
3037
-						$thematic_advance['c_id']  = $this->destination_course_id;
3035
+                        $thematic_advance['attendance_id'] = 0;
3036
+                        $thematic_advance['thematic_id'] = $last_id;
3037
+                        $thematic_advance['c_id']  = $this->destination_course_id;
3038 3038
 
3039 3039
                         $my_id = Database::insert(
3040 3040
                             $table_thematic_advance,
@@ -3042,7 +3042,7 @@  discard block
 block discarded – undo
3042 3042
                             false
3043 3043
                         );
3044 3044
 
3045
-						if ($my_id) {
3045
+                        if ($my_id) {
3046 3046
 
3047 3047
                             $sql = "UPDATE $table_thematic_advance SET id = iid WHERE iid = $my_id";
3048 3048
                             Database::query($sql);
@@ -3054,17 +3054,17 @@  discard block
 block discarded – undo
3054 3054
                                 'ThematicAdvanceAdded',
3055 3055
                                 api_get_user_id()
3056 3056
                             );
3057
-						}
3058
-					}
3057
+                        }
3058
+                    }
3059 3059
 
3060
-					foreach($thematic->thematic_plan_list as $thematic_plan) {
3061
-						unset($thematic_plan['id']);
3060
+                    foreach($thematic->thematic_plan_list as $thematic_plan) {
3061
+                        unset($thematic_plan['id']);
3062 3062
                         unset($thematic_plan['iid']);
3063
-						$thematic_plan['thematic_id'] = $last_id;
3064
-						$thematic_plan['c_id'] = $this->destination_course_id;
3065
-						$my_id = Database::insert($table_thematic_plan, $thematic_plan, false);
3063
+                        $thematic_plan['thematic_id'] = $last_id;
3064
+                        $thematic_plan['c_id'] = $this->destination_course_id;
3065
+                        $my_id = Database::insert($table_thematic_plan, $thematic_plan, false);
3066 3066
 
3067
-						if ($my_id) {
3067
+                        if ($my_id) {
3068 3068
 
3069 3069
                             $sql = "UPDATE $table_thematic_plan SET id = iid WHERE iid = $my_id";
3070 3070
                             Database::query($sql);
@@ -3076,12 +3076,12 @@  discard block
 block discarded – undo
3076 3076
                                 'ThematicPlanAdded',
3077 3077
                                 api_get_user_id()
3078 3078
                             );
3079
-						}
3080
-					}
3081
-				}
3082
-			}
3083
-		}
3084
-	}
3079
+                        }
3080
+                    }
3081
+                }
3082
+            }
3083
+        }
3084
+    }
3085 3085
 
3086 3086
     /**
3087 3087
      * Restore Attendance
@@ -3089,14 +3089,14 @@  discard block
 block discarded – undo
3089 3089
      */
3090 3090
     public function restore_attendance($session_id = 0)
3091 3091
     {
3092
-		if ($this->course->has_resources(RESOURCE_ATTENDANCE)) {
3093
-			$table_attendance = Database :: get_course_table(TABLE_ATTENDANCE);
3094
-			$table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR);
3092
+        if ($this->course->has_resources(RESOURCE_ATTENDANCE)) {
3093
+            $table_attendance = Database :: get_course_table(TABLE_ATTENDANCE);
3094
+            $table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR);
3095 3095
 
3096
-			$resources = $this->course->resources;
3097
-			foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) {
3096
+            $resources = $this->course->resources;
3097
+            foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) {
3098 3098
 
3099
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
3099
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
3100 3100
                 $obj->params['description'] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
3101 3101
                     $obj->params['description'],
3102 3102
                     $this->course->code,
@@ -3108,11 +3108,11 @@  discard block
 block discarded – undo
3108 3108
                 unset($obj->params['id']);
3109 3109
                 unset($obj->params['iid']);
3110 3110
 
3111
-				$obj->params['c_id'] = $this->destination_course_id;
3111
+                $obj->params['c_id'] = $this->destination_course_id;
3112 3112
 
3113
-				$last_id = Database::insert($table_attendance, $obj->params);
3113
+                $last_id = Database::insert($table_attendance, $obj->params);
3114 3114
 
3115
-				if (is_numeric($last_id)) {
3115
+                if (is_numeric($last_id)) {
3116 3116
 
3117 3117
                     $sql = "UPDATE $table_attendance SET id = iid WHERE iid = $last_id";
3118 3118
                     Database::query($sql);
@@ -3126,11 +3126,11 @@  discard block
 block discarded – undo
3126 3126
                     );
3127 3127
 
3128 3128
                     foreach ($obj->attendance_calendar as $attendance_calendar) {
3129
-						unset($attendance_calendar['id']);
3129
+                        unset($attendance_calendar['id']);
3130 3130
                         unset($attendance_calendar['iid']);
3131 3131
 
3132
-						$attendance_calendar['attendance_id'] = $last_id;
3133
-						$attendance_calendar['c_id'] = $this->destination_course_id;
3132
+                        $attendance_calendar['attendance_id'] = $last_id;
3133
+                        $attendance_calendar['c_id'] = $this->destination_course_id;
3134 3134
                         $attendanceCalendarId = Database::insert(
3135 3135
                             $table_attendance_calendar,
3136 3136
                             $attendance_calendar
@@ -3138,11 +3138,11 @@  discard block
 block discarded – undo
3138 3138
 
3139 3139
                         $sql = "UPDATE $table_attendance_calendar SET id = iid WHERE iid = $attendanceCalendarId";
3140 3140
                         Database::query($sql);
3141
-					}
3142
-				}
3143
-			}
3144
-		}
3145
-	}
3141
+                    }
3142
+                }
3143
+            }
3144
+        }
3145
+    }
3146 3146
 
3147 3147
     /**
3148 3148
      * Restore Works
@@ -3283,11 +3283,11 @@  discard block
 block discarded – undo
3283 3283
      */
3284 3284
     public function DBUTF8($str)
3285 3285
     {
3286
-		if (UTF8_CONVERT) {
3286
+        if (UTF8_CONVERT) {
3287 3287
             $str = utf8_encode($str);
3288 3288
         }
3289
-		return $str;
3290
-	}
3289
+        return $str;
3290
+    }
3291 3291
 
3292 3292
     /**
3293 3293
      * @param string $str
@@ -3298,8 +3298,8 @@  discard block
 block discarded – undo
3298 3298
         if (UTF8_CONVERT) {
3299 3299
             $str = utf8_encode($str);
3300 3300
         }
3301
-		return Database::escape_string($str);
3302
-	}
3301
+        return Database::escape_string($str);
3302
+    }
3303 3303
 
3304 3304
     /**
3305 3305
      * @param array $array
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 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
                 }
@@ -1829,7 +1829,7 @@  discard block
 block discarded – undo
1829 1829
                             $sql = "UPDATE $table_que SET
1830 1830
                                         picture = '$picture_name'
1831 1831
                                     WHERE
1832
-                                        c_id = " . $this->destination_course_id . " AND
1832
+                                        c_id = ".$this->destination_course_id." AND
1833 1833
                                         id = $new_id ";
1834 1834
                             Database::query($sql);
1835 1835
                         }
@@ -2057,7 +2057,7 @@  discard block
 block discarded – undo
2057 2057
         $tab_test_category_id_old_new = array(); // used to build the quiz_question_rel_category table
2058 2058
         if ($this->course->has_resources(RESOURCE_TEST_CATEGORY)) {
2059 2059
             $resources = $this->course->resources;
2060
-            foreach ($resources[RESOURCE_TEST_CATEGORY] as $id => $CourseCopyTestCategory ) {
2060
+            foreach ($resources[RESOURCE_TEST_CATEGORY] as $id => $CourseCopyTestCategory) {
2061 2061
                 $tab_test_category_id_old_new[$CourseCopyTestCategory->source_id] = $id;
2062 2062
                 // check if this test_category already exist in the destination BDD
2063 2063
                 // do not Database::escape_string $title and $description, it will be done later
@@ -2208,7 +2208,7 @@  discard block
 block discarded – undo
2208 2208
 							break;
2209 2209
 						case FILE_RENAME:
2210 2210
 							$survey_code = $survey->code.'_';
2211
-							$i=1;
2211
+							$i = 1;
2212 2212
 							$temp_survey_code = $survey_code.$i;
2213 2213
 							while (!$this->is_survey_code_available($temp_survey_code)) {
2214 2214
 								$temp_survey_code = $survey_code.++$i;
@@ -2240,15 +2240,15 @@  discard block
 block discarded – undo
2240 2240
 							$sql = "SELECT * FROM $table_sur
2241 2241
 							        WHERE
2242 2242
 							            c_id = ".$this->destination_course_id." AND
2243
-							            survey_id='".self::DBUTF8escapestring(Database::result($result_check,0,0))."'";
2243
+							            survey_id='".self::DBUTF8escapestring(Database::result($result_check, 0, 0))."'";
2244 2244
 							$result = Database::query($sql);
2245
-							$survey_data = Database::fetch_array($result,'ASSOC');
2245
+							$survey_data = Database::fetch_array($result, 'ASSOC');
2246 2246
 
2247 2247
 							// if the survey is shared => also delete the shared content
2248 2248
 							if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) {
2249
-                                SurveyManager::delete_survey($survey_data['survey_share'], true,$this->destination_course_id);
2249
+                                SurveyManager::delete_survey($survey_data['survey_share'], true, $this->destination_course_id);
2250 2250
 							}
2251
-							SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id);
2251
+							SurveyManager :: delete_survey($survey_data['survey_id'], false, $this->destination_course_id);
2252 2252
 
2253 2253
 							// Insert the new source survey
2254 2254
                             $new_id = Database::insert($table_sur, $params);
@@ -2433,13 +2433,13 @@  discard block
 block discarded – undo
2433 2433
 
2434 2434
 				// Adding the author's image
2435 2435
 				if (!empty($lp->preview_image)) {
2436
-					$new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image));
2436
+					$new_filename = uniqid('').substr($lp->preview_image, strlen($lp->preview_image) - 7, strlen($lp->preview_image));
2437 2437
 					if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) {
2438 2438
 						$copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename);
2439 2439
 						if ($copy_result) {
2440 2440
 							$lp->preview_image = $new_filename;
2441 2441
 						} else {
2442
-							$lp->preview_image ='';
2442
+							$lp->preview_image = '';
2443 2443
 						}
2444 2444
 					}
2445 2445
 				}
@@ -2613,20 +2613,20 @@  discard block
 block discarded – undo
2613 2613
 					$next_item_ids[$new_item_id] = $item['next_item_id'];
2614 2614
 
2615 2615
 					if (!empty($item['prerequisite'])) {
2616
-						if ($lp->lp_type =='2') {
2616
+						if ($lp->lp_type == '2') {
2617 2617
 							// if is an sco
2618
-							$old_prerequisite[$new_item_id]= $item['prerequisite'];
2618
+							$old_prerequisite[$new_item_id] = $item['prerequisite'];
2619 2619
 						} else {
2620
-							$old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']];
2620
+							$old_prerequisite[$new_item_id] = $new_item_ids[$item['prerequisite']];
2621 2621
 						}
2622 2622
 					}
2623 2623
 
2624 2624
 					if (!empty($ref)) {
2625
-						if ($lp->lp_type =='2') {
2625
+						if ($lp->lp_type == '2') {
2626 2626
 							// if is an sco
2627
-							$old_refs[$new_item_id]= $ref;
2627
+							$old_refs[$new_item_id] = $ref;
2628 2628
 						} elseif (isset($new_item_ids[$ref])) {
2629
-                            $old_refs[$new_item_id]= $new_item_ids[$ref];
2629
+                            $old_refs[$new_item_id] = $new_item_ids[$ref];
2630 2630
                         }
2631 2631
 					}
2632 2632
 
@@ -2635,7 +2635,7 @@  discard block
 block discarded – undo
2635 2635
 
2636 2636
 				// Updating prerequisites
2637 2637
 				foreach ($old_prerequisite  as $key=>$my_old_prerequisite) {
2638
-					if ($my_old_prerequisite != ''){
2638
+					if ($my_old_prerequisite != '') {
2639 2639
 						$sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."'
2640 2640
 						        WHERE c_id = ".$this->destination_course_id." AND id = '".$key."'  ";
2641 2641
 						Database::query($sql);
@@ -2653,7 +2653,7 @@  discard block
 block discarded – undo
2653 2653
 
2654 2654
 				foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) {
2655 2655
 					$parent_new_id = 0;
2656
-					if($parent_item_old_id != 0){
2656
+					if ($parent_item_old_id != 0) {
2657 2657
 						$parent_new_id = $new_item_ids[$parent_item_old_id];
2658 2658
 					}
2659 2659
 					$sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."'
@@ -2662,7 +2662,7 @@  discard block
 block discarded – undo
2662 2662
 				}
2663 2663
 				foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) {
2664 2664
 					$previous_new_id = 0;
2665
-					if ($previous_item_old_id != 0){
2665
+					if ($previous_item_old_id != 0) {
2666 2666
 						$previous_new_id = $new_item_ids[$previous_item_old_id];
2667 2667
 					}
2668 2668
 					$sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."'
@@ -2672,7 +2672,7 @@  discard block
 block discarded – undo
2672 2672
 
2673 2673
 				foreach ($next_item_ids as $new_item_id => $next_item_old_id) {
2674 2674
 					$next_new_id = 0;
2675
-					if ($next_item_old_id != 0){
2675
+					if ($next_item_old_id != 0) {
2676 2676
 						$next_new_id = $new_item_ids[$next_item_old_id];
2677 2677
 					}
2678 2678
 					$sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."'
@@ -2682,7 +2682,7 @@  discard block
 block discarded – undo
2682 2682
 
2683 2683
 				foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) {
2684 2684
 					$prerequisite_new_id = 0;
2685
-					if ($prerequisite_old_id != 0){
2685
+					if ($prerequisite_old_id != 0) {
2686 2686
 						$prerequisite_new_id = $new_item_ids[$prerequisite_old_id];
2687 2687
 					}
2688 2688
 					$sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."'
@@ -2803,16 +2803,16 @@  discard block
 block discarded – undo
2803 2803
         if ($handle = opendir($source)) {        // if the folder exploration is sucsessful, continue
2804 2804
             while (false !== ($file = readdir($handle))) { // as long as storing the next file to $file is successful, continue
2805 2805
                 if ($file != '.' && $file != '..') {
2806
-                    $path = $source . '/' . $file;
2806
+                    $path = $source.'/'.$file;
2807 2807
                     if (is_file($path)) {
2808 2808
                        /* if (!is_file($dest . '/' . $file) || $overwrite)
2809 2809
                         if (!@copy($path, $dest . '/' . $file)) {
2810 2810
                             echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>';
2811 2811
                         }*/
2812
-                    } elseif(is_dir($path)) {
2813
-                        if (!is_dir($dest . '/' . $file))
2814
-                        mkdir($dest . '/' . $file);
2815
-                        self:: allow_create_all_directory($path, $dest . '/' . $file, $overwrite);
2812
+                    } elseif (is_dir($path)) {
2813
+                        if (!is_dir($dest.'/'.$file))
2814
+                        mkdir($dest.'/'.$file);
2815
+                        self:: allow_create_all_directory($path, $dest.'/'.$file, $overwrite);
2816 2816
                     }
2817 2817
                 }
2818 2818
             }
@@ -3010,7 +3010,7 @@  discard block
 block discarded – undo
3010 3010
                     $this->course->backup_path,
3011 3011
                     $this->course->info['path']
3012 3012
                 );
3013
-				$thematic->params['c_id']  = $this->destination_course_id;
3013
+				$thematic->params['c_id'] = $this->destination_course_id;
3014 3014
 				unset($thematic->params['id']);
3015 3015
                 unset($thematic->params['iid']);
3016 3016
 
@@ -3034,7 +3034,7 @@  discard block
 block discarded – undo
3034 3034
                         unset($thematic_advance['iid']);
3035 3035
 						$thematic_advance['attendance_id'] = 0;
3036 3036
 						$thematic_advance['thematic_id'] = $last_id;
3037
-						$thematic_advance['c_id']  = $this->destination_course_id;
3037
+						$thematic_advance['c_id'] = $this->destination_course_id;
3038 3038
 
3039 3039
                         $my_id = Database::insert(
3040 3040
                             $table_thematic_advance,
@@ -3057,7 +3057,7 @@  discard block
 block discarded – undo
3057 3057
 						}
3058 3058
 					}
3059 3059
 
3060
-					foreach($thematic->thematic_plan_list as $thematic_plan) {
3060
+					foreach ($thematic->thematic_plan_list as $thematic_plan) {
3061 3061
 						unset($thematic_plan['id']);
3062 3062
                         unset($thematic_plan['iid']);
3063 3063
 						$thematic_plan['thematic_id'] = $last_id;
@@ -3173,7 +3173,7 @@  discard block
 block discarded – undo
3173 3173
                 // re-create dir
3174 3174
                 // @todo check security against injection of dir in crafted course backup here!
3175 3175
                 $path = $obj->params['url'];
3176
-                $path = '/'.str_replace('/','',substr($path,1));
3176
+                $path = '/'.str_replace('/', '', substr($path, 1));
3177 3177
 
3178 3178
                 $workData = array();
3179 3179
                 switch ($this->file_option) {
@@ -3195,9 +3195,9 @@  discard block
 block discarded – undo
3195 3195
                         $obj->params['new_dir'] = $obj->params['title'];
3196 3196
 
3197 3197
                         if (!empty($this->course_origin_id)) {
3198
-                            $sql = 'SELECT * FROM ' . $table_work_assignment . '
3198
+                            $sql = 'SELECT * FROM '.$table_work_assignment.'
3199 3199
                                     WHERE
3200
-                                        c_id = ' . $this->course_origin_id . ' AND
3200
+                                        c_id = ' . $this->course_origin_id.' AND
3201 3201
                                         publication_id = ' . $id_work;
3202 3202
 
3203 3203
                             $result = Database::query($sql);
@@ -3308,7 +3308,7 @@  discard block
 block discarded – undo
3308 3308
     public function DBUTF8_array($array)
3309 3309
     {
3310 3310
         if (UTF8_CONVERT) {
3311
-            foreach ($array as &$item)  {
3311
+            foreach ($array as &$item) {
3312 3312
                 $item = utf8_encode($item);
3313 3313
             }
3314 3314
             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.