Index: openacs-4/packages/acs-subsite/tcl/subsite-procs-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/subsite-procs-oracle.xql,v
diff -u -r1.8 -r1.9
--- openacs-4/packages/acs-subsite/tcl/subsite-procs-oracle.xql 25 Nov 2008 17:08:50 -0000 1.8
+++ openacs-4/packages/acs-subsite/tcl/subsite-procs-oracle.xql 17 Mar 2009 01:11:07 -0000 1.9
@@ -84,20 +84,5 @@
and rownum < 2
-
-
-
- select apm_parameter_value.new(
- package_id => :subsite_id,
- parameter_id => ap.parameter_id,
- value => ap.default_value)
- from apm_parameters ap
- where ap.package_key = :new_package_key
- and not exists (select 1
- from apm_parameters ap2
- where ap2.package_key = :old_package_key
- and ap2.parameter_name = ap.parameter_name)
-
-
Index: openacs-4/packages/acs-subsite/tcl/subsite-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/subsite-procs-postgresql.xql,v
diff -u -r1.10 -r1.11
--- openacs-4/packages/acs-subsite/tcl/subsite-procs-postgresql.xql 25 Nov 2008 17:08:50 -0000 1.10
+++ openacs-4/packages/acs-subsite/tcl/subsite-procs-postgresql.xql 17 Mar 2009 01:11:07 -0000 1.11
@@ -88,16 +88,4 @@
-
-
- select apm_parameter_value__new(null, :subsite_id, ap.parameter_id, ap.default_value)
- from apm_parameters ap
- where ap.package_key = :new_package_key
- and not exists (select 1
- from apm_parameters ap2
- where ap2.package_key = :old_package_key
- and ap2.parameter_name = ap.parameter_name)
-
-
-
Index: openacs-4/packages/acs-subsite/tcl/subsite-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/subsite-procs.tcl,v
diff -u -r1.42 -r1.43
--- openacs-4/packages/acs-subsite/tcl/subsite-procs.tcl 25 Nov 2008 17:08:50 -0000 1.42
+++ openacs-4/packages/acs-subsite/tcl/subsite-procs.tcl 17 Mar 2009 01:11:07 -0000 1.43
@@ -1072,66 +1072,3 @@
} {
return [db_list_of_lists get {}]
}
-
-ad_proc -public subsite::util::get_package_descendent_options {
- package_key
-} {
- Get a list of pretty name, package key pairs for all subsite packages which are descendents
- of the given package key.
-
- @param package_key The parent package's key.
- @return a list of pretty name, package key pairs suitable for use in a template
- select widget.
-} {
- set in_clause '[join [apm_package_descendents $package_key] ',']'
- return [db_list_of_lists get {}]
-}
-
-ad_proc -public subsite::util::convert_type {
- -subsite_id
- -old_package_key
- -new_package_key:required
-} {
- Convert a subsite to a new type, doing the proper instantiate and mount callbacks and
- parameter creation.
-
- @param subsite_id The package id of the subsite to convert (default current subsite)
- @param old_package_key The package key we're converting from (default current package key)
- @param new_package_key The new subsite type we're converting to (required)
-
-} {
- if { ![info exists subsite_id] } {
- set subsite_id [ad_conn subsite_id]
- }
-
- if { ![info exists old_package_key] } {
- set old_package_key [ad_conn package_key]
- }
-
- set node_id [site_node::get_node_id_from_object_id -object_id $subsite_id]
-
- db_dml update_package_key {}
- site_node::update_cache -node_id $node_id
-
- db_foreach get_params {} {
- db_1row get_new_parameter_id {}
- db_dml update_param {}
- }
- db_list copy_new_params {}
- apm_parameter_sync $new_package_key $subsite_id
-
- foreach inherited_package_key [apm_package_inherit_order $new_package_key] {
- if { [lsearch -exact [apm_package_inherit_order $old_package_key] $inherited_package_key]
- == -1 } {
- apm_invoke_callback_proc \
- -package_key $inherited_package_key \
- -type after-instantiate \
- -arg_list [list package_id $subsite_id]
- apm_invoke_callback_proc \
- -package_key $inherited_package_key \
- -type after-mount \
- -arg_list [list node_id $node_id package_id $subsite_id]
- }
- }
-
-}
Index: openacs-4/packages/acs-subsite/tcl/subsite-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/Attic/subsite-procs.xql,v
diff -u -r1.11 -r1.12
--- openacs-4/packages/acs-subsite/tcl/subsite-procs.xql 3 Dec 2008 14:50:32 -0000 1.11
+++ openacs-4/packages/acs-subsite/tcl/subsite-procs.xql 17 Mar 2009 01:11:07 -0000 1.12
@@ -115,48 +115,4 @@
-
-
- select pretty_name, package_key
- from apm_package_types
- where implements_subsite_p = 't'
- and package_key in ($in_clause)
- order by pretty_name
-
-
-
-
-
- update apm_packages
- set package_key = :new_package_key
- where package_id = :subsite_id
-
-
-
-
-
- select parameter_name, parameter_id
- from apm_parameters
- where package_key = :old_package_key
-
-
-
-
-
- select parameter_id as new_parameter_id
- from apm_parameters
- where package_key = :new_package_key
- and parameter_name = :parameter_name
-
-
-
-
-
- update apm_parameter_values
- set parameter_id = :new_parameter_id
- where parameter_id = :parameter_id
- and package_id = :subsite_id
-
-
-
Index: openacs-4/packages/acs-subsite/www/admin/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/admin/index.tcl,v
diff -u -r1.17 -r1.18
--- openacs-4/packages/acs-subsite/www/admin/index.tcl 25 Nov 2008 17:08:50 -0000 1.17
+++ openacs-4/packages/acs-subsite/www/admin/index.tcl 17 Mar 2009 01:11:07 -0000 1.18
@@ -24,4 +24,4 @@
set acs_admin_name $acs_admin_node(instance_name)
set sw_admin_p [permission::permission_p -party_id [ad_conn user_id] -object_id $acs_admin_node(object_id) -privilege admin]
-set convert_subsite_p [expr { [llength [subsite::util::get_package_descendent_options [ad_conn package_key]]] > 0 }]
+set convert_subsite_p [expr { [llength [apm::get_package_descendent_options [ad_conn package_key]]] > 0 }]
Index: openacs-4/packages/acs-subsite/www/admin/subsite-convert-type.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/admin/subsite-convert-type.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/acs-subsite/www/admin/subsite-convert-type.tcl 26 Nov 2008 11:27:29 -0000 1.1
+++ openacs-4/packages/acs-subsite/www/admin/subsite-convert-type.tcl 17 Mar 2009 01:11:07 -0000 1.2
@@ -11,7 +11,7 @@
set context [list $page_title]
-set subsite_package_options [subsite::util::get_package_descendent_options [ad_conn package_key]]
+set subsite_package_options [apm::get_package_descendent_options [ad_conn package_key]]
if { [llength $subsite_package_options] == 0 } {
return .
@@ -26,7 +26,10 @@
}
} -on_submit {
if { $package_key ne [ad_conn package_key] } {
- subsite::util::convert_type -new_package_key $package_key
+ apm::convert_type \
+ -package_id [ad_conn package_id] \
+ -old_package_key [ad_conn package_key] \
+ -new_package_key $package_key
}
ad_returnredirect .
ad_script_abort
Index: openacs-4/packages/acs-tcl/tcl/apm-procs-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-procs-oracle.xql,v
diff -u -r1.14 -r1.15
--- openacs-4/packages/acs-tcl/tcl/apm-procs-oracle.xql 25 Nov 2008 17:08:49 -0000 1.14
+++ openacs-4/packages/acs-tcl/tcl/apm-procs-oracle.xql 17 Mar 2009 01:11:07 -0000 1.15
@@ -200,5 +200,19 @@
+
+
+ select apm_parameter_value.new(
+ package_id => :package_id,
+ parameter_id => ap.parameter_id,
+ value => ap.default_value)
+ from apm_parameters ap
+ where ap.package_key = :new_package_key
+ and not exists (select 1
+ from apm_parameters ap2
+ where ap2.package_key = :old_package_key
+ and ap2.parameter_name = ap.parameter_name)
+
+
Index: openacs-4/packages/acs-tcl/tcl/apm-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-procs-postgresql.xql,v
diff -u -r1.15 -r1.16
--- openacs-4/packages/acs-tcl/tcl/apm-procs-postgresql.xql 25 Nov 2008 17:08:50 -0000 1.15
+++ openacs-4/packages/acs-tcl/tcl/apm-procs-postgresql.xql 17 Mar 2009 01:11:07 -0000 1.16
@@ -180,5 +180,16 @@
+
+
+ select apm_parameter_value__new(null, :package_id, ap.parameter_id, ap.default_value)
+ from apm_parameters ap
+ where ap.package_key = :new_package_key
+ and not exists (select 1
+ from apm_parameters ap2
+ where ap2.package_key = :old_package_key
+ and ap2.parameter_name = ap.parameter_name)
+
+
Index: openacs-4/packages/acs-tcl/tcl/apm-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-procs.tcl,v
diff -u -r1.81 -r1.82
--- openacs-4/packages/acs-tcl/tcl/apm-procs.tcl 23 Dec 2008 01:08:26 -0000 1.81
+++ openacs-4/packages/acs-tcl/tcl/apm-procs.tcl 17 Mar 2009 01:11:07 -0000 1.82
@@ -1982,3 +1982,62 @@
return [array get metrics]
}
+ad_proc -public apm::get_package_descendent_options {
+ package_key
+} {
+ Get a list of pretty name, package key pairs for all packages which are descendents
+ of the given package key.
+
+ @param package_key The parent package's key.
+ @return a list of pretty name, package key pairs suitable for use in a template
+ select widget.
+} {
+ set in_clause '[join [apm_package_descendents $package_key] ',']'
+ return [db_list_of_lists get {}]
+}
+
+
+ad_proc -public apm::convert_type {
+ -package_id:required
+ -old_package_key:required
+ -new_package_key:required
+} {
+ Convert a package instance to a new type, doing the proper instantiate and mount callbacks and
+ parameter creation.
+
+ @param package_id The package instance to convert.
+ @param old_package_key The package key we're converting from.
+ @param new_package_key The new subsite type we're converting to.
+
+} {
+ db_dml update_package_key {}
+
+ set node_id [site_node::get_node_id_from_object_id -object_id $package_id]
+ if { $node_id ne "" } {
+ site_node::update_cache -node_id $node_id
+ }
+
+ db_foreach get_params {} {
+ db_1row get_new_parameter_id {}
+ db_dml update_param {}
+ }
+ db_list copy_new_params {}
+ apm_parameter_sync $new_package_key $package_id
+
+ foreach inherited_package_key [apm_package_inherit_order $new_package_key] {
+ if { [lsearch -exact [apm_package_inherit_order $old_package_key] $inherited_package_key]
+ == -1 } {
+ apm_invoke_callback_proc \
+ -package_key $inherited_package_key \
+ -type after-instantiate \
+ -arg_list [list package_id $package_id]
+ if { $node_id ne "" } {
+ apm_invoke_callback_proc \
+ -package_key $inherited_package_key \
+ -type after-mount \
+ -arg_list [list node_id $node_id package_id $package_id]
+ }
+ }
+ }
+
+}
Index: openacs-4/packages/acs-tcl/tcl/apm-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-procs.xql,v
diff -u -r1.24 -r1.25
--- openacs-4/packages/acs-tcl/tcl/apm-procs.xql 25 Nov 2008 17:08:50 -0000 1.24
+++ openacs-4/packages/acs-tcl/tcl/apm-procs.xql 17 Mar 2009 01:11:07 -0000 1.25
@@ -288,4 +288,48 @@
+
+
+ select pretty_name, package_key
+ from apm_package_types
+ where implements_subsite_p = 't'
+ and package_key in ($in_clause)
+ order by pretty_name
+
+
+
+
+
+ update apm_packages
+ set package_key = :new_package_key
+ where package_id = :package_id
+
+
+
+
+
+ select parameter_name, parameter_id
+ from apm_parameters
+ where package_key = :old_package_key
+
+
+
+
+
+ select parameter_id as new_parameter_id
+ from apm_parameters
+ where package_key = :new_package_key
+ and parameter_name = :parameter_name
+
+
+
+
+
+ update apm_parameter_values
+ set parameter_id = :new_parameter_id
+ where parameter_id = :parameter_id
+ and package_id = :package_id
+
+
+