xowiki::Package instproc www-delete (public)
<instance of xowiki::Package> www-delete [ -item_id item_id ] \ [ -name name ] [ -parent_id parent_id ] [ -return_url return_url ]
Defined in /var/www/openacs.org/packages/xowiki/tcl/package-procs.tcl
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. While the class specific methods are used from the application pages, the package_level method is used from the admin pages. If no "item_id", "name" or "return_url" are given, take it from the query parameters.
- Switches:
- -item_id (optional)
- -name (optional)
- -parent_id (optional)
- -return_url (optional)
- Testcases:
- xowiki_test_cases
Source code: #:log "--D delete [self args]" if {![info exists item_id]} { set item_id [:query_parameter item_id:int32] #:log "--D item_id from query parameter $item_id" } # # if no name is given, take it from the query parameter # if {![info exists name]} { set name [:query_parameter name] } if {![info exists return_url]} { set return_url [:query_parameter_return_url [ad_urlencode_folder_path ${:package_url}]] } if {$item_id eq ""} { set item_info [:item_info_from_url -with_package_prefix false $name] if {[dict get $item_info item_id] == 0} { :log "www-delete: url lookup of '$name' failed" } else { set parent_id [dict get $item_info parent_id] set item_id [dict get $item_info item_id] set name [dict get $item_info name] } } else { set name [::xo::db::CrClass get_name -item_id $item_id] if {![info exists parent_id]} { set parent_id [::xo::db::CrClass get_parent_id -item_id $item_id] } } #:msg item_id=$item_id/name=$name if {$item_id ne ""} { :log "--D trying to delete $item_id $name" set object_type [::xo::db::CrClass get_object_type -item_id $item_id] # In case of PageTemplate and subtypes, we need to check # for pages using this template set classes [list $object_type {*}[$object_type info heritage]] if {"::xowiki::PageTemplate" in $classes} { set count [::xowiki::PageTemplate count_usages -item_id $item_id -publish_status all] if {$count > 0} { return [${:id} error_msg [_ xowiki.error-delete_entries_first [list count $count]]] } } if {[:get_parameter with_general_comments:boolean 0]} { # # We have general comments. In a first step, we have to delete # these, before we are able to delete the item. # set comment_ids [::xo::dc list get_comments { select comment_id from general_comments where object_id = :item_id }] foreach comment_id $comment_ids { :log "-- deleting comment $comment_id" ::xo::db::sql::content_item del -item_id $comment_id } } foreach child_item_id [::xo::db::CrClass get_child_item_ids -item_id $item_id] { :flush_references -item_id $child_item_id } $object_type delete -item_id $item_id :flush_references -item_id $item_id -name $name -parent_id $parent_id :flush_page_fragment_cache -scope agg } else { :log "--D nothing to delete!" } :returnredirect $return_urlXQL Not present: Generic, PostgreSQL, Oracle