Index: openacs-4/packages/news/sql/postgresql/upgrade/upgrade-4.6-5.0d1.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/news/sql/postgresql/upgrade/upgrade-4.6-5.0d1.sql,v diff -u -N -r1.1 -r1.1.20.1 --- openacs-4/packages/news/sql/postgresql/upgrade/upgrade-4.6-5.0d1.sql 6 Oct 2003 12:11:23 -0000 1.1 +++ openacs-4/packages/news/sql/postgresql/upgrade/upgrade-4.6-5.0d1.sql 2 Nov 2013 16:08:07 -0000 1.1.20.1 @@ -6,39 +6,48 @@ --- **** Recreate function. This will drop the views as well. drop function news__status (integer) cascade; -create function news__status (timestamptz, timestamptz) -returns varchar as ' -declare - p_publish_date alias for $1; - p_archive_date alias for $2; -begin + + +-- added +select define_function_args('news__status','publish_date,archive_date'); + +-- +-- procedure news__status/2 +-- +CREATE OR REPLACE FUNCTION news__status( + p_publish_date timestamptz, + p_archive_date timestamptz +) RETURNS varchar AS $$ +DECLARE +BEGIN if p_publish_date is not null then if p_publish_date > current_timestamp then -- Publishing in the future if p_archive_date is null then - return ''going_live_no_archive''; + return 'going_live_no_archive'; else - return ''going_live_with_archive''; + return 'going_live_with_archive'; end if; else -- Published in the past if p_archive_date is null then - return ''published_no_archive''; + return 'published_no_archive'; else if p_archive_date > current_timestamp then - return ''published_with_archive''; + return 'published_with_archive'; else - return ''archived''; + return 'archived'; end if; end if; end if; else -- publish_date null - return ''unapproved''; + return 'unapproved'; end if; -end; -' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; + -- **** Recreate views with calls to new status function create view news_items_live_or_submitted as