Project

General

Profile

Bug #550

[1861-2]Bug in forum Threaded and Nested view if you delete a post + fix

Added by Hubert Borderiou almost 10 years ago. Updated over 8 years ago.

Status:
Bug resolved
Priority:
Normal
Category:
-
Target version:
Start date:
22/01/2010
Due date:
% Done:

90%

Estimated time:
Complexity:
Normal
SCRUM pts - complexity:
1

Description

Hi,
if you delete a post, reply post associted to this one aren't displayed in Threaded and Nested view.
I try a screencast (56") to show you the bug (even if I'm not native english), I hope I'll be more understandable than a text.

Screencast : http://opus.grenet.fr/dokeos/gu/courses/RESSDSIGU/document/flash/2010-01-19_1609.swf?cidReq=RESSDSIGU

A solution to correct this bug, edit file /main/forum|forumfunction.inc.php
(same file and correction for Chamilo 1.8.6.2)
and modify function delete_post($post_id) as bellow

function delete_post($post_id) {
global $table_posts;
global $table_threads;

// get parent_post_id of deleted post
$tab_post_info = get_post_information($post_id);
    $post_parent_id_of_deleted_post = $tab_post_info['post_parent_id'];
    $thread_id_of_deleted_post = $tab_post_info['thread_id'];
    $forum_if_of_deleted_post = $tab_post_info['forum_id'];
    $sql = "UPDATE $table_posts SET post_parent_id=$post_parent_id_of_deleted_post WHERE post_parent_id=$post_id AND thread_id=$thread_id_of_deleted_post AND forum_id=$forum_if_of_deleted_post;";
    api_sql_query($sql,__FILE__,__LINE__);

    $sql="DELETE FROM $table_posts WHERE post_id='".Database::escape_string($post_id)."'"; // note: this has to be a recursive function that deletes all of the posts in this block.
    api_sql_query($sql,__FILE__,__LINE__);

    //delete attachment file about this post id
    delete_attachment($post_id);   

    $last_post_of_thread=check_if_last_post_of_thread(strval(intval($_GET['thread'])));

    if (is_array($last_post_of_thread)) {
        // Decreasing the number of replies for this thread and also changing the last post information
        $sql="UPDATE $table_threads SET thread_replies=thread_replies-1,
                    thread_last_post='".Database::escape_string($last_post_of_thread['post_id'])."',
                    thread_date='".Database::escape_string($last_post_of_thread['post_date'])."'
            WHERE thread_id='".Database::escape_string($_GET['thread'])."'";
        api_sql_query($sql,__FILE__,__LINE__);
        return 'PostDeleted';
    }
    if ($last_post_of_thread==false) {
        // we deleted the very single post of the thread so we need to delete the entry in the thread table also.
        $sql="DELETE FROM $table_threads WHERE thread_id='".Database::escape_string($_GET['thread'])."'";
        api_sql_query($sql,__FILE__,__LINE__);
        return 'PostDeletedSpecial';
    }
}

History

#1

Updated by Hubert Borderiou almost 10 years ago

  • Target version deleted (1.8.6.2 RC1)
#2

Updated by Julio Montoya almost 10 years ago

  • Assignee set to Julio Montoya
  • Target version set to 1.8.7 beta
#3

Updated by Julio Montoya almost 10 years ago

  • Status changed from New to Needs testing
  • Assignee changed from Julio Montoya to Arthur Portugal
  • % Done changed from 0 to 90
  • SCRUM pts - complexity changed from ? to 1

Hello Hubert,
Thanks for reporting and fixing the bug. Your explanation and your screencast were very helpful!

I added your changes here:
http://code.google.com/p/chamilo/source/detail?r=8c9e69bbb42c116143dd81613576d58038830c87&repo=classic

#4

Updated by Yannick Warnier over 8 years ago

  • Status changed from Needs testing to Bug resolved

Also available in: Atom PDF