Index: openacs-4/packages/acs-content-repository/tcl/content-folder-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/content-folder-procs.tcl,v diff -u -r1.11 -r1.12 --- openacs-4/packages/acs-content-repository/tcl/content-folder-procs.tcl 4 Jun 2006 00:45:23 -0000 1.11 +++ openacs-4/packages/acs-content-repository/tcl/content-folder-procs.tcl 15 Nov 2006 17:11:36 -0000 1.12 @@ -15,13 +15,13 @@ ad_proc -public ::content::folder::new { -name:required {-folder_id ""} - {-parent_id ""} + {-parent_id "-4"} {-content_type "content_folder"} {-label ""} {-description ""} {-creation_user ""} {-creation_ip ""} - -creation_date + {-creation_date ""} {-context_id ""} {-package_id ""} } { @@ -58,18 +58,29 @@ } { # FIXME or should this use package instantiate object which is a # little smarter - set var_list [list] - foreach var [list folder_id name label description parent_id context_id package_id] { - lappend var_list [list $var [set $var]] + + if {$parent_id != "-4" && [content::folder::is_registered -folder_id $parent_id -content_type "content_folder"] eq "f"} { + ns_log Error "-20000: This folder does not allow subfolders to be created" } - if {[exists_and_not_null creation_date]} { - lappend var_list [list creation_date $creation_date] + + set folder_id [content::item::new -item_id $folder_id -name $name -parent_id $parent_id -content_type "content_folder" -item_subtype "content_folder" -package_id $package_id -context_id $context_id -creation_user $creation_user -creation_ip $creation_ip -creation_date $creation_date] + + # Insert the folder into cr_folders + db_dml insert_cr_folders "" + + # Update the object to have the label. This is done to prevent content::item::new from generating a revision + db_dml update_object_title "" + + # inherit the attributes of the parent folder + + if {![string eq $parent_id ""]} { + + db_dml inherit_folder_type "" + + # update the child flag on the parent + db_dml update_parent_folder "" } - set folder_id [package_instantiate_object \ - -creation_user $creation_user \ - -creation_ip $creation_ip \ - -var_list $var_list \ - $content_type] + return $folder_id } Index: openacs-4/packages/acs-content-repository/tcl/content-folder-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/Attic/content-folder-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-content-repository/tcl/content-folder-procs.xql 15 Nov 2006 17:11:36 -0000 1.1 @@ -0,0 +1,43 @@ + + + + + + insert into cr_folders ( + folder_id, label, description, package_id + ) values ( + :folder_id, :label, :description, :package_id + ) + + + + + + update acs_objects + set title = :label + where object_id = :folder_id + + + + + + insert into cr_folder_type_map + select + :folder_id as folder_id, content_type + from + cr_folder_type_map + where + folder_id = :parent_id + + + + + + + update cr_folders set has_child_folders = 't' + where folder_id = :parent_id + + + + +