Index: openacs-4/packages/cms/www/modules/items/comment-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/comment-add.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/cms/www/modules/items/comment-add.tcl 16 Aug 2002 03:57:48 -0000 1.3 +++ openacs-4/packages/cms/www/modules/items/comment-add.tcl 19 Aug 2002 03:05:17 -0000 1.4 @@ -42,5 +42,33 @@ } + set query " + select + rel_id, relation_tag, + i.item_id, i.name, trim(r.title) as title, t.pretty_name, + to_char(o.creation_date, 'MM/DD/YY HH24:MM') last_modified + from + cr_items i, acs_object_types t, acs_objects o, cr_revisions r, + cr_child_rels c + where + i.parent_id = :item_id + and + o.object_id = :item_id + and + i.content_type = t.object_type + and + r.revision_id = NVL(i.live_revision, i.latest_revision) + and + c.parent_id = i.parent_id + and + c.child_id = i.item_id + order by + t.pretty_name, title" + +#template::query children multirow $query + + + + template::forward "index?item_id=$object_id" } Index: openacs-4/packages/cms/www/modules/items/publish-status.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/publish-status.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/cms/www/modules/items/publish-status.tcl 16 Aug 2002 03:57:48 -0000 1.3 +++ openacs-4/packages/cms/www/modules/items/publish-status.tcl 19 Aug 2002 03:05:17 -0000 1.4 @@ -65,58 +65,30 @@ # determine if child type constraints have been satisfied set unpublishable_child_types 0 +db_multirow -extend {is_fulfilled difference direction} child_types get_child_types "" { -template::query get_child_types child_types multirow " - select - child_type, relation_tag, min_n, - o.pretty_name as child_type_pretty, - o.pretty_plural as child_type_plural, - decode(max_n, null, '-', max_n) max_n, - ( - select - count(*) - from - cr_child_rels - where - parent_id = i.item_id - and - content_item.get_content_type( child_id ) = c.child_type - and - relation_tag = c.relation_tag - ) child_count - from - cr_type_children c, cr_items i, acs_object_types o - where - c.parent_type = i.content_type - and - c.child_type = o.object_type - and - -- this item is the parent - i.item_id = :item_id -" -eval { - # set is_fulfilled to t if the relationship constraints are fulfilled # otherwise set is_fulfilled to f # keep track of numbers # difference - the (absolute) number of child items in excess or lack # direction - whether "more" or "less" child items are needed - set row(is_fulfilled) t - set row(difference) 0 - set row(direction) "" + set is_fulfilled t + set difference 0 + set direction "" - if { $row(child_count) < $row(min_n) } { - set row(is_fulfilled) f + if { $child_count < $min_n } { + set is_fulfilled f incr unpublishable_child_types - set row(difference) [expr $row(min_n)-$row(child_count)] - set row(direction) more + set difference [expr $min_n - $child_count] + set direction more } - if { ![string equal $row(max_n) -] && $row(child_count) > $row(max_n) } { + if { ![string equal $max_n -] && $child_count > $max_n } { set row(is_fulfilled) f incr unpublishable_child_types - set row(difference) [expr $row(child_count)-$row(max_n)] - set row(direction) less + set difference [expr $child_count - $max_n] + set direction less } } @@ -125,57 +97,30 @@ # determine if relation type constraints have been satisfied set unpublishable_rel_types 0 +db_multirow -extend {is_fulfilled difference direction} rel_types get_rel_types { -template::query get_rel_types rel_types multirow " - select - target_type, relation_tag, min_n, - o.pretty_name as target_type_pretty, - o.pretty_plural as target_type_plural, - decode(max_n, null, '-', max_n) max_n, - ( - select - count(*) - from - cr_item_rels - where - item_id = i.item_id - and - content_item.get_content_type( related_object_id ) = r.target_type - and - relation_tag = r.relation_tag - ) rel_count - from - cr_type_relations r, cr_items i, acs_object_types o - where - o.object_type = r.target_type - and - r.content_type = i.content_type - and - i.item_id = :item_id -" -eval { - # set is_fulfilled to t if the relationship constraints are fulfilled # otherwise set is_fulfilled to f # keep track of numbers # difference - the (absolute) number of related items in excess or lack # direction - whether "more" or "less" related items are needed - set row(is_fulfilled) t - set row(difference) 0 - set row(direction) "" + set is_fulfilled t + set difference 0 + set direction "" - if { $row(rel_count) < $row(min_n) } { - set row(is_fulfilled) f + if { $rel_count < $min_n } { + set is_fulfilled f incr unpublishable_rel_types - set row(difference) [expr $row(min_n)-$row(rel_count)] - set row(direction) more + set difference [expr $min_n - $rel_count] + set direction more } - if { ![string equal $row(max_n) -] && $row(rel_count) > $row(max_n) } { - set row(is_fulfilled) f + if { ![string equal $max_n -] && $rel_count > $max_n } { + set is_fulfilled f incr unpublishable_rel_types - set row(difference) [expr $row(rel_count)-$row(max_n)] - set row(direction) less + set difference [expr $rel_count - $max_n] + set direction less } } Index: openacs-4/packages/cms/www/modules/items/relate-items.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/relate-items.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/cms/www/modules/items/relate-items.tcl 24 May 2001 23:57:17 -0000 1.3 +++ openacs-4/packages/cms/www/modules/items/relate-items.tcl 19 Aug 2002 03:05:17 -0000 1.4 @@ -13,14 +13,7 @@ ######################## BASIC PHASE: create default elements ################### # Get the item title and type - template::query get_item_info item_info onerow " - select - content_item.get_title(i.item_id) as title, - i.content_type - from - cr_items i - where - i.item_id = :item_id" + db_1row get_item_info "" -column_array item_info set item_title $item_info(title) set item_type $item_info(content_type) @@ -39,16 +32,7 @@ } # Get all possible relation types - template::query get_options type_options multilist " - select - lpad(' ', level, '-') || pretty_name as pretty_name, - object_type - from - acs_object_types - connect by - prior object_type = supertype - start with - object_type = 'cr_item_rel'" + set type_options [db_list_of_lists get_options ""] # Prepare the query set sql_items "('" @@ -57,33 +41,8 @@ + db_multirow clip_items get_clip_items "" - template::query get_clip_items clip_items multirow " - select - i.item_id as related_id, - content_item.get_title(i.item_id) as title, - content_item.get_path(i.item_id) as path, - tr.relation_tag - from - cr_items i, cr_type_relations tr - where - content_item.is_subclass(i.content_type, tr.target_type) = 't' - and - content_item.is_subclass(:item_type, tr.content_type) = 't' - and ( - tr.max_n is null - or - (select count(*) from cr_item_rels - where item_id = :item_id - and relation_tag = tr.relation_tag) < tr.max_n - ) - and - i.item_id in $sql_items - and - i.item_id ^= :item_id - order by - path, i.item_id, tr.relation_tag" - if { ${clip_items:rowcount} < 1} { set no_valid_items t return Index: openacs-4/packages/cms/www/modules/items/relate-order.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/relate-order.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/cms/www/modules/items/relate-order.tcl 27 May 2001 00:22:34 -0000 1.3 +++ openacs-4/packages/cms/www/modules/items/relate-order.tcl 19 Aug 2002 03:05:17 -0000 1.4 @@ -26,15 +26,9 @@ db_transaction { # Get item_id the related/child item - template::query get_item_id item_id onevalue " - select - $rel_parent_column - from - $rel_table - 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 @@ -59,42 +53,18 @@ } # grab the (sorted) order of the original related/child item - template::query get_order order_n onevalue " - select - order_n - from - $rel_table - where - rel_id = :rel_id" + set order_n [db_string get_order ""] - # Move the relation up or down if { [string equal $order "up"] } { # Get the previous related/child - template::query get_prev_swap_rel swap_rel onerow " - select - rel_id, order_n - from - $rel_table - where - $rel_parent_column = :item_id - and - order_n = :order_n - 1" + db_0or1row get_prev_swap_rel "" -column_array swap_rel } else { # Get the next related/child item - template::query get_next_swap_rel swap_rel onerow " - select - rel_id, order_n - from - $rel_table - where - $rel_parent_column = :item_id - and - order_n = :order_n + 1" - + db_0or1row get_next_swap_rel "" -column_array swap_rel } Index: openacs-4/packages/cms/www/modules/items/related-items.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/related-items.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/cms/www/modules/items/related-items.tcl 8 Jun 2001 01:44:53 -0000 1.2 +++ openacs-4/packages/cms/www/modules/items/related-items.tcl 19 Aug 2002 03:05:17 -0000 1.3 @@ -8,28 +8,5 @@ -return_url "modules/sitemap/index" \ -request_error -template::query get_related related multirow " - select - r.rel_id, - r.related_object_id item_id, - t.pretty_name as type_name, - NVL(r.relation_tag, '-') as tag, - trim(NVL(content_item.get_title(r.related_object_id), i.name)) title, - ot.pretty_name as content_type - from - cr_item_rels r, acs_objects o, acs_object_types t, - cr_items i, acs_object_types ot - where - r.item_id = :item_id - and - o.object_id = r.rel_id - and - t.object_type = o.object_type - and - i.item_id = r.related_object_id - and - ot.object_type = i.content_type - order by - order_n, title -" +db_multirow related get_related "" Index: openacs-4/packages/cms/www/modules/items/relationship-view.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/relationship-view.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/cms/www/modules/items/relationship-view.tcl 24 May 2001 01:30:52 -0000 1.2 +++ openacs-4/packages/cms/www/modules/items/relationship-view.tcl 19 Aug 2002 03:05:17 -0000 1.3 @@ -7,73 +7,26 @@ # Get misc info -template::query get_rel_info rel_info onerow " - select - t.pretty_name as type_name, t.object_type, - r.item_id, r.related_object_id,\ - content_item.get_title(i.item_id) as item_title, - acs_object.name(r.related_object_id) as related_title, - content_item.is_subclass(o2.object_type, 'content_item') as is_item, - r.relation_tag, r.order_n - from - acs_objects o, acs_object_types t, - cr_item_rels r, cr_items i, acs_objects o2 - where - o.object_type = t.object_type - and - o.object_id = :rel_id - and - r.rel_id = :rel_id - and - i.item_id = r.item_id - and - o2.object_id = r.related_object_id -" +db_1row get_rel_info "" -template::util::array_to_vars rel_info - # Get extra attributes -template::query get_rel_attrs rel_attrs multirow " - select - types.table_name, types.id_column, attr.attribute_name, - attr.pretty_name as attribute_label, attr.datatype, - types.pretty_name as type_name - from - acs_attributes attr, - (select - object_type, table_name, id_column, pretty_name, - level as inherit_level - from - acs_object_types - where - object_type not in ('acs_object', 'cr_item_rel') - connect by - prior supertype = object_type - start with - object_type = :object_type) types - where - attr.object_type (+) = types.object_type - order by - inherit_level desc, attr.pretty_name - " +db_multirow rel_attrs get_rel_attrs "" # Get attribute values... inefficient ! for { set i 1 } { $i <= ${rel_attrs:rowcount} } { incr i } { - upvar 0 "rel_attrs:$i" a_row + upvar 0 "rel_attrs:$i" a_row - if { [string equal $a_row(datatype) date] } { - set what "to_char($a_row(attribute_name), 'Mon DD, YYYY HH24:MI') as value" - } else { - set what "$a_row(attribute_name) as value" - } + if { [string equal $a_row(datatype) date] } { + set what "to_char($a_row(attribute_name), 'Mon DD, YYYY HH24:MI') as value" + } else { + set what "$a_row(attribute_name) as value" + } - template::query get_value value onevalue " - select $what from $a_row(table_name) - where $a_row(id_column) = :rel_id" + set value [db_string get_value ""] - set a_row(value) $value + set a_row(value) $value }