Index: openacs-4/packages/cms/www/modules/items/rename.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/rename.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/cms/www/modules/items/rename.tcl 27 May 2001 00:22:34 -0000 1.3 +++ openacs-4/packages/cms/www/modules/items/rename.tcl 19 Aug 2002 03:30:59 -0000 1.4 @@ -9,14 +9,7 @@ # permissions check - cm_write required to rename an item content::check_access $item_id cm_write -user_id [User::getID] -template::query get_item_name item_name onevalue " - select - name - from - cr_items - where - item_id = :item_id -" +set item_name [db_string get_item_name ""] set page_title "Rename $item_name" @@ -57,13 +50,7 @@ ); end;" - template::query get_parent_id parent_id onevalue " - select - parent_id - from - cr_items - where - item_id = :item_id" + set parent_id [db_string get_parent_id ""] } # flush cache Index: openacs-4/packages/cms/www/modules/items/revision-add-1.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/revision-add-1.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/cms/www/modules/items/revision-add-1.tcl 27 May 2001 04:39:19 -0000 1.3 +++ openacs-4/packages/cms/www/modules/items/revision-add-1.tcl 19 Aug 2002 03:30:59 -0000 1.4 @@ -8,14 +8,8 @@ # check permissions content::check_access $item_id cm_write -user_id [User::getID] -template::query get_content_type content_type onevalue " - select - content_item.get_content_type( :item_id ) - from - dual -" +set content_type [db_string get_content_type ""] - # flush the sitemap folder listing cache in anticipation # of the new item cms_folder::flush sitemap $item_id @@ -27,16 +21,8 @@ template::forward "custom/$content_type/revision-add-1?item_id=$item_id" } +set name [db_string get_name ""] -template::query get_name name onevalue " - select - name - from - cr_items - where - item_id = :item_id" - - # if we have an invalid item_id, then throw error if { [template::util::is_nil name] } { template::request::error bad_item_id \ Index: openacs-4/packages/cms/www/modules/items/revision-add-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/revision-add-2.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/cms/www/modules/items/revision-add-2.tcl 24 May 2001 01:30:52 -0000 1.2 +++ openacs-4/packages/cms/www/modules/items/revision-add-2.tcl 19 Aug 2002 03:30:59 -0000 1.3 @@ -8,17 +8,8 @@ content::check_access $item_id cm_write -user_id [User::getID] # get content_type and name of item -template::query get_one_item one_item onerow " - select - content_type, name - from - cr_items - where - item_id = :item_id -" +db_0or1row get_one_item "" -template::util::array_to_vars one_item - # validate item_id if { [template::util::is_nil content_type] } { template::request::error add_revision "Error - invalid item_id - $item_id" Index: openacs-4/packages/cms/www/modules/items/revision-upload.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/revision-upload.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/cms/www/modules/items/revision-upload.tcl 8 Jun 2001 01:44:53 -0000 1.5 +++ openacs-4/packages/cms/www/modules/items/revision-upload.tcl 19 Aug 2002 03:30:59 -0000 1.6 @@ -26,15 +26,7 @@ template::forward "../sitemap/index" } - template::query get_new_item new_item onerow " - select - NVL(content_item.get_path(:parent_id), '/') as item_path, - pretty_name as content_type_name - from - acs_object_types - where - object_type = :content_type - " + db_0or1row get_new_item "" -column_array new_item if { [template::util::is_nil new_item] } { ns_log Notice "revision-upload.tcl - ERROR: BAD PARENT_ID OR CONTENT_TYPE - $parent_id, $content_type" @@ -76,9 +68,8 @@ if { [form is_request upload] } { - - template::query get_revision_id revision_id onevalue "select acs_object_id_seq.nextval from dual" - element set_properties upload revision_id -value $revision_id + set revision_id [db_string get_revision_id ""] + element set_properties upload revision_id -value $revision_id } Index: openacs-4/packages/cms/www/modules/items/revision.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/revision.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/cms/www/modules/items/revision.tcl 2 Sep 2001 14:24:58 -0000 1.5 +++ openacs-4/packages/cms/www/modules/items/revision.tcl 19 Aug 2002 03:30:59 -0000 1.6 @@ -8,30 +8,8 @@ # flag indicating this is the live revision set live_revision_p 0 +db_1row get_revision_one "" -template::query get_revision one_revision onerow " - select - revision_id, title, description, item_id, mime_type, - content_revision.get_number( revision_id ) revision_number, - ( - select - label - from - cr_mime_types - where - mime_type = cr_revisions.mime_type - ) mime_type_pretty, - to_char(publish_date,'Month DD, YYYY') as publish_date_pretty, - content_length as content_size - from - cr_revisions - where - revision_id = :revision_id -" - -template::util::array_to_vars one_revision - - # Check permissions - must have cm_examine on the item content::check_access $item_id cm_examine \ -mount_point $mount_point \ @@ -48,15 +26,10 @@ # check if the item is publishable (but does not need live revision) -template::query get_status is_publishable onevalue " - select content_item.is_publishable( :item_id ) from dual -" +set is_publishable [db_string get_status ""] - # get total number of revision for this item -template::query get_count revision_count onevalue " - select count(*) from cr_revisions where item_id = :item_id -" +set revision_count [db_string get_count ""] set valid_revision_p "t" @@ -65,14 +38,7 @@ set is_image_mime_type f if { [regexp {text/} $mime_type] } { set is_text_mime_type t - template::query get_content content onevalue " - select - blob_to_string(content) - from - cr_revisions - where - revision_id = :revision_id - " + set content [db_string get_content ""] ns_log notice $content @@ -87,25 +53,7 @@ # get item info -template::query get_one_item one_content_item onerow " - select - name, locale, live_revision as live_revision_id, - ( - select - pretty_name - from - acs_object_types - where - object_type = cr_items.content_type - ) content_type, - content_item.get_path(item_id) as path - from - cr_items - where - item_id = :item_id -" - -template::util::array_to_vars one_content_item +db_1row get_one_item "" if { $live_revision_id == $revision_id } { set live_revision_p 1 @@ -120,36 +68,7 @@ # if column_name is null, then use the attribute_name # if id_column is null, then use 'attribute_id' and 'acs_attribute_values' -template::query get_meta_attrs meta_attributes multilist " - select - attribute_id, pretty_name, - (select pretty_name from acs_object_types - where object_type = attr.object_type) object_type, - nvl(column_name,attribute_name) attribute_name, - nvl(attr.table_name,o.table_name) table_name, - nvl(o.id_column,'object_id') id_column - from - acs_attributes attr, - (select - object_type, table_name, id_column - from - acs_object_types - where - object_type not in ('acs_object','content_revision') - connect by - prior supertype = object_type - start with - object_type = (select - object_type - from - acs_objects - where - object_id = :revision_id) ) o - where - o.object_type = attr.object_type - order by - attr.object_type, attr.sort_order -" +set meta_attributes [db_list_of_lists get_meta_attrs ""] set attr_columns [list] set attr_tables [list] @@ -193,15 +112,8 @@ if { ![string equal $attr_columns ""] } { - template::query get_attr_values attribute_values multilist " - select - [join $attr_columns ", "] - from - [join $attr_tables ", "] - where - [join $column_id_cons " and "]" + set attribute_values [db_list_of_lists get_attr_values ""] - # write the body of the attribute display table to $revision_attr_html set revision_attr_html "" set i 0 Index: openacs-4/packages/cms/www/modules/items/revisions.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/revisions.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/cms/www/modules/items/revisions.tcl 9 Jun 2001 01:06:04 -0000 1.4 +++ openacs-4/packages/cms/www/modules/items/revisions.tcl 19 Aug 2002 03:30:59 -0000 1.5 @@ -16,30 +16,14 @@ -request_error # add content html -template::query get_content_type content_type onevalue " - select - content_item.get_content_type( :item_id ) - from - dual -" +set content_type [db_string get_content_type ""] # get item info +db_1row get_iteminfo "" -template::query get_iteminfo iteminfo onerow " - select - item_id, name, locale, live_revision, publish_status, - content_item.is_publishable(item_id) as is_publishable - from - cr_items - where - item_id = :item_id" -template::util::array_to_vars iteminfo - - # get all revisions - -template::query get_revisions revisions multirow [pagination::paginate_query " +db_multirow revisions get_revisions [pagination::paginate_query " select revision_id, trim(title) as title, Index: openacs-4/packages/cms/www/modules/items/status-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/status-edit.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/cms/www/modules/items/status-edit.tcl 14 Jun 2001 00:28:06 -0000 1.6 +++ openacs-4/packages/cms/www/modules/items/status-edit.tcl 19 Aug 2002 03:30:59 -0000 1.7 @@ -16,16 +16,14 @@ if { [form is_request publish_status] } { - # Determine whether the item has a live revision - template::query get_live_rewision live_revision onevalue " - select live_revision from cr_items where item_id = :item_id - " + # Determine whether the item has a live revision + set live_revision [db_string get_live_revision ""] - if { [template::util::is_nil live_revision] } { - element set_value publish_status is_live f - } else { - element set_value publish_status is_live t - } + if { [template::util::is_nil live_revision] } { + element set_value publish_status is_live f + } else { + element set_value publish_status is_live t + } } @@ -37,8 +35,7 @@ # always show production set options [list [list "Production" production]] -template::query check_status is_publishable onevalue " - select content_item.is_publishable( :item_id ) from dual" +set is_publishable [db_string check_status ""] set is_live [element get_value publish_status is_live] @@ -48,8 +45,7 @@ lappend options [list "Ready" ready] [list "Live (publishes the item)" live] #} -template::query check_published is_published onevalue " - select content_item.is_published( :item_id ) from dual" +set is_published [db_string check_published ""] # show "Expired" only if the item is currently published if { [string equal $is_published t] } { @@ -91,19 +87,8 @@ if { [form is_request publish_status] } { # Get the current status + db_1row get_info "" -column_array info - template::query get_info info onerow " - select - NVL(publish_status, 'production') as publish_status, - to_char(NVL(start_when, sysdate), 'YYYY MM DD HH24 MI SS') start_when, - to_char(NVL(end_when, sysdate + 365), 'YYYY MM DD HH24 MI SS') end_when - from - cr_items i, cr_release_periods r - where - i.item_id = :item_id - and - i.item_id = r.item_id (+)" - form set_values publish_status info } Index: openacs-4/packages/cms/www/modules/items/symlink-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/symlink-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/cms/www/modules/items/symlink-oracle.xql 19 Aug 2002 03:30:59 -0000 1.1 @@ -0,0 +1,18 @@ + + + + oracle8.1.6 + + + + + select parent_id, + content_folder.is_folder(item_id) as folder_p + from cr_items + where item_id = :resolved_id + + + + + + Index: openacs-4/packages/cms/www/modules/items/symlink-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/symlink-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/cms/www/modules/items/symlink-postgresql.xql 19 Aug 2002 03:30:59 -0000 1.1 @@ -0,0 +1,17 @@ + + + + postgresql7.1 + + + + + select parent_id, + content_folder__is_folder(item_id) as folder_p + from cr_items + where item_id = :resolved_id + + + + + Index: openacs-4/packages/cms/www/modules/items/symlink.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/symlink.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/cms/www/modules/items/symlink.tcl 20 Apr 2001 20:51:10 -0000 1.1 +++ openacs-4/packages/cms/www/modules/items/symlink.tcl 19 Aug 2002 03:30:59 -0000 1.2 @@ -1,11 +1,7 @@ # if the item is or is linked to a content_folder, then # use the sitemap module to browse the folder - set sql "select parent_id, - content_folder.is_folder(item_id) as folder_p - from cr_items - where item_id = :resolved_id" - query folder_check onerow $sql + db_0or1row do_folder_check "" -column_array folder_check if { [info exists folder_check] } { set folder_p $folder_check(folder_p) Index: openacs-4/packages/cms/www/modules/items/template-register.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/template-register.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/cms/www/modules/items/template-register.tcl 28 Aug 2001 23:31:30 -0000 1.3 +++ openacs-4/packages/cms/www/modules/items/template-register.tcl 19 Aug 2002 03:30:59 -0000 1.4 @@ -10,10 +10,7 @@ # check to make sure that no template is already registered # to this item in this context - template::query second_template_p second_template_p onevalue " - select count(1) from cr_item_template_map - where use_context = :context - and item_id = :item_id" + set second_template_p [db_string second_template_p ""] if { $second_template_p == 0 } { if { [catch { db_exec_plsql register_template_to_item "begin content_item.register_template( Index: openacs-4/packages/cms/www/modules/items/templates.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/templates.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/cms/www/modules/items/templates.tcl 24 May 2001 23:57:17 -0000 1.3 +++ openacs-4/packages/cms/www/modules/items/templates.tcl 19 Aug 2002 03:30:59 -0000 1.4 @@ -14,65 +14,17 @@ -request_error # check if the user has write permission on the types module -template::query allowed_set_p can_set_default_template onevalue " - select - cms_permission.permission_p( module_id, :user_id, 'cm_write' ) - from - cm_modules - where - key = 'types' -" +set can_set_default_template [db_string allowed_set_p ""] -template::query get_iteminfo iteminfo onerow " - select - object_type, pretty_name, - content_item.get_title(:item_id) name - from - acs_object_types - where - object_type = content_item.get_content_type(:item_id) -" +db_1row get_iteminfo "" -column_array iteminfo set content_type $iteminfo(object_type) # templates registered to this item -template::query get_reg_templates registered_templates multirow " - select - template_id, use_context, - content_item.get_path( template_id ) path, - cms_permission.permission_p( template_id, :user_id, 'cm_examine') - as can_read_template - from - cr_item_template_map t - where - t.item_id = :item_id - order by - path, use_context -" +db_multirow registered_templates get_reg_templates "" # templates registered to this content type -template::query get_type_templates type_templates multirow " - select - template_id, use_context, is_default, - content_item.get_path( template_id ) path, - cms_permission.permission_p( template_id, :user_id, 'cm_examine') - as can_read_template, - (select 1 - from - cr_item_template_map itmap - where - itmap.template_id = t.template_id - and - itmap.use_context = t.use_context - and - itmap.item_id = :item_id) already_registered_p - from - cr_type_template_map t - where - t.content_type = :content_type - order by - path, use_context -" +db_multirow type_templates get_type_templates "" set return_url "index?item_id=$item_id&mount_point=sitemap" Index: openacs-4/packages/cms/www/modules/items/unrelate-item.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/unrelate-item.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/cms/www/modules/items/unrelate-item.tcl 27 May 2001 04:39:19 -0000 1.4 +++ openacs-4/packages/cms/www/modules/items/unrelate-item.tcl 19 Aug 2002 03:30:59 -0000 1.5 @@ -8,10 +8,9 @@ db_transaction { # Get the item_id; determine if the relationship exists - template::query get_item_id item_id onevalue " - select item_id from cr_item_rels where rel_id = :rel_id" + set item_id [db_string get_item_id "" -default ""] - if { [template::util::is_nil item_id] } { + if { [string equal $item_id ""] } { db_abort_transaction request::error no_such_rel "The relationship $rel_id does not exist." return