Index: openacs.org-dev/packages/cms/www/modules/items/publish-status.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs.org-dev/packages/cms/www/modules/items/publish-status.tcl,v diff -u -r1.1.1.1 -r1.1.1.2 --- openacs.org-dev/packages/cms/www/modules/items/publish-status.tcl 9 Jul 2002 17:35:03 -0000 1.1.1.1 +++ openacs.org-dev/packages/cms/www/modules/items/publish-status.tcl 8 Oct 2002 15:47:02 -0000 1.1.1.2 @@ -9,19 +9,7 @@ # Query for publish status and release schedule, if any -template::query get_info info onerow " - select - NVL(initcap(publish_status), 'Production') publish_status, - NVL(to_char(start_when, 'MM/DD/YY HH:MI AM'), 'Immediate') start_when, - NVL(to_char(end_when, 'MM/DD/YY HH:MI AM'), 'Indefinite') end_when, - content_item.is_publishable(:item_id) is_publishable, - live_revision - from - cr_items i, cr_release_periods r - where - i.item_id = :item_id - and - i.item_id = r.item_id (+)" +db_1row get_info "" -column_array info # Build a sentence describing the publishing status @@ -60,15 +48,7 @@ # determine whether the item is publishable or not -template::query get_publish_info publish_info onerow " - select - content_item.is_publishable( item_id ) is_publishable, - live_revision - from - cr_items - where - item_id = :item_id -" +db_1row get_publish_info "" -column_array publish_info template::util::array_to_vars publish_info @@ -80,65 +60,35 @@ # determine if there is an unfinished workflow -template::query unfinished_exists unfinished_workflow_exists onevalue " - select content_workflow.unfinished_workflow_exists( :item_id ) from dual -" +set unfinished_workflow_exists [db_string unfinished_exists ""] # 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 } } @@ -147,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 } }