Index: openacs-4/packages/xowiki/tcl/xowiki-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-callback-procs.tcl,v diff -u -r1.43 -r1.44 --- openacs-4/packages/xowiki/tcl/xowiki-callback-procs.tcl 25 Aug 2008 11:33:56 -0000 1.43 +++ openacs-4/packages/xowiki/tcl/xowiki-callback-procs.tcl 1 Sep 2008 21:15:35 -0000 1.44 @@ -27,7 +27,39 @@ } } + ad_proc -public ::xowiki::before-uninstantiate { + {-package_id:required} + } { + Callback to be called whenever a package instance is deleted. + + @author Gustaf Neumann + } { + ns_log notice "Executing before-uninstantiate" + ::xowiki::delete_gc_messages -package_id $package_id + ns_log notice " before-uninstantiate DONE" + } + + ad_proc -public ::xowiki::delete_gc_messages { + {-package_id:required} + } { + Deletes the messages of general comments to allow to + uninstantiate the package without violating constraints. + + @author Gustaf Neumann + } { + set comment_ids [db_list get_comments " + select g.comment_id + from general_comments g, cr_items i,acs_objects o + where i.item_id = g.object_id + and o.object_id = i.item_id + and o.package_id = $package_id"] + foreach comment_id $comment_ids { + ::xo::db::sql::acs_message delete -message_id $comment_id + } + } + + # # upgrade logic #