Browse Source

Format code, fixing PHP warnings.

Julio Montoya 11 years ago
parent
commit
4c7ae2ff19

+ 30 - 29
main/coursecopy/classes/CourseCopyLearnpath.class.php

@@ -9,82 +9,81 @@ class CourseCopyLearnpath extends Resource {
 	/**
 	 * Type of learnpath (can be dokeos (1), scorm (2), aicc (3))
 	 */
-	var $lp_type;
+	public $lp_type;
 	/**
 	 * The name
 	 */
-	var $name;
+	public $name;
 	/**
 	 * The reference
 	 */
-	var $ref;
+	public $ref;
 	/**
 	 * The description
 	 */
-	var $description;
+	public $description;
 	/**
 	 * Path to the learning path files
 	 */
-	var $path;
+	public $path;
 	/**
 	 * Whether additional commits should be forced or not
 	 */
-	var $force_commit;
+	public $force_commit;
 	/**
 	 * View mode by default ('embedded' or 'fullscreen')
 	 */
-	var $default_view_mod;
+	public $default_view_mod;
 	/**
 	 * Default character encoding
 	 */
-	var $default_encoding;
+	public $default_encoding;
 	/**
 	 * Display order
 	 */
-	var $display_order;
+	public $display_order;
 	/**
 	 * Content editor/publisher
 	 */
-	var $content_maker;
+	public $content_maker;
 	/**
 	 * Location of the content (local or remote)
 	 */
-	var $content_local;
+	public $content_local;
 	/**
 	 * License of the content
 	 */
-	var $content_license;
+	public $content_license;
 	/**
 	 * Whether to prevent reinitialisation or not
 	 */
-	var $prevent_reinit;
+	public $prevent_reinit;
 	/**
 	 * JavaScript library used
 	 */
-	var $js_lib;
+	public $js_lib;
 	/**
 	 * Debug level for this lp
 	 */
-	var $debug;
+	public $debug;
 	/**
 	 * The items
 	 */
-	var $items;
+	public $items;
 	/**
 	 * The learnpath visibility on the homepage
 	 */
-	var $visibility;
-	
+	public $visibility;
+
 	/**
 	 * Author info
 	 */
-	var $author;
-	
+	public $author;
+
 	/**
 	 * Author's image
 	 */
-	var $preview_image;
-								
+	public $preview_image;
 
 	/**
 	 * Create a new learnpath
@@ -127,18 +126,18 @@ class CourseCopyLearnpath extends Resource {
 		$this->content_license = $content_license;
 		$this->debug = $debug;
 		$this->visibility=$visibility;
-		
+
 		$this->use_max_score=$use_max_score;
 		$this->autolunch=$autolunch;
 		$this->created_on=$created_on;
 		$this->modified_on=$modified_on;
 		$this->publicated_on=$publicated_on;
 		$this->expired_on=$expired_on;
-		$this->session_id=$session_id;	
-		
+		$this->session_id=$session_id;
+
 		$this->author= $author;
 		$this->preview_image= $preview_image;
-		
+
 		$this->items = $items;
 	}
 	/**
@@ -153,8 +152,10 @@ class CourseCopyLearnpath extends Resource {
 	 */
 	function has_item($resource)
 	{
-		foreach($this->items as $index => $item) {
-			if( $item['id'] == $resource->get_id() && $item['type'] == $resource->get_type()) {
+		foreach ($this->items as $item) {
+			if ($item['id'] == $resource->get_id() &&
+                isset($item['type']) && $item['type'] == $resource->get_type()
+            ) {
 				return true;
 			}
 		}
@@ -167,4 +168,4 @@ class CourseCopyLearnpath extends Resource {
 		parent::show();
 		echo $this->name;
 	}
-}
+}

+ 7 - 5
main/coursecopy/classes/CourseSelectForm.class.php

@@ -1,6 +1,5 @@
 <?php
 /* For licensing terms, see /license.txt */
-
 require_once 'Course.class.php';
 
 /**
@@ -475,7 +474,7 @@ class CourseSelectForm
                         }
                         break;
                     case RESOURCE_LEARNPATH:
-                        $lps = $_POST['resource'][RESOURCE_LEARNPATH];
+                        $lps = isset($_POST['resource'][RESOURCE_LEARNPATH]) ? $_POST['resource'][RESOURCE_LEARNPATH] : null;
                         if (!empty($lps)) {
                             foreach ($lps as $id => $obj) {
                                 $lp_resource = $course->resources[RESOURCE_LEARNPATH][$id];
@@ -499,9 +498,12 @@ class CourseSelectForm
 						// but in which a document was selected.
 						$documents = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null;
 						if (!empty($resources) && is_array($resources))
-							foreach($resources as $id => $obj) {
-								if ($obj->file_type == 'folder' && ! isset($_POST['resource'][RESOURCE_DOCUMENT][$id]) && is_array($documents)) {
-									foreach($documents as $id_to_check => $post_value) {
+							foreach ($resources as $id => $obj) {
+								if (isset($obj->file_type) && $obj->file_type == 'folder' &&
+                                    !isset($_POST['resource'][RESOURCE_DOCUMENT][$id]) &&
+                                    is_array($documents)
+                                ) {
+									foreach ($documents as $id_to_check => $post_value) {
 										$obj_to_check = $resources[$id_to_check];
 										$shared_path_part = substr($obj_to_check->path,0,strlen($obj->path));
 										if ($id_to_check != $id && $obj->path == $shared_path_part) {

+ 19 - 12
main/coursecopy/classes/Resource.class.php

@@ -42,41 +42,42 @@ define('RESOURCE_WORK', 'work');
  * @todo Use the gloabaly defined constants voor tools and remove the RESOURCE_*
  * constants
  */
-class Resource {
-
+class Resource
+{
     /**
      * The id from this resource in the source course
      */
-    var $source_id;
+    public $source_id;
 
     /**
      * The id from this resource in the destination course
      */
-    var $destination_id;
+    public $destination_id;
 
     /**
      * The type of this resource
      */
-    var $type;
+    public $type;
 
     /**
      * Linked resources
      */
-    var $linked_resources;
+    public $linked_resources;
 
     /**
      * The properties of this resource
      */
-    var $item_properties;
+    public $item_properties;
 
-    var $obj = null;
+    public $obj = null;
 
     /**
      * Create a new Resource
      * @param int $id The id of this resource in the source course.
      * @param constant $type The type of this resource.
      */
-    function Resource($id, $type) {
+    function Resource($id, $type)
+    {
         $this->source_id = $id;
         $this->type = $type;
         $this->destination_id = -1;
@@ -102,8 +103,14 @@ class Resource {
      * Checks if this resource links to a given resource
      */
     function links_to(& $resource) {
-        if (is_array($this->linked_resources[$resource->get_type()])) {
-            return in_array($resource->get_id(), $this->linked_resources[$resource->get_type()]);
+        $type = $resource->get_type();
+        if (isset($this->linked_resources[$type]) &&
+            is_array($this->linked_resources[$type])
+        ) {
+            return in_array(
+                $resource->get_id(),
+                $this->linked_resources[$type]
+            );
         }
         return false;
     }
@@ -212,4 +219,4 @@ class Resource {
     function show() {
         //echo 'RESOURCE: '.$this->get_id().' '.$type[$this->get_type()].' ';
     }
-}
+}

+ 2 - 1
main/inc/lib/document.lib.php

@@ -1833,7 +1833,6 @@ class DocumentManager
         $attributes = array();
         $wanted_attributes = array('src', 'url', '@import', 'href', 'value', 'flashvars');
         $explode_attributes = array('flashvars' => 'file');
-
         $abs_path = '';
 
         if ($recursivity > $max) {
@@ -1869,6 +1868,8 @@ class DocumentManager
             }
         }
 
+        $files_list = array();
+
         switch ($type) {
             case TOOL_DOCUMENT :
             case TOOL_QUIZ: