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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/news/sql/postgresql/upgrade/upgrade-5.2.0d2-5.2.0d3.sql 26 Mar 2005 20:54:27 -0000 1.1 @@ -0,0 +1,128 @@ +select define_function_args ('news__new','item_id,locale,publish_date,text,nls_language,title,mime_type;text/plain,package_id,archive_date,approval_user,approval_date,approval_ip,relation_tag,creation_ip,creation_user,is_live_p;f,lead'); + +create or replace function news__new (integer,varchar,timestamptz,text,varchar,varchar, + varchar,integer,timestamptz,integer,timestamptz,varchar,varchar, + varchar,integer,boolean, varchar) +returns integer as ' +declare + p_item_id alias for $1; -- default null + -- + p_locale alias for $2; -- default null, + -- + p_publish_date alias for $3; -- default null + p_text alias for $4; -- default null + p_nls_language alias for $5; -- default null + p_title alias for $6; -- default null + p_mime_type alias for $7; -- default ''text/plain'' + -- + p_package_id alias for $8; -- default null + p_archive_date alias for $9; -- default null + p_approval_user alias for $10; -- default null + p_approval_date alias for $11; -- default null + p_approval_ip alias for $12; -- default null + -- + p_relation_tag alias for $13; -- default null + -- + -- REMOVED: p_item_subtype alias for $14; -- default ''content_revision'' + -- REMOVED: p_content_type alias for $15; -- default ''news'' + -- REMOVED: p_creation_date alias for $16; -- default current_timestamp + p_creation_ip alias for $14; -- default null + p_creation_user alias for $15; -- default null + -- + p_is_live_p alias for $16; -- default ''f'' + p_lead alias for $17; + + v_news_id integer; + v_item_id integer; + v_id integer; + v_revision_id integer; + v_parent_id integer; + v_name varchar; + v_log_string varchar; +begin + select content_item__get_id(''news'',null,''f'') + into v_parent_id + from dual; + -- + -- this will be used for 2xClick protection + if p_item_id is null then + select acs_object_id_seq.nextval + into v_id + from dual; + else + v_id := p_item_id; + end if; + -- + v_name := ''news-'' || to_char(current_timestamp,''YYYYMMDD'') || ''-'' || v_id; + -- + v_log_string := ''initial submission''; + -- + v_item_id := content_item__new( + v_name, -- name + v_parent_id, -- parent_id + v_id, -- item_id + p_locale, -- locale + current_timestamp, -- creation_date + p_creation_user, -- creation_user + p_package_id, -- context_id + p_creation_ip, -- creation_ip + ''content_item'', -- item_subtype + ''news'', -- content_type + p_title, -- title + null, -- description + p_mime_type, -- mime_type + p_nls_language, -- nls_language + null, -- text + null, -- data + null, -- relation_tag + p_is_live_p -- live_p + ''text'' -- storage_type + p_package_id -- package_id + ); + + v_revision_id := content_revision__new( + p_title, -- title + v_log_string, -- description + p_publish_date, -- publish_date + p_mime_type, -- mime_type + p_nls_language, -- nls_language + p_text, -- data + v_item_id, -- item_id + null, -- revision_id + current_timestamp, -- creation_date + p_creation_user, -- creation_user + p_creation_ip -- creation_ip + ); + + insert into cr_news + (news_id, + lead, + package_id, + archive_date, + approval_user, + approval_date, + approval_ip) + values + (v_revision_id, + p_lead, + p_package_id, + p_archive_date, + p_approval_user, + p_approval_date, + p_approval_ip); + -- make this revision live when immediately approved + if p_is_live_p = ''t'' then + update + cr_items + set + live_revision = v_revision_id, + publish_status = ''ready'' + where + item_id = v_item_id; + end if; + v_news_id := v_revision_id; + return v_news_id; +end; +' language 'plpgsql'; + + Index: openacs-4/packages/news/tcl/news-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/news/tcl/news-procs.tcl,v diff -u -r1.18 -r1.19 --- openacs-4/packages/news/tcl/news-procs.tcl 26 Mar 2005 13:49:55 -0000 1.18 +++ openacs-4/packages/news/tcl/news-procs.tcl 26 Mar 2005 20:54:27 -0000 1.19 @@ -179,19 +179,8 @@ } { @author Robert Locke } { - - set package_id [db_string get_package_id {}] - set url_stub [news_util_get_url $package_id] - - db_1row get_item_id " - select item_id - from cr_revisions - where revision_id=:object_id - " - - set url "${url_stub}item/$item_id" - - return $url + db_1row get {} + return "[ad_url][news_util_get_url $package_id]item/$item_id" } ad_proc news_pretty_status { Index: openacs-4/packages/news/tcl/news-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/news/tcl/news-procs.xql,v diff -u -r1.6 -r1.7 --- openacs-4/packages/news/tcl/news-procs.xql 24 Feb 2005 18:03:05 -0000 1.6 +++ openacs-4/packages/news/tcl/news-procs.xql 26 Mar 2005 20:54:27 -0000 1.7 @@ -2,24 +2,15 @@ - + - - select item_id - from cr_revisions - where revision_id=:object_id - + select r.item_id, n.package_id + from cr_revisions r, cr_news n + where (r.revision_id=:object_id or r.item_id = :object_id) + and r.revision_id = n.news_id - - - select package_id - from cr_news - where news_id=:object_id - - - select max(o.last_modified)