Index: openacs-4/packages/categories/tcl/categories-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/tcl/categories-procs-oracle.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/tcl/categories-procs-oracle.xql 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/tcl/categories-procs-oracle.xql 27 Apr 2003 11:36:23 -0000 1.2 @@ -3,7 +3,7 @@ oracle8.1.6 - + begin @@ -23,7 +23,7 @@ - + begin @@ -41,7 +41,7 @@ - + begin @@ -59,7 +59,7 @@ - + begin @@ -77,7 +77,7 @@ - + begin @@ -88,7 +88,7 @@ - + begin @@ -103,7 +103,7 @@ - + begin @@ -114,7 +114,7 @@ - + begin @@ -125,7 +125,7 @@ - + select acs_object.name(:object_id) from dual Index: openacs-4/packages/categories/tcl/categories-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/tcl/categories-procs-postgresql.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/tcl/categories-procs-postgresql.xql 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/tcl/categories-procs-postgresql.xql 27 Apr 2003 11:36:23 -0000 1.2 @@ -3,7 +3,7 @@ postgresql7.1 - + FIX ME PLSQL FIX ME PLSQL @@ -25,7 +25,7 @@ - + FIX ME PLSQL FIX ME PLSQL @@ -45,7 +45,7 @@ - + FIX ME PLSQL FIX ME PLSQL @@ -65,7 +65,7 @@ - + FIX ME PLSQL FIX ME PLSQL @@ -85,7 +85,7 @@ - + FIX ME PLSQL FIX ME PLSQL @@ -98,7 +98,7 @@ - + FIX ME PLSQL FIX ME PLSQL @@ -115,7 +115,7 @@ - + FIX ME PLSQL FIX ME PLSQL @@ -128,7 +128,7 @@ - + FIX ME PLSQL FIX ME PLSQL @@ -141,7 +141,7 @@ - + select acs_object__name(:object_id) Index: openacs-4/packages/categories/tcl/categories-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/tcl/categories-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/tcl/categories-procs.tcl 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/tcl/categories-procs.tcl 27 Apr 2003 11:36:23 -0000 1.2 @@ -44,34 +44,11 @@ set locale [ad_conn locale] } db_transaction { - set category_id [db_exec_plsql insert_category { - begin - :1 := category.new ( - category_id => :category_id, - locale => :locale, - name => :name, - description => :description, - tree_id => :tree_id, - parent_id => :parent_id, - creation_user => :user_id, - creation_ip => :creation_ip - ); - end; - }] + set category_id [db_exec_plsql insert_category ""] + set default_locale [ad_parameter DefaultLocale acs-lang "en_US"] if {$locale != $default_locale} { - db_exec_plsql insert_default_category { - begin - category.new_translation ( - category_id => :category_id, - locale => :default_locale, - name => :name, - description => :description, - modifying_user => :user_id, - modifying_ip => :creation_ip - ); - end; - } + db_exec_plsql insert_default_category "" } category_tree::flush_cache $tree_id flush_translation_cache $category_id @@ -107,37 +84,10 @@ set locale [ad_conn locale] } db_transaction { - if {![db_0or1row check_category_existence { - select 1 - from category_translations - where category_id = :category_id - and locale = :locale - }]} { - db_exec_plsql insert_category_translation { - begin - category.new_translation ( - category_id => :category_id, - locale => :locale, - name => :name, - description => :description, - modifying_user => :user_id, - modifying_ip => :modifying_ip - ); - end; - } + if {![db_0or1row check_category_existence ""]} { + db_exec_plsql insert_category_translation "" } else { - db_exec_plsql update_category_translation { - begin - category.edit ( - category_id => :category_id, - locale => :locale, - name => :name, - description => :description, - modifying_user => :user_id, - modifying_ip => :modifying_ip - ); - end; - } + db_exec_plsql update_category_translation "" } flush_translation_cache $category_id } @@ -159,11 +109,7 @@ @see category_tree::flush_cache @author Timo Hentschel (thentschel@sussdorff-roy.com) } { - db_exec_plsql delete_category { - begin - category.del ( :category_id ); - end; - } + db_exec_plsql delete_category "" if {!$batch_mode_p} { flush_translation_cache $category_id } @@ -180,15 +126,7 @@ @option parent_id new parent category_id. @author Timo Hentschel (thentschel@sussdorff-roy.com) } { - db_exec_plsql change_parent_category { - begin - category.change_parent ( - category_id => :category_id, - tree_id => :tree_id, - parent_id => :parent_id - ); - end; - } + db_exec_plsql change_parent_category "" category_tree::flush_cache $tree_id } @@ -202,11 +140,7 @@ @see category_tree::flush_cache @author Timo Hentschel (thentschel@sussdorff-roy.com) } { - db_exec_plsql phase_in { - begin - category.phase_in(:category_id); - end; - } + db_exec_plsql phase_in "" } ad_proc -public phase_out { category_id } { @@ -221,11 +155,7 @@ @see category_tree::flush_cache @author Timo Hentschel (thentschel@sussdorff-roy.com) } { - db_exec_plsql phase_out { - begin - category.phase_out(:category_id); - end; - } + db_exec_plsql phase_out "" } ad_proc -public map_object { @@ -243,18 +173,12 @@ db_transaction { # Remove any already mapped categories if we are updating if { $remove_old_p } { - db_dml remove_mapped_categories { - delete from category_object_map - where object_id = :object_id - } + db_dml remove_mapped_categories "" } foreach category_id $category_id_list { if ![empty_string_p $category_id] { - db_dml insert_mapped_categories { - insert into category_object_map (category_id, object_id) - values (:category_id, :object_id) - } + db_dml insert_mapped_categories "" } } } @@ -267,11 +191,7 @@ @return tcl-list of category_ids @author Timo Hentschel (thentschel@sussdorff-roy.com) } { - set result [db_list get_mapped_categories { - select category_id - from category_object_map - where object_id = :object_id - }] + set result [db_list get_mapped_categories ""] return $result } @@ -282,11 +202,7 @@ } { catch {nsv_unset categories} set category_id_old 0 - db_foreach reset_translation_cache { - select category_id, locale, name - from category_translations - order by category_id, locale - } { + db_foreach reset_translation_cache "" { if {$category_id != $category_id_old && $category_id_old != 0} { nsv_set categories $category_id_old [array get cat_lang] unset cat_lang @@ -305,12 +221,7 @@ @param category_id category to be flushed. @author Timo Hentschel (thentschel@sussdorff-roy.com) } { - db_foreach flush_translation_cache { - select locale, name - from category_translations - where category_id = :category_id - order by locale - } { + db_foreach flush_translation_cache "" { set cat_lang($locale) $name } if {[info exists cat_lang]} { @@ -355,7 +266,7 @@ @param object_id object_id to get the name of. @author Timo Hentschel (thentschel@sussdorff-roy.com) } { - set object_name [db_string object_name "select acs_object.name(:object_id) from dual"] + set object_name [db_string object_name ""] return [list "/o/$object_id" $object_name] } @@ -385,11 +296,7 @@ @param object_id category to be displayed. @author Timo Hentschel (thentschel@sussdorff-roy.com) } { - db_1row get_tree_id_for_pageurl { - select tree_id - from categories - where category_id = :object_id - } + db_1row get_tree_id_for_pageurl "" return "categories-browse?tree_ids=$tree_id&category_ids=$object_id" } Index: openacs-4/packages/categories/tcl/categories-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/tcl/Attic/categories-procs.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/tcl/categories-procs.xql 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/tcl/categories-procs.xql 27 Apr 2003 11:36:23 -0000 1.2 @@ -1,7 +1,7 @@ - + select 1 @@ -13,7 +13,7 @@ - + delete from category_object_map @@ -23,7 +23,7 @@ - + insert into category_object_map (category_id, object_id) @@ -33,7 +33,7 @@ - + select category_id @@ -44,7 +44,7 @@ - + select category_id, locale, name @@ -55,7 +55,7 @@ - + select locale, name @@ -67,7 +67,7 @@ - + select tree_id Index: openacs-4/packages/categories/tcl/category-trees-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/tcl/category-trees-procs-oracle.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/tcl/category-trees-procs-oracle.xql 23 Apr 2003 12:29:26 -0000 1.1 +++ openacs-4/packages/categories/tcl/category-trees-procs-oracle.xql 27 Apr 2003 11:36:23 -0000 1.2 @@ -3,7 +3,7 @@ oracle8.1.6 - + begin @@ -17,7 +17,7 @@ - + begin @@ -30,7 +30,7 @@ - + begin @@ -44,7 +44,7 @@ - + begin @@ -63,7 +63,7 @@ - + begin @@ -81,7 +81,7 @@ - + begin @@ -99,7 +99,7 @@ - + begin @@ -117,7 +117,7 @@ - + begin @@ -128,7 +128,7 @@ - + select t.pretty_plural, n.object_id, n.object_name, p.package_id, Index: openacs-4/packages/categories/tcl/category-trees-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/tcl/category-trees-procs-postgresql.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/tcl/category-trees-procs-postgresql.xql 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/tcl/category-trees-procs-postgresql.xql 27 Apr 2003 11:36:23 -0000 1.2 @@ -3,7 +3,7 @@ postgresql7.1 - + FIX ME PLSQL FIX ME PLSQL @@ -19,7 +19,7 @@ - + FIX ME PLSQL FIX ME PLSQL @@ -34,7 +34,7 @@ - + FIX ME PLSQL FIX ME PLSQL @@ -50,7 +50,7 @@ - + FIX ME PLSQL FIX ME PLSQL @@ -71,7 +71,7 @@ - + FIX ME PLSQL FIX ME PLSQL @@ -91,7 +91,7 @@ - + FIX ME PLSQL FIX ME PLSQL @@ -111,7 +111,7 @@ - + FIX ME PLSQL FIX ME PLSQL @@ -131,7 +131,7 @@ - + FIX ME PLSQL FIX ME PLSQL @@ -144,7 +144,7 @@ - + select t.pretty_plural, n.object_id, n.object_name, p.package_id, Index: openacs-4/packages/categories/tcl/category-trees-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/tcl/category-trees-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/tcl/category-trees-procs.tcl 23 Apr 2003 12:29:26 -0000 1.1 +++ openacs-4/packages/categories/tcl/category-trees-procs.tcl 27 Apr 2003 11:36:23 -0000 1.2 @@ -20,11 +20,7 @@ @return array: tree_name description site_wide_p @author Timo Hentschel (thentschel@sussdorff-roy.com) } { - db_1row get_tree_data { - select site_wide_p - from category_trees - where tree_id = :tree_id - } -column_array tree + db_1row get_tree_data "" -column_array tree util_unlist [get_translation $tree_id $locale] tree(tree_name) tree(description) return [array get tree] @@ -43,14 +39,7 @@ If not provided, the whole category tree will be mapped. @author Timo Hentschel (thentschel@sussdorff-roy.com) } { - db_exec_plsql map_tree { - begin - category_tree.map( - object_id => :object_id, - subtree_category_id => :subtree_category_id, - tree_id => :tree_id); - end; - } + db_exec_plsql map_tree "" } ad_proc -public unmap { @@ -64,13 +53,7 @@ @option object_id object to unmap the category tree from. @author Timo Hentschel (thentschel@sussdorff-roy.com) } { - db_exec_plsql unmap_tree { - begin - category_tree.unmap( - object_id => :object_id, - tree_id => :tree_id); - end; - } + db_exec_plsql unmap_tree "" } ad_proc -public copy { @@ -83,14 +66,7 @@ @option dest_tree tree_id of the category tree to copy into. @author Timo Hentschel (thentschel@sussdorff-roy.com) } { - db_exec_plsql copy_tree { - begin - category_tree.copy( - source_tree => :source_tree, - dest_tree => :dest_tree - ); - end; - } + db_exec_plsql copy_tree "" flush_cache $dest_tree flush_translation_cache $dest_tree category::reset_translation_cache @@ -131,33 +107,11 @@ set context_id [ad_conn package_id] } db_transaction { - set tree_id [db_exec_plsql insert_tree { - begin - :1 := category_tree.new ( - tree_id => :tree_id, - tree_name => :name, - description => :description, - locale => :locale, - creation_user => :user_id, - creation_ip => :creation_ip, - context_id => :context_id - ); - end; - }] + set tree_id [db_exec_plsql insert_tree ""] + set default_locale [ad_parameter DefaultLocale acs-lang "en_US"] if {$locale != $default_locale} { - db_exec_plsql insert_default_tree { - begin - category_tree.new_translation ( - tree_id => :tree_id, - tree_name => :name, - description => :description, - locale => :default_locale, - modifying_user => :user_id, - modifying_ip => :creation_ip - ); - end; - } + db_exec_plsql insert_default_tree "" } } flush_translation_cache $tree_id @@ -192,37 +146,10 @@ set locale [ad_conn locale] } db_transaction { - if {![db_0or1row check_tree_existence { - select 1 - from category_tree_translations - where tree_id = :tree_id - and locale = :locale - }]} { - db_exec_plsql insert_tree_translation { - begin - category_tree.new_translation ( - tree_id => :tree_id, - tree_name => :name, - description => :description, - locale => :locale, - modifying_user => :user_id, - modifying_ip => :modifying_ip - ); - end; - } + if {![db_0or1row check_tree_existence ""]} { + db_exec_plsql insert_tree_translation "" } else { - db_exec_plsql update_tree_translation { - begin - category_tree.edit ( - tree_id => :tree_id, - tree_name => :name, - description => :description, - locale => :locale, - modifying_user => :user_id, - modifying_ip => :modifying_ip - ); - end; - } + db_exec_plsql update_tree_translation "" } } flush_translation_cache $tree_id @@ -234,11 +161,7 @@ @param tree_id category tree to be deleted. @author Timo Hentschel (thentschel@sussdorff-roy.com) } { - db_exec_plsql delete_tree { - begin - category_tree.del ( :tree_id ); - end; - } + db_exec_plsql delete_tree "" flush_cache $tree_id flush_translation_cache $tree_id category::reset_translation_cache @@ -253,11 +176,7 @@ } { set result [list] - db_foreach get_mapped_trees { - select tree_id, subtree_category_id - from category_tree_map - where object_id = :object_id - } { + db_foreach get_mapped_trees "" { lappend result [list $tree_id [get_name $tree_id] $subtree_category_id] } @@ -320,19 +239,7 @@ } { set user_id [ad_conn user_id] - set result [db_list_of_lists category_tree_usage { - select t.pretty_plural, n.object_id, n.object_name, p.package_id, - p.instance_name, - acs_permission.permission_p(n.object_id, :user_id, 'read') as read_p - from category_tree_map m, acs_named_objects n, - apm_packages p, apm_package_types t - where m.tree_id = :tree_id - and n.object_id = m.object_id - and p.package_id = n.package_id - and t.package_key = p.package_key - }] - - return $result + return [db_list_of_lists category_tree_usage ""] } ad_proc -public reset_cache { } { @@ -345,12 +252,7 @@ set stack [list] set invalid_p "" set tree [list] - db_foreach reset_cache { - select tree_id, category_id, left_ind, right_ind, - decode(deprecated_p,'f','','1') as deprecated_p - from categories - order by tree_id, left_ind - } { + db_foreach reset_cache "" { if {$tree_id != $tree_id_old && $tree_id_old != 0} { nsv_set category_trees $tree_id_old $tree set cur_level 1 @@ -389,13 +291,7 @@ set stack [list] set invalid_p "" set tree [list] - db_foreach flush_cache { - select category_id, left_ind, right_ind, - decode(deprecated_p,'f','','1') as deprecated_p - from categories - where tree_id = :tree_id - order by left_ind - } { + db_foreach flush_cache "" { lappend tree [list $category_id [ad_decode "$invalid_p$deprecated_p" "" f t] $cur_level] if { [expr $right_ind - $left_ind] > 1} { incr cur_level 1 @@ -424,11 +320,7 @@ } { catch {nsv_unset category_tree_translations} set tree_id_old 0 - db_foreach reset_translation_cache { - select tree_id, locale, name, description - from category_tree_translations - order by tree_id, locale - } { + db_foreach reset_translation_cache "" { if {$tree_id != $tree_id_old && $tree_id_old != 0} { nsv_set category_tree_translations $tree_id_old [array get tree_lang] unset tree_lang @@ -447,12 +339,7 @@ @param tree_id category tree to be flushed. @author Timo Hentschel (thentschel@sussdorff-roy.com) } { - db_foreach flush_translation_cache { - select locale, name, description - from category_tree_translations - where tree_id = :tree_id - order by locale - } { + db_foreach flush_translation_cache "" { set tree_lang($locale) [list $name $description] } if {[info exists tree_lang]} { Index: openacs-4/packages/categories/tcl/category-trees-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/tcl/Attic/category-trees-procs.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/tcl/category-trees-procs.xql 23 Apr 2003 12:29:26 -0000 1.1 +++ openacs-4/packages/categories/tcl/category-trees-procs.xql 27 Apr 2003 11:36:23 -0000 1.2 @@ -1,7 +1,7 @@ - + select site_wide_p @@ -12,7 +12,7 @@ - + select 1 @@ -24,7 +24,7 @@ - + select tree_id, subtree_category_id @@ -35,7 +35,7 @@ - + select tree_id, category_id, left_ind, right_ind, @@ -47,7 +47,7 @@ - + select category_id, left_ind, right_ind, @@ -60,7 +60,7 @@ - + select tree_id, locale, name, description @@ -71,7 +71,7 @@ - + select locale, name, description Index: openacs-4/packages/categories/www/categories-browse-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/Attic/categories-browse-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/categories/www/categories-browse-oracle.xql 27 Apr 2003 11:36:50 -0000 1.1 @@ -0,0 +1,45 @@ + + + + oracle8.1.6 + + + + select t.tree_id + from category_trees t, category_temp tmp + where (t.site_wide_p = 't' + or acs_permission.permission_p(t.tree_id, :user_id, 'category_tree_read') = 't') + and t.tree_id = tmp.category_id + + + + + + select n.object_id + from acs_named_objects n, ($subtree_sql) s + where n.object_id = s.object_id + and acs_permission.permission_p(n.object_id, :user_id, 'read') = 't' + $letter_sql + + + + + + select r.* + from (select n.object_id, n.object_name as object_name, o.creation_date, + t.pretty_name as package_type, n.package_id, p.instance_name, + row_number() over ($order_by_clause) as row_number + from acs_objects o, acs_named_objects n, apm_packages p, apm_package_types t, + ($subtree_sql) s + where n.object_id = s.object_id + and o.object_id = n.object_id + and p.package_id = n.package_id + and t.package_key = p.package_key + and acs_permission.permission_p(n.object_id, :user_id, 'read') = 't' + $letter_sql + $order_by_clause) r + where r.row_number between :first_row and :last_row + + + + Index: openacs-4/packages/categories/www/categories-browse-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/Attic/categories-browse-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/categories/www/categories-browse-postgresql.xql 27 Apr 2003 11:36:50 -0000 1.1 @@ -0,0 +1,45 @@ + + + + postgresql7.1 + + + + select t.tree_id + from category_trees t, category_temp tmp + where (t.site_wide_p = 't' + or acs_permission__permission_p(t.tree_id, :user_id, 'category_tree_read') = 't') + and t.tree_id = tmp.category_id + + + + + + select n.object_id + from acs_named_objects n, ($subtree_sql) s + where n.object_id = s.object_id + and acs_permission__permission_p(n.object_id, :user_id, 'read') = 't' + $letter_sql + + + + + + select r.* + from (select n.object_id, n.object_name as object_name, o.creation_date, + t.pretty_name as package_type, n.package_id, p.instance_name, + row_number() over ($order_by_clause) as row_number + from acs_objects o, acs_named_objects n, apm_packages p, apm_package_types t, + ($subtree_sql) s + where n.object_id = s.object_id + and o.object_id = n.object_id + and p.package_id = n.package_id + and t.package_key = p.package_key + and acs_permission__permission_p(n.object_id, :user_id, 'read') = 't' + $letter_sql + $order_by_clause) r + where r.row_number between :first_row and :last_row + + + + Index: openacs-4/packages/categories/www/categories-browse.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/categories-browse.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/www/categories-browse.tcl 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/www/categories-browse.tcl 27 Apr 2003 11:36:50 -0000 1.2 @@ -37,13 +37,13 @@ set url_vars [export_url_vars tree_ids:multiple category_ids:multiple subtree_p letter] set form_vars [export_form_vars tree_ids:multiple orderby subtree_p letter] -set tree_ids [db_list check_permissions_on_trees [subst { - select tree_id - from category_trees - where (site_wide_p = 't' - or acs_permission.permission_p(tree_id, :user_id, 'category_tree_read') = 't') - and tree_id in ([join $tree_ids ,]) -}]] +db_transaction { + # use temporary table to use only bind vars in queries + foreach tree_id $tree_ids { + db_dml insert_tmp_category_trees "" + } + set tree_ids [db_list check_permissions_on_trees ""] +} template::multirow create trees tree_id tree_name category_id category_name indent selected_p template::util::list_to_lookup $category_ids category_selected @@ -87,88 +87,44 @@ # generate sql for selecting object names beginning with selected letter switch -exact $letter { other { - set letter_sql "and (upper(n.object_name) < 'A' or upper(n.object_name) > 'Z')" + set letter_sql [db_map other_letter] } all { set letter_sql "" } default { set bind_letter "$letter%" - set letter_sql "and upper(n.object_name) like :bind_letter" + set letter_sql [db_map regular_letter] } } set category_ids_length [llength $category_ids] if {$subtree_p == "t"} { # generate sql for exact categorizations plus subcategories - set subtree_sql { - select v.object_id - from (select distinct m.object_id, c.category_id - from category_object_map m, categories c, category_temp t - where c.category_id = t.category_id - and m.category_id in (select c_sub.category_id - from categories c_sub - where c_sub.tree_id = c.tree_id - and c_sub.left_ind >= c.left_ind - and c_sub.left_ind < c.right_ind)) v - group by v.object_id having count(*) = :category_ids_length - } + set subtree_sql [db_map include_subtree] } else { # generate sql for exact categorization - set subtree_sql { - select m.object_id - from category_object_map m, category_temp t - where acs_permission.permission_p(m.object_id, :user_id, 'read') = 't' - and m.category_id = t.category_id - group by m.object_id having count(*) = :category_ids_length - } + set subtree_sql [db_map exact_categorization] } -# query to get the number of pages, number of objects etc used by the paginator -set count_query [subst { - select n.object_id - from acs_named_objects n, ($subtree_sql) s - where n.object_id = s.object_id - $letter_sql -}] - -# paginated query to get the actual objects -set paginated_query [subst { - select r.* - from (select n.object_id, n.object_name as object_name, o.creation_date, - t.pretty_name as package_type, n.package_id, p.instance_name, - row_number() over ($order_by_clause) as row_number - from acs_objects o, acs_named_objects n, apm_packages p, apm_package_types t, - ($subtree_sql) s - where n.object_id = s.object_id - and o.object_id = n.object_id - and p.package_id = n.package_id - and t.package_key = p.package_key - $letter_sql - $order_by_clause) r - where r.row_number between :first_row and :last_row -}] - set p_name "browse_categories" request create request set_param page -datatype integer -value 1 db_transaction { # use temporary table to use only bind vars in queries foreach category_id $category_ids { - db_dml insert_tmp_categories { - insert into category_temp - values (:category_id) - } + db_dml insert_tmp_categories "" } # execute query to count objects and pages - paginator create get_categorized_object_count $p_name $count_query -pagesize 20 -groupsize 10 -contextual -timeout 0 + paginator create get_categorized_object_count $p_name "" -pagesize 20 -groupsize 10 -contextual -timeout 0 + set first_row [paginator get_row $p_name $page] set last_row [paginator get_row_last $p_name $page] # execute query to get the objects on current page - set items [ad_table -Torderby $orderby get_categorized_objects $paginated_query $table_def] + set items [ad_table -Torderby $orderby get_categorized_objects "" $table_def] } paginator get_display_info $p_name info $page Index: openacs-4/packages/categories/www/categories-browse.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/categories-browse.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/categories/www/categories-browse.xql 27 Apr 2003 11:36:50 -0000 1.1 @@ -0,0 +1,55 @@ + + + + + + + insert into category_temp + values (:tree_id) + + + + + + and (upper(n.object_name) < 'A' or upper(n.object_name) > 'Z') + + + + + + and upper(n.object_name) like :bind_letter + + + + + + select v.object_id + from (select distinct m.object_id, c.category_id + from category_object_map m, categories c, category_temp t + where c.category_id = t.category_id + and m.category_id in (select c_sub.category_id + from categories c_sub + where c_sub.tree_id = c.tree_id + and c_sub.left_ind >= c.left_ind + and c_sub.left_ind < c.right_ind)) v + group by v.object_id having count(*) = :category_ids_length + + + + + + select m.object_id + from category_object_map m, category_temp t + where m.category_id = t.category_id + group by m.object_id having count(*) = :category_ids_length + + + + + + insert into category_temp + values (:category_id) + + + + Index: openacs-4/packages/categories/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/index.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/www/index.tcl 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/www/index.tcl 27 Apr 2003 11:36:50 -0000 1.2 @@ -22,11 +22,7 @@ template::multirow create trees tree_id tree_name site_wide_p short_name -db_foreach get_trees { - select tree_id, site_wide_p, - acs_permission.permission_p(tree_id, :user_id, 'category_tree_read') has_read_p - from category_trees t -} { +db_foreach get_trees "" { if { [string equal $has_read_p "t"] || [string equal $site_wide_p "t"] } { set tree_name [category_tree::get_name $tree_id $locale] template::multirow append trees $tree_id $tree_name $site_wide_p Index: openacs-4/packages/categories/www/cadmin/category-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-delete.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/www/cadmin/category-delete.tcl 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/www/cadmin/category-delete.tcl 27 Apr 2003 11:37:12 -0000 1.2 @@ -24,11 +24,7 @@ array set tree [category_tree::get_data $tree_id $locale] set tree_name $tree(tree_name) -set mapped_objects_p [db_string check_mapped_objects { - select decode(count(*),0,0,1) from dual - where exists (select 1 from category_object_map - where category_id = :category_id) -}] +set mapped_objects_p [db_string check_mapped_objects ""] set form_vars [export_form_vars tree_id category_id locale object_id] set page_title "Delete category \"$category_name\"" Index: openacs-4/packages/categories/www/cadmin/category-form.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-form.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/www/cadmin/category-form.tcl 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/www/cadmin/category-form.tcl 27 Apr 2003 11:37:12 -0000 1.2 @@ -34,10 +34,7 @@ } lappend context_bar [list "tree-view?[export_url_vars tree_id locale object_id]" $tree_name] $page_title -set languages [db_list_of_lists get_ad_locales { - select label as name, locale as value - from ad_locales -}] +set languages [db_list_of_lists get_ad_locales ""] ad_form -name category_form -action category-form -export { tree_id parent_id locale object_id } -form { {category_id:key} @@ -48,19 +45,9 @@ set name "" set description "" } -edit_request { - if {![db_0or1row get_category { - select name, description - from category_translations - where category_id = :category_id - and locale = :locale - }]} { + if {![db_0or1row check_translation_existance ""]} { set default_locale [ad_parameter DefaultLocale acs-lang "en_US"] - db_1row get_default_category { - select name, description - from category_translations - where category_id = :category_id - and locale = :default_locale - } + db_1row get_default_translation "" } } -on_submit { set description [util_close_html_tags $description 4000] Index: openacs-4/packages/categories/www/cadmin/category-form.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-form.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/www/cadmin/category-form.xql 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/www/cadmin/category-form.xql 27 Apr 2003 11:37:12 -0000 1.2 @@ -11,7 +11,7 @@ - + select name, description @@ -23,7 +23,7 @@ - + select name, description Index: openacs-4/packages/categories/www/cadmin/category-set-parent.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/category-set-parent.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/www/cadmin/category-set-parent.tcl 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/www/cadmin/category-set-parent.tcl 27 Apr 2003 11:37:12 -0000 1.2 @@ -35,16 +35,7 @@ lappend context_bar [list "tree-view?[export_url_vars tree_id locale object_id]" $tree_name] "Choose parent" -set subtree_categories_list [db_list subtree { - select /*+INDEX(child categories_left_ix)*/ - child.category_id - from categories parent, categories child - where parent.category_id = :category_id - and child.left_ind >= parent.left_ind - and child.left_ind <= parent.right_ind - and child.tree_id = parent.tree_id - order by child.left_ind -}] +set subtree_categories_list [db_list subtree ""] template::multirow create tree category_name category_id deprecated_p level left_indent url_p Index: openacs-4/packages/categories/www/cadmin/category-set-parent.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/category-set-parent.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/www/cadmin/category-set-parent.xql 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/www/cadmin/category-set-parent.xql 27 Apr 2003 11:37:12 -0000 1.2 @@ -3,10 +3,7 @@ - FIX ME REMOVE OPTIMIZATION HINT - - select /*+INDEX(child categories_left_ix)*/ - child.category_id + select child.category_id from categories parent, categories child where parent.category_id = :category_id and child.left_ind >= parent.left_ind Index: openacs-4/packages/categories/www/cadmin/category-usage-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/category-usage-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/categories/www/cadmin/category-usage-oracle.xql 27 Apr 2003 11:37:12 -0000 1.1 @@ -0,0 +1,35 @@ + + + + oracle8.1.6 + + + + select n.object_id + from category_object_map m, acs_named_objects n + where acs_permission.permission_p(m.object_id, :user_id, 'read') = 't' + and m.category_id = :category_id + and n.object_id = m.object_id + + + + + + select r.* + from (select n.object_id, n.object_name as object_name, o.creation_date, + t.pretty_name as package_type, n.package_id, p.instance_name, + row_number() over ($order_by_clause) as row_number + from acs_objects o, acs_named_objects n, apm_packages p, apm_package_types t, + category_object_map m + where n.object_id = m.object_id + and o.object_id = n.object_id + and p.package_id = n.package_id + and t.package_key = p.package_key + and m.category_id = :category_id + and acs_permission.permission_p(m.object_id, :user_id, 'read') = 't' + $order_by_clause) r + where r.row_number between :first_row and :last_row + + + + Index: openacs-4/packages/categories/www/cadmin/category-usage-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/category-usage-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/categories/www/cadmin/category-usage-postgresql.xql 27 Apr 2003 11:37:12 -0000 1.1 @@ -0,0 +1,35 @@ + + + + postgresql7.1 + + + + select n.object_id + from category_object_map m, acs_named_objects n + where acs_permission__permission_p(m.object_id, :user_id, 'read') = 't' + and m.category_id = :category_id + and n.object_id = m.object_id + + + + + + select r.* + from (select n.object_id, n.object_name as object_name, o.creation_date, + t.pretty_name as package_type, n.package_id, p.instance_name, + row_number() over ($order_by_clause) as row_number + from acs_objects o, acs_named_objects n, apm_packages p, apm_package_types t, + category_object_map m + where n.object_id = m.object_id + and o.object_id = n.object_id + and p.package_id = n.package_id + and t.package_key = p.package_key + and m.category_id = :category_id + and acs_permission__permission_p(m.object_id, :user_id, 'read') = 't' + $order_by_clause) r + where r.row_number between :first_row and :last_row + + + + Index: openacs-4/packages/categories/www/cadmin/category-usage.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-usage.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/www/cadmin/category-usage.tcl 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/www/cadmin/category-usage.tcl 27 Apr 2003 11:37:12 -0000 1.2 @@ -52,44 +52,18 @@ set order_by_clause [ad_order_by_from_sort_spec $orderby $table_def] -# query to get the number of pages, number of objects etc used by the paginator -set count_query { - select n.object_id - from category_object_map m, acs_named_objects n - where acs_permission.permission_p(m.object_id, :user_id, 'read') = 't' - and m.category_id = :category_id - and n.object_id = m.object_id -} - -# paginated query to get the actual objects -set paginated_query [subst { - select r.* - from (select n.object_id, n.object_name as object_name, o.creation_date, - t.pretty_name as package_type, n.package_id, p.instance_name, - row_number() over ($order_by_clause) as row_number - from acs_objects o, acs_named_objects n, apm_packages p, apm_package_types t, - category_object_map m - where n.object_id = m.object_id - and o.object_id = n.object_id - and p.package_id = n.package_id - and t.package_key = p.package_key - and m.category_id = :category_id - and acs_permission.permission_p(m.object_id, :user_id, 'read') = 't' - $order_by_clause) r - where r.row_number between :first_row and :last_row -}] - set p_name "category-usage" request create request set_param page -datatype integer -value 1 # execute query to count objects and pages -paginator create get_category_usages $p_name $count_query -pagesize 20 -groupsize 10 -contextual -timeout 0 +paginator create get_category_usages $p_name "" -pagesize 20 -groupsize 10 -contextual -timeout 0 + set first_row [paginator get_row $p_name $page] set last_row [paginator get_row_last $p_name $page] # execute query to get the objects on current page -set items [ad_table -Torderby $orderby get_objects_using_category $paginated_query $table_def] +set items [ad_table -Torderby $orderby get_objects_using_category "" $table_def] paginator get_display_info $p_name info $page set group [paginator get_group $p_name $page] Index: openacs-4/packages/categories/www/cadmin/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/index.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/www/cadmin/index.tcl 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/www/cadmin/index.tcl 27 Apr 2003 11:37:12 -0000 1.2 @@ -29,12 +29,7 @@ template::multirow create trees_with_read_permission tree_id tree_name site_wide_p short_name -db_foreach trees { - select tree_id, site_wide_p, - acs_permission.permission_p(tree_id, :user_id, 'category_tree_write') has_write_p, - acs_permission.permission_p(tree_id, :user_id, 'category_tree_read') has_read_p - from category_trees t -} { +db_foreach trees "" { if { [string equal $has_write_p "t"] } { set tree_name [category_tree::get_name $tree_id $locale] template::multirow append trees_with_write_permission $tree_id $tree_name $site_wide_p @@ -44,5 +39,4 @@ } } - ad_return_template Index: openacs-4/packages/categories/www/cadmin/master.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/master.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/www/cadmin/master.tcl 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/www/cadmin/master.tcl 27 Apr 2003 11:37:12 -0000 1.2 @@ -19,10 +19,7 @@ set locale [ad_parameter DefaultLocale acs-lang "en_US"] } -db_multirow languages get_locales { - select label, locale - from ad_locales -} +db_multirow languages get_locales "" set current_page [ad_conn url] set form_vars [export_ns_set_vars form [list locale xx] [ad_conn form]] Index: openacs-4/packages/categories/www/cadmin/one-object.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/one-object.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/www/cadmin/one-object.tcl 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/www/cadmin/one-object.tcl 27 Apr 2003 11:37:12 -0000 1.2 @@ -30,13 +30,7 @@ template::multirow create mapped_trees tree_name tree_id site_wide_p subtree_category_id subtree_category_name -db_foreach get_mapped_trees { - select t.tree_id, t.site_wide_p, m.subtree_category_id - from category_trees t, category_tree_map m - where m.object_id = :object_id - and m.tree_id = t.tree_id - order by t.tree_id -} { +db_foreach get_mapped_trees "" { if {![empty_string_p $subtree_category_id]} { set subtree_category_name [category::get_name $subtree_category_id $locale] } else { @@ -50,15 +44,7 @@ template::multirow create unmapped_trees tree_id tree_name site_wide_p -db_foreach get_unmapped_trees { - select tree_id, site_wide_p, - acs_permission.permission_p(tree_id, :user_id, 'category_tree_read') has_read_permission - from category_trees t - where not exists (select 1 from category_tree_map m - where m.object_id = :object_id - and m.tree_id = t.tree_id) - order by t.tree_id -} { +db_foreach get_unmapped_trees "" { if { [string equal $has_read_permission t] || [string equal $site_wide_p t] } { set tree_name [category_tree::get_name $tree_id $locale] template::multirow append unmapped_trees $tree_id $tree_name $site_wide_p Index: openacs-4/packages/categories/www/cadmin/site-wide-status-change.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/site-wide-status-change.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/www/cadmin/site-wide-status-change.tcl 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/www/cadmin/site-wide-status-change.tcl 27 Apr 2003 11:37:12 -0000 1.2 @@ -14,10 +14,6 @@ set package_id [ad_conn package_id] permission::require_permission -object_id $package_id -privilege category_admin -db_dml site_wide_status { - update category_trees - set site_wide_p = decode(:action,'1','t','f') - where tree_id = :tree_id -} +db_dml toggle_site_wide_status "" ad_returnredirect "permission-manage?[export_url_vars tree_id locale object_id]" Index: openacs-4/packages/categories/www/cadmin/site-wide-status-change.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/site-wide-status-change.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/www/cadmin/site-wide-status-change.xql 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/www/cadmin/site-wide-status-change.xql 27 Apr 2003 11:37:12 -0000 1.2 @@ -1,7 +1,7 @@ - + update category_trees Index: openacs-4/packages/categories/www/cadmin/tree-copy.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-copy.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/www/cadmin/tree-copy.tcl 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/www/cadmin/tree-copy.tcl 27 Apr 2003 11:37:12 -0000 1.2 @@ -34,12 +34,7 @@ template::multirow create trees tree_id tree_name site_wide_p -db_foreach trees_select { - select tree_id as source_tree_id, site_wide_p, - acs_permission.permission_p(tree_id, :user_id, 'category_tree_read') as has_read_p - from category_trees - where tree_id <> :tree_id -} { +db_foreach trees_select "" { if {$site_wide_p == "t" || $has_read_p == "t"} { set source_tree_name [category_tree::get_name $source_tree_id $locale] template::multirow append trees $source_tree_id $source_tree_name $site_wide_p Index: openacs-4/packages/categories/www/cadmin/tree-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-delete.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/www/cadmin/tree-delete.tcl 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/www/cadmin/tree-delete.tcl 27 Apr 2003 11:37:12 -0000 1.2 @@ -48,13 +48,7 @@ template::multirow create used_categories category_id name -db_foreach get_category_in_use { - select category_id - from categories c - where c.tree_id = :tree_id - and exists (select 1 from category_object_map - where category_id = c.category_id) -} { +db_foreach get_category_in_use "" { set category_name [category::get_name $category_id $locale] template::multirow append used_categories $category_id $category_name } Index: openacs-4/packages/categories/www/cadmin/tree-form.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-form.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/www/cadmin/tree-form.tcl 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/www/cadmin/tree-form.tcl 27 Apr 2003 11:37:12 -0000 1.2 @@ -28,10 +28,7 @@ } lappend context_bar $page_title -set languages [db_list_of_lists get_ad_locales { - select label as name, locale as value - from ad_locales -}] +set languages [db_list_of_lists get_ad_locales ""] ad_form -name tree_form -action tree-form -export { locale object_id } -form { {tree_id:key} Index: openacs-4/packages/categories/www/cadmin/tree-update-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/tree-update-2.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/www/cadmin/tree-update-2.tcl 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/www/cadmin/tree-update-2.tcl 27 Apr 2003 11:37:12 -0000 1.2 @@ -17,19 +17,11 @@ db_transaction { # use temporary table to use only bind vars in queries foreach category_id $category_ids { - db_dml insert_tmp_categories { - insert into category_temp - values (:category_id) - } + db_dml insert_tmp_categories "" } # delete first leaf categories, then parent categories - set category_list [db_list sort_categories_to_delete { - select c.category_id - from categories c, category_temp t - where c.category_id = t.category_id - order by right_ind-left_ind - }] + set category_list [db_list sort_categories_to_delete ""] foreach category_id $category_list { category::delete -batch_mode $category_id Index: openacs-4/packages/categories/www/cadmin/tree-update.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/tree-update.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/categories/www/cadmin/tree-update.tcl 23 Apr 2003 12:29:27 -0000 1.1 +++ openacs-4/packages/categories/www/cadmin/tree-update.tcl 27 Apr 2003 11:37:12 -0000 1.2 @@ -32,12 +32,7 @@ db_transaction { set count 0 - db_foreach get_tree { - select category_id, parent_id - from categories - where tree_id = :tree_id - order by left_ind - } { + db_foreach get_tree "" { incr count 10 if {[empty_string_p $parent_id]} { # need this as an anchor for toplevel categories @@ -81,21 +76,11 @@ if {$count == $last_ind} { # we do this so that there is no conflict in the old left_inds and the new ones - db_dml reset_category_index { - update categories - set left_ind = -left_ind, - right_ind = -right_ind - where tree_id = :tree_id - } + db_dml reset_category_index "" foreach category $done_list { util_unlist $category category_id left_ind right_ind - db_dml update_category_index { - update categories - set left_ind = :left_ind, - right_ind = :right_ind - where category_id = :category_id - } + db_dml update_category_index "" } } category_tree::flush_cache $tree_id @@ -152,20 +137,10 @@ db_transaction { # use temporary table to use only bind vars in queries foreach category_id $category_ids { - db_dml insert_tmp_categories { - insert into category_temp - values (:category_id) - } + db_dml insert_tmp_categories "" } - db_foreach get_used_categories { - select c.category_id, - (select decode(count(*),0,0,1) from dual - where exists (select 1 from category_object_map - where category_id = c.category_id)) as used_p - from categories c, category_temp t - where c.category_id = t.category_id - } { + db_foreach get_used_categories "" { set category_name [category::get_name $category_id $locale] template::multirow append categories $category_id $category_name $used_p }