Browse Source

Copying the forum_image see #5462

Julio Montoya 12 years ago
parent
commit
7f21a26525

+ 1 - 1
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  = '';

+ 12 - 6
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);
 			

+ 2 - 3
main/forum/index.php

@@ -291,7 +291,7 @@ if (is_array($forum_categories_list)) {
 
                         $forum_image = '';
 
-                        echo '<td width="20">';
+                        echo '<td width="20px">';
 
                         // 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 =  "<img src=\"$image_path\" $img_attributes>";
                             } else {
                                 $forum_image = '';
                             }
                             echo $forum_image;
-
                         } else {
                             if ($forum['forum_of_group'] !== '0') {
                                 if (is_array($mywhatsnew_post_info) && !empty($mywhatsnew_post_info)) {