Index: openacs-4/packages/news/sql/postgresql/upgrade/upgrade-5.2.0d2-5.2.0d3.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/news/sql/postgresql/upgrade/upgrade-5.2.0d2-5.2.0d3.sql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/news/sql/postgresql/upgrade/upgrade-5.2.0d2-5.2.0d3.sql	26 Mar 2005 20:54:27 -0000	1.1
+++ openacs-4/packages/news/sql/postgresql/upgrade/upgrade-5.2.0d2-5.2.0d3.sql	26 Mar 2005 21:45:09 -0000	1.2
@@ -126,3 +126,30 @@
 ' language 'plpgsql';
 
 
+create or replace function news__revision_set_active (integer)
+returns integer as '
+declare
+    p_revision_id alias for $1;
+    v_news_item_p boolean;
+    v_item_id cr_items.item_id%TYPE;
+    v_title acs_objects.title%TYPE;
+    -- could be used to check if really a ''news'' item
+begin
+
+    select item_id, title into v_item_id, v_title
+    from cr_revisions
+    where revision_id = p_revision_id;
+
+    update cr_items
+    set live_revision = p_revision_id,
+        publish_status = ''ready''
+    where item_id = v_item_id;
+
+    -- We update the acs_objects title as well.
+
+    update acs_objects set title = v_title
+    where object_id = v_item_id and (title != v_title or title is null);
+
+    return 0;
+end;
+' language 'plpgsql';
