ad_page_contract { Try and look up the item in the content repository @author Unknown @creation-date Unknown @cvs-id $Id: index.vuh,v 1.12 2024/09/11 06:15:51 gustafn Exp $ } { { revision_id "" } } # Get the paths set the_root $::acs::pageroot set the_url [ad_conn path_info] set content_type "content_revision" # Get the IDs set content_root [fs::get_root_folder] set template_root [db_string template_root {}] set file_id [::content::item::get_id -item_path $the_url \ -root_folder_id $content_root \ -resolve_index "f"] set user_id [ad_conn user_id] # # DRB: Note that content::init modifies the local variable the_root, # which is treated as though it's been passed by reference. This # requires that the redirect treat the path as an absolute path within # the filesystem. # if {[parameter::get -parameter BehaveLikeFilesystemP -default 0] || [catch { set init_p [content::init the_url the_root $content_root $template_root \ public $revision_id $content_type] }] || !$init_p } { # # Make sure we are not dealing with an upgraded file and there # exists a file with the title # if {$file_id eq ""} { set splitted_url [split $the_url "/"] set item_url_title [lindex $splitted_url end] # THIS CODE ONLY TAKES TWO FOLDERS INTO ACCOUNT. THIS NEEDS TO BE FIXED LATER set item_url_folder [lindex $splitted_url end-1] set item_url_parent_folder [lindex $splitted_url end-2] set file_id [db_string upgraded_item_id { select i.item_id from cr_revisions r, cr_items i where r.item_id = i.item_id and r.title = :item_url_title and i.parent_id in (select item_id from cr_items where name = :item_url_folder and parent_id in (select item_id from cr_items where name = :item_url_parent_folder)) fetch first 1 row only } -default 0] } if {$file_id == 0} { ns_returnnotfound ad_script_abort } else { if {[content::symlink::is_symlink -item_id $file_id]} { set file_id [content::symlink::resolve -item_id $file_id] } set version_id [content::item::get_live_revision -item_id $file_id] if {[namespace which ::views::record_view] ne ""} { views::record_view -object_id $file_id -viewer_id $user_id } permission::require_permission \ -party_id $user_id \ -object_id $version_id \ -privilege read cr_write_content -revision_id $version_id } } else { set version_id [content::item::get_live_revision -item_id $file_id] permission::require_permission \ -party_id $user_id \ -object_id $version_id \ -privilege read set file "$the_root/$the_url" rp_internal_redirect -absolute_path $file } # Local variables: # mode: tcl # tcl-indent-level: 4 # indent-tabs-mode: nil # End: