Index: openacs-4/packages/acs-subsite/www/admin/applications/index-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/admin/applications/index-postgresql.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-subsite/www/admin/applications/index-postgresql.xql 7 Aug 2017 23:47:58 -0000 1.3 +++ openacs-4/packages/acs-subsite/www/admin/applications/index-postgresql.xql 21 Oct 2018 17:36:23 -0000 1.4 @@ -5,50 +5,47 @@ - - select n.node_id - from site_nodes n, - site_nodes np, - apm_packages p - left outer join lang_messages m - on m.locale = :locale and - '#' || m.package_key || '.' || m.message_key || '#' = p.instance_name - left outer join lang_messages md - on m.locale = 'en_US' and - '#' || md.package_key || '.' || md.message_key || '#' = p.instance_name, - apm_package_types pt - where np.node_id = :subsite_node_id - and n.tree_sortkey between np.tree_sortkey and tree_right(np.tree_sortkey) - and p.package_id = n.object_id - and pt.package_key = p.package_key - [template::list::filter_where_clauses -and -name applications] - order by n.tree_sortkey - + select node_id from ( + WITH RECURSIVE site_node_tree AS ( + select node_id, parent_id, name, object_id from site_nodes where node_id = :subsite_node_id + UNION ALL + select c.node_id, c.parent_id, c.name, c.object_id from site_node_tree tree, site_nodes as c + where c.parent_id = tree.node_id + ) + select n.node_id, n.parent_id, n.name, site_node__url(n.node_id) as url + from site_node_tree n, apm_packages p + left outer join lang_messages m + on m.locale = 'en_US' and + '#' || m.package_key || '.' || m.message_key || '#' = p.instance_name + left outer join lang_messages md + on m.locale = 'en_US' and + '#' || md.package_key || '.' || md.message_key || '#' = p.instance_name, + apm_package_types pt + where p.package_id = n.object_id + and pt.package_key = p.package_key + [template::list::filter_where_clauses -and -name applications] + order by url) node_tree - - select n.node_id, - n.name, - p.package_id, - p.instance_name, - tree_level(n.tree_sortkey) - tree_level(np.tree_sortkey) as treelevel, - pt.pretty_name as package_pretty_name, - exists (select 1 from apm_parameters - where package_key = pt.package_key) as parameters_p - from site_nodes n, - site_nodes np, - apm_packages p, - apm_package_types pt - where np.node_id = :subsite_node_id - and n.tree_sortkey between np.tree_sortkey and tree_right(np.tree_sortkey) - and p.package_id = n.object_id - and pt.package_key = p.package_key - and [template::list::page_where_clause -name applications -key n.node_id] - order by n.tree_sortkey - + select + node_id, name, package_id, instance_name, package_pretty_name, parameters_p, + (char_length(url)-char_length(replace(url, '/', ''))-1) as treelevel + from ( + select n.node_id, + n.name, + p.package_id, + p.instance_name, + site_node__url(n.node_id) as url, + pt.pretty_name as package_pretty_name, + exists (select 1 from apm_parameters where package_key = pt.package_key) as parameters_p + from site_nodes n, apm_packages p, apm_package_types pt + where p.package_id = n.object_id + and pt.package_key = p.package_key + and [template::list::page_where_clause -name applications -key n.node_id] + ) sm0 order by url Index: openacs-4/packages/acs-subsite/www/admin/site-map/index-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/admin/site-map/index-postgresql.xql,v diff -u -r1.14 -r1.15 --- openacs-4/packages/acs-subsite/www/admin/site-map/index-postgresql.xql 7 Aug 2017 23:47:58 -0000 1.14 +++ openacs-4/packages/acs-subsite/www/admin/site-map/index-postgresql.xql 21 Oct 2018 17:36:23 -0000 1.15 @@ -3,21 +3,6 @@ postgresql7.1 - - - select s2.node_id, - s2.name, - s2.directory_p, - tree_level(s2.tree_sortkey) as level, - acs_object__name(s2.object_id) as obj_name, - acs_permission__permission_p(s2.object_id, :user_id, 'admin') as admin_p - from (select tree_ancestor_keys(site_node_get_tree_sortkey(:root_id)) as tree_sortkey) parents, - site_nodes s2 - where s2.tree_sortkey = parents.tree_sortkey - order by level - - - postgresql8.4 @@ -30,41 +15,46 @@ p.instance_name as object_name, acs_permission__permission_p(object_id, :user_id, 'admin') as object_admin_p from apm_packages p join apm_package_types using (package_key) right outer join - (select n.node_id, + (WITH RECURSIVE site_node_path AS ( + select node_id, parent_id + from site_nodes where node_id = :root_id + UNION ALL + select c.node_id, c.parent_id + from site_node_path p, site_nodes as c where c.node_id = p.parent_id + ) + select sm0.*, (char_length(url)-char_length(replace(url, '/', ''))-1) as mylevel + from (select distinct n.node_id, site_node__url(n.node_id) as url, site_node__url(n.parent_id) as parent_url, n.name, case when exists (select 1 from site_nodes where parent_id = n.node_id) then 1 else 0 end as n_children, - case when n.node_id = (select site_node__node_id('/', null)) then 1 else 0 end as root_p, - (tree_level(n.tree_sortkey) - (select tree_level(n2.tree_sortkey) from site_nodes n2 where n2.node_id = (select coalesce(:root_id, site_node__node_id('/', null))))) as mylevel, + case when n.parent_id is NULL then 1 else 0 end as root_p, n.object_id, n.directory_p, n.parent_id - from site_nodes n, site_nodes n2 - where (n.object_id is null - or acs_permission__permission_p(n.object_id, :user_id, 'read')) - and n2.node_id = (select coalesce(:root_id, site_node__node_id('/', null))) - and n.tree_sortkey between n2.tree_sortkey and tree_right(n2.tree_sortkey) - and (n.parent_id is null or n.parent_id in ([join $expand ", "]))) site_map + from site_nodes n, site_node_path path + where (n.object_id is null or acs_permission__permission_p(n.object_id, :user_id, 'read')) + and (n.node_id = path.node_id or n.parent_id in ([join $expand ", "]))) sm0) as site_map on site_map.object_id = p.package_id $where_limit order by url + postgresql8.4 - With apm_services AS ( + WITH apm_services AS ( select package_id, - ap.package_key, - ap.instance_name, - apm_package_type__num_parameters(ap.package_key) as parameter_count - from apm_packages ap, - apm_package_types - where ap.package_key = apm_package_types.package_key - and package_type = 'apm_service' - and not exists (select 1 from site_nodes sn where sn.object_id = package_id) + ap.package_key, + ap.instance_name, + apm_package_type__num_parameters(ap.package_key) as parameter_count + from apm_packages ap, + apm_package_types + where ap.package_key = apm_package_types.package_key + and package_type = 'apm_service' + and not exists (select 1 from site_nodes sn where sn.object_id = package_id) order by instance_name ) select * from apm_services where acs_permission__permission_p(package_id, :user_id, 'admin') Index: openacs-4/packages/acs-subsite/www/admin/site-map/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/admin/site-map/index.tcl,v diff -u -r1.33 -r1.34 --- openacs-4/packages/acs-subsite/www/admin/site-map/index.tcl 9 May 2018 15:33:28 -0000 1.33 +++ openacs-4/packages/acs-subsite/www/admin/site-map/index.tcl 21 Oct 2018 17:36:23 -0000 1.34 @@ -76,31 +76,10 @@ set where_limit "" } -db_foreach path_select {} { - if {$node_id != $root_id && $admin_p == "t"} { - append head [subst {}] - } - if {$name eq ""} { - append head "$obj_name:" - } else { - append head $name - } - - if {$node_id != $root_id && $admin_p == "t"} { - append head "" - } - - if {$directory_p == "t"} { - append head "/" - } -} if_no_rows { - append head " " -} - if {[llength $expand] == 0} { lappend expand $root_id if { $parent_id ne "" } { - lappend expand $parent_id + #lappend expand $parent_id } } @@ -208,6 +187,7 @@ rename_url delete_url parameters_url permissions_url extra_form_part delete_id set open_nodes [list] +set open_nodes [list $root_id] db_foreach nodes_select {} { set add_folder_url "" @@ -219,8 +199,13 @@ set parameters_url "" set permissions_url "" - if { $parent_id ni $open_nodes && $parent_id ne "" && $mylevel > 2 } { continue } - + if { $parent_id ni $open_nodes && $parent_id ne "" && $mylevel > 2 } { + continue + } + if {$name eq ""} { + set name "/" + } + if {$directory_p == "t"} { set add_folder_url [export_vars -base . {expand:multiple root_id node_id {new_parent $node_id} {new_type folder}}] if {$object_id eq ""} { @@ -257,6 +242,12 @@ append indent " " } + # + # Values for expand_mode: + # 0: no children + # 1: has children, node is not open + # 2: has chilren, node is open + # set expand_mode 0 if {!$root_p && $n_children > 0} { set expand_mode 1 @@ -281,7 +272,8 @@ set expand_url "" } - set name_url [export_vars -base . {expand:multiple {root_id $node_id}}] + #set name_url [export_vars -base . {expand:multiple {root_id $node_id}}] + set name_url [export_vars -base . {{root_id $node_id}}] set action_type 0 set action_form_part "" @@ -310,7 +302,8 @@ set action_form_part [export_vars -form {expand:multiple parent_id node_type root_id}] } set delete_id delete-$node_id - + + ns_log notice "append name <$name> name_url <$name_url> expand_mode $expand_mode" multirow append nodes \ $node_id $expand_mode $expand_url $indent $name $name_url $object_name $url $package_pretty_name \ $action_type $action_form_part $add_folder_url $new_app_url $unmount_url $mount_url \ Index: openacs-4/packages/acs-subsite/www/admin/site-map/site-map-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/admin/site-map/site-map-postgresql.xql,v diff -u -r1.4 -r1.5 --- openacs-4/packages/acs-subsite/www/admin/site-map/site-map-postgresql.xql 7 Aug 2017 23:47:58 -0000 1.4 +++ openacs-4/packages/acs-subsite/www/admin/site-map/site-map-postgresql.xql 21 Oct 2018 17:36:23 -0000 1.5 @@ -5,16 +5,18 @@ - select s2.node_id, - s2.name, - s2.directory_p, - tree_level(s2.tree_sortkey) as level, - acs_object__name(s2.object_id) as obj_name, - acs_permission__permission_p(s2.object_id, :user_id, 'admin') as admin_p - from (select tree_ancestor_keys(site_node_get_tree_sortkey(:root_id)) as tree_sortkey) parents, - site_nodes s2 - where s2.tree_sortkey = parents.tree_sortkey - order by level + WITH RECURSIVE site_node_path AS ( + select node_id, parent_id, name, object_id, directory_p, 1 as level + from site_nodes where node_id = :root_id + UNION ALL + select c.node_id, c.parent_id, c.name, c.object_id, c.directory_p, p.level+1 + from site_node_path p, site_nodes as c where c.node_id = p.parent_id + ) + select + node_id, name, directory_p, level, + acs_object__name(object_id) as obj_name, + acs_permission__permission_p(object_id, :user_id, 'admin') as admin_p + from site_node_path order by level desc @@ -29,29 +31,33 @@ directory_p, parent_id, n_children, p.instance_name as object_name, acs_permission__permission_p(object_id, :user_id, 'admin') as object_admin_p, - (select view_p from site_nodes_selection where node_id=site_map.node_id) as view_p + (select view_p from site_nodes_selection where node_id=site_map.node_id) as view_p from apm_packages p join apm_package_types using (package_key) right outer join - (select n.node_id, + (WITH RECURSIVE site_node_path AS ( + select node_id, parent_id + from site_nodes where node_id = :root_id + UNION ALL + select c.node_id, c.parent_id + from site_node_path p, site_nodes as c where c.node_id = p.parent_id + ) + select sm0.*, (char_length(url)-char_length(replace(url, '/', ''))-1) as mylevel + from (select distinct n.node_id, site_node__url(n.node_id) as url, site_node__url(n.parent_id) as parent_url, n.name, case when exists (select 1 from site_nodes where parent_id = n.node_id) then 1 else 0 end as n_children, - case when n.node_id = (select site_node__node_id('/', null)) then 1 else 0 end as root_p, - (tree_level(n.tree_sortkey) - (select tree_level(n2.tree_sortkey) from site_nodes n2 where n2.node_id = (select coalesce(:root_id, site_node__node_id('/', null))))) as mylevel, + case when n.parent_id is NULL then 1 else 0 end as root_p, n.object_id, n.directory_p, n.parent_id - from site_nodes n, site_nodes n2 - where (n.object_id is null - or acs_permission__permission_p(n.object_id, :user_id, 'read')) - and n2.node_id = (select coalesce(:root_id, site_node__node_id('/', null))) - and n.tree_sortkey between n2.tree_sortkey and tree_right(n2.tree_sortkey) - and (n.parent_id is null or n.parent_id in ([join $expand ", "]))) site_map + from site_nodes n, site_node_path path + where (n.object_id is null or acs_permission__permission_p(n.object_id, :user_id, 'read')) + and (n.node_id = path.node_id or n.parent_id in ([join $expand ", "]))) sm0) as site_map on site_map.object_id = p.package_id order by url - + postgresql8.4 Index: openacs-4/packages/acs-subsite/www/admin/site-map/site-map.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/admin/site-map/site-map.tcl,v diff -u -r1.15 -r1.16 --- openacs-4/packages/acs-subsite/www/admin/site-map/site-map.tcl 9 May 2018 15:33:28 -0000 1.15 +++ openacs-4/packages/acs-subsite/www/admin/site-map/site-map.tcl 21 Oct 2018 17:36:23 -0000 1.16 @@ -50,6 +50,11 @@ set user_id [ad_conn user_id] +# +# Build a clickable path named "head" displayed above the site node +# table. +# +set head "" db_foreach path_select {} { if {$node_id != $root_id && $admin_p == "t"} { set href [export_vars -base . {expand:multiple {root_id $node_id}}] @@ -72,6 +77,7 @@ append head " " } + if {[llength $expand] == 0} { lappend expand $root_id if { $parent_id ne "" } { @@ -168,7 +174,10 @@ } } -multirow create nodes node_id expand_mode expand_url tree_indent name name_url instance instance_url type action_type action_form_part add_folder_url new_app_url unmount_url mount_url rename_url delete_url parameters_url permissions_url extra_form_part view_p +multirow create nodes \ + node_id expand_mode expand_url tree_indent name name_url instance instance_url \ + type action_type action_form_part add_folder_url new_app_url unmount_url mount_url \ + rename_url delete_url parameters_url permissions_url extra_form_part view_p set open_nodes [list] db_foreach nodes_select {} { @@ -281,7 +290,11 @@ set action_form_part [export_vars -form {expand:multiple parent_id node_type root_id}] } - multirow append nodes $node_id $expand_mode $expand_url $indent $name $name_url $object_name $url $package_pretty_name $action_type $action_form_part $add_folder_url $new_app_url $unmount_url $mount_url $rename_url $delete_url $parameters_url $permissions_url "" $view_p + multirow append nodes \ + $node_id $expand_mode $expand_url $indent $name $name_url $object_name \ + $url $package_pretty_name $action_type $action_form_part $add_folder_url \ + $new_app_url $unmount_url $mount_url $rename_url $delete_url $parameters_url \ + $permissions_url "" $view_p }