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 -N -r1.332.2.65 -r1.332.2.66 --- openacs-4/packages/xowiki/tcl/package-procs.tcl 31 Aug 2020 14:35:24 -0000 1.332.2.65 +++ openacs-4/packages/xowiki/tcl/package-procs.tcl 7 Oct 2020 10:09:42 -0000 1.332.2.66 @@ -101,6 +101,73 @@ return $name } + Package ad_instproc get_ids_for_bulk_actions {-parent_id page_references} { + + The page_reference is either an item_id, a fully qualified URL + path or the name exactly as stored in the content repository + ("name" attribute in the database, requires parent_id to be + provided as well) + + @param parent_id optional, only needed in lagacy cases, + when page_reference is provided as page name + @param page_references item_ids, paths or names to be resolved as item_ids + @return list of valid item_ids + + } { + set item_ids {} + foreach page_ref $page_references { + # + # First check whether we got a valid item_id, then check for a + # URL path. If both are failing, resort to the legacy methods + # (which will be dropped eventually). + # + if {[string is integer -strict $page_ref]} { + if {[content::item::get -item_id $page_ref]} { + set item_id $page_ref + } + } elseif {[string index $page_ref 0] eq "/"} { + # + # $page_ref looks like a URL path + # + set ref [:item_info_from_url $page_ref] + set item_id [dict get $ref item_id] + ns_log notice "get_ids_for_bulk_actions: URL '$page_ref' item_ref <$ref> -> $item_id" + } else { + # + # Try $page_ref as item_ref + # + set parent_id_arg [expr {[info exists parent_id] ? [list -parent_id $parent_id] : {}}] + set p [:get_page_from_item_ref {*}$parent_id_arg $page_ref] + if {$p ne ""} { + set item_id [$p item_id] + } + ns_log notice "get_ids_for_bulk_actions: tried to resolve item_ref <$page_ref> -> $item_id" + } + + if {![info exists item_id] || $item_id == 0} { + # + # Try to resolve either via a passed in parent_id or via root folder + # + set parent_ids [expr {[info exists parent_id] ? $parent_id : ${:folder_id}}] + foreach parent_id $parent_ids { + set item_id [::xo::db::CrClass lookup -name $page_ref -parent_id $parent_id] + if {$item_id != 0} { + break + } + } + } + + if {$item_id != 0} { + #:log "clipboard-add adds $page_ref // $item_id" + lappend item_ids $item_id + } else { + ns_log warning "get_ids_for_bulk_actions: clipboard entry <$page_ref> could not be resolved" + } + } + return $item_ids + } + + Package instproc normalize_name {{-with_prefix:boolean false} string} { # # Normalize the name (in a narrow sense) which refers to a @@ -2612,7 +2679,7 @@ Package ad_instproc www-delete {-item_id -name -parent_id} { - This web-callabel "delete" method does not require an instantiated object, + This web-callable "delete" method does not require an instantiated object, while the class-specific delete methods in xowiki-procs need these. If a (broken) object can't be instantiated, it cannot be deleted. Therefore, we need this package level delete method.