Index: openacs-4/packages/forums/www/moderate/move.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/moderate/move.tcl,v diff -u -N -r1.8 -r1.9 --- openacs-4/packages/forums/www/moderate/move.tcl 27 Sep 2017 11:07:52 -0000 1.8 +++ openacs-4/packages/forums/www/moderate/move.tcl 13 Nov 2017 14:31:27 -0000 1.9 @@ -37,17 +37,19 @@ } #get the name of forum where the thread will be moved -db_0or1row get_forum_name "select name from forums_forums where forum_id=:selected_forum" +forums::get -forum_id $selected_forum -array forum +set name $forum(name) # Confirmed if {$confirm_p == 1} { set forum_id $selected_forum - #update the initial father message: update forum_id and tree_sortkey. If in final forum there is no any thread then tree_sortkey is 0, - #else tree_sortkey=tree_sortkey+1 - db_0or1row forums::move_message::select_num_msg {} - if {$num_post == 0 } { + # update the initial father message: update forum_id and + # tree_sortkey. If in final forum there is no any thread then + # tree_sortkey is 0, else tree_sortkey=tree_sortkey+1 + set has_posts_p [db_0or1row forums::move_message::has_posts_p {}] + if {!$has_posts_p} { db_dml forums::move_message::update_msg {} } else { db_foreach forums::move_message::select_tree_sortkey {} { @@ -65,13 +67,26 @@ db_dml forums::move_message::update_children {} } - #update final forum: increase thread_count, approved_thread_count and max_child_sortkey, update last_post - db_0or1row forums::move_message::select_new_data_forums_forums {} + # update final forum: increase thread_count, approved_thread_count + # and max_child_sortkey, update last_post + forums::get -forum_id $forum_id -array forum + set max_child_sortkey $forum(max_child_sortkey) + set thread_count $forum(thread_count) + set approved_thread_count $forum(approved_thread_count) db_dml forums::move_message::update_forums_final {} - #update initial forum: decrease thread_count, approved_thread_count and max_child_sortkey, update last_post - db_0or1row forums::move_message::select_data_forum_initial {} - db_dml forums::move_message::update_forum_initial {} + # update initial forum: decrease thread_count, + # approved_thread_count and max_child_sortkey, update last_post + forums::get -forum_id $message(forum_id) -array forum + set max_child_sortkey $forum(max_child_sortkey) + set thread_count $forum(thread_count) + set approved_thread_count $forum(approved_thread_count) + db_dml forums::move_message::update_forum_initial {} + + if { [forum::use_ReadingInfo_p] } { + ns_log Notice "updating reading info $message_id" + db_dml forums::move_message::update_reading_info {} + } # Redirect to the forum Index: openacs-4/packages/forums/www/moderate/move.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/moderate/move.xql,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/forums/www/moderate/move.xql 8 Aug 2006 21:26:53 -0000 1.2 +++ openacs-4/packages/forums/www/moderate/move.xql 13 Nov 2017 14:31:27 -0000 1.3 @@ -1,11 +1,11 @@ - + - select count(forum_id) as num_post - from forums_messages - where forum_id = :forum_id + select 1 where exists ( + select 1 from forums_messages + where forum_id = :forum_id) @@ -35,22 +35,6 @@ - - - select ff.max_child_sortkey, ff.thread_count, ff.approved_thread_count - from forums_forums ff - where ff.forum_id = :forum_id - - - - - - select ff.max_child_sortkey, ff.thread_count, ff.approved_thread_count - from forums_forums ff - where ff.forum_id = $message(forum_id) - - - update forums_forums @@ -59,6 +43,16 @@ where fm.forum_id = $message(forum_id)) where forum_id = $message(forum_id) + + + + + update forums_reading_info set + forum_id (select forum_id from forums_messages + where message_id = $message(message_id)) + where root_message_id = $message(message_id) + +