From 7f21a26525bce2ec4a4aa79ec1d8b23c3f390c93 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 25 Sep 2012 09:46:19 +0200 Subject: [PATCH] Copying the forum_image see #5462 --- main/coursecopy/classes/Course.class.php | 2 +- .../classes/CourseRestorer.class.php | 18 ++++++++++++------ main/forum/index.php | 5 ++--- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/main/coursecopy/classes/Course.class.php b/main/coursecopy/classes/Course.class.php index bba526c04c..c4e63efe60 100644 --- a/main/coursecopy/classes/Course.class.php +++ b/main/coursecopy/classes/Course.class.php @@ -23,7 +23,7 @@ class Course * Create a new Course-object */ function __construct() { - $this->resources = array (); + $this->resources = array(); $this->code = ''; $this->path = ''; $this->backup_path = ''; diff --git a/main/coursecopy/classes/CourseRestorer.class.php b/main/coursecopy/classes/CourseRestorer.class.php index 7be71a8d2d..c34081979f 100644 --- a/main/coursecopy/classes/CourseRestorer.class.php +++ b/main/coursecopy/classes/CourseRestorer.class.php @@ -56,7 +56,6 @@ class CourseRestorer var $file_option; var $set_tools_invisible_by_default; var $skip_content; - var $tools_to_restore = array( 'announcements', 'attendance', @@ -715,11 +714,10 @@ class CourseRestorer */ function restore_forums() { if ($this->course->has_resources(RESOURCE_FORUM)) { - $table_forum = Database::get_course_table(TABLE_FORUM); - - $resources = $this->course->resources; + $table_forum = Database::get_course_table(TABLE_FORUM); + $resources = $this->course->resources; foreach ($resources[RESOURCE_FORUM] as $id => $forum) { - $params = (array)$forum->obj; + $params = (array)$forum->obj; if ($this->course->resources[RESOURCE_FORUMCATEGORY][$params['forum_category']]->destination_id == -1) { $cat_id = $this->restore_forum_category($params['forum_category']); } else { @@ -731,7 +729,15 @@ class CourseRestorer $params['forum_category'] = $cat_id; unset($params['forum_id']); - $params['forum_comment'] = DocumentManager::replace_urls_inside_content_html_from_copy_course($params['forum_comment'], $this->course->code, $this->course->destination_path); + $params['forum_comment'] = DocumentManager::replace_urls_inside_content_html_from_copy_course($params['forum_comment'], $this->course->code, $this->course->destination_path); + + if (!empty($params['forum_image'])) { + $original_forum_image = $this->course->path.'upload/forum/images/'.$params['forum_image']; + if (file_exists($original_forum_image)) { + $new_forum_image = api_get_path(SYS_COURSE_PATH).$this->destination_course_info['path'].'/upload/forum/images/'.$params['forum_image']; + @copy($original_forum_image, $new_forum_image); + } + } $new_id = Database::insert($table_forum, $params); diff --git a/main/forum/index.php b/main/forum/index.php index 321167e6a1..84a4dba4dd 100644 --- a/main/forum/index.php +++ b/main/forum/index.php @@ -291,7 +291,7 @@ if (is_array($forum_categories_list)) { $forum_image = ''; - echo ''; + echo ''; // Showing the image if (!empty($forum['forum_image'])) { @@ -303,14 +303,13 @@ if (is_array($forum_categories_list)) { if (!empty($image_size)) { if ($image_size['width'] > 100 || $image_size['height'] > 100) { //limit display width and height to 100px - $img_attributes = 'width="100" height="100"'; + $img_attributes = ' style="width:100px" width="100px" height="100px"'; } $forum_image = ""; } else { $forum_image = ''; } echo $forum_image; - } else { if ($forum['forum_of_group'] !== '0') { if (is_array($mywhatsnew_post_info) && !empty($mywhatsnew_post_info)) {