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.7 -r1.8
--- openacs-4/packages/new-portal/tcl/portal-procs-oracle.xql	23 Jan 2002 00:26:10 -0000	1.7
+++ openacs-4/packages/new-portal/tcl/portal-procs-oracle.xql	28 Jan 2002 17:51:46 -0000	1.8
@@ -67,6 +67,21 @@
   </querytext>
 </fullquery> 
 
+<fullquery name="portal::configure_dispatch.move_to_page_update">      
+  <querytext>
+    update portal_element_map
+    set page_id = :page_id, 
+    region = :region,
+    sort_key = (select nvl((select max(sort_key) + 1
+	                    from portal_element_map 
+                            where page_id = :page_id
+		            and region = :region), 
+                            1) 
+		 from dual)    
+    where element_id = :element_id
+  </querytext>
+</fullquery> 		
+
 <fullquery name="portal::add_element_to_region.insert">      
   <querytext>
     insert into portal_element_map
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.108 -r1.109
--- openacs-4/packages/new-portal/tcl/portal-procs.tcl	25 Jan 2002 20:04:45 -0000	1.108
+++ openacs-4/packages/new-portal/tcl/portal-procs.tcl	28 Jan 2002 17:51:46 -0000	1.109
@@ -478,10 +478,17 @@
             "move_to_page" {
 		set page_id [ns_set get $form page_id]
 		set element_id [ns_set get $form element_id]
-                
-                #ad_return_complaint 1 "$page_id/$element_id"
+                set curr_reg [db_string move_to_page_curr_select {}] 
+                set target_reg_num [db_string move_to_page_target_select {}] 
 
-                db_dml move_to_page {} 
+                if {$curr_reg > $target_reg_num} {
+                    # the new page dosent have this region, set to max region
+                    set region $target_reg_num
+                } else {
+                    set region $curr_reg
+                }
+
+                db_dml move_to_page_update {} 
 	    }
 	    "hide" {
 		set element_id_list [list]
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.14 -r1.15
--- openacs-4/packages/new-portal/tcl/portal-procs.xql	25 Jan 2002 20:04:45 -0000	1.14
+++ openacs-4/packages/new-portal/tcl/portal-procs.xql	28 Jan 2002 17:51:46 -0000	1.15
@@ -104,14 +104,24 @@
     where element_id = :element_id
   </querytext>
 </fullquery> 
-<fullquery name="portal::configure_dispatch.move_to_page">      
+
+<fullquery name="portal::configure_dispatch.move_to_page_curr_select">      
   <querytext>
-    update portal_element_map
-    set page_id = :page_id
+    select region
+    from portal_element_map
     where element_id = :element_id
   </querytext>
 </fullquery> 
 
+<fullquery name="portal::configure_dispatch.move_to_page_target_select">      
+  <querytext>
+    select count(*) 
+    from portal_pages pp, portal_supported_regions psr 
+    where pp.layout_id = psr.layout_id 
+    and pp.page_id = :page_id
+  </querytext>
+</fullquery> 
+
 <fullquery name="portal::configure_dispatch.hide_update">      
   <querytext>
   update portal_element_map 
Index: openacs-4/packages/new-portal/www/place-element.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/new-portal/www/place-element.adp,v
diff -u -r1.26 -r1.27
--- openacs-4/packages/new-portal/www/place-element.adp	23 Jan 2002 00:26:10 -0000	1.26
+++ openacs-4/packages/new-portal/www/place-element.adp	28 Jan 2002 17:51:46 -0000	1.27
@@ -20,7 +20,7 @@
       </if>
     </if>
 
-
+    <if @num_regions@ gt 1>
 	<if @region@ eq 1>
 	<a href="@target_stub@-2?portal_id=@portal_id@&op=move&element_id=@element_multi.element_id@&direction=right&region=@region@"><img border=0 src="@dir@/arrow-right.gif" alt="move right"></a>
 	</if>
@@ -30,6 +30,7 @@
 	</if>
 	<if @region@ eq @num_regions@><a href="@target_stub@-2?portal_id=@portal_id@&op=move&element_id=@element_multi.element_id@&direction=left&region=@region@"><img border=0 src="@dir@/arrow-left.gif" alt="move left"></a>
 	</if>
+    </if>
 
             <if @element_multi.hideable_p@ eq "t">
             [<a href="@target_stub@-2?portal_id=@portal_id@&op=hide&element_id=@element_multi.element_id@">hide</a>]