Index: openacs-4/packages/xotcl-core/tcl/generic-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/generic-procs.tcl,v diff -u -r1.75 -r1.76 --- openacs-4/packages/xotcl-core/tcl/generic-procs.tcl 29 Jun 2007 16:42:18 -0000 1.75 +++ openacs-4/packages/xotcl-core/tcl/generic-procs.tcl 29 Jun 2007 20:10:02 -0000 1.76 @@ -157,12 +157,36 @@ }]} } + CrClass ad_instproc folder_type_unregister_all { + {-include_sub_types t} + } { + Unregister the object type from all folders on the system + + @param include_sub_types Boolean value (t/f) to flag whether the + operation should be applied on subtypes as well + } { + my instvar object_type + db_foreach all_folders { + select folder_id from cr_folder_type_map + where content_type = :object_type + } { + ::xo::db::sql::content_folder unregister_content_type \ + -folder_id $folder_id \ + -content_type $object_type \ + -include_subtypes $include_subtypes + } + } + CrClass ad_instproc folder_type { + {-include_sub_types t} -folder_id operation } { register the current object type for folder_id. If folder_id is not specified, use the instvar of the class instead. + + @param include_sub_types Boolean value (t/f) to flag whether the + operation should be applied on subtypes as well } { if {$operation ne "register" && $operation ne "unregister"} { error "[self] operation for folder_type must be 'register' or 'unregister'" @@ -172,9 +196,9 @@ my instvar folder_id } ::xo::db::sql::content_folder ${operation}_content_type \ - -folder_id $folder_id \ - -content_type $object_type \ - -include_subtypes t + -folder_id $folder_id \ + -content_type $object_type \ + -include_subtypes $include_subtypes } CrClass instproc create_attributes {} { @@ -290,6 +314,7 @@ CrClass ad_instproc require_folder { {-parent_id -100} + {-content_types content_revision} -package_id -name } { @@ -322,7 +347,7 @@ error "Could not determine package id or community id" } } - set folder_id [ns_cache eval xotcl_object_type_cache cid-$cid { + set folder_id [ns_cache eval xotcl_object_type_cache root_folder-$cid { set folder_name "$name: $cid" if {[info command content::item::get_id_by_name] eq ""} { @@ -339,6 +364,15 @@ -parent_id $parent_id \ -package_id $package_id -context_id $cid] } + # register all specified content types + foreach content_type $content_types { + # if a content_type ends with a *, include subtypes + set with_subtypes [expr {[regexp {^(.*)[*]$} $content_type _ content_type] ? "t" : "f"}] + ::xo::db::sql::content_folder register_content_type \ + -folder_id $folder_id \ + -content_type $content_type \ + -include_subtypes $with_subtypes + } return $folder_id }] @@ -861,7 +895,7 @@ db_transaction { $__class instvar storage_type object_type - $__class folder_type -folder_id $parent_id register + #$__class folder_type -folder_id $parent_id register [self class] lock acs_objects "SHARE ROW EXCLUSIVE" set revision_id [db_nextval acs_object_id_seq] Index: openacs-4/packages/xowiki/tcl/package-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/package-procs.tcl,v diff -u -r1.63 -r1.64 --- openacs-4/packages/xowiki/tcl/package-procs.tcl 27 Jun 2007 09:27:49 -0000 1.63 +++ openacs-4/packages/xowiki/tcl/package-procs.tcl 29 Jun 2007 20:10:02 -0000 1.64 @@ -449,7 +449,11 @@ #my log "--f [my isobject ::$folder_id] folder_id=$folder_id" if {$folder_id == 0} { - set folder_id [::xowiki::Page require_folder -name xowiki -package_id $id] + # TODO: we should make a parameter allowed_page_types (see content_types), + # but the package admin should not have necessarily the rights to change it + set folder_id [::xowiki::Page require_folder \ + -name xowiki -package_id $id \ + -content_types ::xowki::Page* ] } if {![::xotcl::Object isobject ::$folder_id]} { @@ -796,6 +800,7 @@ #my log "--D deleting folder object ::$folder_id" ns_cache flush xotcl_object_cache ::$folder_id ns_cache flush xotcl_object_type_cache item_id-of-$folder_id + ns_cache flush xotcl_object_type_cache root_folder-$id ::$folder_id destroy } set key link-*-$name-$folder_id 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.17 -r1.18 --- openacs-4/packages/xowiki/tcl/xowiki-callback-procs.tcl 8 Jun 2007 12:04:14 -0000 1.17 +++ openacs-4/packages/xowiki/tcl/xowiki-callback-procs.tcl 29 Jun 2007 20:10:02 -0000 1.18 @@ -47,8 +47,9 @@ ns_log notice "-- upgrading to 0.13" set package_id [::Generic::package_id_from_package_key xowiki] set folder_id [::xowiki::Page require_folder \ - -package_id $package_id \ - -name xowiki] + -package_id $package_id \ + -content_types ::xowki::Page* \ + -name xowiki] set r [::CrWikiPage instantiate_all -folder_id $folder_id] db_transaction { array set map {