Browse Source

Use __construct.

Julio Montoya 10 years ago
parent
commit
87990e9dda
30 changed files with 114 additions and 81 deletions
  1. 12 12
      main/coursecopy/classes/Announcement.class.php
  2. 1 1
      main/coursecopy/classes/Attendance.class.php
  3. 5 5
      main/coursecopy/classes/Course.class.php
  4. 2 2
      main/coursecopy/classes/CourseCopyLearnpath.class.php
  5. 3 2
      main/coursecopy/classes/CourseCopyTestCategory.php
  6. 6 5
      main/coursecopy/classes/CourseDescription.class.php
  7. 1 1
      main/coursecopy/classes/CourseRecycler.class.php
  8. 3 3
      main/coursecopy/classes/CourseRestorer.class.php
  9. 5 4
      main/coursecopy/classes/CourseSession.class.php
  10. 2 2
      main/coursecopy/classes/Document.class.php
  11. 2 2
      main/coursecopy/classes/Event.class.php
  12. 3 2
      main/coursecopy/classes/Forum.class.php
  13. 2 2
      main/coursecopy/classes/ForumCategory.class.php
  14. 2 2
      main/coursecopy/classes/ForumPost.class.php
  15. 2 2
      main/coursecopy/classes/ForumTopic.class.php
  16. 2 2
      main/coursecopy/classes/Glossary.class.php
  17. 2 2
      main/coursecopy/classes/Link.class.php
  18. 2 2
      main/coursecopy/classes/LinkCategory.class.php
  19. 2 2
      main/coursecopy/classes/Quiz.class.php
  20. 2 2
      main/coursecopy/classes/QuizQuestion.class.php
  21. 2 2
      main/coursecopy/classes/QuizQuestionOption.class.php
  22. 13 6
      main/coursecopy/classes/Resource.class.php
  23. 2 2
      main/coursecopy/classes/ScormDocument.class.php
  24. 5 2
      main/coursecopy/classes/Survey.class.php
  25. 3 2
      main/coursecopy/classes/SurveyInvitation.class.php
  26. 12 4
      main/coursecopy/classes/SurveyQuestion.class.php
  27. 1 1
      main/coursecopy/classes/Thematic.class.php
  28. 2 2
      main/coursecopy/classes/ToolIntro.class.php
  29. 1 1
      main/coursecopy/classes/Work.class.php
  30. 12 2
      main/coursecopy/classes/wiki.class.php

+ 12 - 12
main/coursecopy/classes/Announcement.class.php

@@ -30,15 +30,15 @@ class Announcement extends Resource
 	 * Has the e-mail been sent?
 	 */
     public $email_sent;
-	
+
     public $attachment_path;
-	
+
     public $attachment_filename;
-	
+
     public $attachment_size;
-	
+
     public $attachment_comment;
-	
+
 	/**
 	 * Create a new announcement
 	 * @param int $id
@@ -47,22 +47,22 @@ class Announcement extends Resource
 	 * @param string $date
 	 * @param int display_order
 	 */
-    function Announcement($id, $title, $content, $date, $display_order, $email_sent, $path, $filename, $size, $comment)
+    function __construct($id, $title, $content, $date, $display_order, $email_sent, $path, $filename, $size, $comment)
     {
-		parent::Resource($id,RESOURCE_ANNOUNCEMENT);
-		
+		parent::__construct($id,RESOURCE_ANNOUNCEMENT);
+
 		$this->content	= $content;
 		$this->title 	= $title;
 		$this->date 	= $date;
 		$this->display_order	= $display_order;
-		$this->email_sent	 	= $email_sent;		
-		
+		$this->email_sent	 	= $email_sent;
+
 		$this->attachment_path 	= $path;
 		$this->attachment_filename = $filename;
 		$this->attachment_size 	= $size;
-		$this->attachment_comment 	= $comment;		
+		$this->attachment_comment 	= $comment;
 	}
-	
+
 	/**
 	 * Show this announcement
 	 */

+ 1 - 1
main/coursecopy/classes/Attendance.class.php

@@ -20,7 +20,7 @@ class Attendance extends Resource
 	 */
     public function __construct($params)
     {
-		parent::Resource($params['id'], RESOURCE_ATTENDANCE);
+		parent::__construct($params['id'], RESOURCE_ATTENDANCE);
 		$this->params = $params;
 	}
 

+ 5 - 5
main/coursecopy/classes/Course.class.php

@@ -24,11 +24,11 @@ class Course
      */
     public function __construct()
     {
-        $this->resources    = array();
-        $this->code         = '';
-        $this->path         = '';
-        $this->backup_path  = '';
-        $this->encoding     = api_get_system_encoding();
+        $this->resources = array();
+        $this->code = '';
+        $this->path = '';
+        $this->backup_path = '';
+        $this->encoding = api_get_system_encoding();
     }
 
     /**

+ 2 - 2
main/coursecopy/classes/CourseCopyLearnpath.class.php

@@ -108,7 +108,7 @@ class CourseCopyLearnpath extends Resource
 	 * @param string $visibility
 	 * @param array  $items
 	 */
-	public function CourseCopyLearnpath(
+	public function __construct(
 		$id,
 		$type,
 		$name,
@@ -137,7 +137,7 @@ class CourseCopyLearnpath extends Resource
 		$session_id,
 		$items
 	) {
-		parent::Resource($id,RESOURCE_LEARNPATH);
+		parent::__construct($id, RESOURCE_LEARNPATH);
 		$this->lp_type = $type;
 		$this->name = $name;
 		$this->path = $path;

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

@@ -25,8 +25,9 @@ class CourseCopyTestcategory extends Resource
      * @param string $title
      * @param string $description
      */
-    function CourseCopyTestcategory($id, $title, $description) {
-        parent::Resource($id, RESOURCE_TEST_CATEGORY);
+    public function __construct($id, $title, $description)
+    {
+        parent::__construct($id, RESOURCE_TEST_CATEGORY);
         $this->title = $title;
         $this->description = $description;
     }

+ 6 - 5
main/coursecopy/classes/CourseDescription.class.php

@@ -13,24 +13,25 @@ class CourseDescription extends Resource
 	/**
 	 * The title
 	 */
-	var $title;
+	public $title;
 	/**
 	 * The content
 	 */
-	var $content;
+	public $content;
 	/**
 	 * The description type
 	 */
-	var $description_type;
+	public $description_type;
+
 	/**
 	 * Create a new course description
 	 * @param int $id
 	 * @param string $title
 	 * @param string $content
 	 */
-	function __construct($id,$title,$content,$description_type)
+	public function __construct($id,$title,$content,$description_type)
 	{
-		parent::Resource($id,RESOURCE_COURSEDESCRIPTION);
+		parent::__construct($id,RESOURCE_COURSEDESCRIPTION);
 		$this->title = $title;
 		$this->content = $content;
 		$this->description_type = $description_type;

+ 1 - 1
main/coursecopy/classes/CourseRecycler.class.php

@@ -21,7 +21,7 @@ class CourseRecycler
      * @param course $course The course-object which contains the items to
      * delete
      */
-    public function CourseRecycler($course)
+    public function __construct($course)
     {
         $this->course = $course;
         $this->course_info = api_get_course_info($this->course->code);

+ 3 - 3
main/coursecopy/classes/CourseRestorer.class.php

@@ -90,9 +90,9 @@ class CourseRestorer
         } else {
             $this->course_origin_id = null;
         }
-		$this->file_option 						= FILE_RENAME;
-		$this->set_tools_invisible_by_default 	= false;
-		$this->skip_content 					= array();
+        $this->file_option = FILE_RENAME;
+        $this->set_tools_invisible_by_default = false;
+        $this->skip_content = array();
 	}
 
 	/**

+ 5 - 4
main/coursecopy/classes/CourseSession.class.php

@@ -13,17 +13,18 @@ class CourseSession extends Resource
     // The title session
 	public $title;
 
-	/*
+	/**
 	 * Create a new Session
 	 * @param int $id
 	 * @param string $title
 	 */
-	function CourseSession($id,$title) {
-		parent::Resource($id,RESOURCE_SESSION_COURSE);
+	public function __construct($id,$title)
+	{
+		parent::__construct($id,RESOURCE_SESSION_COURSE);
 		$this->title = $title;
 	}
 
-	/*
+	/**
 	 * Show this Event
 	 */
 	function show() {

+ 2 - 2
main/coursecopy/classes/Document.class.php

@@ -28,9 +28,9 @@ class Document extends Resource
      * @param string $file_type (DOCUMENT or FOLDER);
      * @param int $size
      */
-    public function Document($id, $path, $comment, $title, $file_type, $size)
+    public function __construct($id, $path, $comment, $title, $file_type, $size)
     {
-        parent::Resource($id, RESOURCE_DOCUMENT);
+        parent::__construct($id, RESOURCE_DOCUMENT);
         $this->path = 'document' . $path;
         $this->comment = $comment;
         $this->title = $title;

+ 2 - 2
main/coursecopy/classes/Event.class.php

@@ -55,9 +55,9 @@ class CalendarEvent extends Resource
 	 * @param string $hour
 	 * @param int $duration
 	 */
-	function CalendarEvent($id, $title, $content, $start_date, $end_date, $attachment_path = null, $attachment_filename= null, $attachment_size= null, $attachment_comment= null, $all_day = 0)
+	function __construct($id, $title, $content, $start_date, $end_date, $attachment_path = null, $attachment_filename= null, $attachment_size= null, $attachment_comment= null, $all_day = 0)
 	{
-		parent::Resource($id,RESOURCE_EVENT);
+		parent::__construct($id,RESOURCE_EVENT);
 
 		$this->title 				= $title;
 		$this->content 				= $content;

+ 3 - 2
main/coursecopy/classes/Forum.class.php

@@ -106,8 +106,9 @@ class Forum extends Resource
     /* function Forum($id, $title, $description, $category_id, $last_post, $topics, $posts, $allow_anonymous, $allow_edit, $approval_direct_post, $allow_attachements,
       $allow_new_topics, $default_view, $of_group, $group_public_private, $order, $locked, $session_id, $image)
       { */
-    function Forum($obj) {
-        parent::Resource($obj->forum_id, RESOURCE_FORUM);
+    function __construct($obj)
+    {
+        parent::__construct($obj->forum_id, RESOURCE_FORUM);
         $this->obj = $obj;
 
         /*

+ 2 - 2
main/coursecopy/classes/ForumCategory.class.php

@@ -13,9 +13,9 @@ class ForumCategory extends Resource
     /**
      * Create a new ForumCategory
      */
-    function ForumCategory($obj)
+    public function __construct($obj)
     {
-        parent::Resource($obj->cat_id, RESOURCE_FORUMCATEGORY);
+        parent::__construct($obj->cat_id, RESOURCE_FORUMCATEGORY);
         $this->obj = $obj;
     }
 

+ 2 - 2
main/coursecopy/classes/ForumPost.class.php

@@ -14,9 +14,9 @@ class ForumPost extends Resource
     /**
      * Create a new ForumPost
      */
-    public function ForumPost($obj)
+    public function __construct($obj)
     {
-        parent::Resource($obj->post_id, RESOURCE_FORUMPOST);
+        parent::__construct($obj->post_id, RESOURCE_FORUMPOST);
         $this->obj = $obj;
     }
 

+ 2 - 2
main/coursecopy/classes/ForumTopic.class.php

@@ -15,9 +15,9 @@ class ForumTopic extends Resource
      */
     /* function ForumTopic($id, $title, $time, $topic_poster_id, $topic_poster_name, $forum_id, $last_post, $replies, $views = 0, $sticky = 0, $locked = 0,
       $time_closed = null, $weight = 0, $title_qualify = null, $qualify_max = 0) */
-    function ForumTopic($obj)
+    function __construct($obj)
     {
-        parent::Resource($obj->thread_id, RESOURCE_FORUMTOPIC);
+        parent::__construct($obj->thread_id, RESOURCE_FORUMTOPIC);
         $this->obj = $obj;
         /*
           $this->title = $title;

+ 2 - 2
main/coursecopy/classes/Glossary.class.php

@@ -22,9 +22,9 @@ class Glossary extends Resource
 	 * @param string $description
 	 * @param int $display_order
 	 */
-    public function Glossary($id,$name,$description,$display_order)
+    public function __construct($id,$name,$description,$display_order)
 	{
-		parent::Resource($id,RESOURCE_GLOSSARY);
+		parent::__construct($id,RESOURCE_GLOSSARY);
 		$this->glossary_id = $id;
 		$this->name = $name;
 		$this->description = $description;

+ 2 - 2
main/coursecopy/classes/Link.class.php

@@ -38,7 +38,7 @@ class Link extends Resource
 	 * @param string $url
 	 * @param string $description
 	 */
-    public function Link(
+    public function __construct(
         $id,
         $title,
         $url,
@@ -47,7 +47,7 @@ class Link extends Resource
         $on_homepage
     )
 	{
-		parent::Resource($id,RESOURCE_LINK);
+		parent::__construct($id,RESOURCE_LINK);
 		$this->title = $title;
 		$this->url = $url;
 		$this->description = $description;

+ 2 - 2
main/coursecopy/classes/LinkCategory.class.php

@@ -28,9 +28,9 @@ class LinkCategory extends Resource
 	 * @param string $title
 	 * @param string $description
 	 */
-	function LinkCategory($id,$title,$description,$display_order)
+	function __construct($id,$title,$description,$display_order)
 	{
-		parent::Resource($id,RESOURCE_LINKCATEGORY);
+		parent::__construct($id,RESOURCE_LINKCATEGORY);
 		$this->title = $title;
 		$this->description = $description;
 		$this->display_order = $display_order;

+ 2 - 2
main/coursecopy/classes/Quiz.class.php

@@ -21,11 +21,11 @@ class Quiz extends Resource
      */
     public $obj; //question
 
-    public function Quiz($obj)
+    public function __construct($obj)
     {
         $this->obj = $obj;
         $this->obj->quiz_type = $this->obj->type;
-        parent::Resource($obj->id, RESOURCE_QUIZ);
+        parent::__construct($obj->id, RESOURCE_QUIZ);
     }
 
     /**

+ 2 - 2
main/coursecopy/classes/QuizQuestion.class.php

@@ -65,7 +65,7 @@ class QuizQuestion extends Resource
      * @param int $type
      * @param int $position
      */
-    public function QuizQuestion(
+    public function __construct(
         $id,
         $question,
         $description,
@@ -77,7 +77,7 @@ class QuizQuestion extends Resource
         $extra,
         $question_category = 0
     ) {
-        parent::Resource($id, RESOURCE_QUIZQUESTION);
+        parent::__construct($id, RESOURCE_QUIZQUESTION);
         $this->question = $question;
         $this->description = $description;
         $this->ponderation = $ponderation;

+ 2 - 2
main/coursecopy/classes/QuizQuestionOption.class.php

@@ -20,9 +20,9 @@ class QuizQuestionOption extends Resource
      * @param int $type
      * @param int $position
      */
-    public function QuizQuestionOption($obj)
+    public function __construct($obj)
     {
-        parent::Resource($obj->id, RESOURCE_QUIZQUESTION);
+        parent::__construct($obj->id, RESOURCE_QUIZQUESTION);
         $this->obj = $obj;
     }
 }

+ 13 - 6
main/coursecopy/classes/Resource.class.php

@@ -70,7 +70,7 @@ class 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)
+    public function __construct($id, $type)
     {
         $this->source_id = $id;
         $this->type = $type;
@@ -82,21 +82,24 @@ class Resource
     /**
      * Add linked resource
      */
-    function add_linked_resource($type, $id) {
+    function add_linked_resource($type, $id)
+    {
         $this->linked_resources[$type][] = $id;
     }
 
     /**
      * Get linked resources
      */
-    function get_linked_resources() {
+    function get_linked_resources()
+    {
         return $this->linked_resources;
     }
 
     /**
      * Checks if this resource links to a given resource
      */
-    function links_to(& $resource) {
+    function links_to(& $resource)
+    {
         $type = $resource->get_type();
         if (isset($this->linked_resources[$type]) &&
             is_array($this->linked_resources[$type])
@@ -130,8 +133,12 @@ class Resource
     /**
      * Get the constant which defines the tool of this resource. This is
      * used in the item_properties table.
-     * @param bool $for_item_property_table (optional)	Added by Ivan, 29-AUG-2009: A parameter for resolving differencies between defined TOOL_* constants and hardcoded strings that are stored in the database.
-     * Example: The constant TOOL_THREAD is defined in the main_api.lib.php with the value 'thread', but the "Forums" tool records in the field 'tool' in the item property table the hardcoded value 'forum_thread'.
+     * @param bool $for_item_property_table (optional)	Added by Ivan,
+     * 29-AUG-2009: A parameter for resolving differencies between defined TOOL_*
+     * constants and hardcoded strings that are stored in the database.
+     * Example: The constant TOOL_THREAD is defined in the main_api.lib.php
+     * with the value 'thread', but the "Forums" tool records in the field 'tool'
+     * in the item property table the hardcoded value 'forum_thread'.
      * @todo once the RESOURCE_* constants are replaced by the globally
      * defined TOOL_* constants, this function will be replaced by get_type()
      */

+ 2 - 2
main/coursecopy/classes/ScormDocument.class.php

@@ -19,9 +19,9 @@ class ScormDocument extends Resource
 	 * @param string $path
 	 * @param string $title
 	 */
-    public function ScormDocument($id, $path, $title)
+    public function __construct($id, $path, $title)
 	{
-		parent::Resource($id,RESOURCE_SCORM);
+		parent::__construct($id,RESOURCE_SCORM);
 		$this->path = 'scorm'.$path;
 		$this->title = $title;
 	}

+ 5 - 2
main/coursecopy/classes/Survey.class.php

@@ -89,7 +89,7 @@ class Survey extends Resource
 	 * @param string $invite_mail
 	 * @param string $reminder_mail
 	 */
-    public function Survey(
+    public function __construct(
         $id,
         $code,
         $title,
@@ -108,7 +108,7 @@ class Survey extends Resource
         $invite_mail,
         $reminder_mail
     ) {
-		parent::Resource($id,RESOURCE_SURVEY);
+		parent::__construct($id,RESOURCE_SURVEY);
 		$this->code = $code;
 		$this->title = $title;
 		$this->subtitle = $subtitle;
@@ -128,6 +128,7 @@ class Survey extends Resource
 		$this->question_ids = array();
 		$this->invitation_ids = array();
 	}
+
 	/**
 	 * Add a question to this survey
 	 */
@@ -135,6 +136,7 @@ class Survey extends Resource
 	{
 		$this->question_ids[] = $id;
 	}
+
 	/**
 	 * Add an invitation to this survey
 	 */
@@ -142,6 +144,7 @@ class Survey extends Resource
 	{
 		$this->invitation_ids[] = $id;
 	}
+
 	/**
 	 * Show this survey
 	 */

+ 3 - 2
main/coursecopy/classes/SurveyInvitation.class.php

@@ -39,15 +39,16 @@ class SurveyInvitation extends Resource
 	 * @param string $invitation_date
 	 * @param string $reminder_date
 	 */
-	function SurveyInvitation($id,$code,$user,$invitation_code,$invitation_date,$reminder_date)
+	public function __construct($id,$code,$user,$invitation_code,$invitation_date,$reminder_date)
 	{
-		parent::Resource($id,RESOURCE_SURVEYINVITATION);
+		parent::__construct($id,RESOURCE_SURVEYINVITATION);
 		$this->code = $code;
 		$this->user = $user;
 		$this->invitation_code = $invitation_code;
 		$this->invitation_date = $invitation_date;
 		$this->reminder_date = $reminder_date;
 	}
+
 	/**
 	 * Show this invitation
 	 */

+ 12 - 4
main/coursecopy/classes/SurveyQuestion.class.php

@@ -55,10 +55,18 @@ class SurveyQuestion extends Resource
 	 * @param int	 $shared_question_id
 	 * @param int	 $max_value
 	 */
-	function SurveyQuestion($id,$survey_id,$survey_question,$survey_question_comment,
-							$type,$display,$sort,$shared_question_id,$max_value)
-	{
-		parent::Resource($id,RESOURCE_SURVEYQUESTION);
+	function __construct(
+		$id,
+		$survey_id,
+		$survey_question,
+		$survey_question_comment,
+		$type,
+		$display,
+		$sort,
+		$shared_question_id,
+		$max_value
+	) {
+		parent::__construct($id,RESOURCE_SURVEYQUESTION);
 		$this->survey_id = $survey_id;
 		$this->survey_question = $survey_question;
 		$this->survey_question_comment = $survey_question_comment;

+ 1 - 1
main/coursecopy/classes/Thematic.class.php

@@ -20,7 +20,7 @@ class Thematic extends Resource
     */
     public function __construct($params)
     {
-        parent::Resource($params['id'], RESOURCE_THEMATIC);
+        parent::__construct($params['id'], RESOURCE_THEMATIC);
         $this->params = $params;
     }
 

+ 2 - 2
main/coursecopy/classes/ToolIntro.class.php

@@ -22,9 +22,9 @@ class ToolIntro extends Resource
 	 * @param int $id The id of this tool introduction in the Chamilo-course
 	 * @param string $intro_text
 	 */
-	function ToolIntro($id, $intro_text)
+	public function __construct($id, $intro_text)
 	{
-		parent::Resource($id,RESOURCE_TOOL_INTRO);
+		parent::__construct($id,RESOURCE_TOOL_INTRO);
 		$this->id = $id;
 		$this->intro_text = $intro_text;
 	}

+ 1 - 1
main/coursecopy/classes/Work.class.php

@@ -19,7 +19,7 @@ class Work extends Resource
      */
     public function __construct($params)
     {
-        parent::Resource($params['id'], RESOURCE_WORK);
+        parent::__construct($params['id'], RESOURCE_WORK);
         $this->params = $params;
     }
 

+ 12 - 2
main/coursecopy/classes/wiki.class.php

@@ -21,8 +21,18 @@ class Wiki extends Resource
 	var $progress;
 	var $version;
 
-	function Wiki($id, $page_id, $reflink, $title, $content, $user_id, $group_id, $timestamp, $progress, $version)
-	{
+	public function __construct(
+		$id,
+		$page_id,
+		$reflink,
+		$title,
+		$content,
+		$user_id,
+		$group_id,
+		$timestamp,
+		$progress,
+		$version
+	) {
 		parent::Resource($id,RESOURCE_WIKI);
 		$this->id						= $id;
 		$this->page_id					= $page_id;