Index: openacs-4/packages/cms/tcl/item-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/Attic/item-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/cms/tcl/item-procs.tcl 12 Jul 2001 06:37:26 -0000 1.2 +++ openacs-4/packages/cms/tcl/item-procs.tcl 10 Aug 2001 15:03:28 -0000 1.3 @@ -26,7 +26,7 @@ ad_proc item::get_live_revision { item_id } { - template::query live_revision onevalue " + template::query glr_get_live_revision live_revision onevalue " select live_revision from cr_items where item_id = :item_id" -cache "item_live_revision $item_id" @@ -53,8 +53,8 @@ # @see proc item::get_live_revision # @see proc item::get_item_from_revision -proc item::get_best_revision { item_id } { - template::query revision_id onevalue " +ad_proc item::get_best_revision { item_id } { + template::query gbr_get_best_revision revision_id onevalue " select content_item.get_best_revision(:item_id) from dual " -cache "item_best_revision $item_id" @@ -73,7 +73,7 @@ # @see proc item::get_best_revision ad_proc item::get_item_from_revision { revision_id } { - template::query item_id onevalue " + template::query gifr_get_one_revision item_id onevalue " select item_id from cr_revisions where revision_id = :revision_id " -cache "item_from_revision $revision_id" return $item_id @@ -90,10 +90,10 @@ # @return The relative URL to the item, or an empty string on failure # @see proc item::get_extended_url -proc item::get_url { item_id } { +ad_proc item::get_url { item_id } { # Get the path - template::query item_path onevalue " + template::query gu_get_path item_path onevalue " select content_item.get_path(:item_id) from dual " -cache "item_path $item_id" @@ -116,22 +116,22 @@ # on failure # @see proc item::get_url -proc item::get_id { url {root_folder ""}} { +ad_proc item::get_id { url {root_folder ""}} { # Strip off file extension set last [string last "." $url] if { $last > 0 } { set url [string range $url 0 [expr $last - 1]] } - - set sql "select content_item.get_id(:url" + # FIX ME + set sql [db_map gi_get_item_id_1] "select content_item.get_id(:url" if { ![template::util::is_nil root_folder] } { - append sql ", :root_folder" + append sql [db_map gi_get_item_id_2] ", :root_folder" } - append sql ") from dual" + append sql [db_map gi_get_item_id_3] ") from dual" # Get the path - template::query item_id onevalue $sql -cache "item_id $url $root_folder" + template::query gi_get_item_id item_id onevalue $sql -cache "item_id $url $root_folder" if { [info exists item_id] } { return $item_id @@ -154,9 +154,9 @@ # return 1 (one) if the revision exists, 0 (zero) otherwise. # @see proc item::get_extended_url -proc item::get_mime_info { revision_id {datasource_ref mime_info} } { +ad_proc item::get_mime_info { revision_id {datasource_ref mime_info} } { - return [template::query mime_info onerow " + return [template::query gmi_get_mime_info mime_info onerow " select m.mime_type, m.file_extension from @@ -179,9 +179,9 @@ # @return The content type of the item, or an empty string if no such # item exists -proc item::get_content_type { item_id } { +ad_proc item::get_content_type { item_id } { - template::query content_type onevalue " + template::query gct_get_content_type content_type onevalue " select content_type from cr_items where item_id = :item_id " -cache "item_content_type $item_id" @@ -218,7 +218,7 @@ # @see proc item::get_mime_info # @see proc item::get_template_id -proc item::get_extended_url { item_id args } { +ad_proc item::get_extended_url { item_id args } { set item_url [get_url $item_id] @@ -294,9 +294,9 @@ # # @see proc item::get_template_url -proc item::get_template_id { item_id {context public} } { +ad_proc item::get_template_id { item_id {context public} } { - template::query template_id onevalue " + template::query gti_get_template_id template_id onevalue " select content_item.get_template(:item_id, :context) as template_id from dual" -cache "item_itemplate_id $item_id" @@ -322,7 +322,7 @@ # # @see proc item::get_template_id -proc item::get_template_url { item_id {context public} } { +ad_proc item::get_template_url { item_id {context public} } { set template_id [get_template_id $item_id $context] @@ -341,8 +341,8 @@ # # @return 1 if the content is null, 0 otherwise -proc item::content_is_null { revision_id } { - template::query content_test onevalue " +ad_proc item::content_is_null { revision_id } { + template::query cin_get_content content_test onevalue " select 't' from cr_revisions where revision_id = :revision_id and content is not null" @@ -367,11 +367,11 @@ # # @return A TCL list of all possible content methods -proc item::content_methods_by_type { content_type args } { +ad_proc item::content_methods_by_type { content_type args } { template::util::get_opts $args - template::query types onelist " + template::query cmbt_get_content_mime_types types onelist " select mime_type from cr_content_mime_type_map where content_type = :content_type and lower(mime_type) like 'text/%' @@ -420,7 +420,7 @@ # @see proc item::get_mime_info # @see proc item::get_content_type -proc item::get_revision_content { revision_id args } { +ad_proc item::get_revision_content { revision_id args } { template::util::get_opts $args @@ -438,10 +438,10 @@ # Get the mime type, decide if we want the text get_mime_info $revision_id - + # FIX ME if { [string equal \ [lindex [split $mime_info(mime_type) "/"] 0] "text"] } { - set text_sql ",\n content.blob_to_string(content) as text" + set text_sql [db_map grc_get_all_content_1] ",\n content.blob_to_string(content) as text" } else { set text_sql "" } @@ -450,14 +450,14 @@ set content_type [get_content_type $item_id] # Get the table name - template::query table_name onevalue " + template::query grc_get_table_names table_name onevalue " select table_name from acs_object_types where object_type = :content_type " -cache "type_table_name $content_type" -persistent \ -timeout 3600 # Get (all) the content (note this is really dependent on file type) - template::query content onerow "select + template::query grc_get_all_content content onerow "select x.*, :item_id as item_id $text_sql, :content_type as content_type @@ -496,8 +496,8 @@ # # @return 1 if the item is publishable, 0 otherwise -proc item::is_publishable { item_id } { - template::query is_publishable onevalue " +ad_proc item::is_publishable { item_id } { + template::query ip_is_publishable_p is_publishable onevalue " select content_item.is_publishable(:item_id) from dual " -cache "item_is_publishable $item_id" @@ -523,8 +523,8 @@ # # @see proc item::is_publishable -proc item::get_publish_status { item_id } { - template::query publish_status onevalue " +ad_proc item::get_publish_status { item_id } { + template::query gps_get_publish_status publish_status onevalue " select publish_status from cr_items where item_id = :item_id " -cache "item_publish_status $item_id" @@ -542,8 +542,8 @@ # # @see proc item::get_best_revision -proc item::get_title { item_id } { - template::query title onevalue " +ad_proc item::get_title { item_id } { + template::query gt_get_title title onevalue " select content_item.get_title(:item_id) from dual " -cache "item_title $item_id" Index: openacs-4/packages/cms/tcl/module-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/module-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/cms/tcl/module-procs.tcl 20 Apr 2001 20:51:09 -0000 1.1 +++ openacs-4/packages/cms/tcl/module-procs.tcl 10 Aug 2001 15:03:28 -0000 1.2 @@ -23,8 +23,8 @@ namespace eval modules { # Get the id of some module, return empty string on failure - proc get_module_id { module_name } { - template::query id onevalue " + ad_proc get_module_id { module_name } { + template::query gmi_get_module_id id onevalue " select module_id from cm_modules where key = :module_name " -cache "get_module_name $module_name" -persistent @@ -33,16 +33,15 @@ } # Get a list of all the mount points - proc getMountPoints {} { + ad_proc getMountPoints {} { - set query "select + template::query gmp_get_mount_points mount_point_list multilist " + select key, name, '' as id, '' as children, 't' as expandable, 'f' as symlink, 0 as update_time from cm_modules - order by sort_key" - - template::query mount_point_list multilist $query + order by sort_key" # Append clipboard lappend mount_point_list [folderCreate "clipboard" "Clipboard" "" [list] t f 0] @@ -51,12 +50,12 @@ } # Generic getCHildFolders procedure for sitemap and templates - proc getChildFolders { mount_point id } { + ad_proc getChildFolders { mount_point id } { # query for child site nodes set module_name [namespace tail [namespace current]] - set query " + template::query gcf_get_child_folders result multilist " select :mount_point as mount_point, r.name, @@ -77,25 +76,24 @@ order by name" - template::query result multilist $query - return $result } namespace eval workspace { - proc getRootFolderID {} { return 0 } + #RBM: FIX ME: This has got to be a hack that was left over in the code! + ad_proc getRootFolderID {} { return 0 } - proc getChildFolders { id } { + ad_proc getChildFolders { id } { return [list] } } namespace eval templates { # Retreive the id of the root folder - proc getRootFolderID {} { + ad_proc getRootFolderID {} { if { ![nsv_exists browser_state template_root] } { - template::query root_id onevalue " + template::query grfi_get_root_id root_id onevalue " select content_template.get_root_folder() from dual" nsv_set browser_state template_root $root_id return $root_id @@ -104,7 +102,7 @@ } } - proc getChildFolders { id } { + ad_proc getChildFolders { id } { if { [string equal $id {}] } { set id [getRootFolderID] } @@ -115,27 +113,27 @@ return [cm::modules::getChildFolders $module_name $id] } - proc getSortedPaths { name id_list {root_id 0} {eval_code {}}} { + ad_proc getSortedPaths { name id_list {root_id 0} {eval_code {}}} { uplevel " cm::modules::sitemap::getSortedPaths $name \{$id_list\} $root_id \{$eval_code\} " } } namespace eval workflow { - proc getRootFolderID {} { return 0 } + ad_proc getRootFolderID {} { return 0 } - proc getChildFolders { id } { + ad_proc getChildFolders { id } { return [list] } } namespace eval sitemap { # Retreive the id of the root folder - proc getRootFolderID {} { + ad_proc getRootFolderID {} { if { ![nsv_exists browser_state sitemap_root] } { - template::query root_id onevalue " + template::query gri_get_root_id root_id onevalue " select content_item.get_root_folder() from dual" nsv_set browser_state sitemap_root $root_id return $root_id @@ -144,7 +142,7 @@ } } - proc getChildFolders { id } { + ad_proc getChildFolders { id } { if { [string equal $id {}] } { set id [getRootFolderID] } @@ -155,13 +153,14 @@ return [cm::modules::getChildFolders $module_name $id] } - proc getSortedPaths { name id_list {root_id 0} {eval_code {}}} { + ad_proc getSortedPaths { name id_list {root_id 0} {eval_code {}}} { set sql_id_list "'" append sql_id_list [join $id_list "','"] append sql_id_list "'" - - set sql_query "select + #FIX ME + set sql_query [db_map gsp_get_sorted_paths] + "select item_id, content_item.get_path(item_id, :sorted_paths_root_id) as item_path, content_type as item_type @@ -171,10 +170,11 @@ item_id in ($sql_id_list) order by item_path" + upvar sql_query __sql upvar sorted_paths_root_id _root_id set _root_id $root_id uplevel " - template::query $name multirow \{$sql_query\} -eval \{$eval_code\} + template::query gsp_get_paths multirow \{$__sql\} -eval \{$eval_code\} " } @@ -185,9 +185,9 @@ # Return a multilist representing the types tree, # for use in a select widget - proc getTypesTree { } { + ad_proc getTypesTree { } { - template::query result multilist " + template::query gtt_get_tree_types result multilist " select lpad(' ', level, '-') || pretty_name as label, object_type as value @@ -204,9 +204,9 @@ return $result } - proc getRootFolderID {} { return "content_revision" } + ad_proc getRootFolderID {} { return "content_revision" } - proc getChildFolders { id } { + ad_proc getChildFolders { id } { set children [list] @@ -217,7 +217,7 @@ # query for message categories set module_name [namespace tail [namespace current]] - set query "select + template::query gcf_get_child_folders result multilist "select :module_name as mount_point, t.pretty_name, t.object_type, @@ -236,26 +236,25 @@ supertype = :id order by t.pretty_name" - - template::query result multilist $query + return $result } } # end of types namespace namespace eval search { - proc getRootFolderID {} { return 0 } + ad_proc getRootFolderID {} { return 0 } - proc getChildFolders { id } { + ad_proc getChildFolders { id } { return [list] } } namespace eval categories { - proc getRootFolderID {} { return 0 } + ad_proc getRootFolderID {} { return 0 } - proc getChildFolders { id } { + ad_proc getChildFolders { id } { set children [list] @@ -269,7 +268,8 @@ # query for keyword categories - set query "select + template::query gcc_get_child_folders children multilist " + select :module_name as mount_point, content_keyword.get_heading(keyword_id) as name, keyword_id, @@ -290,19 +290,17 @@ content_keyword.is_leaf(keyword_id) = 'f' order by name" - - template::query children multilist $query return $children } - proc getSortedPaths { name id_list {root_id 0} {eval_code {}}} { + ad_proc getSortedPaths { name id_list {root_id 0} {eval_code {}}} { set sql_id_list "'" append sql_id_list [join $id_list "','"] append sql_id_list "'" - - set sql_query " + # FIX ME + set sql_query [db_map gsp_get_query] " select keyword_id as item_id, content_keyword.get_path(keyword_id) as item_path, @@ -311,19 +309,20 @@ cr_keywords where keyword_id in ($sql_id_list)" - + + upvar __sql sql_query uplevel " - template::query $name multirow \{$sql_query\} -eval \{$eval_code\} + template::query $name multirow \{$__sql\} -eval \{$eval_code\} " } } # end of categories namespace namespace eval users { - proc getRootFolderID {} { return 0 } + ad_proc getRootFolderID {} { return 0 } - proc getChildFolders { id } { + ad_proc getChildFolders { id } { if { [string equal $id {}] } { set where_clause "not exists (select 1 from group_component_map m @@ -336,7 +335,7 @@ set module_name [namespace tail [namespace current]] - set query "select + template::query gcf_get_child_folders result multilist "select :module_name as mount_point, g.group_name as name, g.group_id, '' as children, @@ -355,20 +354,16 @@ $where_clause order by name" - - ns_log notice $query - - template::query result multilist $query return $result } - proc getSortedPaths { name id_list {root_id 0} {eval_code {}}} { + ad_proc getSortedPaths { name id_list {root_id 0} {eval_code {}}} { set sql_id_list "'" append sql_id_list [join $id_list "','"] append sql_id_list "'" - - set sql_query " + # FIX ME + set sql_query [db_map gsp_get_sort_paths] " select o.object_id as item_id, o.object_type || ': ' || acs_object.name(o.object_id) as item_path, @@ -381,17 +376,18 @@ o.object_id in ($sql_id_list) order by item_path" - - uplevel "template::query $name multirow \{$sql_query\} -eval \{$eval_code\}" + + upvar __sql sql_query + uplevel "template::query $name multirow \{$__sql\} -eval \{$eval_code\}" } } namespace eval clipboard { - proc getRootFolderID {} { return 0 } + ad_proc getRootFolderID {} { return 0 } - proc getChildFolders { id } { + ad_proc getChildFolders { id } { # Only the mount point is expandable if { ![template::util::is_nil id] } { @@ -402,15 +398,14 @@ set module_name [namespace tail [namespace current]] - set query "select + template::query gcf_child_folders result multilist " + select :module_name as mount_point, name, key, '' as children, 'f' as expandable, 'f' as symlink, 0 as update_type from cm_modules order by sort_key" - - template::query result multilist $query return $result } } Index: openacs-4/packages/cms/tcl/pagination-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/Attic/pagination-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/cms/tcl/pagination-procs.tcl 27 May 2001 04:39:19 -0000 1.2 +++ openacs-4/packages/cms/tcl/pagination-procs.tcl 10 Aug 2001 15:03:28 -0000 1.3 @@ -15,12 +15,12 @@ # @param sql The sql query to paginate # @param page The current page number -proc pagination::paginate_query { sql page } { +ad_proc pagination::paginate_query { sql page } { set rows_per_page [pagination::get_rows_per_page] set start_row [expr $rows_per_page*[expr $page-1]+1] - - set query " + #FIX ME + set query [db_map pq_paginate_query] " select * from ( @@ -55,9 +55,9 @@ # @param db A database handle -proc pagination::get_total_pages {} { +ad_proc pagination::get_total_pages {} { uplevel { - template::query total_pages onevalue " + template::query gtp_get_total_pages total_pages onevalue " select ceil(count(*) / [pagination::get_rows_per_page] ) from @@ -78,7 +78,7 @@ # @param page The current page number # @param total_pages The total pages returned by the query -proc pagination::page_number_links { page total_pages } { +ad_proc pagination::page_number_links { page total_pages } { if { $total_pages == 1 } { return "" @@ -144,7 +144,7 @@ # @param set_id The set id -proc pagination::ns_set_to_url_vars { set_id } { +ad_proc pagination::ns_set_to_url_vars { set_id } { set url_vars "" set size [ns_set size $set_id] for { set i 0 } { $i < $size } { incr i } { Index: openacs-4/packages/cms/tcl/perm-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/perm-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/cms/tcl/perm-procs.tcl 20 Apr 2001 20:51:09 -0000 1.1 +++ openacs-4/packages/cms/tcl/perm-procs.tcl 10 Aug 2001 15:03:28 -0000 1.2 @@ -11,7 +11,7 @@ # Will pick up mount_point, id, parent_id if they exist in the calling # frame -proc content::show_error { +ad_proc content::show_error { message {return_url {}} {passthrough {}} } { @@ -42,7 +42,7 @@ # -request_error: if present, use request error as opposed to error box # -refresh: if present, update query cache -proc content::check_access { object_id privilege args } { +ad_proc content::check_access { object_id privilege args } { # Set up the default options foreach varname { mount_point return_url parent_id passthrough } { @@ -62,16 +62,14 @@ # Query the database, set up the array upvar user_permissions user_permissions - set query " + set code [list template::query ca_get_perm_list perm_list multilist " select p.privilege, cms_permission.permission_p ( :object_id, :user_id, p.privilege ) as is_granted from - acs_privileges p" - - set code [list template::query perm_list multilist $query \ + acs_privileges p" \ -cache "content::check_access $object_id $user_id" -persistent \ -timeout 300] if { [info exists opts(refresh)] } { @@ -88,7 +86,7 @@ } # See if the user is even logged in - template::query user_name onevalue " + template::query ca_get_user_name user_name onevalue " select screen_name from users where user_id = :user_id " @@ -98,7 +96,7 @@ } else { # Get the error message - template::query msg_info onerow " + template::query ca_get_msg_info msg_info onerow " select acs_object.name(:object_id) as obj_name, pretty_name as perm_name @@ -132,18 +130,22 @@ } # Flush the cache used by check_access -proc content::flush_access_cache { {object_id {}} } { +ad_proc content::flush_access_cache { {object_id {}} } { template::query::flush_cache "content::check_access ${object_id}*" } # Generate a form for modifying permissions # Requires object_id, grantee_id, user_id to be set in calling frame -proc content::perm_form_generate { form_name_in {passthrough "" } } { +ad_proc content::perm_form_generate { form_name_in {passthrough "" } } { upvar perm_form_name form_name set form_name $form_name_in + # FIX ME + set sql [db_map pfg_get_permission_boxes] + upvar __sql sql + uplevel { set is_request [form is_request $perm_form_name] @@ -152,7 +154,7 @@ set permission_options [list] set permission_values [list] - template::query permission_boxes multirow " + template::query permission_boxes multirow $__sql " select t.child_privilege as privilege, lpad(' ', t.tree_level * 24, ' ') || @@ -219,11 +221,16 @@ # Process the permission form -proc content::perm_form_process { form_name_in } { +ad_proc content::perm_form_process { form_name_in } { upvar perm_form_name form_name set form_name $form_name_in - + # FIX ME + set sql_grant [db_map pfp_grant_permission_1] + set sql_revoke [db_map pfp_revoke_permission_1] + upvar __sql_grant sql_grant + upvar __sql_revoke sql_revoke + uplevel { if { [form is_valid $perm_form_name] } { @@ -233,37 +240,37 @@ form get_values $perm_form_name object_id grantee_id pf_is_recursive set permission_values [element get_values $perm_form_name pf_boxes] - template::begin_db_transaction + db_transaction { - # Assign checked permissions, unassign unchecked ones - foreach pair $permission_options { - set privilege [lindex $pair 1] - if { [lsearch $permission_values $privilege] >= 0 } { - template::query grant_permission dml " - begin - cms_permission.grant_permission ( - item_id => :object_id, - holder_id => :user_id, - privilege => :privilege, - recepient_id => :grantee_id, - is_recursive => :pf_is_recursive - ); - end;" - } else { - template::query revoke_permission dml " - begin - cms_permission.revoke_permission ( - item_id => :object_id, - holder_id => :user_id, - privilege => :privilege, - revokee_id => :grantee_id, - is_recursive => :pf_is_recursive - ); - end;" - } - } + # Assign checked permissions, unassign unchecked ones + foreach pair $permission_options { + set privilege [lindex $pair 1] + if { [lsearch $permission_values $privilege] >= 0 } { + template::query pfp_grant_permission grant_permission dml $__sql_grant " + begin + cms_permission.grant_permission ( + item_id => :object_id, + holder_id => :user_id, + privilege => :privilege, + recepient_id => :grantee_id, + is_recursive => :pf_is_recursive + ); + end;" + } else { + template::query pfp_revoke_permission revoke_permission dml $__sql_revoke" + begin + cms_permission.revoke_permission ( + item_id => :object_id, + holder_id => :user_id, + privilege => :privilege, + revokee_id => :grantee_id, + is_recursive => :pf_is_recursive + ); + end;" + } + } - template::end_db_transaction + } # Recache the permissions content::check_access $object_id "cm_read" \ Index: openacs-4/packages/cms/tcl/publish-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/publish-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/cms/tcl/publish-procs.tcl 27 May 2001 04:39:19 -0000 1.2 +++ openacs-4/packages/cms/tcl/publish-procs.tcl 10 Aug 2001 15:03:28 -0000 1.3 @@ -328,14 +328,16 @@ # @see proc publish::get_publish_roots # @see proc publish::write_multiple_files -proc publish::write_multiple_blobs { - db url revision_id {root_path ""} +ad_proc publish::write_multiple_blobs { + url revision_id {root_path ""} } { foreach_publish_path $url { mkdirs $filename - ns_ora blob_get_file $db " + + db_blob_get_file wmb_get_blob_file " select content from cr_revisions where revision_id = $revision_id " $filename + ns_chmod $filename 0764 ns_log notice "PUBLISH: Wrote revision $revision_id to $filename" } $root_path @@ -389,7 +391,7 @@ # @see proc content::get_content_value # @see proc publish::get_publish_roots -proc publish::write_content { revision_id args } { +ad_proc publish::write_content { revision_id args } { template::util::get_opts $args @@ -399,46 +401,46 @@ set root_path $opts(root_path) } - set db [template::begin_db_transaction] + db_transaction { - # Get the item id if none specified - if { [template::util::is_nil opts(item_id)] } { - set item_id [content_item::get_item_from_revision $revision_id] - - if { [template::util::is_nil item_id] } { - ns_log notice \ - "WARNING: publish::write_content: No such revision $revision_id" - template::end_db_transaction - return "" - } - } else { - set item_id $opts(item_id) + # Get the item id if none specified + if { [template::util::is_nil opts(item_id)] } { + set item_id [content_item::get_item_from_revision $revision_id] + + if { [template::util::is_nil item_id] } { + ns_log notice \ + "WARNING: publish::write_content: No such revision $revision_id" + return "" + } + } else { + set item_id $opts(item_id) + } } set file_url [item::get_extended_url $item_id -revision_id $revision_id] - # Write blob/text to file - ns_log notice "Writing item $item_id to $file_url" + db_transaction { + # Write blob/text to file + ns_log notice "Writing item $item_id to $file_url" - if { [info exists opts(text)] } { - set text [content::get_content_value $revision_id] - write_multiple_files $file_url $text $root_path - } else { + if { [info exists opts(text)] } { + set text [content::get_content_value $revision_id] + write_multiple_files $file_url $text $root_path + } else { - # Determine if the blob is null. If it is, give up (or else the - # ns_ora blob_get_file will crash). - if { [item::content_is_null $revision_id] } { - ns_log notice \ - "WARNING: publish::write_content: No content supplied for revision $revision_id" - return "" - } + # Determine if the blob is null. If it is, give up (or else the + # ns_ora blob_get_file will crash). + if { [item::content_is_null $revision_id] } { + ns_log notice \ + "WARNING: publish::write_content: No content supplied for revision $revision_id" + return "" + } - # Write the blob - write_multiple_blobs $db $file_url $revision_id $root_path + # Write the blob + write_multiple_blobs $file_url $revision_id $root_path + } } - template::end_db_transaction - # Return either the full path or the relative URL return $file_url } @@ -454,6 +456,8 @@ # # @return Everything between the <body> and the </body> tags # if they exist; the unchanged HTML if they do not +# +# FIX ME: This approach is not really flexible, as HTML 4 accepts tags broken in lines proc publish::get_html_body { html } { @@ -503,15 +507,15 @@ # @see proc publish::merge_with_template # @see proc publish::handle_item -proc publish::render_subitem { +ad_proc publish::render_subitem { main_item_id relation_type relation_tag \ index is_embed extra_args {is_merge t} } { # Get the child item if { [string equal $relation_type child] } { - template::query subitems onelist " + template::query rs_get_subitems subitems onelist " select child_id from @@ -525,7 +529,7 @@ order by order_n" -cache "item_child_items $main_item_id $relation_tag" } else { - template::query subitems onelist " + template::query cs_get_subitems_related subitems onelist " select related_object_id from @@ -543,7 +547,7 @@ set sub_item_id [lindex $subitems [expr $index - 1]] if { [template::util::is_nil sub_item_id] } { - ns_log notice "No such subitem" + ns_log notice "publish::render_subitem: No such subitem" return "" } @@ -1171,7 +1175,7 @@ # tag. Uses the title for alt text if no alt text is specified # externally. -proc publish::handle::image { item_id args } { +ad_proc publish::handle::image { item_id args } { template::util::get_opts $args @@ -1190,7 +1194,7 @@ } # If the merging failed, output a straight tag - template::query image_info onerow " + template::query i_get_image_info image_info onerow " select im.width, im.height, r.title as image_alt from @@ -1294,7 +1298,7 @@ # @see proc publish::publish_revision # @see proc publish::unpublish_item -proc publish::set_publish_status { item_id new_status {revision_id ""} } { +ad_proc publish::set_publish_status { item_id new_status {revision_id ""} } { switch $new_status { @@ -1340,8 +1344,8 @@ } - ns_ora dml $db "update cr_items set publish_status = :new_status - where item_id = :item_id" + db_dml sps_update_cr_items "update cr_items set publish_status = :new_status + where item_id = :item_id" } @@ -1352,70 +1356,67 @@ # # @see proc publish::schedule_status_sweep -proc publish::track_publish_status {} { +ad_proc publish::track_publish_status {} { ns_log notice "PUBLISH: Tracking publish status" - set db [template::begin_db_transaction] + db_transaction { - if { [catch { + if { [catch { - # Get all ready but nonlive items, make them live - template::query items multilist " - select - distinct i.item_id, i.live_revision - from - cr_items i, cr_release_periods p - where - i.publish_status = 'ready' - and - i.live_revision is not null - and - i.item_id = p.item_id - and - (sysdate between p.start_when and p.end_when) - " -db $db + # Get all ready but nonlive items, make them live + template::query tps_get_items_multilist items multilist " + select + distinct i.item_id, i.live_revision + from + cr_items i, cr_release_periods p + where + i.publish_status = 'ready' + and + i.live_revision is not null + and + i.item_id = p.item_id + and + (sysdate between p.start_when and p.end_when) + " - # Have to do it this way, or else "no active select", since - # the other queries will clobber the current query - foreach pair $items { - set item_id [lindex $pair 0] - set live_revision [lindex $pair 1] - publish::set_publish_status $db $item_id live $live_revision - } + # Have to do it this way, or else "no active select", since + # the other queries will clobber the current query + foreach pair $items { + set item_id [lindex $pair 0] + set live_revision [lindex $pair 1] + publish::set_publish_status $db $item_id live $live_revision + } - # Get all live but expired items, make them nonlive - template::query items onelist " - select - distinct i.item_id - from - cr_items i, cr_release_periods p - where - i.publish_status = 'live' - and - i.live_revision is not null - and - i.item_id = p.item_id - and - not exists (select 1 from cr_release_periods p2 - where p2.item_id = i.item_id - and (sysdate between p2.start_when and p2.end_when) - ) - " -db $db + # Get all live but expired items, make them nonlive + template::query tps_get_items_onelist items onelist " + select + distinct i.item_id + from + cr_items i, cr_release_periods p + where + i.publish_status = 'live' + and + i.live_revision is not null + and + i.item_id = p.item_id + and + not exists (select 1 from cr_release_periods p2 + where p2.item_id = i.item_id + and (sysdate between p2.start_when and p2.end_when) + ) + " - foreach item_id $items { - publish::set_publish_status $db $item_id expired - } + foreach item_id $items { + publish::set_publish_status $db $item_id expired + } - } errmsg] } { - ns_log notice "Error in publish::track_publish_status: $errmsg" + } errmsg] } { + ns_log notice "Error in publish::track_publish_status: $errmsg" + } } - - template::end_db_transaction - template::release_db_handle - } # @public schedule_status_sweep