xowiki::Package instproc get_ids_for_bulk_actions (public)

 <instance of xowiki::Package[i]> get_ids_for_bulk_actions \
    [ -parent_id parent_id ] page_references

Defined in /var/www/openacs.org/packages/xowiki/tcl/package-procs.tcl

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)

Switches:
-parent_id (optional)
optional, only needed in legacy cases, when page_reference is provided as page name
Parameters:
page_references (required)
item_ids, paths or names to be resolved as item_ids
Returns:
list of valid item_ids

Testcases:
No testcase defined.
Source code:
set item_ids {}
foreach page_ref $page_references {
  set item_id 0
  #
  # 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]} {
    ::xo::dc 0or1row -prepare integer check_ref {
      select item_id from cr_items where 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
    #
    if {![info exists parent_id]} {
      set parent_ids [list ""]
    } else {
      set parent_ids $parent_id
    }
    foreach p_id $parent_ids {
      set p [:get_page_from_item_ref -parent_id $p_id $page_ref]
      if {$p ne ""} {
        set item_id [$p item_id]
        break
      }
    }
    ns_log notice "get_ids_for_bulk_actions: tried to resolve item_ref <$page_ref> -> $item_id"
  }

  if {$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 p_id $parent_ids {
      set item_id [::xo::db::CrClass lookup -name $page_ref -parent_id $p_id]
      if {$item_id != 0} {
        break
      }
    }
  }

  if {$item_id != 0} {
    #:log "add $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
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: