Bug #1370 - Updating some forum-related objects and the CourseBuilder class.

skala
Ivan Tcholakov 16 years ago
parent 5fbc9321f5
commit a5fce5a857
  1. 13
      main/coursecopy/classes/CourseBuilder.class.php
  2. 77
      main/coursecopy/classes/Forum.class.php
  3. 23
      main/coursecopy/classes/ForumCategory.class.php
  4. 25
      main/coursecopy/classes/ForumPost.class.php
  5. 69
      main/coursecopy/classes/ForumTopic.class.php

@ -131,9 +131,9 @@ class CourseBuilder
$db_result = api_sql_query($sql, __FILE__, __LINE__); $db_result = api_sql_query($sql, __FILE__, __LINE__);
while ($obj = Database::fetch_object($db_result)) while ($obj = Database::fetch_object($db_result))
{ {
$forum = new Forum($obj->forum_id, $obj->forum_name, $obj->forum_description, $obj->cat_id, $obj->forum_last_post_id); $forum = new Forum($obj->forum_id, $obj->forum_title, $obj->forum_comment, $obj->forum_category, $obj->forum_last_post, $obj->forum_threads, $obj->forum_posts, $obj->allow_anonymous, $obj->allow_edit, $obj->approval_direct_post, $obj->allow_attachements, $obj->allow_new_threads, $obj->default_view, $obj->forum_of_group, $obj->forum_group_public_private, $obj->forum_order, $obj->locked, $obj->session_id, $obj->forum_image);
$this->course->add_resource($forum); $this->course->add_resource($forum);
$this->build_forum_category($obj->cat_id); $this->build_forum_category($obj->forum_category);
} }
$this->build_forum_topics(); $this->build_forum_topics();
$this->build_forum_posts(); $this->build_forum_posts();
@ -148,7 +148,7 @@ class CourseBuilder
$db_result = api_sql_query($sql, __FILE__, __LINE__); $db_result = api_sql_query($sql, __FILE__, __LINE__);
while ($obj = Database::fetch_object($db_result)) while ($obj = Database::fetch_object($db_result))
{ {
$forum_category = new ForumCategory($obj->cat_id, $obj->cat_title); $forum_category = new ForumCategory($obj->cat_id, $obj->cat_title, $obj->cat_comment, $obj->cat_order, $obj->locked, $obj->session_id);
$this->course->add_resource($forum_category); $this->course->add_resource($forum_category);
} }
} }
@ -162,7 +162,7 @@ class CourseBuilder
$db_result = api_sql_query($sql, __FILE__, __LINE__); $db_result = api_sql_query($sql, __FILE__, __LINE__);
while ($obj = Database::fetch_object($db_result)) while ($obj = Database::fetch_object($db_result))
{ {
$forum_topic = new ForumTopic($obj->topic_id, $obj->topic_title, $obj->topic_time, $obj->prenom, $obj->nom, $obj->topic_notify, $obj->forum_id, $obj->topic_last_post_id); $forum_topic = new ForumTopic($obj->thread_id, $obj->thread_title, $obj->thread_date, $obj->thread_poster_id, $obj->thread_poster_name, $obj->forum_id, $obj->thread_last_post, $obj->thread_replies, $obj->thread_views, $obj->thread_sticky, $obj->locked, $obj->thread_close_date, $obj->thread_weight, $obj->thread_title_qualify, $obj->thread_qualify_max);
$this->course->add_resource($forum_topic); $this->course->add_resource($forum_topic);
} }
} }
@ -172,12 +172,11 @@ class CourseBuilder
function build_forum_posts() function build_forum_posts()
{ {
$table_post = Database :: get_course_table(TABLE_FORUM_POST); $table_post = Database :: get_course_table(TABLE_FORUM_POST);
$table_posttext = Database :: get_course_table(TOOL_FORUM_POST_TEXT_TABLE); $sql = 'SELECT * FROM '.$table_post;
$sql = 'SELECT * FROM '.$table_post.' p,'.$table_posttext.' pt WHERE p.post_id = pt.post_id';
$db_result = api_sql_query($sql, __FILE__, __LINE__); $db_result = api_sql_query($sql, __FILE__, __LINE__);
while ($obj = Database::fetch_object($db_result)) while ($obj = Database::fetch_object($db_result))
{ {
$forum_post = new ForumPost($obj->post_id, $obj->post_title, $obj->post_text, $obj->post_time, $obj->poster_ip, $obj->prenom, $obj->nom, $obj->topic_notify, $obj->parent_id, $obj->topic_id); $forum_post = new ForumPost($obj->post_id, $obj->post_title, $obj->post_text, $obj->post_date, $obj->poster_ip, $obj->poster_name, $obj->post_notification, $obj->post_parent_id, $obj->thread_id, $obj->visible);
$this->course->add_resource($forum_post); $this->course->add_resource($forum_post);
} }
} }

@ -42,19 +42,89 @@ class Forum extends Resource
*/ */
var $category_id; var $category_id;
/** /**
* * Last post
*/ */
var $last_post; var $last_post;
/** /**
* Create a new ForumPost * Number of threads
*/ */
function Forum($id,$title,$description,$category_id,$last_post) var $topics;
/**
* Number of posts
*/
var $posts;
/**
* Allow anonimous
*/
var $allow_anonymous;
/**
* Allow edit
*/
var $allow_edit;
/**
* Approval direct post
*/
var $approval_direct_post;
/**
* Allow attachments
*/
var $allow_attachements;
/**
* Allow new threads
*/
var $allow_new_topics;
/**
* Default view
*/
var $default_view;
/**
* Group forum
*/
var $of_group;
/**
* Public/private group forum
*/
var $group_public_private;
/**
* Order
*/
var $order;
/**
* Locked or not
*/
var $locked;
/**
* Session id
*/
var $session_id;
/**
* Image
*/
var $image;
/**
* Create a new Forum
*/
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)
{ {
parent::Resource($id,RESOURCE_FORUM); parent::Resource($id,RESOURCE_FORUM);
$this->title = $title; $this->title = $title;
$this->description = $description; $this->description = $description;
$this->category_id = $category_id; $this->category_id = $category_id;
$this->last_post = $last_post; $this->last_post = $last_post;
$this->topics = $topics;
$this->posts = $posts;
$this->allow_anonymous = $allow_anonymous;
$this->allow_edit = $allow_edit;
$this->approval_direct_post = $approval_direct_post;
$this->allow_attachements = $allow_attachements;
$this->allow_new_topics = $allow_new_topics;
$this->default_view = $default_view;
$this->of_group = $of_group;
$this->group_public_private = $group_public_private;
$this->order = $order;
$this->locked = $locked;
$this->session_id = $session_id;
$this->image = $image;
} }
/** /**
* Show this resource * Show this resource
@ -65,4 +135,3 @@ class Forum extends Resource
echo $this->title; echo $this->title;
} }
} }
?>

@ -33,13 +33,33 @@ class ForumCategory extends Resource
* The title * The title
*/ */
var $title; var $title;
/**
* The description
*/
var $description;
/**
* The order
*/
var $order;
/**
* Locked flag
*/
var $locked;
/**
* The session id
*/
var $session_id;
/** /**
* Create a new ForumCategory * Create a new ForumCategory
*/ */
function ForumCategory($id,$title) function ForumCategory($id, $title, $description, $order, $locked, $session_id)
{ {
parent::Resource($id,RESOURCE_FORUMCATEGORY); parent::Resource($id,RESOURCE_FORUMCATEGORY);
$this->title = $title; $this->title = $title;
$this->description = $description;
$this->order = $order;
$this->locked = $locked;
$this->session_id = $session_id;
} }
/** /**
* Show this resource * Show this resource
@ -50,4 +70,3 @@ class ForumCategory extends Resource
echo $this->title; echo $this->title;
} }
} }
?>

@ -46,13 +46,9 @@ class ForumPost extends Resource
*/ */
var $poster_ip; var $poster_ip;
/** /**
* Poster firstname * Poster name
*/ */
var $firstname; var $poster_name;
/**
* Poster lastname
*/
var $lastname;
/** /**
* Topic notify * Topic notify
*/ */
@ -65,21 +61,25 @@ class ForumPost extends Resource
* Topic id * Topic id
*/ */
var $topic_id; var $topic_id;
/** /**
* Visible flag
*/
var $visible;
/**
* Create a new ForumPost * Create a new ForumPost
*/ */
function ForumPost($id,$title,$text,$post_time,$poster_ip,$firstname,$lastname,$topic_notify,$parent_post_id,$topic_id) function ForumPost($id, $title, $text, $post_time, $poster_ip, $poster_name, $topic_notify, $parent_post_id, $topic_id, $visible)
{ {
parent::Resource($id,RESOURCE_FORUMPOST); parent::Resource($id, RESOURCE_FORUMPOST);
$this->title = $title; $this->title = $title;
$this->text = $text; $this->text = $text;
$this->post_time = $post_time; $this->post_time = $post_time;
$this->poster_ip = $poster_ip; $this->poster_ip = $poster_ip;
$this->firstname = $firstname; $this->poster_name = $poster_name;
$this->lastname = $lastname;
$this->topic_notify = $topic_notify; $this->topic_notify = $topic_notify;
$this->parent_post_id = $parent_post_id; $this->parent_post_id = $parent_post_id;
$this->topic_id = $topic_id; $this->topic_id = $topic_id;
$this->visible = $visible;
} }
/** /**
* Show this resource * Show this resource
@ -87,7 +87,6 @@ class ForumPost extends Resource
function show() function show()
{ {
parent::show(); parent::show();
echo $this->title.' ('.$this->firstname.' '.$this->lastname.', '.$this->post_time.')'; echo $this->title.' ('.$this->poster_name.', '.$this->post_time.')';
} }
} }
?>

@ -38,17 +38,13 @@ class ForumTopic extends Resource
*/ */
var $time; var $time;
/** /**
* Poster firstname * Poster id
*/ */
var $firstname; var $topic_poster_id;
/** /**
* Poster lastname * Poster name
*/ */
var $lastname; var $topic_poster_name;
/**
* Topic notify
*/
var $topic_notify;
/** /**
* Parent forum * Parent forum
*/ */
@ -57,19 +53,61 @@ class ForumTopic extends Resource
* Last post * Last post
*/ */
var $last_post; var $last_post;
/** /**
* How many replies are there
*/
var $replies;
/**
* How many times has been viewed
*/
var $views;
/**
* Sticky or not
*/
var $sticky;
/**
* Locked or not
*/
var $locked;
/**
* Date of closing
*/
var $time_closed;
// From the Gradebook tool?
/**
* Weight
*/
var $weight;
/**
* Weight
*/
var $title_qualify;
/**
* Weight
*/
var $qualify_max;
/**
* Create a new ForumTopic * Create a new ForumTopic
*/ */
function ForumTopic($id,$title,$time,$firstname,$lastname,$topic_notify,$forum_id,$last_post) function ForumTopic($id, $title, $time, $topic_poster_id, $topic_poster_name, $forum_id, $last_post, $replies, $views, $sticky, $locked, $time_closed, $weight, $title_qualify, $qualify_max)
{ {
parent::Resource($id,RESOURCE_FORUMTOPIC); parent::Resource($id, RESOURCE_FORUMTOPIC);
$this->title = $title; $this->title = $title;
$this->time = $time; $this->time = $time;
$this->firstname = $firstname; $this->topic_poster_id = $topic_poster_id;
$this->lastname = $lastname; $this->topic_poster_name = $topic_poster_name;
$this->topic_notify = $topic_notify;
$this->forum_id = $forum_id; $this->forum_id = $forum_id;
$this->last_post = $last_post; $this->last_post = $last_post;
$this->replies = $replies;
$this->views = $views;
$this->sticky = $sticky;
$this->locked = $locked;
$this->time_closed = $time_closed;
$this->weight = $weight;
$this->title_qualify = $title_qualify;
$this->qualify_max = $qualify_max;
} }
/** /**
* Show this resource * Show this resource
@ -77,7 +115,6 @@ class ForumTopic extends Resource
function show() function show()
{ {
parent::show(); parent::show();
echo $this->title.' ('.$this->firstname.' '.$this->lastname.', '.$this->topic_time.')'; echo $this->title.' ('.$this->topic_poster_name.', '.$this->topic_time.')';
} }
} }
?>
Loading…
Cancel
Save