xowiki::Package instproc require_root_folder (public)
<instance of xowiki::Package> require_root_folder \ [ -parent_id parent_id ] [ -content_types content_types ] \ -name name
Defined in /var/www/openacs.org/packages/xowiki/tcl/package-procs.tcl
Make sure, the root folder for the given package exists. If not, create it and register all allowed content types.
- Switches:
- -parent_id (optional, defaults to
"-100"
)- -content_types (optional)
- -name (required)
- Returns:
- folder_id
- Testcases:
- package_normalize_path, create_form_with_form_instance
Source code: set folder_id [xo::xotcl_package_cache eval root_folder-${:id} { set folder_id [::xo::db::CrClass lookup -name $name -parent_id $parent_id] if {$folder_id == 0} { # # When the folder_id is empty, then something is wrong. Maybe an # earlier update script was not running correctly. # set old_folder_id [xo::dc get_value double_check_old_package { select item_id from cr_items where name = :name and parent_id = :parent_id }] if {$old_folder_id ne ""} { :log "-- try to transform old root folder $old_folder_id of package ${:id}" ::xowiki::transform_root_folder ${:id} set folder_id $old_folder_id } else { # # Check, if the package_key belongs to xowiki (it might be a # subclass). If this is not the case, the call is probably an # error and we do not want to create a root folder. # set package_class [::xo::PackageMgr get_package_class_from_package_key ${:package_key}] if {$package_class eq ""} { ad_log error "trying to create an xowiki root folder for non-xowiki package ${:id}" error "trying to create an xowiki root folder for non-xowiki package ${:id}" } else { ::xowiki::Package require_site_wide_pages set form_id [::${:id} instantiate_forms -forms en:folder.form] set f [FormPage new -name $name -text "" -package_id ${:id} -parent_id $parent_id -nls_language en_US -publish_status ready -instance_attributes {} -page_template $form_id -destroy_on_cleanup ] $f save_new set folder_id [$f item_id] ::xo::db::sql::acs_object set_attribute -object_id_in $folder_id -attribute_name_in context_id -value_in ${:id} :log "CREATED folder '$name' and parent $parent_id ==> $folder_id" } } } # register all specified content types #::xo::db::CrFolder register_content_types # -folder_id $folder_id # -content_types $content_types #:log "returning from cache folder_id $folder_id" return $folder_id }] #:log "returning from require folder_id $folder_id" return $folder_idXQL Not present: Generic, PostgreSQL, Oracle