Index: openacs-4/packages/theme-selva/sql/oracle/theme-selva-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/theme-selva/sql/oracle/theme-selva-drop.sql,v
diff -u -r1.1.2.1 -r1.1.2.2
--- openacs-4/packages/theme-selva/sql/oracle/theme-selva-drop.sql	3 Mar 2006 12:39:49 -0000	1.1.2.1
+++ openacs-4/packages/theme-selva/sql/oracle/theme-selva-drop.sql	10 Mar 2006 11:12:09 -0000	1.1.2.2
@@ -1,22 +1,58 @@
 -- packages/theme-selva/sql/oracle/theme-selva-drop.sql
 
--- reverting parameters to default
-UPDATE apm_parameter_values 
-	SET attr_value = '/packages/dotlrn/www/dotlrn-master' 
-	WHERE parameter_id IN (SELECT parameter_id FROM apm_parameters WHERE parameter_name='DefaultMaster');
+declare 
 
--- setting sloan theme for all portals
-UPDATE portals 
-	SET theme_id = (SELECT theme_id FROM portal_element_themes WHERE name LIKE '%sloan%');
+	selva_site_template_id  dotlrn_site_templates.site_template_id%TYPE;
+	sloan_site_template_id  dotlrn_site_templates.site_template_id%TYPE;
+	selva_theme_id  portal_element_themes.theme_id%TYPE;
+	sloan_theme_id  portal_element_themes.theme_id%TYPE;
 
--- removing selva theme
-declare
-    v_theme_id	portal_element_themes.theme_id%TYPE;
 begin
-    SELECT theme_id INTO v_theme_id FROM portal_element_themes WHERE name='selva';
-	DELETE FROM portal_element_themes WHERE theme_id = v_theme_id;
-    acs_object.del(v_theme_id);
 
+	-- reverting selva site-templates to sloan
+
+	select site_template_id into selva_site_template_id
+		from dotlrn_site_templates
+		where pretty_name = 'Selva Theme';
+
+	select site_template_id into sloan_site_template_id
+		from dotlrn_site_templates
+		where pretty_name = '#new-portal.sloan_theme_name#';
+
+	update apm_parameter_values 
+        set attr_value = sloan_site_template_id
+		where parameter_id in ( select parameter_id 
+				from apm_parameters 
+				where (parameter_name = 'CommDefaultSiteTemplate_p' or parameter_name = 'UserDefaultSiteTemplate_p') and attr_value = selva_site_template_id);
+
+	-- reverting to sloan for user/comm 
+
+	update dotlrn_communities_all
+		set site_template_id = sloan_site_template_id
+		where site_template_id = selva_site_template_id;
+
+	update dotlrn_user_profile_rels
+		set site_template_id = sloan_site_template_id
+		where site_template_id = selva_site_template_id;
+
+	-- removing selva site-template
+
+	delete from dotlrn_site_templates where site_template_id = selva_site_template_id;
+
+	-- removing the Selva theme
+
+	select theme_id into selva_theme_id 
+        from portal_element_themes 
+		where name = 'selva'; 
+
+	select theme_id into sloan_theme_id 
+        from portal_element_themes 
+		where name = '#new-portal.sloan_theme_name#'; 
+
+	update portals set theme_id = sloan_theme_id where theme_id = selva_theme_id;
+	delete from portal_element_themes WHERE theme_id = selva_theme_id;
+    acs_object.del(selva_theme_id);
+
 end;
 /
-show errors
+show errors;
