Completed
Push — 1.10.x ( 2b98e4...2d791d )
by Yannick
161:21 queued 116:16
created
main/coursecopy/classes/CourseBuilder.class.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 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
     {
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
      * @param string   $courseCode
124 124
      * @param bool     true if you want to get the elements that exists in the course and
125 125
      *                 in the session, (session_id = 0 or session_id = X)
126
-     * @return object The course object structure
126
+     * @return Course The course object structure
127 127
      */
128 128
     public function build(
129 129
         $session_id = 0,
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
         $table_doc = Database:: get_course_table(TABLE_DOCUMENT);
596 596
 
597 597
         if (!empty($courseId) && !empty($session_id)) {
598
-            $session_id  = intval($session_id);
598
+            $session_id = intval($session_id);
599 599
             if ($with_base_content) {
600 600
                 $session_condition = api_get_session_condition(
601 601
                     $session_id,
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
                 'title' => get_lang('OrphanQuestions', ''),
805 805
                 'type' => 2
806 806
             );
807
-            $newQuiz = new Quiz((object)$obj);
807
+            $newQuiz = new Quiz((object) $obj);
808 808
             if (!empty($orphanQuestionIds)) {
809 809
                 foreach ($orphanQuestionIds as $index => $orphanId) {
810 810
                     $order = $index + 1;
Please login to merge, or discard this patch.
main/coursecopy/classes/CourseSelectForm.class.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 {
14 14
 	/**
15 15
 	 * Display the form
16
-	 * @param array $hidden_fiels Hidden fields to add to the form.
16
+	 * @param array $hidden_fields Hidden fields to add to the form.
17 17
 	 * @param boolean the document array will be serialize. This is used in the course_copy.php file
18 18
 	 */
19 19
 	static function display_form($course, $hidden_fields = null, $avoid_serialize = false)
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 
571 571
 	/**
572 572
 	 * Display the form session export
573
-	 * @param array $hidden_fiels Hidden fields to add to the form.
573
+	 * @param array $hidden_fields Hidden fields to add to the form.
574 574
 	 * @param boolean the document array will be serialize. This is used in the course_copy.php file
575 575
 	 */
576 576
 	 public static function display_form_session_export($list_course, $hidden_fields = null, $avoid_serialize = false)
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -136,13 +136,13 @@  discard block
 block discarded – undo
136 136
 
137 137
 		//get destination course title
138 138
 		if (!empty($hidden_fields['destination_course'])) {
139
-            $sessionTitle = !empty($hidden_fields['destination_session']) ? ' (' . api_get_session_name(
139
+            $sessionTitle = !empty($hidden_fields['destination_session']) ? ' ('.api_get_session_name(
140 140
                 $hidden_fields['destination_session']
141
-            ) . ')' : null;
141
+            ).')' : null;
142 142
 
143 143
             $course_infos = CourseManager::get_course_information($hidden_fields['destination_course']);
144 144
 			echo '<h3>';
145
-			echo get_lang('DestinationCourse').' : '.$course_infos['title'] . ' ('.$course_infos['code'].') '.$sessionTitle;
145
+			echo get_lang('DestinationCourse').' : '.$course_infos['title'].' ('.$course_infos['code'].') '.$sessionTitle;
146 146
 			echo '</h3>';
147 147
 		}
148 148
         echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>';
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 			/*Documents are avoided due the huge amount of memory that the serialize php function "eats"
299 299
 			(when there are directories with hundred/thousand of files) */
300 300
 			// this is a known issue of serialize
301
-			$course->resources['document']= null;
301
+			$course->resources['document'] = null;
302 302
 		}
303 303
 
304 304
 		echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>';
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 		    Display::display_warning_message(get_lang('NoDataAvailable'));
316 316
 		} else {
317 317
     		if (!empty($hidden_fields['destination_session'])) {
318
-    			echo '<br /><button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES, $charset))."'".')) return false;" >'.
318
+    			echo '<br /><button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset))."'".')) return false;" >'.
319 319
                     get_lang('Ok').'</button>';
320 320
     		} else {
321 321
                 if ($recycleOption) {
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
      */
340 340
     static function display_hidden_quiz_questions($course)
341 341
     {
342
-		if(is_array($course->resources)){
342
+		if (is_array($course->resources)) {
343 343
 			foreach ($course->resources as $type => $resources) {
344 344
 				if (count($resources) > 0) {
345 345
 					switch ($type) {
@@ -359,10 +359,10 @@  discard block
 block discarded – undo
359 359
      */
360 360
     static function display_hidden_scorm_directories($course)
361 361
     {
362
-        if (is_array($course->resources)){
362
+        if (is_array($course->resources)) {
363 363
 			foreach ($course->resources as $type => $resources) {
364 364
 				if (count($resources) > 0) {
365
-					switch($type) {
365
+					switch ($type) {
366 366
 						case RESOURCE_SCORM:
367 367
 							foreach ($resources as $id => $resource) {
368 368
 								echo '<input type="hidden" name="resource['.RESOURCE_SCORM.']['.$id.']" id="resource['.RESOURCE_SCORM.']['.$id.']" value="On" />';
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 			if (is_array($resource)) {
409 409
 				$resource = array_keys($resource);
410 410
 
411
-				foreach	($resource as $resource_item) {
411
+				foreach ($resource as $resource_item) {
412 412
 
413 413
 					$condition_session = '';
414 414
 					if (!empty($session_id)) {
@@ -444,8 +444,8 @@  discard block
 block discarded – undo
444 444
                                         tool = '".RESOURCE_DOCUMENT."' AND
445 445
                                         ref = $resource_item ";
446 446
                             $res = Database::query($sql);
447
-                            $all_properties = array ();
448
-                            while ($item_property = Database::fetch_array($res,'ASSOC')) {
447
+                            $all_properties = array();
448
+                            while ($item_property = Database::fetch_array($res, 'ASSOC')) {
449 449
                                 $all_properties[] = $item_property;
450 450
                             }
451 451
                             $course->resources[RESOURCE_DOCUMENT][$resource_item]->item_properties = $all_properties;
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
 
461 461
 				switch ($type) {
462 462
 					case RESOURCE_SURVEYQUESTION:
463
-						foreach($resources as $id => $obj) {
463
+						foreach ($resources as $id => $obj) {
464 464
 						    if (isset($_POST['resource'][RESOURCE_SURVEY]) &&
465 465
                                 is_array($_POST['resource'][RESOURCE_SURVEY]) &&
466 466
                                 !in_array($obj->survey_id, array_keys($_POST['resource'][RESOURCE_SURVEY]))
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
                                 ) {
536 536
 									foreach ($documents as $id_to_check => $post_value) {
537 537
 										$obj_to_check = $resources[$id_to_check];
538
-										$shared_path_part = substr($obj_to_check->path,0,strlen($obj->path));
538
+										$shared_path_part = substr($obj_to_check->path, 0, strlen($obj->path));
539 539
 										if ($id_to_check != $id && $obj->path == $shared_path_part) {
540 540
 											$_POST['resource'][RESOURCE_DOCUMENT][$id] = 1;
541 541
 											break;
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 								$resource_is_used_elsewhere = $course->is_linked_resource($obj);
550 550
 								// check if document is in a quiz (audio/video)
551 551
 								if ($type == RESOURCE_DOCUMENT && $course->has_resources(RESOURCE_QUIZ)) {
552
-									foreach($course->resources[RESOURCE_QUIZ] as $quiz) {
552
+									foreach ($course->resources[RESOURCE_QUIZ] as $quiz) {
553 553
                                         $quiz = $quiz->obj;
554 554
 										if (isset($quiz->media) && $quiz->media == $id) {
555 555
 											$resource_is_used_elsewhere = true;
@@ -618,15 +618,15 @@  discard block
 block discarded – undo
618 618
 		<?php
619 619
 
620 620
 		//get destination course title
621
-		if(!empty($hidden_fields['destination_course'])) {
621
+		if (!empty($hidden_fields['destination_course'])) {
622 622
              if (!empty($hidden_fields['destination_session'])) {
623
-                 $sessionTitle = ' (' . api_get_session_name($hidden_fields['destination_session']) . ')';
623
+                 $sessionTitle = ' ('.api_get_session_name($hidden_fields['destination_session']).')';
624 624
              } else {
625 625
                  $sessionTitle = null;
626 626
              }
627 627
             $course_infos = CourseManager::get_course_information($hidden_fields['destination_course']);
628 628
 			echo '<h3>';
629
-				echo get_lang('DestinationCourse') . ' : ' . $course_infos['title'] . $sessionTitle;
629
+				echo get_lang('DestinationCourse').' : '.$course_infos['title'].$sessionTitle;
630 630
 			echo '</h3>';
631 631
 		}
632 632
 
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
 		echo '<script type="text/javascript">var myUpload = new upload(1000);</script>';
635 635
 		echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="myUpload.start(\'dynamic_div\',\''.api_get_path(WEB_CODE_PATH).'img/progress_bar.gif\',\''.get_lang('PleaseStandBy').'\',\'upload_form\')">';
636 636
 		echo '<input type="hidden" name="action" value="course_select_form"/>';
637
-		foreach ($list_course as $course){
637
+		foreach ($list_course as $course) {
638 638
 			foreach ($course->resources as $type => $resources) {
639 639
 				if (count($resources) > 0) {
640 640
 					echo '<img id="img_'.$course->code.'" src="../img/1.gif" onclick="javascript:exp('."'$course->code'".');" />';
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 		if ($avoid_serialize) {
663 663
 			//Documents are avoided due the huge amount of memory that the serialize php function "eats" (when there are directories with hundred/thousand of files)
664 664
 			// this is a known issue of serialize
665
-			$course->resources['document']= null;
665
+			$course->resources['document'] = null;
666 666
 		}
667 667
 		echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>';
668 668
 		if (is_array($hidden_fields)) {
Please login to merge, or discard this patch.
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.
Indentation   +252 added lines, -252 removed lines patch added patch discarded remove patch
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class CourseSelectForm
13 13
 {
14
-	/**
15
-	 * Display the form
16
-	 * @param array $hidden_fiels Hidden fields to add to the form.
17
-	 * @param boolean the document array will be serialize. This is used in the course_copy.php file
18
-	 */
19
-	static function display_form($course, $hidden_fields = null, $avoid_serialize = false)
14
+    /**
15
+     * Display the form
16
+     * @param array $hidden_fiels Hidden fields to add to the form.
17
+     * @param boolean the document array will be serialize. This is used in the course_copy.php file
18
+     */
19
+    static function display_form($course, $hidden_fields = null, $avoid_serialize = false)
20 20
     {
21 21
         global $charset;
22 22
         $resource_titles[RESOURCE_GRADEBOOK] = get_lang('Gradebook');
@@ -134,50 +134,50 @@  discard block
 block discarded – undo
134 134
 		</script>
135 135
 		<?php
136 136
 
137
-		//get destination course title
138
-		if (!empty($hidden_fields['destination_course'])) {
137
+        //get destination course title
138
+        if (!empty($hidden_fields['destination_course'])) {
139 139
             $sessionTitle = !empty($hidden_fields['destination_session']) ? ' (' . api_get_session_name(
140 140
                 $hidden_fields['destination_session']
141 141
             ) . ')' : null;
142 142
 
143 143
             $course_infos = CourseManager::get_course_information($hidden_fields['destination_course']);
144
-			echo '<h3>';
145
-			echo get_lang('DestinationCourse').' : '.$course_infos['title'] . ' ('.$course_infos['code'].') '.$sessionTitle;
146
-			echo '</h3>';
147
-		}
144
+            echo '<h3>';
145
+            echo get_lang('DestinationCourse').' : '.$course_infos['title'] . ' ('.$course_infos['code'].') '.$sessionTitle;
146
+            echo '</h3>';
147
+        }
148 148
         echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>';
149
-		echo '<script type="text/javascript">var myUpload = new upload(1000);</script>';
149
+        echo '<script type="text/javascript">var myUpload = new upload(1000);</script>';
150 150
         $icon = Display::returnIconPath('myprogress_bar.gif');
151
-		echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="javascript: myUpload.start(\'dynamic_div\',\''.$icon.',\''.get_lang('PleaseStandBy', '').'\',\'upload_form\')">';
152
-		echo '<input type="hidden" name="action" value="course_select_form"/>';
151
+        echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="javascript: myUpload.start(\'dynamic_div\',\''.$icon.',\''.get_lang('PleaseStandBy', '').'\',\'upload_form\')">';
152
+        echo '<input type="hidden" name="action" value="course_select_form"/>';
153 153
 
154
-		if (!empty($hidden_fields['destination_course']) &&
154
+        if (!empty($hidden_fields['destination_course']) &&
155 155
             !empty($hidden_fields['origin_course']) &&
156 156
             !empty($hidden_fields['destination_session']) &&
157 157
             !empty($hidden_fields['origin_session'])
158 158
         ) {
159
-			echo '<input type="hidden" name="destination_course" 	value="'.$hidden_fields['destination_course'].'"/>';
160
-			echo '<input type="hidden" name="origin_course" 		value="'.$hidden_fields['origin_course'].'"/>';
161
-			echo '<input type="hidden" name="destination_session" 	value="'.$hidden_fields['destination_session'].'"/>';
162
-			echo '<input type="hidden" name="origin_session" 		value="'.$hidden_fields['origin_session'].'"/>';
163
-		}
159
+            echo '<input type="hidden" name="destination_course" 	value="'.$hidden_fields['destination_course'].'"/>';
160
+            echo '<input type="hidden" name="origin_course" 		value="'.$hidden_fields['origin_course'].'"/>';
161
+            echo '<input type="hidden" name="destination_session" 	value="'.$hidden_fields['destination_session'].'"/>';
162
+            echo '<input type="hidden" name="origin_session" 		value="'.$hidden_fields['origin_session'].'"/>';
163
+        }
164 164
 
165
-		$element_count = 0;
165
+        $element_count = 0;
166 166
         $forum_categories = array();
167 167
         $forums = array();
168 168
         $forum_topics = array();
169 169
 
170 170
         echo '<p>';
171
-		echo get_lang('SelectResources');
172
-		echo '</p>';
171
+        echo get_lang('SelectResources');
172
+        echo '</p>';
173 173
 
174 174
         Display::display_normal_message(get_lang('DontForgetToSelectTheMediaFilesIfYourResourceNeedIt'));
175 175
 
176 176
         foreach ($course->resources as $type => $resources) {
177 177
             if (count($resources) > 0) {
178
-				switch ($type) {
179
-					//Resources to avoid
180
-					case RESOURCE_FORUMCATEGORY:
178
+                switch ($type) {
179
+                    //Resources to avoid
180
+                    case RESOURCE_FORUMCATEGORY:
181 181
                         foreach ($resources as $id => $resource) {
182 182
                             $forum_categories[$id] = $resource;
183 183
                         }
@@ -196,49 +196,49 @@  discard block
 block discarded – undo
196 196
                         $element_count++;
197 197
                         break;
198 198
                     case RESOURCE_LINKCATEGORY:
199
-					case RESOURCE_FORUMPOST:
200
-					case RESOURCE_QUIZQUESTION:
201
-					case RESOURCE_SURVEYQUESTION:
202
-					case RESOURCE_SURVEYINVITATION:
203
-					case RESOURCE_SCORM:
204
-						break;
199
+                    case RESOURCE_FORUMPOST:
200
+                    case RESOURCE_QUIZQUESTION:
201
+                    case RESOURCE_SURVEYQUESTION:
202
+                    case RESOURCE_SURVEYINVITATION:
203
+                    case RESOURCE_SCORM:
204
+                        break;
205 205
                     default :
206
-						echo '<img id="img_'.$type.'" src="'.Display::returnIconPath('1.gif').'" onclick="javascript:exp('."'$type'".');" />&nbsp;';
207
-						echo '<b onclick="javascript:exp('."'$type'".');" >'.$resource_titles[$type].'</b><br />';
208
-						echo '<div id="div_'.$type.'">';
209
-						if ($type == RESOURCE_LEARNPATH) {
210
-    						Display::display_warning_message(get_lang('ToExportLearnpathWithQuizYouHaveToSelectQuiz'));
211
-    						Display::display_warning_message(get_lang('IfYourLPsHaveAudioFilesIncludedYouShouldSelectThemFromTheDocuments'));
212
-						}
213
-						if ($type == RESOURCE_DOCUMENT) {
206
+                        echo '<img id="img_'.$type.'" src="'.Display::returnIconPath('1.gif').'" onclick="javascript:exp('."'$type'".');" />&nbsp;';
207
+                        echo '<b onclick="javascript:exp('."'$type'".');" >'.$resource_titles[$type].'</b><br />';
208
+                        echo '<div id="div_'.$type.'">';
209
+                        if ($type == RESOURCE_LEARNPATH) {
210
+                            Display::display_warning_message(get_lang('ToExportLearnpathWithQuizYouHaveToSelectQuiz'));
211
+                            Display::display_warning_message(get_lang('IfYourLPsHaveAudioFilesIncludedYouShouldSelectThemFromTheDocuments'));
212
+                        }
213
+                        if ($type == RESOURCE_DOCUMENT) {
214 214
                             if (api_get_setting('show_glossary_in_documents') != 'none') {
215 215
                                 Display::display_warning_message(get_lang('ToExportDocumentsWithGlossaryYouHaveToSelectGlossary'));
216 216
                             }
217
-						}
217
+                        }
218 218
 
219
-						echo '<blockquote>';
219
+                        echo '<blockquote>';
220 220
                         echo '<div class="btn-group">';
221
-						echo "<a class=\"btn btn-default\" href=\"javascript: void(0);\" onclick=\"javascript: setCheckbox('$type',true);\" >".get_lang('All')."</a>";
221
+                        echo "<a class=\"btn btn-default\" href=\"javascript: void(0);\" onclick=\"javascript: setCheckbox('$type',true);\" >".get_lang('All')."</a>";
222 222
                         echo "<a class=\"btn btn-default\" href=\"javascript: void(0);\" onclick=\"javascript:setCheckbox('$type',false);\" >".get_lang('None')."</a>";
223
-						echo '</div><br />';
223
+                        echo '</div><br />';
224 224
 
225
-						foreach ($resources as $id => $resource) {
225
+                        foreach ($resources as $id => $resource) {
226 226
                             if ($resource) {
227
-								// Event obj in 1.9.x in 1.10.x the class is CalendarEvent
227
+                                // Event obj in 1.9.x in 1.10.x the class is CalendarEvent
228 228
                                 Coursecopy\Resource::setClassType($resource);
229 229
                                 echo '<label class="checkbox">';
230 230
                                 echo '<input type="checkbox" name="resource['.$type.']['.$id.']"  id="resource['.$type.']['.$id.']" />';
231 231
                                 $resource->show();
232 232
                                 echo '</label>';
233 233
                             }
234
-						}
235
-						echo '</blockquote>';
236
-						echo '</div>';
237
-						echo '<script language="javascript">exp('."'$type'".')</script>';
238
-						$element_count++;
234
+                        }
235
+                        echo '</blockquote>';
236
+                        echo '</div>';
237
+                        echo '<script language="javascript">exp('."'$type'".')</script>';
238
+                        $element_count++;
239 239
                 }
240
-			}
241
-		}
240
+            }
241
+        }
242 242
 
243 243
         //Fixes forum order
244 244
         if (!empty($forum_categories)) {
@@ -294,65 +294,65 @@  discard block
 block discarded – undo
294 294
             echo '<script language="javascript">exp('."'$type'".')</script>';
295 295
         }
296 296
 
297
-		if ($avoid_serialize) {
298
-			/*Documents are avoided due the huge amount of memory that the serialize php function "eats"
297
+        if ($avoid_serialize) {
298
+            /*Documents are avoided due the huge amount of memory that the serialize php function "eats"
299 299
 			(when there are directories with hundred/thousand of files) */
300
-			// this is a known issue of serialize
301
-			$course->resources['document']= null;
302
-		}
300
+            // this is a known issue of serialize
301
+            $course->resources['document']= null;
302
+        }
303 303
 
304
-		echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>';
304
+        echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>';
305 305
 
306
-		if (is_array($hidden_fields)) {
307
-			foreach ($hidden_fields as $key => $value) {
308
-				echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>';
309
-			}
310
-		}
306
+        if (is_array($hidden_fields)) {
307
+            foreach ($hidden_fields as $key => $value) {
308
+                echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>';
309
+            }
310
+        }
311 311
 
312 312
         $recycleOption = isset($_POST['recycle_option']) ? true : false;
313 313
 
314
-		if (empty($element_count)) {
315
-		    Display::display_warning_message(get_lang('NoDataAvailable'));
316
-		} else {
317
-    		if (!empty($hidden_fields['destination_session'])) {
318
-    			echo '<br /><button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES, $charset))."'".')) return false;" >'.
314
+        if (empty($element_count)) {
315
+            Display::display_warning_message(get_lang('NoDataAvailable'));
316
+        } else {
317
+            if (!empty($hidden_fields['destination_session'])) {
318
+                echo '<br /><button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES, $charset))."'".')) return false;" >'.
319 319
                     get_lang('Ok').'</button>';
320
-    		} else {
320
+            } else {
321 321
                 if ($recycleOption) {
322 322
                     echo '<br /><button class="save" type="submit">'.
323 323
                         get_lang('Ok').'</button>';
324 324
                 } else {
325
-    			    echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.
325
+                    echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.
326 326
                     get_lang('Ok').'</button>';
327 327
                 }
328
-    		}
329
-		}
328
+            }
329
+        }
330 330
 
331
-		CourseSelectForm :: display_hidden_quiz_questions($course);
332
-		CourseSelectForm :: display_hidden_scorm_directories($course);
333
-		echo '</form>';
334
-		echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>';
335
-	}
331
+        CourseSelectForm :: display_hidden_quiz_questions($course);
332
+        CourseSelectForm :: display_hidden_scorm_directories($course);
333
+        echo '</form>';
334
+        echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>';
335
+    }
336 336
 
337 337
     /**
338 338
      * @param $course
339 339
      */
340 340
     static function display_hidden_quiz_questions($course)
341 341
     {
342
-		if(is_array($course->resources)){
343
-			foreach ($course->resources as $type => $resources) {
344
-				if (count($resources) > 0) {
345
-					switch ($type) {
346
-						case RESOURCE_QUIZQUESTION:
347
-							foreach ($resources as $id => $resource) {
348
-								echo '<input type="hidden" name="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" id="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" value="On" />';
349
-							}
350
-							break;
351
-					}
352
-				}
353
-			}
354
-		}
355
-	}
342
+        if(is_array($course->resources)){
343
+            foreach ($course->resources as $type => $resources) {
344
+                if (count($resources) > 0) {
345
+                    switch ($type) {
346
+                        case RESOURCE_QUIZQUESTION:
347
+                            foreach ($resources as $id => $resource) {
348
+                                echo '<input type="hidden" name="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" id="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" value="On" />';
349
+                            }
350
+                            break;
351
+                    }
352
+                }
353
+            }
354
+        }
355
+    }
356 356
 
357 357
     /**
358 358
      * @param $course
@@ -360,30 +360,30 @@  discard block
 block discarded – undo
360 360
     static function display_hidden_scorm_directories($course)
361 361
     {
362 362
         if (is_array($course->resources)){
363
-			foreach ($course->resources as $type => $resources) {
364
-				if (count($resources) > 0) {
365
-					switch($type) {
366
-						case RESOURCE_SCORM:
367
-							foreach ($resources as $id => $resource) {
368
-								echo '<input type="hidden" name="resource['.RESOURCE_SCORM.']['.$id.']" id="resource['.RESOURCE_SCORM.']['.$id.']" value="On" />';
369
-							}
370
-							break;
371
-					}
372
-				}
373
-			}
374
-		}
375
-	}
363
+            foreach ($course->resources as $type => $resources) {
364
+                if (count($resources) > 0) {
365
+                    switch($type) {
366
+                        case RESOURCE_SCORM:
367
+                            foreach ($resources as $id => $resource) {
368
+                                echo '<input type="hidden" name="resource['.RESOURCE_SCORM.']['.$id.']" id="resource['.RESOURCE_SCORM.']['.$id.']" value="On" />';
369
+                            }
370
+                            break;
371
+                    }
372
+                }
373
+            }
374
+        }
375
+    }
376 376
 
377
-	/**
378
-	 * Get the posted course
379
-	 * @param string $from who calls the function?
377
+    /**
378
+     * Get the posted course
379
+     * @param string $from who calls the function?
380 380
      * It can be copy_course, create_backup, import_backup or recycle_course
381 381
      * @param int $session_id
382 382
      * @param string $course_code
383
-	 * @return course The course-object with all resources selected by the user
384
-	 * in the form given by display_form(...)
385
-	 */
386
-	public static function get_posted_course($from = '', $session_id = 0, $course_code = '')
383
+     * @return course The course-object with all resources selected by the user
384
+     * in the form given by display_form(...)
385
+     */
386
+    public static function get_posted_course($from = '', $session_id = 0, $course_code = '')
387 387
     {
388 388
         $course = null;
389 389
 
@@ -393,30 +393,30 @@  discard block
 block discarded – undo
393 393
             return false;
394 394
         }
395 395
 
396
-		// Create the resource DOCUMENT objects
397
-		// Loading the results from the checkboxes of ethe javascript
398
-		$resource = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null;
396
+        // Create the resource DOCUMENT objects
397
+        // Loading the results from the checkboxes of ethe javascript
398
+        $resource = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null;
399 399
 
400
-		$course_info = api_get_course_info($course_code);
401
-		$table_doc = Database::get_course_table(TABLE_DOCUMENT);
402
-		$table_prop = Database::get_course_table(TABLE_ITEM_PROPERTY);
403
-		$course_id = $course_info['real_id'];
400
+        $course_info = api_get_course_info($course_code);
401
+        $table_doc = Database::get_course_table(TABLE_DOCUMENT);
402
+        $table_prop = Database::get_course_table(TABLE_ITEM_PROPERTY);
403
+        $course_id = $course_info['real_id'];
404 404
 
405
-		/* Searching the documents resource that have been set to null because
405
+        /* Searching the documents resource that have been set to null because
406 406
         $avoid_serialize is true in the display_form() function*/
407
-		if ($from == 'copy_course') {
408
-			if (is_array($resource)) {
409
-				$resource = array_keys($resource);
407
+        if ($from == 'copy_course') {
408
+            if (is_array($resource)) {
409
+                $resource = array_keys($resource);
410 410
 
411
-				foreach	($resource as $resource_item) {
411
+                foreach	($resource as $resource_item) {
412 412
 
413
-					$condition_session = '';
414
-					if (!empty($session_id)) {
415
-						$session_id = intval($session_id);
416
-						$condition_session = ' AND d.session_id ='.$session_id;
417
-					}
413
+                    $condition_session = '';
414
+                    if (!empty($session_id)) {
415
+                        $session_id = intval($session_id);
416
+                        $condition_session = ' AND d.session_id ='.$session_id;
417
+                    }
418 418
 
419
-					$sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size
419
+                    $sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size
420 420
 							FROM '.$table_doc.' d, '.$table_prop.' p
421 421
 							WHERE
422 422
 							    d.c_id = '.$course_id.' AND
@@ -425,8 +425,8 @@  discard block
 block discarded – undo
425 425
                                 p.ref = d.id AND p.visibility != 2 AND
426 426
                                 d.id = '.$resource_item.$condition_session.'
427 427
 							ORDER BY path';
428
-					$db_result = Database::query($sql);
429
-					while ($obj = Database::fetch_object($db_result)) {
428
+                    $db_result = Database::query($sql);
429
+                    while ($obj = Database::fetch_object($db_result)) {
430 430
                         $doc = new Document(
431 431
                             $obj->id,
432 432
                             $obj->path,
@@ -450,25 +450,25 @@  discard block
 block discarded – undo
450 450
                             }
451 451
                             $course->resources[RESOURCE_DOCUMENT][$resource_item]->item_properties = $all_properties;
452 452
                         }
453
-					}
454
-				}
455
-			}
456
-		}
453
+                    }
454
+                }
455
+            }
456
+        }
457 457
 
458
-		if (is_array($course->resources)) {
459
-			foreach ($course->resources as $type => $resources) {
458
+        if (is_array($course->resources)) {
459
+            foreach ($course->resources as $type => $resources) {
460 460
 
461
-				switch ($type) {
462
-					case RESOURCE_SURVEYQUESTION:
463
-						foreach($resources as $id => $obj) {
464
-						    if (isset($_POST['resource'][RESOURCE_SURVEY]) &&
461
+                switch ($type) {
462
+                    case RESOURCE_SURVEYQUESTION:
463
+                        foreach($resources as $id => $obj) {
464
+                            if (isset($_POST['resource'][RESOURCE_SURVEY]) &&
465 465
                                 is_array($_POST['resource'][RESOURCE_SURVEY]) &&
466 466
                                 !in_array($obj->survey_id, array_keys($_POST['resource'][RESOURCE_SURVEY]))
467 467
                             ) {
468
-								unset($course->resources[$type][$id]);
469
-							}
470
-						}
471
-						break;
468
+                                unset($course->resources[$type][$id]);
469
+                            }
470
+                        }
471
+                        break;
472 472
                     case RESOURCE_FORUMTOPIC:
473 473
                     case RESOURCE_FORUMPOST:
474 474
                        //Add post from topic
@@ -520,62 +520,62 @@  discard block
 block discarded – undo
520 520
                                 }
521 521
                             }
522 522
                         }
523
-					case RESOURCE_LINKCATEGORY :
524
-					case RESOURCE_FORUMCATEGORY :
525
-					case RESOURCE_QUIZQUESTION :
526
-					case RESOURCE_DOCUMENT:
527
-						// Mark folders to import which are not selected by the user to import,
528
-						// but in which a document was selected.
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) {
532
-								if (isset($obj->file_type) && $obj->file_type == 'folder' &&
523
+                    case RESOURCE_LINKCATEGORY :
524
+                    case RESOURCE_FORUMCATEGORY :
525
+                    case RESOURCE_QUIZQUESTION :
526
+                    case RESOURCE_DOCUMENT:
527
+                        // Mark folders to import which are not selected by the user to import,
528
+                        // but in which a document was selected.
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) {
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
-									foreach ($documents as $id_to_check => $post_value) {
537
-										$obj_to_check = $resources[$id_to_check];
538
-										$shared_path_part = substr($obj_to_check->path,0,strlen($obj->path));
539
-										if ($id_to_check != $id && $obj->path == $shared_path_part) {
540
-											$_POST['resource'][RESOURCE_DOCUMENT][$id] = 1;
541
-											break;
542
-										}
543
-									}
544
-								}
545
-							}
546
-					default :
547
-						if (!empty($resources) && is_array($resources)) {
548
-							foreach ($resources as $id => $obj) {
549
-								$resource_is_used_elsewhere = $course->is_linked_resource($obj);
550
-								// check if document is in a quiz (audio/video)
551
-								if ($type == RESOURCE_DOCUMENT && $course->has_resources(RESOURCE_QUIZ)) {
552
-									foreach($course->resources[RESOURCE_QUIZ] as $quiz) {
536
+                                    foreach ($documents as $id_to_check => $post_value) {
537
+                                        $obj_to_check = $resources[$id_to_check];
538
+                                        $shared_path_part = substr($obj_to_check->path,0,strlen($obj->path));
539
+                                        if ($id_to_check != $id && $obj->path == $shared_path_part) {
540
+                                            $_POST['resource'][RESOURCE_DOCUMENT][$id] = 1;
541
+                                            break;
542
+                                        }
543
+                                    }
544
+                                }
545
+                            }
546
+                    default :
547
+                        if (!empty($resources) && is_array($resources)) {
548
+                            foreach ($resources as $id => $obj) {
549
+                                $resource_is_used_elsewhere = $course->is_linked_resource($obj);
550
+                                // check if document is in a quiz (audio/video)
551
+                                if ($type == RESOURCE_DOCUMENT && $course->has_resources(RESOURCE_QUIZ)) {
552
+                                    foreach($course->resources[RESOURCE_QUIZ] as $quiz) {
553 553
                                         $quiz = $quiz->obj;
554
-										if (isset($quiz->media) && $quiz->media == $id) {
555
-											$resource_is_used_elsewhere = true;
556
-										}
557
-									}
558
-								}
559
-								if (!isset($_POST['resource'][$type][$id]) && !$resource_is_used_elsewhere) {
560
-									unset($course->resources[$type][$id]);
561
-								}
562
-							}
563
-						}
564
-				}
565
-			}
566
-		}
567
-
568
-		return $course;
569
-	}
570
-
571
-	/**
572
-	 * Display the form session export
573
-	 * @param array $hidden_fiels Hidden fields to add to the form.
574
-	 * @param boolean the document array will be serialize. This is used in the course_copy.php file
575
-	 */
576
-	 public static function display_form_session_export($list_course, $hidden_fields = null, $avoid_serialize = false)
577
-     {
578
-         ?>
554
+                                        if (isset($quiz->media) && $quiz->media == $id) {
555
+                                            $resource_is_used_elsewhere = true;
556
+                                        }
557
+                                    }
558
+                                }
559
+                                if (!isset($_POST['resource'][$type][$id]) && !$resource_is_used_elsewhere) {
560
+                                    unset($course->resources[$type][$id]);
561
+                                }
562
+                            }
563
+                        }
564
+                }
565
+            }
566
+        }
567
+
568
+        return $course;
569
+    }
570
+
571
+    /**
572
+     * Display the form session export
573
+     * @param array $hidden_fiels Hidden fields to add to the form.
574
+     * @param boolean the document array will be serialize. This is used in the course_copy.php file
575
+     */
576
+        public static function display_form_session_export($list_course, $hidden_fields = null, $avoid_serialize = false)
577
+        {
578
+            ?>
579 579
 		<script>
580 580
 			function exp(item) {
581 581
 				el = document.getElementById('div_'+item);
@@ -617,65 +617,65 @@  discard block
 block discarded – undo
617 617
 		</script>
618 618
 		<?php
619 619
 
620
-		//get destination course title
621
-		if(!empty($hidden_fields['destination_course'])) {
622
-             if (!empty($hidden_fields['destination_session'])) {
623
-                 $sessionTitle = ' (' . api_get_session_name($hidden_fields['destination_session']) . ')';
624
-             } else {
625
-                 $sessionTitle = null;
626
-             }
620
+        //get destination course title
621
+        if(!empty($hidden_fields['destination_course'])) {
622
+                if (!empty($hidden_fields['destination_session'])) {
623
+                    $sessionTitle = ' (' . api_get_session_name($hidden_fields['destination_session']) . ')';
624
+                } else {
625
+                    $sessionTitle = null;
626
+                }
627 627
             $course_infos = CourseManager::get_course_information($hidden_fields['destination_course']);
628
-			echo '<h3>';
629
-				echo get_lang('DestinationCourse') . ' : ' . $course_infos['title'] . $sessionTitle;
630
-			echo '</h3>';
631
-		}
628
+            echo '<h3>';
629
+                echo get_lang('DestinationCourse') . ' : ' . $course_infos['title'] . $sessionTitle;
630
+            echo '</h3>';
631
+        }
632 632
 
633
-		echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>';
634
-		echo '<script type="text/javascript">var myUpload = new upload(1000);</script>';
633
+        echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>';
634
+        echo '<script type="text/javascript">var myUpload = new upload(1000);</script>';
635 635
         $icon = Display::returnIconPath('progress_bar.gif');
636
-		echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="myUpload.start(\'dynamic_div\',\''.$icon.'\',\''.get_lang('PleaseStandBy').'\',\'upload_form\')">';
637
-		echo '<input type="hidden" name="action" value="course_select_form"/>';
638
-		foreach ($list_course as $course){
639
-			foreach ($course->resources as $type => $resources) {
640
-				if (count($resources) > 0) {
641
-					echo '<img id="img_'.$course->code.'" src="'.Display::returnIconPath('1.gif').'" onclick="javascript:exp('."'$course->code'".');" />';
642
-					echo '<b  onclick="javascript:exp('."'$course->code'".');" > '.$course->code.'</b><br />';
643
-					echo '<div id="div_'.$course->code.'">';
644
-					echo '<blockquote>';
636
+        echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="myUpload.start(\'dynamic_div\',\''.$icon.'\',\''.get_lang('PleaseStandBy').'\',\'upload_form\')">';
637
+        echo '<input type="hidden" name="action" value="course_select_form"/>';
638
+        foreach ($list_course as $course){
639
+            foreach ($course->resources as $type => $resources) {
640
+                if (count($resources) > 0) {
641
+                    echo '<img id="img_'.$course->code.'" src="'.Display::returnIconPath('1.gif').'" onclick="javascript:exp('."'$course->code'".');" />';
642
+                    echo '<b  onclick="javascript:exp('."'$course->code'".');" > '.$course->code.'</b><br />';
643
+                    echo '<div id="div_'.$course->code.'">';
644
+                    echo '<blockquote>';
645 645
 
646 646
                     echo '<div class="btn-group">';
647
-					echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',true);\" >".get_lang('All')."</a>";
647
+                    echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',true);\" >".get_lang('All')."</a>";
648 648
                     echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',false);\" >".get_lang('None')."</a>";
649
-					echo '</div><br />';
649
+                    echo '</div><br />';
650 650
 
651
-					foreach ($resources as $id => $resource) {
652
-						echo '<label class="checkbox" for="resource['.$course->code.']['.$id.']">';
651
+                    foreach ($resources as $id => $resource) {
652
+                        echo '<label class="checkbox" for="resource['.$course->code.']['.$id.']">';
653 653
                         echo '<input type="checkbox" name="resource['.$course->code.']['.$id.']" id="resource['.$course->code.']['.$id.']"/>';
654
-						$resource->show();
655
-						echo '</label>';
656
-					}
657
-					echo '</blockquote>';
658
-					echo '</div>';
659
-					echo '<script type="text/javascript">exp('."'$course->code'".')</script>';
660
-				}
661
-			}
662
-		}
663
-		if ($avoid_serialize) {
664
-			//Documents are avoided due the huge amount of memory that the serialize php function "eats" (when there are directories with hundred/thousand of files)
665
-			// this is a known issue of serialize
666
-			$course->resources['document']= null;
667
-		}
668
-		echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>';
669
-		if (is_array($hidden_fields)) {
670
-			foreach ($hidden_fields as $key => $value) {
671
-				echo "\n";
672
-				echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>';
673
-			}
674
-		}
675
-		echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.get_lang('Ok').'</button>';
676
-		CourseSelectForm :: display_hidden_quiz_questions($course);
677
-		CourseSelectForm :: display_hidden_scorm_directories($course);
678
-		echo '</form>';
679
-		echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>';
680
-	}
654
+                        $resource->show();
655
+                        echo '</label>';
656
+                    }
657
+                    echo '</blockquote>';
658
+                    echo '</div>';
659
+                    echo '<script type="text/javascript">exp('."'$course->code'".')</script>';
660
+                }
661
+            }
662
+        }
663
+        if ($avoid_serialize) {
664
+            //Documents are avoided due the huge amount of memory that the serialize php function "eats" (when there are directories with hundred/thousand of files)
665
+            // this is a known issue of serialize
666
+            $course->resources['document']= null;
667
+        }
668
+        echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>';
669
+        if (is_array($hidden_fields)) {
670
+            foreach ($hidden_fields as $key => $value) {
671
+                echo "\n";
672
+                echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>';
673
+            }
674
+        }
675
+        echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.get_lang('Ok').'</button>';
676
+        CourseSelectForm :: display_hidden_quiz_questions($course);
677
+        CourseSelectForm :: display_hidden_scorm_directories($course);
678
+        echo '</form>';
679
+        echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>';
680
+    }
681 681
 }
Please login to merge, or discard this patch.
main/coursecopy/classes/DummyCourseCreator.class.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -280,6 +280,7 @@
 block discarded – undo
280 280
 	}
281 281
 	/**
282 282
 	 * Get dummy titles, descriptions and texts
283
+	 * @param string $type
283 284
 	 */
284 285
 	function get_dummy_content($type)
285 286
 	{
Please login to merge, or discard this patch.
Indentation   +279 added lines, -279 removed lines patch added patch discarded remove patch
@@ -20,289 +20,289 @@
 block discarded – undo
20 20
  */
21 21
 class DummyCourseCreator
22 22
 {
23
-	/**
24
-	 * The dummy course
25
-	 */
26
-	public $course;
27
-	/**
28
-	 *
29
-	 */
30
-	public $default_property = array();
23
+    /**
24
+     * The dummy course
25
+     */
26
+    public $course;
27
+    /**
28
+     *
29
+     */
30
+    public $default_property = array();
31 31
 
32
-	/**
33
-	 * Create the dummy course
34
-	 */
35
-	public function create_dummy_course($course_code)
36
-	{
37
-		$this->default_property['insert_user_id'] = '1';
38
-		$this->default_property['insert_date'] = date('Y-m-d H:i:s');
39
-		$this->default_property['lastedit_date'] = date('Y-m-d H:i:s');
40
-		$this->default_property['lastedit_user_id'] = '1';
41
-		$this->default_property['to_group_id'] = '0';
42
-		$this->default_property['to_user_id'] = null;
43
-		$this->default_property['visibility'] = '1';
44
-		$this->default_property['start_visible'] = '0000-00-00 00:00:00';
45
-		$this->default_property['end_visible'] =  '0000-00-00 00:00:00';
32
+    /**
33
+     * Create the dummy course
34
+     */
35
+    public function create_dummy_course($course_code)
36
+    {
37
+        $this->default_property['insert_user_id'] = '1';
38
+        $this->default_property['insert_date'] = date('Y-m-d H:i:s');
39
+        $this->default_property['lastedit_date'] = date('Y-m-d H:i:s');
40
+        $this->default_property['lastedit_user_id'] = '1';
41
+        $this->default_property['to_group_id'] = '0';
42
+        $this->default_property['to_user_id'] = null;
43
+        $this->default_property['visibility'] = '1';
44
+        $this->default_property['start_visible'] = '0000-00-00 00:00:00';
45
+        $this->default_property['end_visible'] =  '0000-00-00 00:00:00';
46 46
 
47
-		$course = api_get_course_info($course_code);
48
-		$this->course = new Course();
49
-		$tmp_path = api_get_path(SYS_COURSE_PATH).$course['directory'].'/document/tmp_'.uniqid('');
50
-		@mkdir($tmp_path, api_get_permissions_for_new_directories(), true);
51
-		$this->course->backup_path = $tmp_path;
52
-		$this->create_dummy_links();
53
-		$this->create_dummy_events();
54
-		$this->create_dummy_forums();
55
-		$this->create_dummy_announcements();
56
-		$this->create_dummy_documents();
57
-		$this->create_dummy_learnpaths();
58
-		$cr = new CourseRestorer($this->course);
59
-		$cr->set_file_option(FILE_OVERWRITE);
60
-		$cr->restore($course_code);
61
-		rmdirr($tmp_path);
62
-	}
63
-	/**
64
-	 * Create dummy documents
65
-	 */
66
-	function create_dummy_documents()
67
-	{
68
-		$course = api_get_course_info();
69
-		$course_doc_path = $this->course->backup_path.'/document/';
70
-		$number_of_documents = rand(10, 30);
71
-		$extensions = array ('html', 'doc');
72
-		$directories = array();
73
-		$property = $this->default_property;
74
-		$property['lastedit_type'] = 'DocumentAdded';
75
-		$property['tool'] = TOOL_DOCUMENT;
76
-		$doc_id = 0;
77
-		for ($doc_id = 1; $doc_id < $number_of_documents; $doc_id ++)
78
-		{
79
-			$path = '';
80
-			$doc_type = rand(0, count($extensions) - 1);
81
-			$extension = $extensions[$doc_type];
82
-			$filename = $this->get_dummy_content('title').'_'.$doc_id.'.'.$extension;
83
-			$content = $this->get_dummy_content('text');
84
-			$dirs = rand(0, 3);
85
-			for ($i = 0; $i < $dirs; $i ++)
86
-			{
87
-				$path .= 'directory/';
88
-				$directories[$path] = 1;
89
-			}
90
-			$dir_to_make = $course_doc_path.$path;
91
-			if (!is_dir($dir_to_make))
92
-			{
93
-				@mkdir($dir_to_make, api_get_permissions_for_new_directories(), true);
94
-			}
95
-			$file = $course_doc_path.$path.$filename;
96
-			$fp = fopen($file, 'w');
97
-			fwrite($fp, $content);
98
-			fclose($fp);
99
-			$size = filesize($file);
100
-			$document = new Document($doc_id, '/'.$path.$filename,$this->get_dummy_content('description'),$this->get_dummy_content('title'), 'file', $size);
101
-			$document->item_properties[] = $property;
102
-			$this->course->add_resource($document);
103
-		}
104
-		foreach($directories as $path => $flag)
105
-		{
106
-			$path = substr($path,0,strlen($path)-1);
107
-			$document = new Document($doc_id++,'/'.$path, $this->get_dummy_content('description'),$this->get_dummy_content('title'),'folder',0);
108
-			$property['lastedit_type'] = 'FolderCreated';
109
-			$document->item_properties[] = $property;
110
-			$this->course->add_resource($document);
111
-		}
112
-	}
113
-	/**
114
-	 * Create dummy announcements
115
-	 */
116
-	function create_dummy_announcements()
117
-	{
118
-		$property = $this->default_property;
119
-		$property['lastedit_type'] = 'AnnouncementAdded';
120
-		$property['tool'] = TOOL_ANNOUNCEMENT;
121
-		$number_of_announcements = rand(10, 30);
122
-		for ($i = 0; $i < $number_of_announcements; $i ++)
123
-		{
124
-			$time = mktime(rand(1, 24), rand(1, 60), 0, rand(1, 12), rand(1, 28), intval(date('Y')));
125
-			$date = date('Y-m-d', $time);
126
-			$announcement = new Announcement($i,$this->get_dummy_content('title'),$this->get_dummy_content('text'), $date,0);
127
-			$announcement->item_properties[] = $property;
128
-			$this->course->add_resource($announcement);
129
-		}
130
-	}
131
-	/**
132
-	 * Create dummy events
133
-	 */
134
-	function create_dummy_events()
135
-	{
136
-		$number_of_events = rand(10, 30);
137
-		$property = $this->default_property;
138
-		$property['lastedit_type'] = 'AgendaAdded';
139
-		$property['tool'] = TOOL_CALENDAR_EVENT;
140
-		for ($i = 0; $i < $number_of_events; $i ++)
141
-		{
142
-			$hour = rand(1,24);
143
-			$minute = rand(1,60);
144
-			$second = rand(1,60);
145
-			$day = rand(1,28);
146
-			$month = rand(1,12);
147
-			$year = intval(date('Y'));
148
-			$time = mktime($hour,$minute,$second,$month,$day,$year);
149
-			$start_date = date('Y-m-d H:m:s', $time);
150
-			$hour = rand($hour,24);
151
-			$minute = rand($minute,60);
152
-			$second = rand($second,60);
153
-			$day = rand($day,28);
154
-			$month = rand($month,12);
155
-			$year = intval(date('Y'));
156
-			$time = mktime($hour,$minute,$second,$month,$day,$year);
157
-			$end_date = date('Y-m-d H:m:s', $time);
158
-			$event = new CalendarEvent(
159
-				$i,
160
-				$this->get_dummy_content('title'),
161
-				$this->get_dummy_content('text'),
162
-				$start_date,
163
-				$end_date
164
-			);
165
-			$event->item_properties[] = $property;
166
-			$this->course->add_resource($event);
167
-		}
168
-	}
169
-	/**
170
-	 * Create dummy links
171
-	 */
172
-	function create_dummy_links()
173
-	{
174
-		// create categorys
175
-		$number_of_categories = rand(5, 10);
176
-		for ($i = 0; $i < $number_of_categories; $i ++)
177
-		{
178
-			$linkcat = new LinkCategory($i, $this->get_dummy_content('title'), $this->get_dummy_content('description'),$i);
179
-			$this->course->add_resource($linkcat);
180
-		}
181
-		// create links
182
-		$number_of_links = rand(5, 50);
183
-		$on_homepage = rand(0,20) == 0 ? 1 : 0;
184
-		$property = $this->default_property;
185
-		$property['lastedit_type'] = 'LinkAdded';
186
-		$property['tool'] = TOOL_LINK;
187
-		for ($i = 0; $i < $number_of_links; $i ++)
188
-		{
189
-			$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);
190
-			$link->item_properties[] = $property;
191
-			$this->course->add_resource($link);
192
-		}
193
-	}
194
-	/**
195
-	 * Create dummy forums
196
-	 */
197
-	function create_dummy_forums()
198
-	{
199
-		$number_of_categories = rand(2, 6);
200
-		$number_of_forums = rand(5, 50);
201
-		$number_of_topics = rand(30, 100);
202
-		$number_of_posts = rand(100, 1000);
203
-		$last_forum_post = array ();
204
-		$last_topic_post = array ();
205
-		// create categorys
206
-		$order = 1;
207
-		for ($i = 1; $i <= $number_of_categories; $i ++)
208
-		{
209
-			$forumcat = new ForumCategory($i, $this->get_dummy_content('title'), $this->get_dummy_content('description'), $order, 0, 0);
210
-			$this->course->add_resource($forumcat);
211
-			$order++;
212
-		}
213
-		// create posts
214
-		for ($post_id = 1; $post_id <= $number_of_posts; $post_id ++)
215
-		{
216
-			$topic_id = rand(1, $number_of_topics);
217
-			$last_topic_post[$topic_id] = $post_id;
218
-			$post = new ForumPost($post_id, $this->get_dummy_content('title'), $this->get_dummy_content('text'), date('Y-m-d H:i:s'), 1, 'Portal Administrator', 0, 0, $topic_id, 0, 1);
219
-			$this->course->add_resource($post);
220
-		}
221
-		// create topics
222
-		for ($topic_id = 1; $topic_id <= $number_of_topics; $topic_id ++)
223
-		{
224
-			$forum_id = rand(1, $number_of_forums);
225
-			$last_forum_post[$forum_id] = $last_topic_post[$topic_id];
226
-			$topic = new ForumTopic($topic_id, $this->get_dummy_content('title'), '2011-03-31 12:10:00', 'Chamilo', 'Administrator', 0, $forum_id, $last_topic_post[$topic_id]);
227
-			$this->course->add_resource($topic);
228
-		}
229
-		// create forums
230
-		for ($forum_id = 1; $forum_id <= $number_of_forums; $forum_id ++)
231
-		{
232
-			$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]);
233
-			$this->course->add_resource($forum);
234
-		}
235
-	}
236
-	/**
237
-	 * Create dummy learnpaths
238
-	 */
239
-	function create_dummy_learnpaths()
240
-	{
241
-		$number_of_learnpaths = rand(3,5);
242
-		$global_item_id = 1;
243
-		for($i=1; $i<=$number_of_learnpaths;$i++)
244
-		{
245
-		$chapters = array();
246
-		$number_of_chapters = rand(1,6);
247
-		for($chapter_id = 1; $chapter_id <= $number_of_chapters; $chapter_id++)
248
-		{
249
-			$chapter['name'] = $this->get_dummy_content('title');
250
-			$chapter['description'] = $this->get_dummy_content('description');
251
-			$chapter['display_order'] = $chapter_id;
252
-			$chapter['items'] = array();
253
-			$number_of_items = rand(5,20);
254
-			for( $item_id = 1; $item_id<$number_of_items; $item_id++)
255
-			{
256
-				$types = array(RESOURCE_ANNOUNCEMENT, RESOURCE_EVENT, RESOURCE_DOCUMENT,RESOURCE_LINK,RESOURCE_FORUM,RESOURCE_FORUMPOST,RESOURCE_FORUMTOPIC);
257
-				$type = $types[rand(0,count($types)-1)];
258
-				$resources = $this->course->resources[$type];
259
-				$resource = $resources[rand(0,count($resources)-1)];
260
-				$item = array();
261
-				$item['type'] = $resource->type;
262
-				$item['id'] = $resource->source_id;
263
-				$item['display_order'] = $item_id;
264
-				$item['title'] = $this->get_dummy_content('title');
265
-				$item['description'] = $this->get_dummy_content('description');
266
-				$item['ref_id'] = $global_item_id;
267
-				if( rand(0,5) == 1 && $item_id > 1)
268
-				{
269
-					$item['prereq_type'] = 'i';
270
-					$item['prereq'] = rand($global_item_id - $item_id,$global_item_id-1);
271
-				}
272
-				$chapter['items'][] = $item;
273
-				$global_item_id++;
274
-			}
275
-			$chapters[] = $chapter;
276
-		}
277
-		$lp = new CourseCopyLearnpath($i,$this->get_dummy_content('title'),$this->get_dummy_content('description'),1,$chapters);
278
-		$this->course->add_resource($lp);
279
-		}
280
-	}
281
-	/**
282
-	 * Get dummy titles, descriptions and texts
283
-	 */
284
-	function get_dummy_content($type)
285
-	{
286
-		$dummy_text = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque lectus. Duis sodales. Vivamus et nunc. Phasellus interdum est a lorem. Fusce venenatis luctus lectus. Mauris quis turpis ac erat rhoncus suscipit. Phasellus elit dui, semper at, porta ut, egestas ac, enim. Quisque pellentesque, nisl nec consequat mollis, ipsum justo pellentesque nibh, non faucibus odio ante at lorem. Donec vitae pede ut felis ultricies semper. Suspendisse velit nibh, interdum quis, gravida nec, dapibus ac, leo. Cras id sem ut tellus tincidunt scelerisque. Aenean ac magna feugiat dolor accumsan dignissim. Integer eget nisl.
47
+        $course = api_get_course_info($course_code);
48
+        $this->course = new Course();
49
+        $tmp_path = api_get_path(SYS_COURSE_PATH).$course['directory'].'/document/tmp_'.uniqid('');
50
+        @mkdir($tmp_path, api_get_permissions_for_new_directories(), true);
51
+        $this->course->backup_path = $tmp_path;
52
+        $this->create_dummy_links();
53
+        $this->create_dummy_events();
54
+        $this->create_dummy_forums();
55
+        $this->create_dummy_announcements();
56
+        $this->create_dummy_documents();
57
+        $this->create_dummy_learnpaths();
58
+        $cr = new CourseRestorer($this->course);
59
+        $cr->set_file_option(FILE_OVERWRITE);
60
+        $cr->restore($course_code);
61
+        rmdirr($tmp_path);
62
+    }
63
+    /**
64
+     * Create dummy documents
65
+     */
66
+    function create_dummy_documents()
67
+    {
68
+        $course = api_get_course_info();
69
+        $course_doc_path = $this->course->backup_path.'/document/';
70
+        $number_of_documents = rand(10, 30);
71
+        $extensions = array ('html', 'doc');
72
+        $directories = array();
73
+        $property = $this->default_property;
74
+        $property['lastedit_type'] = 'DocumentAdded';
75
+        $property['tool'] = TOOL_DOCUMENT;
76
+        $doc_id = 0;
77
+        for ($doc_id = 1; $doc_id < $number_of_documents; $doc_id ++)
78
+        {
79
+            $path = '';
80
+            $doc_type = rand(0, count($extensions) - 1);
81
+            $extension = $extensions[$doc_type];
82
+            $filename = $this->get_dummy_content('title').'_'.$doc_id.'.'.$extension;
83
+            $content = $this->get_dummy_content('text');
84
+            $dirs = rand(0, 3);
85
+            for ($i = 0; $i < $dirs; $i ++)
86
+            {
87
+                $path .= 'directory/';
88
+                $directories[$path] = 1;
89
+            }
90
+            $dir_to_make = $course_doc_path.$path;
91
+            if (!is_dir($dir_to_make))
92
+            {
93
+                @mkdir($dir_to_make, api_get_permissions_for_new_directories(), true);
94
+            }
95
+            $file = $course_doc_path.$path.$filename;
96
+            $fp = fopen($file, 'w');
97
+            fwrite($fp, $content);
98
+            fclose($fp);
99
+            $size = filesize($file);
100
+            $document = new Document($doc_id, '/'.$path.$filename,$this->get_dummy_content('description'),$this->get_dummy_content('title'), 'file', $size);
101
+            $document->item_properties[] = $property;
102
+            $this->course->add_resource($document);
103
+        }
104
+        foreach($directories as $path => $flag)
105
+        {
106
+            $path = substr($path,0,strlen($path)-1);
107
+            $document = new Document($doc_id++,'/'.$path, $this->get_dummy_content('description'),$this->get_dummy_content('title'),'folder',0);
108
+            $property['lastedit_type'] = 'FolderCreated';
109
+            $document->item_properties[] = $property;
110
+            $this->course->add_resource($document);
111
+        }
112
+    }
113
+    /**
114
+     * Create dummy announcements
115
+     */
116
+    function create_dummy_announcements()
117
+    {
118
+        $property = $this->default_property;
119
+        $property['lastedit_type'] = 'AnnouncementAdded';
120
+        $property['tool'] = TOOL_ANNOUNCEMENT;
121
+        $number_of_announcements = rand(10, 30);
122
+        for ($i = 0; $i < $number_of_announcements; $i ++)
123
+        {
124
+            $time = mktime(rand(1, 24), rand(1, 60), 0, rand(1, 12), rand(1, 28), intval(date('Y')));
125
+            $date = date('Y-m-d', $time);
126
+            $announcement = new Announcement($i,$this->get_dummy_content('title'),$this->get_dummy_content('text'), $date,0);
127
+            $announcement->item_properties[] = $property;
128
+            $this->course->add_resource($announcement);
129
+        }
130
+    }
131
+    /**
132
+     * Create dummy events
133
+     */
134
+    function create_dummy_events()
135
+    {
136
+        $number_of_events = rand(10, 30);
137
+        $property = $this->default_property;
138
+        $property['lastedit_type'] = 'AgendaAdded';
139
+        $property['tool'] = TOOL_CALENDAR_EVENT;
140
+        for ($i = 0; $i < $number_of_events; $i ++)
141
+        {
142
+            $hour = rand(1,24);
143
+            $minute = rand(1,60);
144
+            $second = rand(1,60);
145
+            $day = rand(1,28);
146
+            $month = rand(1,12);
147
+            $year = intval(date('Y'));
148
+            $time = mktime($hour,$minute,$second,$month,$day,$year);
149
+            $start_date = date('Y-m-d H:m:s', $time);
150
+            $hour = rand($hour,24);
151
+            $minute = rand($minute,60);
152
+            $second = rand($second,60);
153
+            $day = rand($day,28);
154
+            $month = rand($month,12);
155
+            $year = intval(date('Y'));
156
+            $time = mktime($hour,$minute,$second,$month,$day,$year);
157
+            $end_date = date('Y-m-d H:m:s', $time);
158
+            $event = new CalendarEvent(
159
+                $i,
160
+                $this->get_dummy_content('title'),
161
+                $this->get_dummy_content('text'),
162
+                $start_date,
163
+                $end_date
164
+            );
165
+            $event->item_properties[] = $property;
166
+            $this->course->add_resource($event);
167
+        }
168
+    }
169
+    /**
170
+     * Create dummy links
171
+     */
172
+    function create_dummy_links()
173
+    {
174
+        // create categorys
175
+        $number_of_categories = rand(5, 10);
176
+        for ($i = 0; $i < $number_of_categories; $i ++)
177
+        {
178
+            $linkcat = new LinkCategory($i, $this->get_dummy_content('title'), $this->get_dummy_content('description'),$i);
179
+            $this->course->add_resource($linkcat);
180
+        }
181
+        // create links
182
+        $number_of_links = rand(5, 50);
183
+        $on_homepage = rand(0,20) == 0 ? 1 : 0;
184
+        $property = $this->default_property;
185
+        $property['lastedit_type'] = 'LinkAdded';
186
+        $property['tool'] = TOOL_LINK;
187
+        for ($i = 0; $i < $number_of_links; $i ++)
188
+        {
189
+            $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);
190
+            $link->item_properties[] = $property;
191
+            $this->course->add_resource($link);
192
+        }
193
+    }
194
+    /**
195
+     * Create dummy forums
196
+     */
197
+    function create_dummy_forums()
198
+    {
199
+        $number_of_categories = rand(2, 6);
200
+        $number_of_forums = rand(5, 50);
201
+        $number_of_topics = rand(30, 100);
202
+        $number_of_posts = rand(100, 1000);
203
+        $last_forum_post = array ();
204
+        $last_topic_post = array ();
205
+        // create categorys
206
+        $order = 1;
207
+        for ($i = 1; $i <= $number_of_categories; $i ++)
208
+        {
209
+            $forumcat = new ForumCategory($i, $this->get_dummy_content('title'), $this->get_dummy_content('description'), $order, 0, 0);
210
+            $this->course->add_resource($forumcat);
211
+            $order++;
212
+        }
213
+        // create posts
214
+        for ($post_id = 1; $post_id <= $number_of_posts; $post_id ++)
215
+        {
216
+            $topic_id = rand(1, $number_of_topics);
217
+            $last_topic_post[$topic_id] = $post_id;
218
+            $post = new ForumPost($post_id, $this->get_dummy_content('title'), $this->get_dummy_content('text'), date('Y-m-d H:i:s'), 1, 'Portal Administrator', 0, 0, $topic_id, 0, 1);
219
+            $this->course->add_resource($post);
220
+        }
221
+        // create topics
222
+        for ($topic_id = 1; $topic_id <= $number_of_topics; $topic_id ++)
223
+        {
224
+            $forum_id = rand(1, $number_of_forums);
225
+            $last_forum_post[$forum_id] = $last_topic_post[$topic_id];
226
+            $topic = new ForumTopic($topic_id, $this->get_dummy_content('title'), '2011-03-31 12:10:00', 'Chamilo', 'Administrator', 0, $forum_id, $last_topic_post[$topic_id]);
227
+            $this->course->add_resource($topic);
228
+        }
229
+        // create forums
230
+        for ($forum_id = 1; $forum_id <= $number_of_forums; $forum_id ++)
231
+        {
232
+            $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]);
233
+            $this->course->add_resource($forum);
234
+        }
235
+    }
236
+    /**
237
+     * Create dummy learnpaths
238
+     */
239
+    function create_dummy_learnpaths()
240
+    {
241
+        $number_of_learnpaths = rand(3,5);
242
+        $global_item_id = 1;
243
+        for($i=1; $i<=$number_of_learnpaths;$i++)
244
+        {
245
+        $chapters = array();
246
+        $number_of_chapters = rand(1,6);
247
+        for($chapter_id = 1; $chapter_id <= $number_of_chapters; $chapter_id++)
248
+        {
249
+            $chapter['name'] = $this->get_dummy_content('title');
250
+            $chapter['description'] = $this->get_dummy_content('description');
251
+            $chapter['display_order'] = $chapter_id;
252
+            $chapter['items'] = array();
253
+            $number_of_items = rand(5,20);
254
+            for( $item_id = 1; $item_id<$number_of_items; $item_id++)
255
+            {
256
+                $types = array(RESOURCE_ANNOUNCEMENT, RESOURCE_EVENT, RESOURCE_DOCUMENT,RESOURCE_LINK,RESOURCE_FORUM,RESOURCE_FORUMPOST,RESOURCE_FORUMTOPIC);
257
+                $type = $types[rand(0,count($types)-1)];
258
+                $resources = $this->course->resources[$type];
259
+                $resource = $resources[rand(0,count($resources)-1)];
260
+                $item = array();
261
+                $item['type'] = $resource->type;
262
+                $item['id'] = $resource->source_id;
263
+                $item['display_order'] = $item_id;
264
+                $item['title'] = $this->get_dummy_content('title');
265
+                $item['description'] = $this->get_dummy_content('description');
266
+                $item['ref_id'] = $global_item_id;
267
+                if( rand(0,5) == 1 && $item_id > 1)
268
+                {
269
+                    $item['prereq_type'] = 'i';
270
+                    $item['prereq'] = rand($global_item_id - $item_id,$global_item_id-1);
271
+                }
272
+                $chapter['items'][] = $item;
273
+                $global_item_id++;
274
+            }
275
+            $chapters[] = $chapter;
276
+        }
277
+        $lp = new CourseCopyLearnpath($i,$this->get_dummy_content('title'),$this->get_dummy_content('description'),1,$chapters);
278
+        $this->course->add_resource($lp);
279
+        }
280
+    }
281
+    /**
282
+     * Get dummy titles, descriptions and texts
283
+     */
284
+    function get_dummy_content($type)
285
+    {
286
+        $dummy_text = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque lectus. Duis sodales. Vivamus et nunc. Phasellus interdum est a lorem. Fusce venenatis luctus lectus. Mauris quis turpis ac erat rhoncus suscipit. Phasellus elit dui, semper at, porta ut, egestas ac, enim. Quisque pellentesque, nisl nec consequat mollis, ipsum justo pellentesque nibh, non faucibus odio ante at lorem. Donec vitae pede ut felis ultricies semper. Suspendisse velit nibh, interdum quis, gravida nec, dapibus ac, leo. Cras id sem ut tellus tincidunt scelerisque. Aenean ac magna feugiat dolor accumsan dignissim. Integer eget nisl.
287 287
 		Ut sit amet nulla. Vestibulum venenatis posuere mauris. Nullam magna leo, blandit luctus, consequat quis, gravida nec, justo. Nam pede. Etiam ut nisl. In at quam scelerisque sapien faucibus commodo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Proin mattis lorem quis nunc. Praesent placerat ligula id elit. Aenean blandit, purus sit amet pharetra auctor, libero orci rutrum felis, sit amet sodales mauris ipsum ultricies sapien. Vivamus wisi. Cras elit elit, ullamcorper ac, interdum nec, pulvinar nec, lacus. In lacus. Vivamus auctor, arcu vitae tincidunt porta, eros lacus tristique justo, vitae semper risus neque eget massa. Vivamus turpis.
288 288
 		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.
289 289
 		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.
290 290
 		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.';
291
-		switch($type)
292
-		{
293
-		 case 'description':
294
-		 	$descriptions = explode(".",$dummy_text);
295
-		 	return $descriptions[rand(0,count($descriptions)-1)];
296
-		 	break;
297
-		 case 'title':
298
-		 	$dummy_text = str_replace(array("\n",'.',',',"\t"),array(' ','','',' '),$dummy_text);
299
-		 	$titles = explode(" ",$dummy_text);
300
-		 	return trim($titles[rand(0,count($titles)-1)]);
301
-		 	break;
302
-		 case 'text':
303
-		 	$texts = explode("\n",$dummy_text);
304
-		 	return $texts[rand(0,count($texts)-1)];
305
-		 	break;
306
-		}
307
-	}
291
+        switch($type)
292
+        {
293
+            case 'description':
294
+             $descriptions = explode(".",$dummy_text);
295
+                return $descriptions[rand(0,count($descriptions)-1)];
296
+                break;
297
+            case 'title':
298
+             $dummy_text = str_replace(array("\n",'.',',',"\t"),array(' ','','',' '),$dummy_text);
299
+                $titles = explode(" ",$dummy_text);
300
+                return trim($titles[rand(0,count($titles)-1)]);
301
+                break;
302
+            case 'text':
303
+             $texts = explode("\n",$dummy_text);
304
+                return $texts[rand(0,count($texts)-1)];
305
+                break;
306
+        }
307
+    }
308 308
 }
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 		$this->default_property['to_user_id'] = null;
43 43
 		$this->default_property['visibility'] = '1';
44 44
 		$this->default_property['start_visible'] = '0000-00-00 00:00:00';
45
-		$this->default_property['end_visible'] =  '0000-00-00 00:00:00';
45
+		$this->default_property['end_visible'] = '0000-00-00 00:00:00';
46 46
 
47 47
 		$course = api_get_course_info($course_code);
48 48
 		$this->course = new Course();
@@ -68,13 +68,13 @@  discard block
 block discarded – undo
68 68
 		$course = api_get_course_info();
69 69
 		$course_doc_path = $this->course->backup_path.'/document/';
70 70
 		$number_of_documents = rand(10, 30);
71
-		$extensions = array ('html', 'doc');
71
+		$extensions = array('html', 'doc');
72 72
 		$directories = array();
73 73
 		$property = $this->default_property;
74 74
 		$property['lastedit_type'] = 'DocumentAdded';
75 75
 		$property['tool'] = TOOL_DOCUMENT;
76 76
 		$doc_id = 0;
77
-		for ($doc_id = 1; $doc_id < $number_of_documents; $doc_id ++)
77
+		for ($doc_id = 1; $doc_id < $number_of_documents; $doc_id++)
78 78
 		{
79 79
 			$path = '';
80 80
 			$doc_type = rand(0, count($extensions) - 1);
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 			$filename = $this->get_dummy_content('title').'_'.$doc_id.'.'.$extension;
83 83
 			$content = $this->get_dummy_content('text');
84 84
 			$dirs = rand(0, 3);
85
-			for ($i = 0; $i < $dirs; $i ++)
85
+			for ($i = 0; $i < $dirs; $i++)
86 86
 			{
87 87
 				$path .= 'directory/';
88 88
 				$directories[$path] = 1;
@@ -97,14 +97,14 @@  discard block
 block discarded – undo
97 97
 			fwrite($fp, $content);
98 98
 			fclose($fp);
99 99
 			$size = filesize($file);
100
-			$document = new Document($doc_id, '/'.$path.$filename,$this->get_dummy_content('description'),$this->get_dummy_content('title'), 'file', $size);
100
+			$document = new Document($doc_id, '/'.$path.$filename, $this->get_dummy_content('description'), $this->get_dummy_content('title'), 'file', $size);
101 101
 			$document->item_properties[] = $property;
102 102
 			$this->course->add_resource($document);
103 103
 		}
104
-		foreach($directories as $path => $flag)
104
+		foreach ($directories as $path => $flag)
105 105
 		{
106
-			$path = substr($path,0,strlen($path)-1);
107
-			$document = new Document($doc_id++,'/'.$path, $this->get_dummy_content('description'),$this->get_dummy_content('title'),'folder',0);
106
+			$path = substr($path, 0, strlen($path) - 1);
107
+			$document = new Document($doc_id++, '/'.$path, $this->get_dummy_content('description'), $this->get_dummy_content('title'), 'folder', 0);
108 108
 			$property['lastedit_type'] = 'FolderCreated';
109 109
 			$document->item_properties[] = $property;
110 110
 			$this->course->add_resource($document);
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
 		$property['lastedit_type'] = 'AnnouncementAdded';
120 120
 		$property['tool'] = TOOL_ANNOUNCEMENT;
121 121
 		$number_of_announcements = rand(10, 30);
122
-		for ($i = 0; $i < $number_of_announcements; $i ++)
122
+		for ($i = 0; $i < $number_of_announcements; $i++)
123 123
 		{
124 124
 			$time = mktime(rand(1, 24), rand(1, 60), 0, rand(1, 12), rand(1, 28), intval(date('Y')));
125 125
 			$date = date('Y-m-d', $time);
126
-			$announcement = new Announcement($i,$this->get_dummy_content('title'),$this->get_dummy_content('text'), $date,0);
126
+			$announcement = new Announcement($i, $this->get_dummy_content('title'), $this->get_dummy_content('text'), $date, 0);
127 127
 			$announcement->item_properties[] = $property;
128 128
 			$this->course->add_resource($announcement);
129 129
 		}
@@ -137,23 +137,23 @@  discard block
 block discarded – undo
137 137
 		$property = $this->default_property;
138 138
 		$property['lastedit_type'] = 'AgendaAdded';
139 139
 		$property['tool'] = TOOL_CALENDAR_EVENT;
140
-		for ($i = 0; $i < $number_of_events; $i ++)
140
+		for ($i = 0; $i < $number_of_events; $i++)
141 141
 		{
142
-			$hour = rand(1,24);
143
-			$minute = rand(1,60);
144
-			$second = rand(1,60);
145
-			$day = rand(1,28);
146
-			$month = rand(1,12);
142
+			$hour = rand(1, 24);
143
+			$minute = rand(1, 60);
144
+			$second = rand(1, 60);
145
+			$day = rand(1, 28);
146
+			$month = rand(1, 12);
147 147
 			$year = intval(date('Y'));
148
-			$time = mktime($hour,$minute,$second,$month,$day,$year);
148
+			$time = mktime($hour, $minute, $second, $month, $day, $year);
149 149
 			$start_date = date('Y-m-d H:m:s', $time);
150
-			$hour = rand($hour,24);
151
-			$minute = rand($minute,60);
152
-			$second = rand($second,60);
153
-			$day = rand($day,28);
154
-			$month = rand($month,12);
150
+			$hour = rand($hour, 24);
151
+			$minute = rand($minute, 60);
152
+			$second = rand($second, 60);
153
+			$day = rand($day, 28);
154
+			$month = rand($month, 12);
155 155
 			$year = intval(date('Y'));
156
-			$time = mktime($hour,$minute,$second,$month,$day,$year);
156
+			$time = mktime($hour, $minute, $second, $month, $day, $year);
157 157
 			$end_date = date('Y-m-d H:m:s', $time);
158 158
 			$event = new CalendarEvent(
159 159
 				$i,
@@ -173,20 +173,20 @@  discard block
 block discarded – undo
173 173
 	{
174 174
 		// create categorys
175 175
 		$number_of_categories = rand(5, 10);
176
-		for ($i = 0; $i < $number_of_categories; $i ++)
176
+		for ($i = 0; $i < $number_of_categories; $i++)
177 177
 		{
178
-			$linkcat = new LinkCategory($i, $this->get_dummy_content('title'), $this->get_dummy_content('description'),$i);
178
+			$linkcat = new LinkCategory($i, $this->get_dummy_content('title'), $this->get_dummy_content('description'), $i);
179 179
 			$this->course->add_resource($linkcat);
180 180
 		}
181 181
 		// create links
182 182
 		$number_of_links = rand(5, 50);
183
-		$on_homepage = rand(0,20) == 0 ? 1 : 0;
183
+		$on_homepage = rand(0, 20) == 0 ? 1 : 0;
184 184
 		$property = $this->default_property;
185 185
 		$property['lastedit_type'] = 'LinkAdded';
186 186
 		$property['tool'] = TOOL_LINK;
187
-		for ($i = 0; $i < $number_of_links; $i ++)
187
+		for ($i = 0; $i < $number_of_links; $i++)
188 188
 		{
189
-			$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);
189
+			$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);
190 190
 			$link->item_properties[] = $property;
191 191
 			$this->course->add_resource($link);
192 192
 		}
@@ -200,18 +200,18 @@  discard block
 block discarded – undo
200 200
 		$number_of_forums = rand(5, 50);
201 201
 		$number_of_topics = rand(30, 100);
202 202
 		$number_of_posts = rand(100, 1000);
203
-		$last_forum_post = array ();
204
-		$last_topic_post = array ();
203
+		$last_forum_post = array();
204
+		$last_topic_post = array();
205 205
 		// create categorys
206 206
 		$order = 1;
207
-		for ($i = 1; $i <= $number_of_categories; $i ++)
207
+		for ($i = 1; $i <= $number_of_categories; $i++)
208 208
 		{
209 209
 			$forumcat = new ForumCategory($i, $this->get_dummy_content('title'), $this->get_dummy_content('description'), $order, 0, 0);
210 210
 			$this->course->add_resource($forumcat);
211 211
 			$order++;
212 212
 		}
213 213
 		// create posts
214
-		for ($post_id = 1; $post_id <= $number_of_posts; $post_id ++)
214
+		for ($post_id = 1; $post_id <= $number_of_posts; $post_id++)
215 215
 		{
216 216
 			$topic_id = rand(1, $number_of_topics);
217 217
 			$last_topic_post[$topic_id] = $post_id;
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 			$this->course->add_resource($post);
220 220
 		}
221 221
 		// create topics
222
-		for ($topic_id = 1; $topic_id <= $number_of_topics; $topic_id ++)
222
+		for ($topic_id = 1; $topic_id <= $number_of_topics; $topic_id++)
223 223
 		{
224 224
 			$forum_id = rand(1, $number_of_forums);
225 225
 			$last_forum_post[$forum_id] = $last_topic_post[$topic_id];
@@ -227,9 +227,9 @@  discard block
 block discarded – undo
227 227
 			$this->course->add_resource($topic);
228 228
 		}
229 229
 		// create forums
230
-		for ($forum_id = 1; $forum_id <= $number_of_forums; $forum_id ++)
230
+		for ($forum_id = 1; $forum_id <= $number_of_forums; $forum_id++)
231 231
 		{
232
-			$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]);
232
+			$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]);
233 233
 			$this->course->add_resource($forum);
234 234
 		}
235 235
 	}
@@ -238,25 +238,25 @@  discard block
 block discarded – undo
238 238
 	 */
239 239
 	function create_dummy_learnpaths()
240 240
 	{
241
-		$number_of_learnpaths = rand(3,5);
241
+		$number_of_learnpaths = rand(3, 5);
242 242
 		$global_item_id = 1;
243
-		for($i=1; $i<=$number_of_learnpaths;$i++)
243
+		for ($i = 1; $i <= $number_of_learnpaths; $i++)
244 244
 		{
245 245
 		$chapters = array();
246
-		$number_of_chapters = rand(1,6);
247
-		for($chapter_id = 1; $chapter_id <= $number_of_chapters; $chapter_id++)
246
+		$number_of_chapters = rand(1, 6);
247
+		for ($chapter_id = 1; $chapter_id <= $number_of_chapters; $chapter_id++)
248 248
 		{
249 249
 			$chapter['name'] = $this->get_dummy_content('title');
250 250
 			$chapter['description'] = $this->get_dummy_content('description');
251 251
 			$chapter['display_order'] = $chapter_id;
252 252
 			$chapter['items'] = array();
253
-			$number_of_items = rand(5,20);
254
-			for( $item_id = 1; $item_id<$number_of_items; $item_id++)
253
+			$number_of_items = rand(5, 20);
254
+			for ($item_id = 1; $item_id < $number_of_items; $item_id++)
255 255
 			{
256
-				$types = array(RESOURCE_ANNOUNCEMENT, RESOURCE_EVENT, RESOURCE_DOCUMENT,RESOURCE_LINK,RESOURCE_FORUM,RESOURCE_FORUMPOST,RESOURCE_FORUMTOPIC);
257
-				$type = $types[rand(0,count($types)-1)];
256
+				$types = array(RESOURCE_ANNOUNCEMENT, RESOURCE_EVENT, RESOURCE_DOCUMENT, RESOURCE_LINK, RESOURCE_FORUM, RESOURCE_FORUMPOST, RESOURCE_FORUMTOPIC);
257
+				$type = $types[rand(0, count($types) - 1)];
258 258
 				$resources = $this->course->resources[$type];
259
-				$resource = $resources[rand(0,count($resources)-1)];
259
+				$resource = $resources[rand(0, count($resources) - 1)];
260 260
 				$item = array();
261 261
 				$item['type'] = $resource->type;
262 262
 				$item['id'] = $resource->source_id;
@@ -264,17 +264,17 @@  discard block
 block discarded – undo
264 264
 				$item['title'] = $this->get_dummy_content('title');
265 265
 				$item['description'] = $this->get_dummy_content('description');
266 266
 				$item['ref_id'] = $global_item_id;
267
-				if( rand(0,5) == 1 && $item_id > 1)
267
+				if (rand(0, 5) == 1 && $item_id > 1)
268 268
 				{
269 269
 					$item['prereq_type'] = 'i';
270
-					$item['prereq'] = rand($global_item_id - $item_id,$global_item_id-1);
270
+					$item['prereq'] = rand($global_item_id - $item_id, $global_item_id - 1);
271 271
 				}
272 272
 				$chapter['items'][] = $item;
273 273
 				$global_item_id++;
274 274
 			}
275 275
 			$chapters[] = $chapter;
276 276
 		}
277
-		$lp = new CourseCopyLearnpath($i,$this->get_dummy_content('title'),$this->get_dummy_content('description'),1,$chapters);
277
+		$lp = new CourseCopyLearnpath($i, $this->get_dummy_content('title'), $this->get_dummy_content('description'), 1, $chapters);
278 278
 		$this->course->add_resource($lp);
279 279
 		}
280 280
 	}
@@ -288,20 +288,20 @@  discard block
 block discarded – undo
288 288
 		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.
289 289
 		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.
290 290
 		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.';
291
-		switch($type)
291
+		switch ($type)
292 292
 		{
293 293
 		 case 'description':
294
-		 	$descriptions = explode(".",$dummy_text);
295
-		 	return $descriptions[rand(0,count($descriptions)-1)];
294
+		 	$descriptions = explode(".", $dummy_text);
295
+		 	return $descriptions[rand(0, count($descriptions) - 1)];
296 296
 		 	break;
297 297
 		 case 'title':
298
-		 	$dummy_text = str_replace(array("\n",'.',',',"\t"),array(' ','','',' '),$dummy_text);
299
-		 	$titles = explode(" ",$dummy_text);
300
-		 	return trim($titles[rand(0,count($titles)-1)]);
298
+		 	$dummy_text = str_replace(array("\n", '.', ',', "\t"), array(' ', '', '', ' '), $dummy_text);
299
+		 	$titles = explode(" ", $dummy_text);
300
+		 	return trim($titles[rand(0, count($titles) - 1)]);
301 301
 		 	break;
302 302
 		 case 'text':
303
-		 	$texts = explode("\n",$dummy_text);
304
-		 	return $texts[rand(0,count($texts)-1)];
303
+		 	$texts = explode("\n", $dummy_text);
304
+		 	return $texts[rand(0, count($texts) - 1)];
305 305
 		 	break;
306 306
 		}
307 307
 	}
Please login to merge, or discard this patch.
main/coursecopy/classes/Event.class.php 2 patches
Doc Comments   -3 removed lines patch added patch discarded remove patch
@@ -50,9 +50,6 @@
 block discarded – undo
50 50
      * @param int $id
51 51
      * @param string $title
52 52
      * @param string $content
53
-     * @param string $date
54
-     * @param string $hour
55
-     * @param int $duration
56 53
      */
57 54
     public function __construct(
58 55
         $id,
Please login to merge, or discard this patch.
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -66,19 +66,19 @@
 block discarded – undo
66 66
         $attachment_comment = null,
67 67
         $all_day = 0
68 68
     ) {
69
-		parent::__construct($id, RESOURCE_EVENT);
69
+        parent::__construct($id, RESOURCE_EVENT);
70 70
 
71
-		$this->title = $title;
72
-		$this->content = $content;
73
-		$this->start_date = $start_date;
74
-		$this->end_date = $end_date;
75
-		$this->all_day = $all_day;
71
+        $this->title = $title;
72
+        $this->content = $content;
73
+        $this->start_date = $start_date;
74
+        $this->end_date = $end_date;
75
+        $this->all_day = $all_day;
76 76
 
77
-		$this->attachment_path = $attachment_path;
78
-		$this->attachment_filename = $attachment_filename;
79
-		$this->attachment_size = $attachment_size;
80
-		$this->attachment_comment = $attachment_comment;
81
-	}
77
+        $this->attachment_path = $attachment_path;
78
+        $this->attachment_filename = $attachment_filename;
79
+        $this->attachment_size = $attachment_size;
80
+        $this->attachment_comment = $attachment_comment;
81
+    }
82 82
 
83 83
     /**
84 84
      * Show this Event
Please login to merge, or discard this patch.
main/coursecopy/classes/QuizQuestion.class.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -115,6 +115,9 @@
 block discarded – undo
115 115
         $this->answers[] = $answer;
116 116
     }
117 117
 
118
+    /**
119
+     * @param QuizQuestionOption $option_obj
120
+     */
118 121
     public function add_option($option_obj)
119 122
     {
120 123
         $this->question_options[$option_obj->obj->id] = $option_obj;
Please login to merge, or discard this patch.
main/coursecopy/classes/Resource.class.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -128,7 +128,7 @@
 block discarded – undo
128 128
 
129 129
     /**
130 130
      * Resturns the type of this resource
131
-     * @return constant The type.
131
+     * @return integer The type.
132 132
      */
133 133
     public function get_type()
134 134
     {
Please login to merge, or discard this patch.
main/coursecopy/copy_course_session_selected.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -65,6 +65,9 @@
 block discarded – undo
65 65
 
66 66
 /* FUNCTIONS */
67 67
 
68
+/**
69
+ * @param string $name
70
+ */
68 71
 function make_select_session_list($name, $sessions, $attr = array())
69 72
 {
70 73
 
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 $nameTools = get_lang('CopyCourse');
49 49
 $returnLink = api_get_path(
50 50
         WEB_CODE_PATH
51
-    ) . 'course_info/maintenance_coach.php?' . api_get_cidreq();
51
+    ).'course_info/maintenance_coach.php?'.api_get_cidreq();
52 52
 $interbreadcrumb[] = array(
53 53
     'url' => $returnLink,
54 54
     'name' => get_lang('Maintenance')
@@ -71,29 +71,29 @@  discard block
 block discarded – undo
71 71
     $attrs = '';
72 72
     if (count($attr) > 0) {
73 73
         foreach ($attr as $key => $value) {
74
-            $attrs .= ' ' . $key . '="' . $value . '"';
74
+            $attrs .= ' '.$key.'="'.$value.'"';
75 75
         }
76 76
     }
77
-    $output = '<select name="' . $name . '" ' . $attrs . '>';
77
+    $output = '<select name="'.$name.'" '.$attrs.'>';
78 78
 
79 79
     if (count($sessions) == 0) {
80
-        $output .= '<option value = "0">' . get_lang(
80
+        $output .= '<option value = "0">'.get_lang(
81 81
                 'ThereIsNotStillASession'
82
-            ) . '</option>';
82
+            ).'</option>';
83 83
     } else {
84
-        $output .= '<option value = "0">' . get_lang(
84
+        $output .= '<option value = "0">'.get_lang(
85 85
                 'SelectASession'
86
-            ) . '</option>';
86
+            ).'</option>';
87 87
     }
88 88
 
89 89
     if (is_array($sessions)) {
90 90
         foreach ($sessions as $session) {
91 91
             $category_name = '';
92 92
             if (!empty($session['category_name'])) {
93
-                $category_name = ' (' . $session['category_name'] . ')';
93
+                $category_name = ' ('.$session['category_name'].')';
94 94
             }
95 95
 
96
-            $output .= '<option value="' . $session['id'] . '">' . $session['name'] . ' ' . $category_name . '</option>';
96
+            $output .= '<option value="'.$session['id'].'">'.$session['name'].' '.$category_name.'</option>';
97 97
         }
98 98
     }
99 99
     $output .= '</select>';
@@ -118,43 +118,43 @@  discard block
 block discarded – undo
118 118
     // Actions
119 119
     $html .= '<div class="actions">';
120 120
     // Link back to the documents overview
121
-    $html .= '<a href="' . $returnLink . '">' . Display::return_icon(
122
-            'back.png', get_lang('BackTo') . ' ' . get_lang('Maintenance'), '', ICON_SIZE_MEDIUM
123
-        ) . '</a>';
121
+    $html .= '<a href="'.$returnLink.'">'.Display::return_icon(
122
+            'back.png', get_lang('BackTo').' '.get_lang('Maintenance'), '', ICON_SIZE_MEDIUM
123
+        ).'</a>';
124 124
     $html .= '</div>';
125 125
 
126 126
     $html .= Display::return_message(
127 127
             get_lang('CopyCourseFromSessionToSessionExplanation')
128 128
     );
129 129
 
130
-    $html .= '<form name="formulaire" method="post" action="' . api_get_self(
131
-        ) . '?' . api_get_cidreq() . '" >';
130
+    $html .= '<form name="formulaire" method="post" action="'.api_get_self(
131
+        ).'?'.api_get_cidreq().'" >';
132 132
     $html .= '<table border="0" cellpadding="5" cellspacing="0" width="100%">';
133 133
 
134 134
     // Source
135
-    $html .= '<tr><td width="15%"><b>' . get_lang(
135
+    $html .= '<tr><td width="15%"><b>'.get_lang(
136 136
             'OriginCoursesFromSession'
137
-        ) . ':</b></td>';
138
-    $html .= '<td width="10%" align="left">' . api_get_session_name(
137
+        ).':</b></td>';
138
+    $html .= '<td width="10%" align="left">'.api_get_session_name(
139 139
             $sessionId
140
-        ) . '</td>';
140
+        ).'</td>';
141 141
     $html .= '<td width="50%">';
142
-    $html .= "{$courseInfo['title']} ({$courseInfo['code']})" . '</td></tr>';
142
+    $html .= "{$courseInfo['title']} ({$courseInfo['code']})".'</td></tr>';
143 143
 
144 144
     // Destination
145
-    $html .= '<tr><td width="15%"><b>' . get_lang(
145
+    $html .= '<tr><td width="15%"><b>'.get_lang(
146 146
             'DestinationCoursesFromSession'
147
-        ) . ':</b></td>';
147
+        ).':</b></td>';
148 148
     $html .= '<td width="10%" align="left"><div id="ajax_sessions_list_destination">';
149 149
     $html .= '<select name="sessions_list_destination" onchange="javascript: xajax_searchCourses(this.value,\'destination\');">';
150 150
     if (empty($sessions)) {
151
-        $html .= '<option value = "0">' . get_lang(
151
+        $html .= '<option value = "0">'.get_lang(
152 152
                 'ThereIsNotStillASession'
153
-            ) . '</option>';
153
+            ).'</option>';
154 154
     } else {
155
-        $html .= '<option value = "0">' . get_lang(
155
+        $html .= '<option value = "0">'.get_lang(
156 156
                 'SelectASession'
157
-            ) . '</option>';
157
+            ).'</option>';
158 158
         foreach ($sessions as $session) {
159 159
             if ($session['id'] == $sessionId) {
160 160
                 continue;
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
                 continue;
165 165
             }
166 166
 
167
-            $html .= '<option value="' . $session['id'] . '">' . $session['name'] . '</option>';
167
+            $html .= '<option value="'.$session['id'].'">'.$session['name'].'</option>';
168 168
         }
169 169
     }
170 170
 
@@ -176,17 +176,17 @@  discard block
 block discarded – undo
176 176
     $html .= '</tr></table>';
177 177
 
178 178
     $html .= "<fieldset>";
179
-    $html .= '<legend>' . get_lang('TypeOfCopy') . ' <small>(' . get_lang('CopyOnlySessionItems') . ')</small></legend>';
179
+    $html .= '<legend>'.get_lang('TypeOfCopy').' <small>('.get_lang('CopyOnlySessionItems').')</small></legend>';
180 180
     $html .= '<label class="radio"><input type="radio" id="copy_option_1" name="copy_option" value="full_copy" checked="checked"/>';
181
-    $html .= get_lang('FullCopy') . '</label>';
181
+    $html .= get_lang('FullCopy').'</label>';
182 182
     $html .= '<label class="radio"><input type="radio" id="copy_option_2" name="copy_option" value="select_items"/>';
183
-    $html .= ' ' . get_lang('LetMeSelectItems') . '</label><br/>';
183
+    $html .= ' '.get_lang('LetMeSelectItems').'</label><br/>';
184 184
 
185 185
     $html .= "</fieldset>";
186 186
 
187
-    $html .= '<button class="save" type="submit" onclick="javascript:if(!confirm(' . "'" . addslashes(
187
+    $html .= '<button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(
188 188
             api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)
189
-        ) . "'" . ')) return false;">' . get_lang('CopyCourse') . '</button>';
189
+        )."'".')) return false;">'.get_lang('CopyCourse').'</button>';
190 190
     $html .= '</form>';
191 191
     echo $html;
192 192
 }
@@ -212,10 +212,10 @@  discard block
 block discarded – undo
212 212
 
213 213
             $courseTitle = str_replace("'", "\'", $course['title']);
214 214
 
215
-            $return .= '<option value="' . $course['code'] . '" title="' . @htmlspecialchars(
216
-                    $course['title'] . ' (' . $course['visual_code'] . ')', ENT_QUOTES, api_get_system_encoding()
217
-                ) . '">' .
218
-                $course['title'] . ' (' . $course['visual_code'] . ')</option>';
215
+            $return .= '<option value="'.$course['code'].'" title="'.@htmlspecialchars(
216
+                    $course['title'].' ('.$course['visual_code'].')', ENT_QUOTES, api_get_system_encoding()
217
+                ).'">'.
218
+                $course['title'].' ('.$course['visual_code'].')</option>';
219 219
         }
220 220
         $return .= '</select>';
221 221
         $_SESSION['course_list_destination'] = $course_list_destination;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 /* HTML head extra */
234 234
 
235 235
 $htmlHeadXtra[] = $xajax->getJavascript(
236
-    api_get_path(WEB_LIBRARY_PATH) . 'xajax/'
236
+    api_get_path(WEB_LIBRARY_PATH).'xajax/'
237 237
 );
238 238
 $htmlHeadXtra[] = '<script>
239 239
 	function checkSelected(id_select,id_radio,id_title,id_destination) {
@@ -378,13 +378,13 @@  discard block
 block discarded – undo
378 378
 
379 379
         CourseSelectForm :: display_form($course, $hiddenFields, true);
380 380
 
381
-        echo '<div style="float:right"><a href="javascript:window.history.go(-1);">' .
381
+        echo '<div style="float:right"><a href="javascript:window.history.go(-1);">'.
382 382
             Display::return_icon(
383
-                'back.png', get_lang('Back') . ' ' . get_lang('To') . ' ' . get_lang(
383
+                'back.png', get_lang('Back').' '.get_lang('To').' '.get_lang(
384 384
                     'PlatformAdmin'
385 385
                 ), array('style' => 'vertical-align:middle')
386
-            ) .
387
-            get_lang('Back') . '</a></div>';
386
+            ).
387
+            get_lang('Back').'</a></div>';
388 388
     } else {
389 389
         Display::display_error_message(
390 390
             get_lang('You must select a course from original session and select a destination session')
Please login to merge, or discard this patch.
main/cron/create_course_sessions.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -50,6 +50,7 @@  discard block
 block discarded – undo
50 50
 /**
51 51
  * Returns a quarter from a month
52 52
  * @param   string  The month (digit), with or without leading 0
53
+ * @param string $month
53 54
  * @return  int The yearly quarter (1, 2, 3 or 4) in which this month lies
54 55
  */
55 56
 function getQuarter($month)
@@ -96,6 +97,7 @@  discard block
 block discarded – undo
96 97
 /**
97 98
  * Returns the first month of the quarter
98 99
  * @param   int Quarter
100
+ * @param integer $quarter
99 101
  * @return  string Number of the month, with leading 0
100 102
  */
101 103
 function getQuarterFirstMonth($quarter)
@@ -116,6 +118,7 @@  discard block
 block discarded – undo
116 118
 /**
117 119
  * Get the quarter in Roman letters
118 120
  * @param   int Quarter
121
+ * @param integer $quarter
119 122
  * @return  string  Roman letters
120 123
  */
121 124
 function getQuarterRoman($quarter)
Please login to merge, or discard this patch.
Spacing   +7 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
     exit; //do not run from browser
15 15
 }
16 16
 
17
-require_once __DIR__ . "/../inc/global.inc.php";
17
+require_once __DIR__."/../inc/global.inc.php";
18 18
 
19 19
 // First day of the current month to create sessions and add courses for the next month (e.g. "07")
20 20
 define("OFFSET", "15");
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 {
42 42
     $startDate = $initialDate ? $initialDate : date("Y-m-01");
43 43
     $month = getQuarterFirstMonth(getQuarter(date('m', $startDate)));
44
-    $startDate = substr($startDate, 0, 5) . $month . '-01';
44
+    $startDate = substr($startDate, 0, 5).$month.'-01';
45 45
     $nextQuarterStartDate = date('Y-m-d', api_strtotime($startDate.' + 3 month'));
46 46
     $endDate = date('Y-m-d', api_strtotime($nextQuarterStartDate.' - 1 minute'));
47 47
     return array('startDate' => $startDate, 'endDate' => $endDate);
@@ -145,8 +145,7 @@  discard block
 block discarded – undo
145 145
 {
146 146
     echo "\n";
147 147
     echo $courses ?
148
-        "Creating sessions and adding courses for the period between ".$startDate." and ".$endDate :
149
-        "Every course is already in session for the period between ".$startDate." and ".$endDate;
148
+        "Creating sessions and adding courses for the period between ".$startDate." and ".$endDate : "Every course is already in session for the period between ".$startDate." and ".$endDate;
150 149
     echo "\n=====================================================================================\n\n";
151 150
     // Loop through courses creating one session per each and adding them
152 151
     foreach ($courses as $course) {
@@ -155,8 +154,8 @@  discard block
 block discarded – undo
155 154
         $year = date("Y", api_strtotime($startDate));
156 155
         $quarter = getQuarter($month);
157 156
         $quarter = getQuarterRoman($quarter);
158
-        $period = $year . '-' . $quarter;
159
-        $sessionName = '[' . $period . '] ' . $course['title'];
157
+        $period = $year.'-'.$quarter;
158
+        $sessionName = '['.$period.'] '.$course['title'];
160 159
         $sessionId = SessionManager::create_session(
161 160
             $sessionName,
162 161
             $startDate,
@@ -175,7 +174,7 @@  discard block
 block discarded – undo
175 174
 }
176 175
 
177 176
 // Starts the script
178
-echo "Starting process..." . PHP_EOL;
177
+echo "Starting process...".PHP_EOL;
179 178
 // Get first active administrator
180 179
 $administrators = array_reverse(UserManager::get_all_administrators());
181 180
 $lastingAdministrators = count($administrators);
@@ -196,7 +195,7 @@  discard block
 block discarded – undo
196 195
 
197 196
 // Creates course sessions for the following month
198 197
 $offsetDay = intval(substr($dates['endDate'], 8, 2)) - OFFSET;
199
-if (date("Y-m-d") >= date(substr($dates['endDate'], 0, 8) . $offsetDay)) {
198
+if (date("Y-m-d") >= date(substr($dates['endDate'], 0, 8).$offsetDay)) {
200 199
     $dates = getQuarterFirstAndLastDates(date("Y-m-d", api_strtotime(date("Y-m-01")." + 3 month")));
201 200
     // Get courses that don't have any session the next month
202 201
     $courses = CourseManager::getCoursesWithoutSession($dates['startDate'], $dates['endDate']);
Please login to merge, or discard this patch.
main/cron/import_csv.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     public $conditions;
49 49
 
50 50
     /**
51
-     * @param Logger $logger
51
+     * @param Monolog\Logger $logger
52 52
      * @param array
53 53
      */
54 54
     public function __construct($logger, $conditions)
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     }
67 67
 
68 68
     /**
69
-     * @return mixed
69
+     * @return boolean
70 70
      */
71 71
     public function getDumpValues()
72 72
     {
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /* For licensing terms, see /license.txt */
3 3
 
4
-if (PHP_SAPI !='cli') {
4
+if (PHP_SAPI != 'cli') {
5 5
     die('Run this script through the command line or comment this line in the code');
6 6
 }
7 7
 
@@ -365,11 +365,11 @@  discard block
 block discarded – undo
365 365
                 $row = $this->cleanUserRow($row);
366 366
 
367 367
                 $user_id = UserManager::get_user_id_from_original_id(
368
-                    $row['extra_' . $this->extraFieldIdNameList['user']],
368
+                    $row['extra_'.$this->extraFieldIdNameList['user']],
369 369
                     $this->extraFieldIdNameList['user']
370 370
                 );
371
-                $userInfo  = array();
372
-                $userInfoByOfficialCode  = null;
371
+                $userInfo = array();
372
+                $userInfoByOfficialCode = null;
373 373
 
374 374
                 if (!empty($user_id)) {
375 375
                     $userInfo = api_get_user_info($user_id);
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
                     $result = UserManager::update_user(
424 424
                         $userInfo['user_id'],
425 425
                         $row['firstname'], // <<-- changed
426
-                        $row['lastname'],  // <<-- changed
426
+                        $row['lastname'], // <<-- changed
427 427
                         $userInfo['username'],
428 428
                         null, //$password = null,
429 429
                         $row['auth_source'],
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 
558 558
                     if ($row['action'] == 'delete') {
559 559
                         // Inactive one year later
560
-                        $userInfo['expiration_date'] = api_get_utc_datetime(api_strtotime(time() + 365*24*60*60));
560
+                        $userInfo['expiration_date'] = api_get_utc_datetime(api_strtotime(time() + 365 * 24 * 60 * 60));
561 561
                     }
562 562
 
563 563
                     $password = $row['password']; // change password
@@ -606,8 +606,8 @@  discard block
 block discarded – undo
606 606
                     $result = UserManager::update_user(
607 607
                         $userInfo['user_id'],
608 608
                         $row['firstname'], // <<-- changed
609
-                        $row['lastname'],  // <<-- changed
610
-                        $row['username'],  // <<-- changed
609
+                        $row['lastname'], // <<-- changed
610
+                        $row['username'], // <<-- changed
611 611
                         $password, //$password = null,
612 612
                         $row['auth_source'],
613 613
                         $email,
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
         $data = Import::csv_to_array($file);
675 675
 
676 676
         if (!empty($data)) {
677
-            $this->logger->addInfo(count($data) . " records found.");
677
+            $this->logger->addInfo(count($data)." records found.");
678 678
             $eventsToCreate = array();
679 679
             $errorFound = false;
680 680
             foreach ($data as $row) {
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
                     );
689 689
                 }
690 690
 
691
-                $courseCode  = null;
691
+                $courseCode = null;
692 692
                 if (isset($row['coursecode'])) {
693 693
                     $courseCode = $row['coursecode'];
694 694
                 }
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
                 }
743 743
 
744 744
                 $date = $row['date'];
745
-                $startTime  = $row['time_start'];
745
+                $startTime = $row['time_start'];
746 746
                 $endTime = $row['time_end'];
747 747
                 $title = $row['title'];
748 748
                 $comment = $row['comment'];
@@ -966,7 +966,7 @@  discard block
 block discarded – undo
966 966
                 $row = $this->cleanCourseRow($row);
967 967
 
968 968
                 $courseId = CourseManager::get_course_id_from_original_id(
969
-                    $row['extra_' . $this->extraFieldIdNameList['course']],
969
+                    $row['extra_'.$this->extraFieldIdNameList['course']],
970 970
                     $this->extraFieldIdNameList['course']
971 971
                 );
972 972
 
@@ -1084,7 +1084,7 @@  discard block
 block discarded – undo
1084 1084
         $data = Import::csv_reader($file);
1085 1085
 
1086 1086
         if (!empty($data)) {
1087
-            $this->logger->addInfo(count($data) . " records found.");
1087
+            $this->logger->addInfo(count($data)." records found.");
1088 1088
             foreach ($data as $row) {
1089 1089
                 $chamiloUserName = $row['UserName'];
1090 1090
                 $chamiloCourseCode = $row['CourseCode'];
@@ -1126,7 +1126,7 @@  discard block
 block discarded – undo
1126 1126
                 );
1127 1127
 
1128 1128
                 $this->logger->addError(
1129
-                    "User '$chamiloUserName' was remove from Session: #$chamiloSessionId - Course: " . $courseInfo['code']
1129
+                    "User '$chamiloUserName' was remove from Session: #$chamiloSessionId - Course: ".$courseInfo['code']
1130 1130
                 );
1131 1131
 
1132 1132
             }
@@ -1143,7 +1143,7 @@  discard block
 block discarded – undo
1143 1143
         $data = Import::csv_reader($file);
1144 1144
 
1145 1145
         if (!empty($data)) {
1146
-            $this->logger->addInfo(count($data) . " records found.");
1146
+            $this->logger->addInfo(count($data)." records found.");
1147 1147
             foreach ($data as $row) {
1148 1148
                 $chamiloUserName = $row['UserName'];
1149 1149
                 $chamiloCourseCode = $row['CourseCode'];
@@ -1198,7 +1198,7 @@  discard block
 block discarded – undo
1198 1198
                 }
1199 1199
 
1200 1200
                 $this->logger->addError(
1201
-                    "User '$chamiloUserName' with status $type was added to session: #$chamiloSessionId - Course: " . $courseInfo['code']
1201
+                    "User '$chamiloUserName' with status $type was added to session: #$chamiloSessionId - Course: ".$courseInfo['code']
1202 1202
                 );
1203 1203
             }
1204 1204
         }
@@ -1441,7 +1441,7 @@  discard block
 block discarded – undo
1441 1441
      */
1442 1442
     private function importSessions($file, $moveFile = true, &$teacherBackup = array(), &$groupBackup = array())
1443 1443
     {
1444
-        $avoid =  null;
1444
+        $avoid = null;
1445 1445
         if (isset($this->conditions['importSessions']) &&
1446 1446
             isset($this->conditions['importSessions']['update'])
1447 1447
         ) {
@@ -1486,7 +1486,7 @@  discard block
 block discarded – undo
1486 1486
         $data = Import::csv_reader($file);
1487 1487
 
1488 1488
         if (!empty($data)) {
1489
-            $this->logger->addInfo(count($data) . " records found.");
1489
+            $this->logger->addInfo(count($data)." records found.");
1490 1490
             foreach ($data as $row) {
1491 1491
                 $chamiloUserName = $row['UserName'];
1492 1492
                 $chamiloCourseCode = $row['CourseCode'];
@@ -1533,7 +1533,7 @@  discard block
 block discarded – undo
1533 1533
                 }
1534 1534
 
1535 1535
                 $this->logger->addError(
1536
-                    "User '$chamiloUserName' with status $type was added to session: #$chamiloSessionId - Course: " . $courseInfo['code']
1536
+                    "User '$chamiloUserName' with status $type was added to session: #$chamiloSessionId - Course: ".$courseInfo['code']
1537 1537
                 );
1538 1538
             }
1539 1539
         }
Please login to merge, or discard this patch.