Index: openacs-4/packages/new-portal/tcl/portal-procs-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/new-portal/tcl/portal-procs-oracle.xql,v
diff -u -r1.23 -r1.24
--- openacs-4/packages/new-portal/tcl/portal-procs-oracle.xql 8 Aug 2007 11:43:57 -0000 1.23
+++ openacs-4/packages/new-portal/tcl/portal-procs-oracle.xql 24 Apr 2009 11:51:20 -0000 1.24
@@ -79,14 +79,9 @@
insert into portal_element_map
- (element_id, name, pretty_name, page_id, datasource_id, region,
- sort_key)
+ (element_id, name, pretty_name, page_id, datasource_id, region, sort_key)
values
- (:new_element_id, :ds_name, :pretty_name, :page_id, :ds_id, :region,
- nvl((select max(sort_key) + 1
- from portal_element_map
- where region = :region
- and page_id = :page_id), 1))
+ (:new_element_id, :ds_name, :pretty_name, :page_id, :ds_id, :region, :sort_key)
Index: openacs-4/packages/new-portal/tcl/portal-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/new-portal/tcl/portal-procs-postgresql.xql,v
diff -u -r1.12 -r1.13
--- openacs-4/packages/new-portal/tcl/portal-procs-postgresql.xql 8 Aug 2007 11:43:57 -0000 1.12
+++ openacs-4/packages/new-portal/tcl/portal-procs-postgresql.xql 24 Apr 2009 11:51:20 -0000 1.13
@@ -80,14 +80,9 @@
insert into portal_element_map
- (element_id, name, pretty_name, page_id, datasource_id, region,
- sort_key)
+ (element_id, name, pretty_name, page_id, datasource_id, region, sort_key)
values
- (:new_element_id, :ds_name, :pretty_name, :page_id, :ds_id, :region,
- coalesce((select max(sort_key) + 1
- from portal_element_map
- where region = :region
- and page_id = :page_id), 1))
+ (:new_element_id, :ds_name, :pretty_name, :page_id, :ds_id, :region, :sort_key)
Index: openacs-4/packages/new-portal/tcl/portal-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/new-portal/tcl/portal-procs.tcl,v
diff -u -r1.187 -r1.188
--- openacs-4/packages/new-portal/tcl/portal-procs.tcl 9 Nov 2008 23:29:27 -0000 1.187
+++ openacs-4/packages/new-portal/tcl/portal-procs.tcl 24 Apr 2009 11:51:20 -0000 1.188
@@ -1156,12 +1156,14 @@
{-portal_id:required}
{-portlet_name:required}
{-force_region ""}
+ {-sort_key ""}
{-page_name ""}
{-pretty_name ""}
} {
Add an element to a portal given a datasource name. Used for procs
that have no knowledge of regions
+ @param sort_key If provided will be used to insert the element. Other elements won't be reordered
@return the id of the new element
} {
if {[empty_string_p $pretty_name]} {
@@ -1225,6 +1227,7 @@
-page_name $page_name \
-layout_id $layout_id \
-pretty_name $pretty_name \
+ -sort_key $sort_key \
$portal_id \
$portlet_name \
$min_region \
@@ -1264,13 +1267,15 @@
{-layout_id:required}
{-page_name ""}
{-pretty_name ""}
+ {-sort_key ""}
portal_id
ds_name
region
} {
Add an element to a portal in a region, given a datasource name
@return the id of the new element
+ @param sort_key If set will be used to insert the element. The other elements won't be reordered
@param portal_id
@param ds_name
} {
@@ -1302,6 +1307,13 @@
} else {
# no template, or the template dosen't have this D
+
+ # sort_key will be used only on insert
+ if { $sort_key eq "" } {
+ set sort_key [db_string get_sort_key {} -default "1"]
+ set sort_key [ad_decode $sort_key "" "1" $sort_key]
+ }
+
db_transaction {
set new_element_id [db_nextval acs_object_id_seq]
db_dml insert {}
@@ -2101,6 +2113,7 @@
{-pretty_name ""}
{-extra_params ""}
{-force_region ""}
+ {-sort_key ""}
{-param_action "overwrite"}
} {
A helper proc for portlet "add_self_to_page" procs.
@@ -2112,11 +2125,13 @@
IMPROVE ME: refactor
@return element_id The new element's id
+
@param portal_id The page to add the portlet to
@param portlet_name The name of the portlet to add
- @param key the key for the value (defaults to package_id)
@param value the value of the key
+ @param key the key for the value (defaults to package_id)
@param extra_params a list of extra key/value pairs to insert or append
+ @param sort_key If set, will be used to insert a new element. Other elements of the region won't be reordered
} {
if {[empty_string_p $param_action]} {
@@ -2134,7 +2149,8 @@
-portlet_name $portlet_name \
-pretty_name $pretty_name \
-page_name $page_name \
- -force_region $force_region
+ -force_region $force_region \
+ -sort_key $sort_key
]
# There is already a value for the param which is overwritten
Index: openacs-4/packages/new-portal/tcl/portal-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/new-portal/tcl/portal-procs.xql,v
diff -u -r1.49 -r1.50
--- openacs-4/packages/new-portal/tcl/portal-procs.xql 11 Mar 2008 19:31:30 -0000 1.49
+++ openacs-4/packages/new-portal/tcl/portal-procs.xql 24 Apr 2009 11:51:21 -0000 1.50
@@ -400,6 +400,14 @@
+
+
+ select max(sort_key) + 1
+ from portal_element_map
+ where region = :region and page_id = :page_id
+
+
+
select page_id