+
+
Index: openacs-4/packages/categories/www/master.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/Attic/master.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/master.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,12 @@
+#
+# author: Timo Hentschel (thentschel@sussdorff-roy.com)
+#
+
+# There seems to be no way to elegantly set default values here
+if { ![info exists path_id] } {
+ set path_id ""
+}
+
+if { ![info exists context_bar] } {
+ set context_bar ""
+}
Index: openacs-4/packages/categories/www/cadmin/category-delete-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-delete-2.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/category-delete-2.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,24 @@
+ad_page_contract {
+
+ Deletes a category from a category tree
+
+ @author Timo Hentschel (thentschel@sussdorff-roy.com)
+ @cvs-id $Id:
+} {
+ tree_id:integer
+ category_id:integer
+ {locale ""}
+ object_id:integer,optional
+}
+
+permission::require_permission -object_id $tree_id -privilege category_tree_write
+
+db_transaction {
+ category::delete $category_id
+ category_tree::flush_cache $tree_id
+} on_error {
+ ad_return_complaint "Error Deleting Node" " This node contains leaf (child) nodes. If you really want to delete those leaf nodes, plesae delete them first. Thank you."
+ return
+}
+
+ad_returnredirect "tree-view?[export_url_vars tree_id locale object_id]"
Index: openacs-4/packages/categories/www/cadmin/category-delete-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-delete-oracle.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/category-delete-oracle.xql 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,17 @@
+
+
+
+ oracle 8.1.6
+
+
+
+
+ select case when count(*) = 0 then 0 else 1 end from dual
+ where exists (select 1 from category_object_map
+ where category_id = :category_id)
+
+
+
+
+
+
Index: openacs-4/packages/categories/www/cadmin/category-delete-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-delete-postgresql.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/category-delete-postgresql.xql 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,17 @@
+
+
+
+ postgresql 7.1
+
+
+
+
+ select case when count(*) = 0 then 0 else 1 end
+ where exists (select 1 from category_object_map
+ where category_id = :category_id)
+
+
+
+
+
+
Index: openacs-4/packages/categories/www/cadmin/category-delete.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-delete.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/category-delete.adp 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,23 @@
+
+@page_title;noquote@
+@context_bar;noquote@
+@locale@
+
+
+This category is still mapped to some objects.
+
+Are you sure you want to delete category "@category_name@"?
+
+
+
+
+
+
+
+
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
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/category-delete.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,43 @@
+ad_page_contract {
+
+ Deletes a category
+
+ @author Timo Hentschel (thentschel@sussdorff-roy.com)
+ @cvs-id $Id:
+} {
+ tree_id:integer
+ category_id:integer
+ {locale ""}
+ object_id:integer,optional
+} -properties {
+ page_title:onevalue
+ context_bar:onevalue
+ locale:onevalue
+ form_vars:onevalue
+ mapped_objects_p:onevalue
+}
+
+set user_id [ad_maybe_redirect_for_registration]
+permission::require_permission -object_id $tree_id -privilege category_tree_write
+
+set category_name [category::get_name $category_id $locale]
+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 form_vars [export_form_vars tree_id category_id locale object_id]
+set page_title "Delete category \"$category_name\""
+
+if {[info exists object_id]} {
+ set context_bar [list [category::get_object_context $object_id] [list "one-object?[export_url_vars locale object_id]" "Category Management"]]
+} else {
+ set context_bar [list [list ".?[export_url_vars locale]" "Category Management"]]
+}
+lappend context_bar [list "tree-view?[export_url_vars tree_id locale object_id]" $tree_name] "Delete \"$category_name\""
+
+ad_return_template
Index: openacs-4/packages/categories/www/cadmin/category-form.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-form.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/category-form.adp 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,8 @@
+
+@page_title@
+@context_bar;noquote@
+f
+
+
+
+
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
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/category-form.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,76 @@
+ad_page_contract {
+ Form to add/edit a category.
+
+ @author Timo Hentschel (thentschel@sussdorff-roy.com)
+ @cvs-id $Id:
+} {
+ tree_id:integer
+ category_id:integer,optional
+ {parent_id:integer,optional [db_null]}
+ {locale ""}
+ object_id:integer,optional
+} -properties {
+ context_bar:onevalue
+ page_title:onevalue
+}
+
+set user_id [ad_maybe_redirect_for_registration]
+set package_id [ad_conn package_id]
+permission::require_permission -object_id $tree_id -privilege category_tree_write
+
+if {[info exists category_id]} {
+ set page_title "Edit category"
+} else {
+ set page_title "Add category"
+}
+
+array set tree [category_tree::get_data $tree_id $locale]
+set tree_name $tree(tree_name)
+
+if {[info exists object_id]} {
+ set context_bar [list [category::get_object_context $object_id] [list "one-object?[export_url_vars locale object_id]" "Category Management"]]
+} else {
+ set context_bar [list [list ".?[export_url_vars locale]" "Category Management"]]
+}
+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
+}]
+
+ad_form -name category_form -action category-form -export { tree_id parent_id locale object_id } -form {
+ {category_id:key}
+ {name:text {label "Name"} {html {size 50 maxlength 200}}}
+ {language:text(select) {label "Language"} {value $locale} {options $languages}}
+ {description:text(textarea),optional {label "Description"} {html {rows 5 cols 80}}}
+} -new_request {
+ 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
+ }]} {
+ 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
+ }
+ }
+} -on_submit {
+ set description [util_close_html_tags $description 4000]
+} -new_data {
+ category::add -category_id $category_id -tree_id $tree_id -parent_id $parent_id -locale $language -name $name -description $description
+} -edit_data {
+ category::update -category_id $category_id -locale $language -name $name -description $description
+} -after_submit {
+ ad_returnredirect "tree-view?[export_url_vars tree_id locale object_id]"
+ ad_script_abort
+}
+
+ad_return_template
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
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/category-form.xql 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+ select label as name, locale as value
+ from ad_locales
+
+
+
+
+
+
+
+
+ select name, description
+ from category_translations
+ where category_id = :category_id
+ and locale = :locale
+
+
+
+
+
+
+
+
+ select name, description
+ from category_translations
+ where category_id = :category_id
+ and locale = :default_locale
+
+
+
+
+
+
Index: openacs-4/packages/categories/www/cadmin/category-phase-out.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-phase-out.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/category-phase-out.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,24 @@
+ad_page_contract {
+ Phases a category in/out.
+
+ @author Timo Hentschel (thentschel@sussdorff-roy.com)
+ @cvs-id $Id:
+} {
+ tree_id:integer
+ category_id:integer
+ phase_out_p:integer
+ {locale ""}
+ object_id:integer,optional
+}
+
+permission::require_permission -object_id $tree_id -privilege category_tree_write
+
+if {$phase_out_p} {
+ category::phase_out $category_id
+ category_tree::flush_cache $tree_id
+} else {
+ category::phase_in $category_id
+ category_tree::flush_cache $tree_id
+}
+
+ad_returnredirect "tree-view?[export_url_vars tree_id locale object_id]"
Index: openacs-4/packages/categories/www/cadmin/category-set-parent-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/category-set-parent-2.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/category-set-parent-2.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,19 @@
+ad_page_contract {
+
+ Changes the parent category of a category.
+
+ @author Timo Hentschel (thentschel@sussdorff-roy.com)
+ @cvs-id $Id:
+} {
+ tree_id:integer
+ category_id:integer
+ {parent_id:integer,optional [db_null]}
+ {locale ""}
+ object_id:integer,optional
+}
+
+permission::require_permission -object_id $tree_id -privilege category_tree_write
+
+category::change_parent -tree_id $tree_id -category_id $category_id -parent_id $parent_id
+
+ad_returnredirect "tree-view?[export_url_vars tree_id locale object_id]"
Index: openacs-4/packages/categories/www/cadmin/category-set-parent-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/category-set-parent-oracle.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/category-set-parent-oracle.xql 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,22 @@
+
+
+
+ oracle 8.1.6
+
+
+
+
+ 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
+
+
+
+
+
+
Index: openacs-4/packages/categories/www/cadmin/category-set-parent.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/category-set-parent.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/category-set-parent.adp 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,29 @@
+
+@page_title;noquote@
+@context_bar;noquote@
+@locale@
+
+
+
+ Category Name Hierarchy Level
+ Root Level 0
+
+
+
+
+ @tree.left_indent;noquote@
+
+ @tree.category_name@
+
+
+ @tree.category_name@
+
+
+
+
+ @tree.level@
+
+
+
+
+
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
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/category-set-parent.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,62 @@
+ad_page_contract {
+
+ Changes the parent category of a category.
+
+ @author Timo Hentschel (thentschel@sussdorff-roy.com)
+ @cvs-id $Id:
+} {
+ tree_id:integer
+ category_id:integer
+ {locale ""}
+ object_id:integer,optional
+} -properties {
+ page_title:onevalue
+ context_bar:onevalue
+ locale:onevalue
+ tree_name:onevalue
+ url_vars:onevalue
+ tree:multirow
+}
+
+set user_id [ad_maybe_redirect_for_registration]
+permission::require_permission -object_id $tree_id -privilege category_tree_write
+
+array set one_tree [category_tree::get_data $tree_id $locale]
+set tree_name $one_tree(tree_name)
+
+set url_vars [export_url_vars tree_id category_id locale object_id]
+set page_title "Choose a parent node"
+
+if {[info exists object_id]} {
+ set context_bar [list [category::get_object_context $object_id] [list "one-object?[export_url_vars locale object_id]" "Category Management"]]
+} else {
+ set context_bar [list [list ".?[export_url_vars locale]" "Category Management"]]
+}
+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
+}]
+
+template::multirow create tree category_name category_id deprecated_p level left_indent url_p
+
+foreach category [category_tree::get_tree -all $tree_id $locale] {
+ util_unlist $category category_id category_name deprecated_p level
+
+ if { [lsearch $subtree_categories_list $category_id]==-1 } {
+ set url_p 1
+ } else {
+ set url_p 0
+ }
+ template::multirow append tree $category_name $category_id $deprecated_p $level [category::repeat_string " " [expr ($level-1)*5]] $url_p
+}
+
+ad_return_template
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
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/category-set-parent.xql 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,21 @@
+
+
+
+
+
+ FIX ME REMOVE OPTIMIZATION HINT
+
+ 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
+
+
+
+
+
+
Index: openacs-4/packages/categories/www/cadmin/category-usage.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-usage.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/category-usage.adp 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,39 @@
+
+@page_title;noquote@
+@context_bar;noquote@
+@locale@
+
+
+
+@object_count@ objects on @page_count@ pages
+
+
+
+ <<
+
+
+ <
+
+
+
+
+
+ @pages.page@
+
+
+ @page@
+
+
+
+
+
+ >
+
+
+ >>
+
+
+
+
+
+@items;noquote@
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
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/category-usage.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,102 @@
+ad_page_contract {
+
+ Show all objects mapped to a category.
+
+ @author Timo Hentschel (thentschel@sussdorff-roy.com)
+ @cvs-id $Id:
+} {
+ category_id:integer
+ tree_id:integer
+ {locale ""}
+ object_id:integer,optional
+ {page:integer,optional 1}
+ {orderby:optional object_name}
+} -properties {
+ page_title:onevalue
+ context_bar:onevalue
+ locale:onevalue
+ url_vars:onevalue
+ object_count:onevalue
+ page_count:onevalue
+ page:onevalue
+ orderby:onevalue
+ items:onevalue
+ info:onerow
+ pages:onerow
+}
+
+set user_id [ad_maybe_redirect_for_registration]
+array set tree [category_tree::get_data $tree_id $locale]
+if {$tree(site_wide_p) == "f"} {
+ permission::require_permission -object_id $tree_id -privilege category_tree_read
+}
+
+set tree_name $tree(tree_name)
+set category_name [category::get_name $category_id $locale]
+set page_title "Objects using category \"$category_name\" of tree \"$tree_name\""
+set url_vars [export_url_vars category_id tree_id locale object_id]
+
+if {[info exists object_id]} {
+ set context_bar [list [category::get_object_context $object_id] [list "one-object?[export_url_vars locale object_id]" "Category Management"]]
+} else {
+ set context_bar [list [list ".?[export_url_vars locale]" "Category Management"]]
+}
+lappend context_bar [list "tree-view?[export_url_vars tree_id locale object_id]" $tree_name] "\"$category_name\" Usage"
+
+set table_def {
+ {object_name "Object Name" {upper(n.object_name) $order} {
$object_name }}
+ {instance_name "Package" {} {$instance_name }}
+ {package_type "Package Type" {} r}
+ {creation_date "Creation Date" {} r}
+}
+
+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
+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]
+
+paginator get_display_info $p_name info $page
+set group [paginator get_group $p_name $page]
+paginator get_context $p_name pages [paginator get_pages $p_name $group]
+paginator get_context $p_name groups [paginator get_groups $p_name $group 10]
+
+set object_count [paginator get_row_count $p_name]
+set page_count [paginator get_page_count $p_name]
+
+ad_return_template
Index: openacs-4/packages/categories/www/cadmin/index-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/index-oracle.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/index-oracle.xql 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,18 @@
+
+
+
+ oracle 8.1.6
+
+
+
+
+ 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
+
+
+
+
+
+
Index: openacs-4/packages/categories/www/cadmin/index-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/index-postgresql.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/index-postgresql.xql 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,18 @@
+
+
+
+ postgresql 7.1
+
+
+
+
+ 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
+
+
+
+
+
+
Index: openacs-4/packages/categories/www/cadmin/index.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/index.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/index.adp 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,55 @@
+
+@page_title;noquote@
+@context_bar;noquote@
+@locale@
+
+ Trees you have the write permission on:
+
+
+
+
+
+
+
+
+
+
+
+
Trees you have only the read permission on:
+
+
+
+
+
+
+
+
+
+Create a new tree
+
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
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/index.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,48 @@
+ad_page_contract {
+
+ The index page of the category trees administration
+ presenting a list of trees the person has a permission to see/modify
+
+ @author Timo Hentschel (thentschel@sussdorff-roy.com)
+ @cvs-id $Id:
+} {
+ {locale ""}
+} -properties {
+ page_title:onevalue
+ context_bar:onevalue
+ locale:onevalue
+ url_vars:onevalue
+ trees_with_write_permission:multirow
+ trees_with_read_permission:multirow
+}
+
+set page_title "Category Management"
+set context_bar [list $page_title]
+set url_vars [export_url_vars locale]
+
+set user_id [ad_maybe_redirect_for_registration]
+set package_id [ad_conn package_id]
+
+permission::require_permission -object_id $package_id -privilege category_admin
+
+template::multirow create trees_with_write_permission tree_id tree_name site_wide_p short_name
+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
+} {
+ 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
+ } elseif { [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_with_read_permission $tree_id $tree_name $site_wide_p
+ }
+}
+
+
+ad_return_template
Index: openacs-4/packages/categories/www/cadmin/master.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/master.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/master.adp 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,17 @@
+
+@page_title;noquote@
+@context_bar;noquote@
+
+
+ >@languages.label@
+
+
+
+
+
+
+
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
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/master.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,28 @@
+#
+# author: Timo Hentschel (thentschel@sussdorff-roy.com)
+#
+
+# There seems to be no way to elegantly set default values here
+if { ![info exists path_id] } {
+ set path_id ""
+}
+
+if { ![info exists context_bar] } {
+ set context_bar ""
+}
+
+if { ![info exists change_locale] } {
+ set change_locale t
+}
+
+if {![exists_and_not_null locale]} {
+ set locale [ad_parameter DefaultLocale acs-lang "en_US"]
+}
+
+db_multirow languages get_locales {
+ select label, locale
+ from ad_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/master.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/master.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/master.xql 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+ select label, locale
+ from ad_locales
+
+
+
+
+
+
Index: openacs-4/packages/categories/www/cadmin/one-object-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/one-object-oracle.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/one-object-oracle.xql 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,21 @@
+
+
+
+ oracle 8.1.6
+
+
+
+
+ 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
+
+
+
+
+
+
Index: openacs-4/packages/categories/www/cadmin/one-object-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/one-object-postgresql.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/one-object-postgresql.xql 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,21 @@
+
+
+
+ postgresql 7.1
+
+
+
+
+ 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
+
+
+
+
+
+
Index: openacs-4/packages/categories/www/cadmin/one-object.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/one-object.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/one-object.adp 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,65 @@
+
+@page_title;noquote@
+@context_bar;noquote@
+@locale@
+
+
+
+
+
+
+
The following category trees are available:
+
+
+
+
+
+
+
+
+Create and map a new category tree
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
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/one-object.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,68 @@
+ad_page_contract {
+
+ This entry page for different object in ACS that
+ need to manage which categories that can be mapped
+ to contained objects.
+
+ @author Timo Hentschel (thentschel@sussdorff-roy.com)
+ @cvs-id $Id:
+} {
+ object_id:integer,notnull
+ {locale ""}
+} -properties {
+ page_title:onevalue
+ context_bar:onevalue
+ locale:onevalue
+ mapped_trees:multirow
+ unmapped_trees:multirow
+ object_name:onevalue
+ url_vars:onevalue
+}
+
+set user_id [ad_maybe_redirect_for_registration]
+permission::require_permission -object_id $object_id -privilege admin
+
+set context_bar [category::get_object_context $object_id]
+set object_name [lindex $context_bar 1]
+set page_title "Category Management"
+set context_bar [list $context_bar $page_title]
+set url_vars [export_url_vars locale object_id]
+
+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
+} {
+ if {![empty_string_p $subtree_category_id]} {
+ set subtree_category_name [category::get_name $subtree_category_id $locale]
+ } else {
+ set subtree_category_name ""
+ }
+ set tree_name [category_tree::get_name $tree_id $locale]
+ template::multirow append mapped_trees $tree_name $tree_id $site_wide_p $subtree_category_id $subtree_category_name
+}
+
+
+
+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
+} {
+ 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
+ }
+}
+
+ad_return_template
Index: openacs-4/packages/categories/www/cadmin/one-object.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/one-object.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/one-object.xql 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+ 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
+
+
+
+
+
+
Index: openacs-4/packages/categories/www/cadmin/permission-manage.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/permission-manage.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/permission-manage.adp 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,18 @@
+
+@page_title;noquote@
+@context_bar;noquote@
+f
+
+
+
+ This is a site wide category tree
+
+ Make it Local
+
+
+
+ This tree is local
+
+ Make it Site-Wide
+
+
Index: openacs-4/packages/categories/www/cadmin/permission-manage.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/permission-manage.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/permission-manage.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,37 @@
+ad_page_contract {
+ Let the user toggle the site-wide status of a category tree.
+
+ @author Timo Hentschel (thentschel@sussdorff-roy.com)
+ @cvs-id $Id:
+} {
+ tree_id:integer
+ object_id:integer,optional
+ {locale ""}
+} -properties {
+ page_title:onevalue
+ context_bar:onevalue
+ sw_tree_p:onevalue
+ admin_p:onevalue
+ url_vars:onevalue
+}
+
+set user_id [ad_maybe_redirect_for_registration]
+permission::require_permission -object_id $tree_id -privilege category_tree_grant_permissions
+
+array set tree [category_tree::get_data $tree_id $locale]
+set tree_name $tree(tree_name)
+set page_title "Permission Management for $tree_name"
+
+if {[info exists object_id]} {
+ set context_bar [list [category::get_object_context $object_id] [list "one-object?[export_url_vars locale object_id]" "Category Management"]]
+} else {
+ set context_bar [list [list ".?[export_url_vars locale]" "Category Management"]]
+}
+lappend context_bar [list "tree-view?[export_url_vars tree_id locale object_id]" $tree_name] "Manage Permissions"
+
+set url_vars [export_url_vars tree_id object_id locale]
+set package_id [ad_conn package_id]
+set admin_p [permission::permission_p -object_id $package_id -privilege category_admin]
+set sw_tree_p [ad_decode $tree(site_wide_p) f 0 1]
+
+ad_return_template
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
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/site-wide-status-change.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,23 @@
+ad_page_contract {
+ Toggle the site-wide status of a category tree.
+
+ @author Timo Hentschel (thentschel@sussdorff-roy.com)
+ @cvs-id $Id:
+} {
+ tree_id:integer
+ action:integer
+ {locale ""}
+ object_id:integer,optional
+}
+
+set user_id [ad_maybe_redirect_for_registration]
+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
+}
+
+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
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/site-wide-status-change.xql 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+ update category_trees
+ set site_wide_p = case when :action = '1' then 't' else 'f' end
+ where tree_id = :tree_id
+
+
+
+
+
+
Index: openacs-4/packages/categories/www/cadmin/subtree-choose.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/subtree-choose.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/subtree-choose.adp 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,17 @@
+
+@page_title;noquote@
+@context_bar;noquote@
+@locale@
+
+
+
+
+
+
+
+ @tree.left_indent;noquote@ @tree.category_name@ [ Add this subtree ] @tree.level@
+
+
+
Index: openacs-4/packages/categories/www/cadmin/subtree-choose.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/subtree-choose.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/subtree-choose.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,41 @@
+ad_page_contract {
+
+ This page displays a category tree.
+ Next to each category there will be a map subtree link.
+
+ @author Timo Hentschel (thentschel@sussdorff-roy.com)
+ @cvs-id $Id:
+} {
+ tree_id:integer
+ {locale ""}
+ object_id:integer,notnull
+} -properties {
+ page_title:onevalue
+ context_bar:onevalue
+ locale:onevalue
+ url_vars:onevalue
+ tree:multirow
+}
+
+set user_id [ad_maybe_redirect_for_registration]
+permission::require_permission -object_id $object_id -privilege admin
+
+array set tree_data [category_tree::get_data $tree_id $locale]
+if {$tree_data(site_wide_p) == "f"} {
+ permission::require_permission -object_id $tree_id -privilege category_tree_read
+}
+
+set page_title "Choose a subtree to map"
+set url_vars [export_url_vars locale object_id]
+
+set context_bar [list [category::get_object_context $object_id] [list "one-object?[export_url_vars locale object_id]" "Category Management"] "Map subtree"]
+
+template::multirow create tree category_id category_name level left_indent
+
+foreach category [category_tree::get_tree -all $tree_id $locale] {
+ util_unlist $category category_id category_name deprecated_p level
+
+ template::multirow append tree $category_id $category_name $level [category::repeat_string " " [expr ($level-1)*5]]
+}
+
+ad_return_template
Index: openacs-4/packages/categories/www/cadmin/subtree-map.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/subtree-map.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/subtree-map.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,24 @@
+ad_page_contract {
+
+ Map a subtree to a package (or object)
+
+ @author Timo Hentschel (thentschel@sussdorff-roy.com)
+ @cvs-id $Id:
+} {
+ source_tree_id:integer,notnull
+ category_id:integer,notnull
+ {locale ""}
+ object_id:integer,notnull
+}
+
+set user_id [ad_maybe_redirect_for_registration]
+permission::require_permission -object_id $object_id -privilege admin
+
+array set tree [category_tree::get_data $source_tree_id $locale]
+if {$tree(site_wide_p) == "f"} {
+ permission::require_permission -object_id $source_tree_id -privilege category_tree_read
+}
+
+category_tree::map -tree_id $source_tree_id -subtree_category_id $category_id -object_id $object_id
+
+ad_returnredirect "one-object?[export_url_vars locale object_id]"
Index: openacs-4/packages/categories/www/cadmin/tree-copy-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-copy-2.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-copy-2.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,19 @@
+ad_page_contract {
+
+ This page copies a category tree into another category tree
+
+ @author Timo Hentschel (thentschel@sussdorff-roy.com)
+ @cvs-id $Id:
+} {
+ tree_id:integer
+ source_tree_id:integer
+ {locale ""}
+ object_id:integer,optional
+}
+
+set user_id [ad_maybe_redirect_for_registration]
+permission::require_permission -object_id $tree_id -privilege category_tree_write
+
+category_tree::copy -source_tree $source_tree_id -dest_tree $tree_id
+
+ad_returnredirect "tree-view?[export_url_vars tree_id locale object_id]"
Index: openacs-4/packages/categories/www/cadmin/tree-copy-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/tree-copy-oracle.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-copy-oracle.xql 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,18 @@
+
+
+
+ oracle 8.1.6
+
+
+
+
+ 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
+
+
+
+
+
+
Index: openacs-4/packages/categories/www/cadmin/tree-copy-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/tree-copy-postgresql.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-copy-postgresql.xql 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,18 @@
+
+
+
+ postgresql 7.1
+
+
+
+
+ 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
+
+
+
+
+
+
Index: openacs-4/packages/categories/www/cadmin/tree-copy.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-copy.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-copy.adp 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,24 @@
+
+@page_title;noquote@
+@context_bar;noquote@
+@locale@
+
+
+
+
+
+There are no category trees available
+
+
+
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
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-copy.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,49 @@
+ad_page_contract {
+
+ Let the user select a category tree which will be copied into the current category tree
+
+ @author Timo Hentschel (thentschel@sussdorff-roy.com)
+ @cvs-id $Id:
+} {
+ tree_id:integer
+ {locale ""}
+ object_id:integer,optional
+} -properties {
+ page_title:onevalue
+ context_bar:onevalue
+ locale:onevalue
+ trees:multirow
+ tree_id:onevalue
+ url_vars:onevalue
+}
+
+set user_id [ad_maybe_redirect_for_registration]
+permission::require_permission -object_id $tree_id -privilege category_tree_write
+
+set url_vars [export_url_vars locale object_id]
+set page_title "Choose a tree to copy"
+array set tree [category_tree::get_data $tree_id $locale]
+set tree_name $tree(tree_name)
+
+if {[info exists object_id]} {
+ set context_bar [list [category::get_object_context $object_id] [list "one-object?[export_url_vars locale object_id]" "Category Management"]]
+} else {
+ set context_bar [list [list ".?[export_url_vars locale]" "Category Management"]]
+}
+lappend context_bar [list "tree-view?[export_url_vars tree_id locale object_id]" $tree_name] "Copy a tree"
+
+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
+} {
+ 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
+ }
+}
+
+ad_return_template
Index: openacs-4/packages/categories/www/cadmin/tree-delete-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-delete-2.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-delete-2.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,29 @@
+ad_page_contract {
+
+ This page checks whether the category tree can be deleted and deletes it.
+
+ @author Timo Hentschel (thentschel@sussdorff-roy.com)
+ @cvs-id $Id:
+} {
+ tree_id:integer,notnull
+ {locale ""}
+ object_id:integer,optional
+}
+
+set user_id [ad_maybe_redirect_for_registration]
+permission::require_permission -object_id $tree_id -privilege category_tree_write
+
+set instance_list [category_tree::usage $tree_id]
+
+if {[llength $instance_list] > 0} {
+ ad_return_complaint 1 "This category tree is still in use."
+ return
+}
+
+category_tree::delete $tree_id
+
+if {![info exists object_id]} {
+ ad_returnredirect ".?[export_url_vars locale]"
+} else {
+ ad_returnredirect "one-object?[export_url_vars locale object_id]"
+}
Index: openacs-4/packages/categories/www/cadmin/tree-delete.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-delete.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-delete.adp 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,35 @@
+
+@page_title;noquote@
+@context_bar;noquote@
+@locale@
+
+
+
+ Tree Name @tree_name@
+ Description @tree_description@
+
+
+
+
+ This tree is still used by some modules. For a complete list, please go
+ here .
+
+
+
+ The following categories of this tree are still in use:
+
+
+
+
+ Are you sure you want to delete the tree "@tree_name@"?
+
+
+
+
+
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
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-delete.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,62 @@
+ad_page_contract {
+
+ This page checks whether the category tree can be deleted and asks for confirmation.
+
+ @author Timo Hentschel (thentschel@sussdorff-roy.com)
+ @cvs-id $Id:
+} {
+ tree_id:integer,notnull
+ {locale ""}
+ object_id:integer,optional
+} -properties {
+ page_title:onevalue
+ context_bar:onevalue
+ locale:onevalue
+ tree_name:onevalue
+ tree_description:onevalue
+ instances_using_p:onevalue
+ form_vars:onevalue
+ url_vars:onevalue
+ used_categories:multirow
+}
+
+set user_id [ad_maybe_redirect_for_registration]
+permission::require_permission -object_id $tree_id -privilege category_tree_write
+
+array set tree [category_tree::get_data $tree_id $locale]
+set tree_name $tree(tree_name)
+set tree_description $tree(description)
+
+set page_title "Delete Category Tree \"$tree_name\""
+if {[info exists object_id]} {
+ set context_bar [list [category::get_object_context $object_id] [list "one-object?[export_url_vars locale object_id]" "Category Management"]]
+} else {
+ set context_bar [list [list ".?[export_url_vars locale]" "Category Management"]]
+}
+lappend context_bar [list "tree-view?[export_url_vars tree_id locale object_id]" $tree_name] Delete
+
+set instance_list [category_tree::usage $tree_id]
+
+if {[llength $instance_list] > 0} {
+ set instances_using_p t
+} else {
+ set instances_using_p f
+}
+
+set form_vars [export_form_vars tree_id locale object_id]
+set url_vars [export_url_vars tree_id locale object_id]
+
+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)
+} {
+ set category_name [category::get_name $category_id $locale]
+ template::multirow append used_categories $category_id $category_name
+}
+
+ad_return_template
Index: openacs-4/packages/categories/www/cadmin/tree-delete.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-delete.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-delete.xql 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+ 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)
+
+
+
+
+
+
Index: openacs-4/packages/categories/www/cadmin/tree-form.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-form.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-form.adp 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,8 @@
+
+@page_title@
+@context_bar;noquote@
+f
+
+
+
+
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
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-form.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,69 @@
+ad_page_contract {
+ Form to add/edit a category tree.
+
+ @author Timo Hentschel (thentschel@sussdorff-roy.com)
+ @cvs-id $Id:
+} {
+ tree_id:integer,optional
+ {locale ""}
+ object_id:integer,optional
+} -properties {
+ context_bar:onevalue
+ page_title:onevalue
+}
+
+set user_id [ad_maybe_redirect_for_registration]
+set package_id [ad_conn package_id]
+
+if {[info exists tree_id]} {
+ set page_title "Edit tree"
+} else {
+ set page_title "Add tree"
+}
+
+if {[info exists object_id]} {
+ set context_bar [list [category::get_object_context $object_id] [list "one-object?[export_url_vars locale object_id]" "Category Management"]]
+} else {
+ set context_bar [list [list ".?[export_url_vars locale]" "Category Management"]]
+}
+lappend context_bar $page_title
+
+set languages [db_list_of_lists get_ad_locales {
+ select label as name, locale as value
+ from ad_locales
+}]
+
+ad_form -name tree_form -action tree-form -export { locale object_id } -form {
+ {tree_id:key}
+ {tree_name:text {label "Name"} {html {size 50 maxlength 50}}}
+ {language:text(select) {label "Language"} {value $locale} {options $languages}}
+ {description:text(textarea),optional {label "Description"} {html {rows 5 cols 80}}}
+} -new_request {
+ permission::require_permission -object_id $package_id -privilege category_admin
+ set tree_name ""
+ set description ""
+} -edit_request {
+ permission::require_permission -object_id $tree_id -privilege category_tree_write
+ set action Edit
+ util_unlist [category_tree::get_translation $tree_id $locale] tree_name description
+} -on_submit {
+ set description [util_close_html_tags $description 4000]
+} -new_data {
+ db_transaction {
+ category_tree::add -tree_id $tree_id -name $tree_name -description $description -locale $language -context_id $package_id
+ if { [info exists object_id] } {
+ category_tree::map -tree_id $tree_id -object_id $object_id
+ set return_url "one-object?[export_url_vars locale object_id]"
+ } else {
+ set return_url ".?[export_url_vars locale]"
+ }
+ }
+} -edit_data {
+ category_tree::update -tree_id $tree_id -name $tree_name -description $description -locale $language
+ set return_url "tree-view?[export_url_vars tree_id locale object_id]"
+} -after_submit {
+ ad_returnredirect $return_url
+ ad_script_abort
+}
+
+ad_return_template
Index: openacs-4/packages/categories/www/cadmin/tree-form.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/tree-form.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-form.xql 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+ select label as name, locale as value
+ from ad_locales
+
+
+
+
+
+
Index: openacs-4/packages/categories/www/cadmin/tree-map.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-map.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-map.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,25 @@
+ad_page_contract {
+
+ This script assigns one category tree to an object.
+
+ @author Timo Hentschel (thentschel@sussdorff-roy.com)
+ @cvs-id $Id:
+} {
+ tree_id:integer,notnull
+ {locale ""}
+ object_id:integer,notnull
+}
+
+set user_id [ad_maybe_redirect_for_registration]
+permission::require_permission -object_id $object_id -privilege admin
+
+array set tree [category_tree::get_data $tree_id $locale]
+if {$tree(site_wide_p) == "f"} {
+ permission::require_permission -object_id $tree_id -privilege category_tree_read
+}
+
+category_tree::map -tree_id $tree_id -object_id $object_id
+
+set return_url "one-object?[export_url_vars locale object_id]"
+
+ad_returnredirect $return_url
Index: openacs-4/packages/categories/www/cadmin/tree-unmap-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-unmap-2.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-unmap-2.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,23 @@
+ad_page_contract {
+
+ Unmapping a category tree from an object.
+
+ @author Timo Hentschel (thentschel@sussdorff-roy.com)
+ @cvs-id $Id:
+} {
+ tree_id:integer,notnull
+ {locale ""}
+ object_id:integer,notnull
+}
+
+set user_id [ad_maybe_redirect_for_registration]
+permission::require_permission -object_id $object_id -privilege admin
+
+array set tree [category_tree::get_data $tree_id $locale]
+if {$tree(site_wide_p) == "f"} {
+ permission::require_permission -object_id $tree_id -privilege category_tree_read
+}
+
+category_tree::unmap -tree_id $tree_id -object_id $object_id
+
+ad_returnredirect "one-object?[export_url_vars locale object_id]"
Index: openacs-4/packages/categories/www/cadmin/tree-unmap.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-unmap.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-unmap.adp 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,20 @@
+
+@page_title;noquote@
+@context_bar;noquote@
+@locale@
+
+Are you sure you want to unmap the tree "@tree_name@" from "@object_name@"?
+
+
+
+
+
+
+
+
Index: openacs-4/packages/categories/www/cadmin/tree-unmap.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-unmap.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-unmap.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,39 @@
+ad_page_contract {
+
+ Unmapping a category tree from an object.
+
+ @author Timo Hentschel (thentschel@sussdorff-roy.com)
+ @cvs-id $Id:
+} {
+ tree_id:integer,notnull
+ {locale ""}
+ object_id:integer,notnull
+} -properties {
+ page_title:onevalue
+ context_bar:onevalue
+ locale:onevalue
+ tree_name:onevalue
+ object_name:onevalue
+ form_vars:onevalue
+ cancel_form_vars:onevalue
+}
+
+set user_id [ad_maybe_redirect_for_registration]
+permission::require_permission -object_id $object_id -privilege admin
+
+array set tree [category_tree::get_data $tree_id $locale]
+if {$tree(site_wide_p) == "f"} {
+ permission::require_permission -object_id $tree_id -privilege category_tree_read
+}
+
+set page_title "Unmap tree"
+set form_vars [export_form_vars tree_id locale object_id]
+set cancel_form_vars [export_form_vars locale object_id]
+
+set object_context [category::get_object_context $object_id]
+set object_name [lindex $object_context 1]
+set tree_name $tree(tree_name)
+
+set context_bar [list $object_context [list "one-object?[export_url_vars locale object_id]" "Category Management"] "Unmap \"$tree_name\""]
+
+ad_return_template
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
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-update-2.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,48 @@
+ad_page_contract {
+ Bulk delete of categories.
+
+ @author Timo Hentschel (thentschel@sussdorff-roy.com)
+ @cvs-id $Id:
+} {
+ category_ids:integer,multiple
+ tree_id:integer
+ {locale ""}
+ object_id:integer,optional
+}
+
+permission::require_permission -object_id $tree_id -privilege category_tree_write
+
+set list_of_errors ""
+
+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)
+ }
+ }
+
+ # 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
+ }]
+
+ foreach category_id $category_list {
+ category::delete -batch_mode $category_id
+ }
+ category::reset_translation_cache
+ category_tree::flush_cache $tree_id
+} on_error {
+ append list_of_errors " Node [category::get_name $category_id $locale] contains leaf (child) categories. If you really want to delete those leaf categories, plesae delete them first"
+}
+
+if { [llength $list_of_errors] >0 } {
+ ad_return_complaint "Error Deleting Nodes" $list_of_errors
+ return
+}
+
+ad_returnredirect "tree-view?[export_url_vars tree_id locale object_id]"
Index: openacs-4/packages/categories/www/cadmin/tree-update-2.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/tree-update-2.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-update-2.xql 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+ insert into category_temp
+ values (:category_id)
+
+
+
+
+
+
+
+
+ select c.category_id
+ from categories c, category_temp t
+ where c.category_id = t.category_id
+ order by right_ind-left_ind
+
+
+
+
+
+
Index: openacs-4/packages/categories/www/cadmin/tree-update-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/tree-update-oracle.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-update-oracle.xql 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,20 @@
+
+
+
+ oracle 8.1.6
+
+
+
+
+ select c.category_id,
+ (select case when count(*) = 0 then 0 else 1 end 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
+
+
+
+
+
+
Index: openacs-4/packages/categories/www/cadmin/tree-update-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/tree-update-postgresql.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-update-postgresql.xql 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,20 @@
+
+
+
+ postgresql 7.1
+
+
+
+
+ select c.category_id,
+ (select case when count(*) = 0 then 0 else 1 end
+ 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
+
+
+
+
+
+
Index: openacs-4/packages/categories/www/cadmin/tree-update.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/tree-update.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-update.adp 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,28 @@
+
+@page_title;noquote@
+@context_bar;noquote@
+@locale@
+
+Are you sure that you want to delete these categories?
+
+
+@categories.name@ (still used )
+
+
+
+
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
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-update.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,182 @@
+ad_page_contract {
+ Bulk operation on a category tree:
+ sort, phase in, phase out, delete
+
+ @author Timo Hentschel (thentschel@sussdorff-roy.com)
+ @cvs-id $Id:
+} {
+ tree_id:integer
+ sort_key:array
+ {check:array ""}
+ {submit_sort ""}
+ {submit_phase_in ""}
+ {submit_phase_out ""}
+ {submit_delete ""}
+ {locale ""}
+ object_id:integer,optional
+} -properties {
+ page_title:onevalue
+ context_bar:onevalue
+ locale:onevalue
+ categories:multirow
+ form_vars_delete:onevalue
+ form_vars_cancel:onevalue
+}
+
+permission::require_permission -object_id $tree_id -privilege category_tree_write
+
+array set tree [category_tree::get_data $tree_id $locale]
+
+if {![empty_string_p $submit_sort]} {
+
+ 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
+ } {
+ incr count 10
+ if {[empty_string_p $parent_id]} {
+ # need this as an anchor for toplevel categories
+ set parent_id -1
+ }
+ if {[info exists sort_key($category_id)]} {
+ lappend child($parent_id) [list $sort_key($category_id) $category_id 0 0]
+ } else {
+ lappend child($parent_id) [list $count $category_id 0 0]
+ }
+ }
+ set last_ind [expr ($count / 5) + 1]
+
+ set count 1
+ set stack [list]
+ set done_list [list]
+ # put toplevel categories on stack
+ if {[info exists child(-1)]} {
+ set stack [lsort -integer -index 0 $child(-1)]
+ }
+
+ while {[llength $stack] > 0} {
+ set next [lindex $stack 0]
+ set act_category [lindex $next 1]
+ set stack [lrange $stack 1 end]
+ if {[lindex $next 2]>0} {
+ ## the children of this parent are done, so this category is also done
+ lappend done_list [list $act_category [lindex $next 2] $count]
+ } elseif {[info exists child($act_category)]} {
+ ## put category and all children back on stack
+ set next [lreplace $next 2 2 $count]
+ set stack [linsert $stack 0 $next]
+ set stack [concat [lsort -integer -index 0 $child($act_category)] $stack]
+ } else {
+ ## this category has no children, so it is done
+ lappend done_list [list $act_category $count [expr $count + 1]]
+ incr count 1
+ }
+ incr count 1
+ }
+
+ 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
+ }
+
+ 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
+ }
+ }
+ }
+ category_tree::flush_cache $tree_id
+ }
+
+ if {$count != $last_ind} {
+ ad_return_complaint 1 "Error during update: $done_list"
+ return
+ }
+ ad_returnredirect "tree-view?[export_url_vars tree_id locale object_id]"
+ return
+
+} elseif {![empty_string_p $submit_phase_in]} {
+
+ db_transaction {
+ foreach category_id [array names check] {
+ category::phase_in $category_id
+ }
+ category_tree::flush_cache $tree_id
+ }
+
+ ad_returnredirect "tree-view?[export_url_vars tree_id locale object_id]"
+ return
+
+} elseif {![empty_string_p $submit_phase_out]} {
+
+ db_transaction {
+ foreach category_id [array names check] {
+ category::phase_out $category_id
+ }
+ category_tree::flush_cache $tree_id
+ }
+
+ ad_returnredirect "tree-view?[export_url_vars tree_id locale object_id]"
+ return
+
+} elseif {![empty_string_p $submit_delete]} {
+
+ set category_ids [array names check]
+ set page_title "Delete Confirmation Page"
+ set tree_name $tree(tree_name)
+
+ if {[info exists object_id]} {
+ set context_bar [list [category::get_object_context $object_id] [list "one-object?[export_url_vars locale object_id]" "Category Management"]]
+ } else {
+ set context_bar [list [list ".?[export_url_vars locale]" "Category Management"]]
+ }
+ lappend context_bar [list "tree-view?[export_url_vars tree_id locale object_id]" $tree_name] "Delete categories"
+
+ set form_vars_cancel [export_form_vars tree_id locale object_id]
+ set form_vars_delete [export_form_vars category_ids:multiple tree_id locale object_id]
+
+ template::multirow create categories category_id name used_p
+ 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_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
+ } {
+ set category_name [category::get_name $category_id $locale]
+ template::multirow append categories $category_id $category_name $used_p
+ }
+ }
+
+} else {
+
+ ns_log Warning "Unhandled user input in packages/categories/www/tree-update.tcl"
+ ad_returnredirect "tree-view?[export_url_vars tree_id locale object_id pass]"
+ return
+
+}
+
+ad_return_template
Index: openacs-4/packages/categories/www/cadmin/tree-update.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/tree-update.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-update.xql 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+ select category_id, parent_id
+ from categories
+ where tree_id = :tree_id
+ order by left_ind
+
+
+
+
+
+
+
+
+ update categories
+ set left_ind = -left_ind,
+ right_ind = -right_ind
+ where tree_id = :tree_id
+
+
+
+
+
+
+
+
+ update categories
+ set left_ind = :left_ind,
+ right_ind = :right_ind
+ where category_id = :category_id
+
+
+
+
+
+
+
+
+ insert into category_temp
+ values (:category_id)
+
+
+
+
+
+
Index: openacs-4/packages/categories/www/cadmin/tree-usage.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-usage.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-usage.adp 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,29 @@
+
+@page_title;noquote@
+@context_bar;noquote@
+@locale@
+
+
+
+ Tree Name @tree_name@
+ Description @tree_description@
+
+
+
+
+ @modules.package@: @modules.instance_name@
+
+
+ There are @instances_without_permission@ more uses of this tree, but you
+ don't have the permission to see them.
+
+
+ This tree is not used.
+
Index: openacs-4/packages/categories/www/cadmin/tree-usage.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-usage.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-usage.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,54 @@
+ad_page_contract {
+
+ This page shows all the package instanes mapped to a particular category tree.
+
+ @author Timo Hentschel (thentschel@sussdorff-roy.com)
+ @cvs-id $Id:
+} {
+ tree_id:integer,notnull
+ {locale ""}
+ object_id:integer,optional
+} -properties {
+ page_title:onevalue
+ context_bar:onevalue
+ locale:onevalue
+ tree_name:onevalue
+ tree_description:onevalue
+ modules:multirow
+ instances_without_permission:onevalue
+}
+
+set user_id [ad_maybe_redirect_for_registration]
+
+array set tree [category_tree::get_data $tree_id $locale]
+if {$tree(site_wide_p) == "f"} {
+ permission::require_permission -object_id $tree_id -privilege category_tree_read
+}
+
+set tree_name $tree(tree_name)
+set tree_description $tree(description)
+set page_title "Modules using Category Tree \"$tree_name\""
+
+if {[info exists object_id]} {
+ set context_bar [list [category::get_object_context $object_id] [list "one-object?[export_url_vars locale object_id]" "Category Management"]]
+} else {
+ set context_bar [list [list ".?[export_url_vars locale]" "Category Management"]]
+}
+lappend context_bar [list "tree-view?[export_url_vars tree_id locale object_id]" $tree_name] Usage
+
+
+template::multirow create modules package object_id object_name package_id instance_name read_p
+
+set instance_list [category_tree::usage $tree_id]
+
+set instances_without_permission 0
+foreach instance $instance_list {
+ util_unlist $instance package object_id object_name package_id instance_name read_p
+ if {$read_p == "t"} {
+ template::multirow append modules $package $object_id $object_name $package_id $instance_name $read_p
+ } else {
+ incr instances_without_permission
+ }
+}
+
+ad_return_template
Index: openacs-4/packages/categories/www/cadmin/tree-view-simple.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/tree-view-simple.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-view-simple.adp 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,15 @@
+
+@page_title;noquote@
+@context_bar;noquote@
+@locale@
+
+
+
+ Category Name
+
+
+
+ @tree.left_indent;noquote@ @tree.category_name@
+
+
+
Index: openacs-4/packages/categories/www/cadmin/tree-view-simple.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/Attic/tree-view-simple.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-view-simple.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,46 @@
+ad_page_contract {
+
+ Display a simple view of a category tree.
+
+ @author Timo Hentschel (thentschel@sussdorff-roy.com)
+ @cvs-id $Id:
+} {
+ tree_id:integer
+ target_tree_id:integer
+ {locale ""}
+ object_id:integer,optional
+} -properties {
+ page_title:onevalue
+ context_bar:onevalue
+ locale:onevalue
+ tree:multirow
+}
+
+set user_id [ad_maybe_redirect_for_registration]
+
+array set target_tree [category_tree::get_data $target_tree_id $locale]
+set target_tree_name $target_tree(tree_name)
+if {$target_tree(site_wide_p) == "f"} {
+ permission::require_permission -object_id $tree_id -privilege category_tree_read
+}
+array set one_tree [category_tree::get_data $tree_id $locale]
+set tree_name $one_tree(tree_name)
+
+set page_title "Simplified tree view"
+
+if {[info exists object_id]} {
+ set context_bar [list [category::get_object_context $object_id] [list "one-object?[export_url_vars locale object_id]" "Category Management"]]
+} else {
+ set context_bar [list [list ".?[export_url_vars locale]" "Category Management"]]
+}
+lappend context_bar [list "tree-view?[export_url_vars tree_id locale object_id]" $target_tree_name] [list "tree-copy?tree_id=$target_tree_id&[export_url_vars locale object_id]" "Copy a tree"] "View \"$tree_name\""
+
+template::multirow create tree category_name deprecated_p level left_indent
+
+foreach category [category_tree::get_tree -all $tree_id $locale] {
+ util_unlist $category category_id category_name deprecated_p level
+
+ template::multirow append tree $category_name $deprecated_p $level [category::repeat_string " " [expr ($level-1)*5]]
+}
+
+ad_return_template
Index: openacs-4/packages/categories/www/cadmin/tree-view.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-view.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-view.adp 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,98 @@
+
+@page_title;noquote@
+@context_bar;noquote@
+@locale@
+
+
+
+ Tree Name @tree_name@
+ Description @tree_description@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ no categories have been created...
+
Index: openacs-4/packages/categories/www/cadmin/tree-view.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-view.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-view.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,58 @@
+ad_page_contract {
+
+ Display a category tree
+
+ @author Timo Hentschel (thentschel@sussdorff-roy.com)
+ @cvs-id $Id:
+} {
+ tree_id:integer,notnull
+ {locale ""}
+ object_id:integer,optional
+} -properties {
+ page_title:onevalue
+ tree_name:onevalue
+ tree_description:onevalue
+ context_bar:onevalue
+ locale:onevalue
+ one_tree:multirow
+ form_vars:onevalue
+ url_vars:onevalue
+ can_grant_p:onevalue
+ can_write_p:onevalue
+}
+
+set user_id [ad_maybe_redirect_for_registration]
+
+array set tree [category_tree::get_data $tree_id $locale]
+if {$tree(site_wide_p) == "f"} {
+ permission::require_permission -object_id $tree_id -privilege category_tree_read
+}
+
+set url_vars [export_url_vars tree_id locale object_id]
+set form_vars [export_form_vars tree_id locale object_id]
+
+set tree_name $tree(tree_name)
+set tree_description $tree(description)
+
+set page_title "Category Tree \"$tree_name\""
+if {[info exists object_id]} {
+ set context_bar [list [category::get_object_context $object_id] [list "one-object?[export_url_vars locale object_id]" "Category Management"] $tree_name]
+} else {
+ set context_bar [list [list ".?[export_url_vars locale]" "Category Management"] $tree_name]
+}
+
+set can_write_p [permission::permission_p -object_id $tree_id -privilege category_tree_write]
+set can_grant_p [permission::permission_p -object_id $tree_id -privilege category_tree_grant_permissions]
+
+template::multirow create one_tree category_name sort_key category_id deprecated_p level left_indent
+
+set sort_key 0
+
+foreach category [category_tree::get_tree -all $tree_id $locale] {
+ util_unlist $category category_id category_name deprecated_p level
+ incr sort_key 10
+
+ template::multirow append one_tree $category_name $sort_key $category_id $deprecated_p $level [category::repeat_string " " [expr ($level-1)*5]]
+}
+
+ad_return_template
Index: openacs-4/packages/categories/www/doc/index.html
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/doc/index.html,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/doc/index.html 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,237 @@
+
+
+ Categories
+
+
+
+Categories
+
+Object Names and IdHandler Service Contract
+Functionality overview
+
+Categories are organized in separate category trees.
+
+When a package admin clicks on an Administer Categories link, they are presented with
+a page that shows the following items:
+
+
+ list of trees currently mapped to the object (this "object" will be usually a package
+ instance)
+ list of trees that can be mapped to the object ,
+ those trees are just the trees that the admin has the 'category_read' permission on
+ link to create and map a new category tree
+
+
+Creating a new tree involves entering tree name and description.
+The name must be unique among all the trees.
+
+Upon creation of a tree, the admin is granted the 'category_read' and 'category_write' permisssions.
+
+Normally, the category_write permission should not be shared with anybody else,
+in the rare cases when granting this permission to another party is needed,
+site-wide admin intervention will be required.
+
+In addition to mapping an entire tree to an object, admins have the option
+of mapping only a subtree of an existing tree. To do that, they have to click on
+a "Map subtree" link, after which they will see a list of tree nodes.
+ The mapped subtree will consist of all subcategories of the category
+the user selected - the category itself will not be included.
+Note that the mapped subtree will not be a new tree. Therefore
+this option should be used only if an admin plans to use the subtree 'as
+is' and has no intention of making changes to it.
+
+An alternative solution is available for admins who want to
+create a tree by copying one of the existing trees and subsequently
+playing around with it (moving/adding/deleting categories).
+To accomplish that, they would have to create a new tree,
+go to the admin page for this tree and click on a "Copy existing
+tree" link. They will see a list of available trees to copy. Clicking on the "Copy this one" link will result
+in creating copies of the categories from the source
+trees and placing them in the new tree.
+ This operation
+can be performed several times, each time the copied
+categories will be placed as toplevel categories of the tree.
+
+As far as unmapping is concerned, this operation
+doesn't delete the mapping between categories and objects.
+
+
+
+Permissions
+
The creator of the category tree is granted the category_tree_read, category_tree_write
+and category_tree_grant_permissions privileges.
+
+
+
+
+
+The operations one can perform on categories are:
+
+(a) changing of a parent
+ (b) adding childen
+ (c) deleting
+ (d) editing
+ (e) phasing in/out
+ (f) changing sort key
+
+
+ad (d) You cannot delete a category that has children.
+Also, you cannot delete a category that has objects mapped to it (do we want it or not?)
+
+ad (e) The effect of phasing out a category is that users no longer will be able to associate objects
+with it, but existing associations will still be visible
+
+Deletions and phasing it/out can be performed as bulk operations.
+
+ad (f) sort key is used to order children of the same parent category,
+that is the elements of the tree are sorted first by parent, then
+by the sort key.
+
+
+
+
+
+Datamodel
+
+This table actually stores the information whether the tree is side-wide or not.
+
+create table category_trees (
+ tree_id integer primary key
+ constraint cat_trees_tree_id_fk
+ references acs_objects on delete cascade,
+ site_wide_p char(1) default 't'
+ constraint cat_trees_site_wide_p_ck
+ check (site_wide_p in ('t','f'))
+);
+
+
+
+Here the tree's name and description is stored in different translations.
+
+create table category_tree_translations (
+ tree_id integer
+ constraint cat_tree_trans_tree_id_fk
+ references category_trees on delete cascade,
+ locale varchar2(5) not null
+ constraint cat_tree_trans_locale_fk
+ references ad_locales,
+ name varchar2(50) not null,
+ description varchar2(1000),
+ primary key (tree_id, locale)
+);
+
+
+
+This table stores the tree hierarchy by holding the information about
+the parent category. The tree is ordered by a nested index (left_ind, right_ind).
+
+create table categories (
+ category_id integer primary key
+ constraint cat_category_id_fk
+ references acs_objects on delete cascade,
+ tree_id integer
+ constraint cat_tree_id_fk
+ references category_trees on delete cascade,
+ parent_id integer
+ constraint cat_parent_id_fk
+ references categories,
+ deprecated_p char(1) default 'f'
+ constraint cat_deprecated_p_ck
+ check (deprecated_p in ('t','f')),
+ left_ind integer,
+ right_ind integer
+);
+
+
+
+Here the actual categories are stored together with different translations.
+
+create table category_translations (
+ category_id integer
+ constraint cat_trans_category_id_fk
+ references categories on delete cascade,
+ locale varchar2(5) not null
+ constraint cat_trans_locale_fk
+ references ad_locales,
+ name varchar2(200),
+ description varchar2(4000),
+ primary key (category_id, locale)
+);
+
+
+
+This table contains mapping between categories and objects
+
+create table category_object_map (
+ category_id integer
+ constraint cat_object_map_category_id_fk
+ references categories on delete cascade,
+ object_id integer
+ constraint cat_object_map_object_id_fk
+ references acs_objects on delete cascade,
+ primary key (object_id, category_id)
+) organization index;
+
+
+
+This is the table for the relation of trees and objects.
+subtree_category_id comes to play in situations when you
+map a subtree of an existing tree to an object.
+
+create table category_tree_map (
+ tree_id integer
+ constraint cat_tree_map_tree_id_fk
+ references category_trees on delete cascade,
+ object_id integer
+ constraint cat_tree_map_object_id_fk
+ references acs_objects on delete cascade,
+ subtree_category_id integer default null
+ constraint cat_tree_map_subtree_id_fk
+ references categories,
+ primary key (object_id, tree_id)
+) organization index;
+
+
+
+Known Limitations
+
+The tree order is the same for all translations.
+You can map a tree only once to a package (or other object).
+The number of objects mapped to a category is not shown yet.
+These results should be cached.
+When browsing categories all mapped categories should be shown
+for each object.
+There should be browsing widget easily used by other packages
+to let the user browse through all categorized objects.
+
+
+
+Integration with other packages
+
Here are the changes needed to be made to integrate with other packages.
+
+
+index.adp
+ Provide an admin-link to
+/categories/cadmin/one-object?object_id=@package_id@ to let admins
+map trees to the package instance.
+
+
+form-page.tcl
+ Use this in ad_form to display all mapped category trees and
+selected categories (if editing an object):
+
+ {category_ids:integer(category),multiple,optional {label "Categories"}
+ {html {size 4}} {value {$object_id $package_id}}}
+
+Alternatively, you can include the following in your adp:
+
+
+In the processing part of ad_form use:
+
+category::map_object -remove_old -object_id $object_id $category_ids
+
+
+
+timo@studio-k4.de
+
+
Index: openacs-4/packages/categories/www/doc/o.html
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/doc/o.html,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/doc/o.html 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,192 @@
+
+
+ Object Names and IdHandler Service Contract
+
+
+
+Object Names and IdHandler Service Contract
+
+
+Object Names
+
+When presenting a list of objects in a package not native to the
+objects (i.e. permissioning, community-member, category-usage)
+there has to be a fast and easy way to figure out the name of
+objects. Until now, this has been done by using something like
+
+acs_objects.name(object_id)
+
+which essential means that for every object to be displayed
+(and since the mentioned pages are in no means scalable and
+therefore are likely to display a huge amount of objects)
+this pl/sql proc will have to figure out which package-specific
+pl/sql proc to call which itself will do at least one query
+to get the object-name.
+
+Obviously, this is highly undesirable since it is not scalable
+at all. Therefore, a new way had to be found to get the name
+of an object:
+
+-------------------
+-- NAMED OBJECTS --
+-------------------
+
+create table acs_named_objects (
+ object_id integer not null
+ constraint acs_named_objs_pk primary key
+ constraint acs_named_objs_object_id_fk
+ references acs_objects(object_id) on delete cascade,
+ object_name varchar2(200),
+ package_id integer
+ constraint acs_named_objs_package_id_fk
+ references apm_packages(package_id) on delete cascade
+);
+
+create index acs_named_objs_name_ix on acs_named_objects (substr(upper(object_name),1,1));
+create index acs_named_objs_package_ix on acs_named_objects(package_id);
+
+begin
+ acs_object_type.create_type (
+ supertype => 'acs_object',
+ object_type => 'acs_named_object',
+ pretty_name => 'Named Object',
+ pretty_plural => 'Named Objects',
+ table_name => 'acs_named_objects',
+ id_column => 'object_id'
+ );
+end;
+/
+show errors
+
+
+This means that every displayable object-type should no longer be
+derived from acs_objects, but from acs_named_objects and that
+by using triggers or extending the appropriate pl/sql procs,
+every displayable object (certainly not acs_rels or something the
+like) should have an evtry in that extension of the acs_objects table.
+
+In that way, when having to display a list of objects, one can simply
+join the acs_named_objects table to get the names and package_ids
+in an easy and - more importantly - fast and scalable way.
+
+The only shortcomming of this solution is the disregard of
+internationalization, but in cases where there objects in more
+than one language, it should be the triggers / pl/sql procs task
+to make sure that acs_named_objects contains names in the
+default language if possible.
+
+
+
IdHandler Service Contract
+
+Besides displaying the names of objects, some pages also want to
+provide links to the objects. Unfortunately, there currently is no
+way to do so.
+
+First, we need to know that package_id of the package
+responsible for the object. This information is currently impossible
+to get since we would need to go up the context hierarchy until we
+finally get hold of an apm_package object. But lets assume we
+get this information by using the new acs_named_objects
+table, then we would need to figure out the url to that
+package instance. This can be done, but again by calling a
+highly unefficient pl/sql proc. But even then we would need the
+local url to the page being able to display a certain object.
+Since a package may have more than one type of objects (i.e. file folders,
+files, file versions), we can not simply store additional
+package information about which page to call to display an object.
+
+The solution to this kind of problem is by not resolving the url
+at all during display-time, but doing so at the time the user
+actually wants to see an object. The links would simply direct
+to /o/$object_id, which is a global virtual-url-handling page
+that will figure out the package instance url (by using
+acs_named_objects and the pl/sql proc) and then relying
+upon a Service Contract to get the local url - that means every
+package holding displayable objects should implement this
+interface for its objects:
+
+
+declare
+ v_id integer;
+begin
+ v_id := acs_sc_contract.new(
+ contract_name => 'AcsObject',
+ contract_desc => 'Acs Object Id Handler'
+ );
+ v_id := acs_sc_msg_type.new(
+ msg_type_name => 'AcsObject.PageUrl.InputType',
+ msg_type_spec => 'object_id:integer'
+ );
+ v_id := acs_sc_msg_type.new(
+ msg_type_name => 'AcsObject.PageUrl.OutputType',
+ msg_type_spec => 'page_url:string'
+ );
+ v_id := acs_sc_operation.new(
+ contract_name => 'AcsObject',
+ operation_name => 'PageUrl',
+ operation_desc => 'Returns the package specific url to a page
+that displays an object',
+ operation_iscachable_p => 'f',
+ operation_nargs => 1,
+ operation_inputtype => 'AcsObject.PageUrl.InputType',
+ operation_outputtype => 'AcsObject.PageUrl.OutputType'
+ );
+
+ v_id := acs_sc_impl.new (
+ 'AcsObject',
+ 'apm_package_idhandler',
+ 'acs-kernel'
+ );
+ v_id := acs_sc_impl.new_alias (
+ 'AcsObject',
+ 'apm_package_idhandler',
+ 'PageUrl',
+ 'apm_pageurl',
+ 'TCL'
+ );
+ acs_sc_binding.new (
+ contract_name => 'AcsObject',
+ impl_name => 'apm_package_idhandler'
+ );
+
+ v_id := acs_sc_impl.new (
+ 'AcsObject',
+ 'user_idhandler',
+ 'acs-kernel'
+ );
+ v_id := acs_sc_impl.new_alias (
+ 'AcsObject',
+ 'user_idhandler',
+ 'PageUrl',
+ 'acs_user::pageurl',
+ 'TCL'
+ );
+ acs_sc_binding.new (
+ contract_name => 'AcsObject',
+ impl_name => 'user_idhandler'
+ );
+end;
+
+The appropriate tcl-procs look like the following:
+
+ad_proc -public apm_pageurl { object_id } {
+ Service Contract Proc to resolve a url for a package_id
+} {
+ return
+}
+
+namespace eval acs_user {
+ ad_proc -public pageurl { object_id } {
+ Service Contract Proc to resolve a url for a user_id
+ } {
+ return "shared/community-member?user_id=$object_id"
+ }
+}
+
+Note that the name of the implementation has to be the object-type
+followed by _idhandler.
+
+
+timo@studio-k4.de
+
+
Index: openacs-4/packages/categories/www/include/widget.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/include/widget.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/include/widget.adp 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,10 @@
+
+
+ @trees.tree_name@:
+
+
+ selected >@trees.indent;noquote@@trees.category_name@
+
+
+
+
Index: openacs-4/packages/categories/www/include/widget.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/include/widget.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/include/widget.tcl 23 Apr 2003 12:29:27 -0000 1.1
@@ -0,0 +1,31 @@
+#
+# author: Timo Hentschel (thentschel@sussdorff-roy.com)
+#
+
+if {![info exists object_id]} {
+ set object_id 0
+}
+if {![info exists package_id]} {
+ set package_id [ad_conn package_id]
+}
+if {![info exists name]} {
+ set name category_ids
+}
+
+template::multirow create trees tree_id tree_name category_id selected_p category_name indent
+
+template::util::list_to_lookup [category::get_mapped_categories $object_id] mapped
+
+foreach tree [category_tree::get_mapped_trees $package_id] {
+ util_unlist $tree tree_id tree_name subtree_id
+ set one_tree [list]
+ foreach category [category_tree::get_tree -subtree_id $subtree_id $tree_id] {
+ util_unlist $category category_id category_name deprecated_p level
+ set indent ""
+ if {$level>1} {
+ set indent "[category::repeat_string " " [expr 2*$level -4]].."
+ }
+ set selected_p [info exists mapped($category_id)]
+ template::multirow append trees $tree_id $tree_name $category_id $selected_p $category_name $indent
+ }
+}