Jelajahi Sumber

Minor - format code.

Julio Montoya 10 tahun lalu
induk
melakukan
956475f2e3

+ 14 - 5
main/coursecopy/classes/CourseArchiver.class.php

@@ -1,5 +1,4 @@
 <?php
-
 /* For licensing terms, see /license.txt */
 
 require_once 'Course.class.php';
@@ -22,7 +21,10 @@ class CourseArchiver
         $dir = api_get_path(SYS_ARCHIVE_PATH);
         if ($handle = @ opendir($dir)) {
             while (($file = readdir($handle)) !== false) {
-                if ($file != "." && $file != ".." && strpos($file, 'CourseArchiver_') === 0 && is_dir($dir . '/' . $file)) {
+                if ($file != "." && $file != ".." &&
+                    strpos($file, 'CourseArchiver_') === 0 &&
+                    is_dir($dir . '/' . $file)
+                ) {
                     rmdirr($dir . '/' . $file);
                 }
             }
@@ -152,15 +154,20 @@ class CourseArchiver
                     $course_code = $file_parts[1];
                     $file_parts = explode('.', $file_parts[2]);
                     $date = $file_parts[0];
-                    $ext = $file_parts[1];
+                    $ext = isset($file_parts[1]) ? $file_parts[1] : null;
                     if ($ext == 'zip' && ($user_id != null && $owner_id == $user_id || $user_id == null)) {
                         $date = substr($date, 0, 4) . '-' . substr($date, 4, 2) . '-' . substr($date, 6, 2) . ' ' . substr($date, 9, 2) . ':' . substr($date, 11, 2) . ':' . substr($date, 13, 2);
-                        $backup_files[] = array('file' => $file, 'date' => $date, 'course_code' => $course_code);
+                        $backup_files[] = array(
+                            'file' => $file,
+                            'date' => $date,
+                            'course_code' => $course_code
+                        );
                     }
                 }
             }
             closedir($dir);
         }
+
         return $backup_files;
     }
 
@@ -174,8 +181,10 @@ class CourseArchiver
         $new_dir = api_get_path(SYS_ARCHIVE_PATH);
         if (is_dir($new_dir) && is_writable($new_dir)) {
             move_uploaded_file($file, api_get_path(SYS_ARCHIVE_PATH).$new_filename);
+
             return $new_filename;
         }
+
         return false;
     }
 
@@ -218,7 +227,7 @@ class CourseArchiver
             return new Course();
         }
         $course->backup_path = $unzip_dir;
+
         return $course;
     }
-
 }

+ 37 - 7
main/coursecopy/classes/CourseCopyLearnpath.class.php

@@ -1,11 +1,13 @@
 <?php
 /* For licensing terms, see /license.txt */
+
 /**
- * A learnpath
+ * Class CourseCopyLearnpath
  * @author Bart Mollet <bart.mollet@hogent.be>
  * @package chamilo.backup
  */
-class CourseCopyLearnpath extends Resource {
+class CourseCopyLearnpath extends Resource
+{
 	/**
 	 * Type of learnpath (can be dokeos (1), scorm (2), aicc (3))
 	 */
@@ -106,9 +108,35 @@ class CourseCopyLearnpath extends Resource {
 	 * @param string $visibility
 	 * @param array  $items
 	 */
-	function CourseCopyLearnpath($id,$type,$name, $path,$ref,$description,$content_local,$default_encoding,$default_view_mode,$prevent_reinit,$force_commit,
-	                             $content_maker, $display_order,$js_lib,$content_license,$debug, $visibility, $author, $preview_image,
-	                             $use_max_score, $autolunch, $created_on, $modified_on, $publicated_on, $expired_on, $session_id, $items) {
+	public function CourseCopyLearnpath(
+		$id,
+		$type,
+		$name,
+		$path,
+		$ref,
+		$description,
+		$content_local,
+		$default_encoding,
+		$default_view_mode,
+		$prevent_reinit,
+		$force_commit,
+		$content_maker,
+		$display_order,
+		$js_lib,
+		$content_license,
+		$debug,
+		$visibility,
+		$author,
+		$preview_image,
+		$use_max_score,
+		$autolunch,
+		$created_on,
+		$modified_on,
+		$publicated_on,
+		$expired_on,
+		$session_id,
+		$items
+	) {
 		parent::Resource($id,RESOURCE_LEARNPATH);
 		$this->lp_type = $type;
 		$this->name = $name;
@@ -147,6 +175,7 @@ class CourseCopyLearnpath extends Resource {
 	{
 		return $this->items;
 	}
+
 	/**
 	 * Check if a given resource is used as an item in this chapter
 	 */
@@ -154,13 +183,14 @@ class CourseCopyLearnpath extends Resource {
 	{
 		foreach ($this->items as $item) {
 			if ($item['id'] == $resource->get_id() &&
-                isset($item['type']) && $item['type'] == $resource->get_type()
-            ) {
+				isset($item['type']) && $item['type'] == $resource->get_type()
+			) {
 				return true;
 			}
 		}
 		return false;
 	}
+
 	/**
 	 * Show this learnpath
 	 */

+ 2 - 1
main/coursecopy/classes/CourseCopyTestCategory.php

@@ -34,7 +34,8 @@ class CourseCopyTestcategory extends Resource
     /**
      * Show the test_category title, used in the partial recycle_course.php form
      */
-    function show() {
+    function show()
+    {
         parent::show();
         echo $this->title;
     }

+ 7 - 4
main/coursecopy/classes/CourseDescription.class.php

@@ -21,24 +21,27 @@ class CourseDescription extends Resource
 	/**
 	 * The description type
 	 */
-	var $description_type;	
+	var $description_type;
 	/**
 	 * Create a new course description
 	 * @param int $id
 	 * @param string $title
 	 * @param string $content
 	 */
-	function __construct($id,$title,$content,$description_type) {
+	function __construct($id,$title,$content,$description_type)
+	{
 		parent::Resource($id,RESOURCE_COURSEDESCRIPTION);
 		$this->title = $title;
 		$this->content = $content;
 		$this->description_type = $description_type;
 	}
+
 	/**
 	 * Show this Event
 	 */
-	function show() {
+	function show()
+	{
 		parent::show();
 		echo $this->title;
 	}
-}
+}