Index: openacs-4/contrib/obsolete-packages/bboard-portlets/sql/oracle/bboard-portlets-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/bboard-portlets/sql/oracle/bboard-portlets-create.sql,v diff -u -N --- openacs-4/contrib/obsolete-packages/bboard-portlets/sql/oracle/bboard-portlets-create.sql 28 Jul 2001 23:58:07 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,31 +0,0 @@ --- --- packages/bboard-portlet/sql/bboard-portlets-create.sql --- - --- Creates bboard datasources for portal portlets - --- Copyright (C) 2001 ArsDigita Corporation --- @author Phong Nguyen (phong@arsdigita.com) --- @creation-date 2001-02-26 - --- $Id: bboard-portlets-create.sql,v 1.1 2001/07/28 23:58:07 donb Exp $ - --- This is free software distributed under the terms of the GNU Public --- License. Full text of the license is available from the GNU Project: --- http://www.fsf.org/copyleft/gpl.html - -declare - ds_id portal_datasources.datasource_id%TYPE; -begin - ds_id := portal_datasource.new( - data_type => 'raw', - package_key => 'bboard', - mime_type => 'application/x-ats', - name => 'Summarize bboard applications', - description => 'Summarizes the bboard topics for all instances of bboard mounted below the current node', - content_varchar => '/packages/bboard-portlets/www/summarize', - configurable_p => 'f' - ); -end; -/ -show errors Index: openacs-4/contrib/obsolete-packages/bboard-portlets/sql/oracle/bboard-portlets-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/bboard-portlets/sql/oracle/bboard-portlets-drop.sql,v diff -u -N --- openacs-4/contrib/obsolete-packages/bboard-portlets/sql/oracle/bboard-portlets-drop.sql 28 Jul 2001 23:58:07 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,37 +0,0 @@ --- --- packages/bboard-portlets/sql/bboard-portlets-drop.sql --- - --- Drops bboard datasources for portal portlets - --- Copyright (C) 2001 ArsDigita Corporation --- @author Michael Bryzek (mbryzek@arsdigita.com) --- @creation-date 2001-02-26 - --- $Id: bboard-portlets-drop.sql,v 1.1 2001/07/28 23:58:07 donb Exp $ - --- This is free software distributed under the terms of the GNU Public --- License. Full text of the license is available from the GNU Project: --- http://www.fsf.org/copyleft/gpl.html - -declare - ds_id portal_datasources.datasource_id%TYPE; -begin - - begin - select datasource_id into ds_id - from portal_datasources - where name = 'Summarize bboard applications' - and package_key = 'bboard'; - exception when no_data_found then - ds_id := null; - end; - - if ds_id is not null then - portal_datasource.delete(ds_id); - end if; - -end; -/ -show errors; - Index: openacs-4/contrib/obsolete-packages/bboard-portlets/sql/postgresql/bboard-portlets-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/bboard-portlets/sql/postgresql/bboard-portlets-create.sql,v diff -u -N --- openacs-4/contrib/obsolete-packages/bboard-portlets/sql/postgresql/bboard-portlets-create.sql 28 Jul 2001 23:58:07 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,20 +0,0 @@ --- --- packages/bboard-portlet/sql/bboard-portlets-create.sql --- - --- Creates bboard datasources for portal portlets - --- Copyright (C) 2001 ArsDigita Corporation --- @author Phong Nguyen (phong@arsdigita.com) --- @creation-date 2001-02-26 - --- $Id: bboard-portlets-create.sql,v 1.1 2001/07/28 23:58:07 donb Exp $ - --- This is free software distributed under the terms of the GNU Public --- License. Full text of the license is available from the GNU Project: --- http://www.fsf.org/copyleft/gpl.html - -select portal_datasource__new(NULL, 'raw', 'application/x-ats', NULL, 'Summarize bboard applications', - 'Summarizes the bboard topics for all instances of bboard mounted below the current node', - 'f', '/packages/bboard-portlets/www/summarize', 'bboard', 'portal_datasource', - current_timestamp, NULL, NULL, NULL); Index: openacs-4/contrib/obsolete-packages/bboard-portlets/sql/postgresql/bboard-portlets-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/bboard-portlets/sql/postgresql/bboard-portlets-drop.sql,v diff -u -N --- openacs-4/contrib/obsolete-packages/bboard-portlets/sql/postgresql/bboard-portlets-drop.sql 28 Jul 2001 23:58:07 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,37 +0,0 @@ --- --- packages/bboard-portlets/sql/bboard-portlets-drop.sql --- - --- Drops bboard datasources for portal portlets - --- Copyright (C) 2001 ArsDigita Corporation --- @author Michael Bryzek (mbryzek@arsdigita.com) --- @creation-date 2001-02-26 - --- $Id: bboard-portlets-drop.sql,v 1.1 2001/07/28 23:58:07 donb Exp $ - --- This is free software distributed under the terms of the GNU Public --- License. Full text of the license is available from the GNU Project: --- http://www.fsf.org/copyleft/gpl.html - -declare - ds_id portal_datasources.datasource_id%TYPE; -begin - - begin - select datasource_id into ds_id - from portal_datasources - where name = 'Summarize bboard applications' - and package_key = 'bboard'; - exception when no_data_found then - ds_id := null; - end; - - if ds_id is not null then - portal_datasource.delete(ds_id); - end if; - -end; -/ -show errors; - Index: openacs-4/contrib/obsolete-packages/bboard-portlets/tcl/bboard-portlets-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/bboard-portlets/tcl/bboard-portlets-procs.tcl,v diff -u -N --- openacs-4/contrib/obsolete-packages/bboard-portlets/tcl/bboard-portlets-procs.tcl 10 Sep 2002 22:22:25 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,39 +0,0 @@ -# /packages/bboard-portlets/tcl/bboard-portlets-procs.tcl - -ad_page_contract { - - Procedures to supports bboard portlets - - @author mbryzek@arsdigita.com - @creation-date 2001-03-01 - @cvs-id $Id: bboard-portlets-procs.tcl,v 1.2 2002/09/10 22:22:25 jeffd Exp $ -} - - -ad_proc bboard_portlets_mount_application { - { -object_id "" } - { -node_id "" } - { -package_id "" } -} { - Mounts a bboard application beneath the portal associated with - object_id. If no such portal exists, does nothing. This function is - used as a callback in the acs-subsite group callback system - - @author mbryzek@arsdigita.com - @creation-date Fri Feb 9 18:55:22 2001 - - @return The package id of the newly mounted package, or the empty - string if no package was mounted - -} { - if { [empty_string_p $object_id] } { - error "Object ID must be specified" - } - - # Find the node ID for the portal associated with this object - set node_id [portal_node_id_for_object $object_id] - if { [empty_string_p $node_id] } { - return "" - } - return [subsite::auto_mount_application -node_id $node_id bboard] -} Index: openacs-4/contrib/obsolete-packages/bboard-portlets/www/summarize-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/bboard-portlets/www/summarize-oracle.xql,v diff -u -N --- openacs-4/contrib/obsolete-packages/bboard-portlets/www/summarize-oracle.xql 28 Jul 2001 23:58:07 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,26 +0,0 @@ - - - - oracle8.1.6 - - - - - select b.forum_id, - b.short_name, - site_node.url(sn.node_id) as url, - acs_object.name(sn.object_id) as bboard_name - from bboard_forums b, - site_nodes sn, - apm_packages apm - where sn.object_id = b.bboard_id(+) - and sn.parent_id = :node_id - and sn.object_id = apm.package_id - and apm.package_key = 'bboard' - order by lower(bboard_name) - - - - - - Index: openacs-4/contrib/obsolete-packages/bboard-portlets/www/summarize-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/bboard-portlets/www/summarize-postgresql.xql,v diff -u -N --- openacs-4/contrib/obsolete-packages/bboard-portlets/www/summarize-postgresql.xql 10 Oct 2001 06:57:56 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,24 +0,0 @@ - - - - postgresql7.1 - - - - - select b.forum_id, - b.short_name, - site_node__url(sn.node_id) as url, - acs_object__name(sn.object_id) as bboard_name - from bboard_forums b left join site_nodes sn on (sn.object_id = b.bboard_id), - apm_packages apm - where sn.parent_id = :node_id - and sn.object_id = apm.package_id - and apm.package_key = 'bboard' - order by 4 - - - - - - Index: openacs-4/contrib/obsolete-packages/bboard-portlets/www/summarize.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/bboard-portlets/www/summarize.adp,v diff -u -N --- openacs-4/contrib/obsolete-packages/bboard-portlets/www/summarize.adp 28 Jul 2001 23:58:07 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,21 +0,0 @@ - Index: openacs-4/contrib/obsolete-packages/bboard-portlets/www/summarize.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/bboard-portlets/www/summarize.tcl,v diff -u -N --- openacs-4/contrib/obsolete-packages/bboard-portlets/www/summarize.tcl 28 Jul 2001 23:58:07 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,34 +0,0 @@ -# /packages/portal-creator/www/datasources/bboard/summarize.tcl - -ad_page_contract { - Summarizes all bboard applications mounted directly below this node - - @author Phong Nguyen (phong@arsdigita.com) - @creation-date 2001-02-26 - @cvs-id $Id: summarize.tcl,v 1.1 2001/07/28 23:58:07 donb Exp $ -} { -} -properties { - context_bar:onevalue -} - -set node_id [ad_conn node_id] - -# get all of the bboard packages mounted under this node -db_multirow bboard select_bboard { - select b.forum_id, - b.short_name, - site_node.url(sn.node_id) as url, - acs_object.name(sn.object_id) as bboard_name - from bboard_forums b, - site_nodes sn, - apm_packages apm - where sn.object_id = b.bboard_id(+) - and sn.parent_id = :node_id - and sn.object_id = apm.package_id - and apm.package_key = 'bboard' - order by lower(bboard_name) -} - -set subsite_url [site_node_closest_ancestor_package_url -package_key acs-subsite] - -ad_return_template Index: openacs-4/packages/bookmarks/bookmarks.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bookmarks/bookmarks.info,v diff -u -N -r1.22 -r1.23 --- openacs-4/packages/bookmarks/bookmarks.info 30 Nov 2002 17:26:26 -0000 1.22 +++ openacs-4/packages/bookmarks/bookmarks.info 17 May 2003 10:18:32 -0000 1.23 @@ -40,7 +40,7 @@ Areas that need improvement: The query on the index page is a bit slow - closing and opening folders becomes impractible with for example 200 bookmarks. Users who have this many bookmarks can preferably use the Javascript version. - + Index: openacs-4/packages/bookmarks/sql/postgresql/bookmarks-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bookmarks/sql/postgresql/bookmarks-create.sql,v diff -u -N -r1.21 -r1.22 --- openacs-4/packages/bookmarks/sql/postgresql/bookmarks-create.sql 21 Dec 2002 22:30:01 -0000 1.21 +++ openacs-4/packages/bookmarks/sql/postgresql/bookmarks-create.sql 17 May 2003 10:18:52 -0000 1.22 @@ -32,9 +32,9 @@ -- meta tags that could be looked up regularly meta_keywords text, meta_description text, - last_checked_date timestamp, + last_checked_date timestamptz, -- the last time the site returned a "live" status - last_live_date timestamp + last_live_date timestamptz ); create function inline_0 () @@ -84,7 +84,7 @@ constraint bm_bookmarks_parent_id_fk references acs_objects (object_id), -- When the bookmark was last clicked on - last_access_date timestamp, + last_access_date timestamptz, tree_sortkey varbit ); @@ -250,7 +250,7 @@ -- easily grow very large in big communities sharing bookmarks actively -- refers to whether a folder is open or closed closed_p boolean default 'f', - creation_date timestamp, + creation_date timestamptz, constraint bm_in_closed_p_pk primary key (bookmark_id, in_closed_p_id) ); @@ -347,7 +347,7 @@ END; ' LANGUAGE 'plpgsql'; -CREATE FUNCTION bookmark__new (integer,integer,integer,varchar,boolean,integer,timestamp with time zone,integer,varchar,integer) +CREATE FUNCTION bookmark__new (integer,integer,integer,varchar,boolean,integer,timestamptz,integer,varchar,integer) RETURNS integer AS ' DECLARE p_bookmark_id ALIAS FOR $1; -- in bm_bookmarks.bookmark_id%TYPE, Index: openacs-4/packages/bookmarks/sql/postgresql/bookmarks-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bookmarks/sql/postgresql/bookmarks-drop.sql,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/bookmarks/sql/postgresql/bookmarks-drop.sql 3 Jun 2001 04:22:52 -0000 1.2 +++ openacs-4/packages/bookmarks/sql/postgresql/bookmarks-drop.sql 17 May 2003 10:18:52 -0000 1.3 @@ -59,7 +59,7 @@ -- KDK: Complete drop index bm_bookmarks_idx1; -- KDK: Complete -drop index bm_bookmarks_idx2; +-- drop index bm_bookmarks_idx2; -- Drop bookmark table and package @@ -75,7 +75,7 @@ -- (new, delete, name, get_in_closed_p, update_in_closed_p_one_user, update_in_closed_p_all_users, -- toggle_open_close, toggle_open_close_all, get_root_folder, new_root_folder, private_p, -- update_private_p, initialize_in_closed_p) -DROP FUNCTION bookmark__new (varchar,varchar,varchar,text,text,integer,varchar,integer); +DROP FUNCTION bookmark__new (integer,integer,integer,varchar,boolean,integer,timestamptz,integer,varchar,integer); DROP FUNCTION bookmark__delete (integer); DROP FUNCTION bookmark__name (integer); DROP FUNCTION bookmark__get_in_closed_p (integer,integer); @@ -88,8 +88,8 @@ DROP FUNCTION bookmark__private_p (integer); DROP FUNCTION bookmark__update_private_p (integer, boolean); DROP FUNCTION bookmark__initialize_in_closed_p (integer, integer); +DROP FUNCTION bm_bookmarks_get_tree_sortkey(integer); - -- Delete all url objects and corresponding acs objects -- KDK: Complete Index: openacs-4/packages/bulk-mail/bulk-mail.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/bulk-mail.info,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/bulk-mail/bulk-mail.info 16 Jan 2003 13:44:20 -0000 1.3 +++ openacs-4/packages/bulk-mail/bulk-mail.info 17 May 2003 10:19:06 -0000 1.4 @@ -7,41 +7,16 @@ f f - + oracle postgresql Yonatan Feldman - + - - - - - - - - - - - - - - - - - - - - - - - - - Index: openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-package-create.sql,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-package-create.sql 16 Jan 2003 13:44:34 -0000 1.3 +++ openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-package-create.sql 17 May 2003 10:19:23 -0000 1.4 @@ -7,7 +7,7 @@ select define_function_args('bulk_mail__new','bulk_mail_id,package_id,send_date,date_format,sent_p;f,from_addr,subject,reply_to,extra_headers,message,query,creation_date;now(),creation_user,creation_ip,context_id'); -create function bulk_mail__new (integer, integer, varchar, varchar, varchar, varchar, varchar, varchar, varchar, text, varchar, timestamp, integer, varchar, integer) +create function bulk_mail__new (integer, integer, varchar, varchar, varchar, varchar, varchar, varchar, varchar, text, varchar, timestamptz, integer, varchar, integer) returns integer as ' declare bulk_mail__new__bulk_mail_id alias for $1; -- default to null Index: openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-package-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-package-drop.sql,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-package-drop.sql 12 Jun 2002 13:53:13 -0000 1.2 +++ openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-package-drop.sql 17 May 2003 10:19:23 -0000 1.3 @@ -5,5 +5,5 @@ -- @version $Id$ -- -drop function bulk_mail__new (integer, integer, varchar, varchar, varchar, varchar, varchar, varchar, varchar, text, varchar, timestamp, integer, varchar, integer); +drop function bulk_mail__new (integer, integer, varchar, varchar, varchar, varchar, varchar, varchar, varchar, text, varchar, timestamptz, integer, varchar, integer); drop function bulk_mail__delete (integer); Index: openacs-4/packages/calendar/calendar.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/calendar.info,v diff -u -N -r1.16 -r1.17 --- openacs-4/packages/calendar/calendar.info 16 Jan 2003 13:45:11 -0000 1.16 +++ openacs-4/packages/calendar/calendar.info 17 May 2003 10:19:55 -0000 1.17 @@ -22,132 +22,8 @@ + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Index: openacs-4/packages/calendar/sql/postgresql/cal-item-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/sql/postgresql/cal-item-create.sql,v diff -u -N -r1.10 -r1.11 --- openacs-4/packages/calendar/sql/postgresql/cal-item-create.sql 22 Jul 2002 21:46:19 -0000 1.10 +++ openacs-4/packages/calendar/sql/postgresql/cal-item-create.sql 17 May 2003 10:20:23 -0000 1.11 @@ -113,7 +113,7 @@ integer, -- recurrence_id acs_events.recurrence_id%TYPE varchar, -- object_type acs_objects.object_type%TYPE integer, -- context_id acs_objects.context_id%TYPE - timestamp, -- createion_date acs_objects.creation_date%TYPE + timestamptz,-- creation_date acs_objects.creation_date%TYPE integer, -- creation_user acs_objects.creation_user%TYPE varchar -- creation_ip acs_objects.creation_ip%TYPE ) Index: openacs-4/packages/calendar/sql/postgresql/cal-item-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/sql/postgresql/cal-item-drop.sql,v diff -u -N -r1.4 -r1.5 --- openacs-4/packages/calendar/sql/postgresql/cal-item-drop.sql 8 Mar 2002 22:29:24 -0000 1.4 +++ openacs-4/packages/calendar/sql/postgresql/cal-item-drop.sql 17 May 2003 10:20:23 -0000 1.5 @@ -25,7 +25,7 @@ integer, varchar, integer, - timestamp, + timestamptz, integer, varchar ); Index: openacs-4/packages/calendar/sql/postgresql/calendar-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/sql/postgresql/calendar-create.sql,v diff -u -N -r1.10 -r1.11 --- openacs-4/packages/calendar/sql/postgresql/calendar-create.sql 21 Aug 2002 15:28:55 -0000 1.10 +++ openacs-4/packages/calendar/sql/postgresql/calendar-create.sql 17 May 2003 10:20:23 -0000 1.11 @@ -284,7 +284,7 @@ boolean, -- calendar.private_p integer, -- calendar.package_id integer, -- acs_objects.context_id%TYPE - timestamp, -- acs_objects.creation_date%TYPE + timestamptz, -- acs_objects.creation_date%TYPE integer, -- acs_objects.creation_user%TYPE varchar -- acs_objects.creation_ip%TYPE ) @@ -443,7 +443,7 @@ CREATE FUNCTION calendar__month_name( - timestamp + timestamptz ) RETURNS varchar AS 'declare @@ -461,12 +461,12 @@ CREATE FUNCTION calendar__next_month( - timestamp + timestamptz ) -RETURNS timestamp +RETURNS timestamptz AS 'declare next_month__current_dates alias for $1; - v_date timestamp; + v_date timestamptz; begin --select trunc(add_months(to_date(db_sysdate), -1)) select date_trunc(''day'', current_timestamp + cast(''1 month'' as interval)) @@ -479,9 +479,9 @@ CREATE FUNCTION calendar__prev_month( - timestamp + timestamptz ) -RETURNS timestamp +RETURNS timestamptz AS 'declare prev_month__current_date alias for $1; v_date date; @@ -497,7 +497,7 @@ CREATE FUNCTION calendar__num_day_in_month( - timestamp + timestamptz ) RETURNS integer AS 'declare @@ -514,12 +514,12 @@ CREATE FUNCTION calendar__first_displayed_date( - timestamp + timestamptz ) -RETURNS timestamp +RETURNS timestamptz AS 'declare first_displayed_date__current_date alias for $1; - v_date timestamp; + v_date timestamptz; begin select next_day(date_trunc(''Month'', current_date) - 7 , ''SUNDAY'') into v_date @@ -531,12 +531,12 @@ CREATE FUNCTION calendar__last_displayed_date( - timestamp + timestamptz ) -RETURNS timestamp +RETURNS timestamptz AS 'declare last_displayed_date__current_date alias for $1; - v_date timestamp; + v_date timestamptz; begin select next_day(last_day(current_date), ''SATURDAY'') into v_date Index: openacs-4/packages/calendar/sql/postgresql/calendar-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/sql/postgresql/calendar-drop.sql,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/calendar/sql/postgresql/calendar-drop.sql 27 Sep 2001 04:12:20 -0000 1.5 +++ openacs-4/packages/calendar/sql/postgresql/calendar-drop.sql 17 May 2003 10:20:23 -0000 1.6 @@ -140,7 +140,7 @@ boolean, -- calendar.private_p integer, -- calendar.package_id integer, -- acs_objects.context_id%TYPE - timestamp, -- acs_objects.creation_date%TYPE + timestamptz, -- acs_objects.creation_date%TYPE integer, -- acs_objects.creation_user%TYPE varchar -- acs_objects.creation_ip%TYPE ); @@ -168,27 +168,27 @@ ); DROP FUNCTION calendar__month_name( - timestamp + timestamptz ); DROP FUNCTION calendar__next_month( - timestamp + timestamptz ); DROP FUNCTION calendar__prev_month( - timestamp + timestamptz ); DROP FUNCTION calendar__num_day_in_month( - timestamp + timestamptz ); DROP FUNCTION calendar__first_displayed_date( - timestamp + timestamptz ); DROP FUNCTION calendar__last_displayed_date( - timestamp + timestamptz ); -- drop table Index: openacs-4/packages/calendar/tcl/cal-item-2-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/tcl/Attic/cal-item-2-procs-postgresql.xql,v diff -u -N -r1.7 -r1.8 --- openacs-4/packages/calendar/tcl/cal-item-2-procs-postgresql.xql 4 Dec 2002 09:44:35 -0000 1.7 +++ openacs-4/packages/calendar/tcl/cal-item-2-procs-postgresql.xql 17 May 2003 10:20:49 -0000 1.8 @@ -5,7 +5,7 @@ - select CASE WHEN (:start_date::timestamp - :end_date::timestamp) <= 0 + select CASE WHEN :start_date::timestamptz <= :end_date::timestamptz THEN 1 ELSE -1 END @@ -19,9 +19,9 @@ 0 as n_attachments, to_char(start_date, 'YYYY-MM-DD HH:MI:SS') as start_date, end_date as end_date, - to_char(start_date, 'YYYY-MM-DD HH24:MI:SS') as ansi_start_date, - to_char(end_date, 'YYYY-MM-DD HH24:MI:SS') as ansi_end_date, - coalesce(a.name, e.name) as name, + to_char(start_date, 'YYYY-MM-DD HH24:MI:SS') as full_start_date, + to_char(end_date, 'YYYY-MM-DD HH24:MI:SS') as full_end_date, + coalesce(e.name, a.name) as name, coalesce(e.description, a.description) as description, recurrence_id, i.item_type_id, Index: openacs-4/packages/calendar/tcl/cal-item-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/tcl/cal-item-procs-postgresql.xql,v diff -u -N -r1.13 -r1.14 --- openacs-4/packages/calendar/tcl/cal-item-procs-postgresql.xql 30 Nov 2002 17:27:51 -0000 1.13 +++ openacs-4/packages/calendar/tcl/cal-item-procs-postgresql.xql 17 May 2003 10:20:49 -0000 1.14 @@ -25,8 +25,8 @@ select timespan__new ( - :start_date::timestamp, - :end_date::timestamp + :start_date::timestamptz, + :end_date::timestamptz ) @@ -60,8 +60,8 @@ select time_interval__edit ( :interval_id, - :start_date::timestamp, - :end_date::timestamp + :start_date::timestamptz, + :end_date::timestamptz ) Index: openacs-4/packages/calendar/tcl/calendar-display-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/tcl/Attic/calendar-display-procs-postgresql.xql,v diff -u -N -r1.8 -r1.9 --- openacs-4/packages/calendar/tcl/calendar-display-procs-postgresql.xql 18 Nov 2002 18:01:10 -0000 1.8 +++ openacs-4/packages/calendar/tcl/calendar-display-procs-postgresql.xql 17 May 2003 10:20:50 -0000 1.9 @@ -35,6 +35,19 @@ + + + select to_char(to_date(:current_date, 'yyyy-mm-dd'), 'D') + as day_of_the_week, + to_char(next_day(to_date(:current_date, 'yyyy-mm-dd')- '1 week'::interval, 'Sunday'), 'YYYY-MM-DD') + as sunday_of_the_week, + to_char(next_day(to_date(:current_date, 'yyyy-mm-dd'), 'Saturday'), 'YYYY-MM-DD') + as saturday_of_the_week + from dual + + + + select to_char(start_date, 'J') as start_date_julian, @@ -96,8 +109,8 @@ and e.activity_id = a.activity_id and start_date between to_date(:current_date,:date_format) and - to_date(:current_date,:date_format) + (24 - 1/3600)/24 -and cal_items.cal_item_id= e.event_id + to_date(:current_date,:date_format) + cast('23 hours 59 minutes 59 seconds' as interval) +and cal_items.cal_item_id= e.event_id and e.event_id in ( select cal_item_id @@ -139,5 +152,34 @@ + + + + + select to_char(start_date, 'HH24') as start_hour, + to_char(start_date, 'HH:MIpm') as pretty_start_date, + to_char(end_date, 'HH:MIpm') as pretty_end_date, + coalesce(e.name, a.name) as name, + coalesce(e.status_summary, a.status_summary) as status_summary, + e.event_id as item_id +from acs_activities a, + acs_events e, + timespans s, + time_intervals t +where e.timespan_id = s.timespan_id +and s.interval_id = t.interval_id +and e.activity_id = a.activity_id +and start_date between + to_date(:current_date,:date_format) and + to_date(:current_date,:date_format) + cast('23 hours 59 minutes 59 seconds' as interval) +and e.event_id +in ( + select cal_item_id + from cal_items + where on_which_calendar = :calendar_id + ) + + + Index: openacs-4/packages/calendar/tcl/calendar-outlook-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/tcl/Attic/calendar-outlook-procs-postgresql.xql,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/calendar/tcl/calendar-outlook-procs-postgresql.xql 26 Jul 2002 03:20:28 -0000 1.1 +++ openacs-4/packages/calendar/tcl/calendar-outlook-procs-postgresql.xql 17 May 2003 10:20:50 -0000 1.2 @@ -3,13 +3,13 @@ postgresql7.1.2 - -select to_char(timezone__utc_to_local(tz_id, utc_time), :format) -from timezones, -(select timezone__convert_to_utc(tz_id, :timestamp) as utc_time -from timezones where tz= :server_tz) foo -where tz= :user_tz - + + + select to_char(server.utc_time - timezone__get_offset(timezone__get_id(:user_tz), server.utc_time), :format) + from (select timezone__convert_to_utc(tz_id, :timestamp) as utc_time + from timezones where tz= :server_tz) server; + + Index: openacs-4/packages/calendar/tcl/calendar-outlook-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/tcl/calendar-outlook-procs.tcl,v diff -u -N -r1.8 -r1.9 --- openacs-4/packages/calendar/tcl/calendar-outlook-procs.tcl 10 Dec 2002 18:38:30 -0000 1.8 +++ openacs-4/packages/calendar/tcl/calendar-outlook-procs.tcl 17 May 2003 10:20:50 -0000 1.9 @@ -24,8 +24,8 @@ ad_proc -private adjust_timezone { {-timestamp:required} - {-server_tz "US/Eastern"} - {-user_tz "US/Eastern"} + {-server_tz:required} + {-user_tz:required} {-format "YYYY-MM-DD HH24:MI:SS"} } { return [db_string adjust_timezone {}] @@ -76,8 +76,11 @@ # If necessary, select recurrence information # Convert some dates for timezone - set cal_item(ansi_start_date) [adjust_timezone -timestamp $cal_item(ansi_start_date) -format $date_format -user_tz "Universal"] - set cal_item(ansi_end_date) [adjust_timezone -timestamp $cal_item(ansi_end_date) -format $date_format -user_tz "Universal"] + set server_tz [parameter::get_from_package_key -package_key acs-lang -parameter SystemTimezone] + set cal_item(full_start_date) \ + [adjust_timezone -timestamp $cal_item(full_start_date) -format $date_format -user_tz "Universal" -server_tz $server_tz] + set cal_item(full_end_date) \ + [adjust_timezone -timestamp $cal_item(full_end_date) -format $date_format -user_tz "Universal" -server_tz $server_tz] # Here we have some fields # start_time end_time title description Index: openacs-4/packages/calendar/tcl/calendar-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/tcl/calendar-procs.tcl,v diff -u -N -r1.11 -r1.12 --- openacs-4/packages/calendar/tcl/calendar-procs.tcl 30 Nov 2002 17:27:51 -0000 1.11 +++ openacs-4/packages/calendar/tcl/calendar-procs.tcl 17 May 2003 10:20:50 -0000 1.12 @@ -122,14 +122,23 @@ # figure out if user have a private calendar or not # again, best suited to be rolled into the pl/sql -ad_proc calendar_have_private_p { {-return_id 0} party_id } { - +ad_proc calendar_have_private_p { + {-return_id 0} + {-calendar_id_list {}} + party_id +} { check to see if ther user have a prviate calendar if -return_id is 1, then proc will return the calendar_id + @param calendar_id_list If you supply the calendar_id_list, then we'll only search + for a personal calendar among the calendars supplied here. } { - set result [db_string get_calendar_info "" -default 0] + if { [llength $calendar_id_list] > 0 } { + set result [db_string get_calendar_info_calendar_id_list {} -default 0] + } else { + set result [db_string get_calendar_info {} -default 0] + } if { ![string equal $result "0"] } { Index: openacs-4/packages/calendar/tcl/calendar-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/tcl/calendar-procs.xql,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/calendar/tcl/calendar-procs.xql 15 Oct 2001 18:46:59 -0000 1.2 +++ openacs-4/packages/calendar/tcl/calendar-procs.xql 17 May 2003 10:20:50 -0000 1.3 @@ -28,4 +28,14 @@ + + + select calendar_id + from calendars + where owner_id = :party_id + and private_p = 't' + and calendar_id in ([join $calendar_id_list ", "]) + + + Index: openacs-4/packages/calendar/www/cal-dayview-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/Attic/cal-dayview-postgresql.xql,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/calendar/www/cal-dayview-postgresql.xql 23 Sep 2001 14:45:00 -0000 1.1 +++ openacs-4/packages/calendar/www/cal-dayview-postgresql.xql 17 May 2003 10:21:14 -0000 1.2 @@ -20,7 +20,7 @@ and e.activity_id = a.activity_id and start_date between to_date(:current_date,:date_format) and - to_date(:current_date,:date_format) + (24 - 1/3600)/24 + to_date(:current_date,:date_format) + cast('23 hours 59 minutes 59 seconds' as interval) and e.event_id in ( select cal_item_id @@ -49,7 +49,7 @@ and e.activity_id = a.activity_id and start_date between to_date(:current_date,:date_format) and - to_date(:current_date,:date_format) + (24 - 1/3600)/24 + to_date(:current_date,:date_format) + cast('23 hours 59 minutes 59 seconds' as interval) and e.event_id in ( select cal_item_id Index: openacs-4/packages/calendar/www/cal-item-new.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/cal-item-new.tcl,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/calendar/www/cal-item-new.tcl 18 Nov 2002 18:01:11 -0000 1.6 +++ openacs-4/packages/calendar/www/cal-item-new.tcl 17 May 2003 10:21:14 -0000 1.7 @@ -37,7 +37,7 @@ -label "Calendar ID" -datatype integer -widget hidden -value $calendar_id element create cal_item title \ - -label "[_ calendar.Title_1]" -datatype text -widget text -html {size 60} + -label "[_ calendar.Title_1]" -datatype text -widget text -html {size 60} -maxlength 255 element create cal_item date \ -label "[_ calendar.Date_1]" -datatype date -widget date Index: openacs-4/packages/calendar/www/cal-listview-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/Attic/cal-listview-postgresql.xql,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/calendar/www/cal-listview-postgresql.xql 23 Sep 2001 14:45:00 -0000 1.1 +++ openacs-4/packages/calendar/www/cal-listview-postgresql.xql 17 May 2003 10:21:14 -0000 1.2 @@ -20,7 +20,7 @@ and e.activity_id = a.activity_id and start_date between to_date(:current_date,:date_format) and - to_date(:current_date,:date_format) + (24 - 1/3600)/24 + to_date(:current_date,:date_format) + cast('23 hours 59 minutes 59 seconds' as interval) and e.event_id in ( select cal_item_id @@ -49,7 +49,7 @@ and e.activity_id = a.activity_id and start_date between to_date(:current_date,:date_format) and - to_date(:current_date,:date_format) + (24 - 1/3600)/24 + to_date(:current_date,:date_format) + cast('23 hours 59 minutes 59 seconds' as interval) and e.event_id in ( select cal_item_id Index: openacs-4/packages/calendar/www/cal-weekview-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/Attic/cal-weekview-postgresql.xql,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/calendar/www/cal-weekview-postgresql.xql 16 Oct 2001 18:18:36 -0000 1.6 +++ openacs-4/packages/calendar/www/cal-weekview-postgresql.xql 17 May 2003 10:21:14 -0000 1.7 @@ -8,9 +8,9 @@ select to_char(to_date(:current_date, 'yyyy-mm-dd'), 'D') as day_of_the_week, - to_char(next_day(to_date(:current_date, 'yyyy-mm-dd')-7, 'SUNDAY'), 'YYYY-MM-DD') + to_char(next_day(to_date(:current_date, 'yyyy-mm-dd') - cast(7 as interval), 'SUNDAY'), 'YYYY-MM-DD') as sunday_of_the_week, - to_char(next_day(to_date(:current_date, 'yyyy-mm-dd')+7, 'Saturday'), 'YYYY-MM-DD') + to_char(next_day(to_date(:current_date, 'yyyy-mm-dd') + cast(7 as interval), 'Saturday'), 'YYYY-MM-DD') as saturday_of_the_week from dual Index: openacs-4/packages/calendar/www/view.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/view.adp,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/calendar/www/view.adp 7 Nov 2002 12:45:07 -0000 1.6 +++ openacs-4/packages/calendar/www/view.adp 17 May 2003 10:21:14 -0000 1.7 @@ -19,5 +19,3 @@ - - Index: openacs-4/packages/calendar/www/view.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/view.tcl,v diff -u -N -r1.9 -r1.10 --- openacs-4/packages/calendar/www/view.tcl 20 Nov 2002 17:22:11 -0000 1.9 +++ openacs-4/packages/calendar/www/view.tcl 17 May 2003 10:21:14 -0000 1.10 @@ -12,6 +12,14 @@ {julian_date ""} {calendar_list:multiple ""} {sort_by ""} +} -validate { + valid_date -requires { date } { + if {![string equal $date ""]} { + if {[catch {set date [clock format [clock scan $date] -format "%Y-%m-%d"]} err]} { + ad_complain "Your input was not valid. It has to be in the form YYYYMMDD." + } + } + } } set package_id [ad_conn package_id] @@ -25,13 +33,37 @@ # Set up some template set item_template "\$item" set hour_template "\$hour" -set item_add_template "+" +set item_add_template "\"[_" + # Depending on the view, make a different widget if {$view == "day"} { + + # Check that the previous and next days are in the tcl boundaries + # so that the calendar widget doesn't bomb when it creates the next/prev links + if {[catch {set yest [clock format [clock scan "1 day ago" -base [clock scan $date]] -format "%Y-%m-%d"]}]} { + set previous_link "" + } else { + if {[catch {clock scan $yest}]} { + set previous_link "" + } else { + set previous_link "<" + } + } + + if {[catch {set tomor [clock format [clock scan "1 day" -base [clock scan $date]] -format "%Y-%m-%d"]}]} { + set next_link "" + } else { + if {[catch {clock scan $tomor}]} { + set next_link "" + } else { + set next_link ">" + } + } + set cal_stuff [calendar::one_day_display \ - -prev_nav_template "<" \ - -next_nav_template ">" \ + -prev_nav_template $previous_link \ + -next_nav_template $next_link \ -item_template $item_template \ -hour_template $hour_template \ -date $date -start_hour 7 -end_hour 22 \ @@ -40,25 +72,71 @@ } if {$view == "week"} { + + # Check that the previous and next weeks are in the tcl boundaries + # so that the calendar widget doesn't bomb when it creates the next/prev links + if {[catch {set prev_w [clock format [clock scan "1 week ago" -base [clock scan $date]] -format "%Y-%m-%d"]}]} { + set previous_link "" + } else { + if {[catch {clock scan $prev_w}]} { + set previous_link "" + } else { + set previous_link "<" + } + } + + if {[catch {set next_w [clock format [clock scan "1 week" -base [clock scan $date]] -format "%Y-%m-%d"]}]} { + set next_link "" + } else { + if {[catch {clock scan $next_w}]} { + set next_link "" + } else { + set next_link ">" + } + } + set cal_stuff [calendar::one_week_display \ -item_template $item_template \ -day_template "\$day - \$pretty_date     ([_ calendar.Add_Item])" \ -date $date \ -calendar_id_list $calendar_list \ - -prev_week_template "<" \ - -next_week_template ">" - ] + -prev_week_template $previous_link \ + -next_week_template $next_link] + } if {$view == "month"} { + + # Check that the previous and next months are in the tcl boundaries + # so that the calendar widget doesn't bomb when it creates the next/prev links + if {[catch {set prev_m [clock format [clock scan "1 month ago" -base [clock scan $date]] -format "%Y-%m-%d"]}]} { + set previous_link "" + } else { + if {[catch {clock scan $prev_m}]} { + set previous_link "" + } else { + set previous_link "<" + } + } + + if {[catch {set next_m [clock format [clock scan "1 month" -base [clock scan $date]] -format "%Y-%m-%d"]}]} { + set next_link "" + } else { + if {[catch {clock scan $next_m}]} { + set next_link "" + } else { + set next_link ">" + } + } + set cal_stuff [calendar::one_month_display \ -item_template "$item_template" \ -day_template "\$day_number" \ -date $date \ -item_add_template "$item_add_template" \ -calendar_id_list $calendar_list \ - -prev_month_template "<" \ - -next_month_template ">"] + -prev_month_template $previous_link \ + -next_month_template $next_link] } if {$view == "list"} { Index: openacs-4/packages/chat/chat.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/chat/chat.info,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/chat/chat.info 16 Jan 2003 13:45:37 -0000 1.3 +++ openacs-4/packages/chat/chat.info 17 May 2003 10:21:44 -0000 1.4 @@ -16,7 +16,7 @@ ArsDigita Corporation ACS Chat is now support both HTML client and Java applet client. - + Index: openacs-4/packages/clickthrough/clickthrough.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/clickthrough/clickthrough.info,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/clickthrough/clickthrough.info 11 Jan 2002 18:30:36 -0000 1.5 +++ openacs-4/packages/clickthrough/clickthrough.info 17 May 2003 10:22:04 -0000 1.6 @@ -22,7 +22,7 @@ Any link can be clickthrough-enabled by embedding special information in its destination address. This is achieved by wrapping the href attribute with a call to `clickthrough_href' (e.g., [clickthrough_href http://www.arsdigita.com]). - + Index: openacs-4/packages/cms/cms.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/cms.info,v diff -u -N -r1.8 -r1.9 --- openacs-4/packages/cms/cms.info 23 Sep 2002 23:32:12 -0000 1.8 +++ openacs-4/packages/cms/cms.info 17 May 2003 10:22:20 -0000 1.9 @@ -19,7 +19,7 @@ - + Index: openacs-4/packages/cms/sql/postgresql/cms-content-methods.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/sql/postgresql/cms-content-methods.sql,v diff -u -N -r1.4 -r1.5 --- openacs-4/packages/cms/sql/postgresql/cms-content-methods.sql 8 Jun 2001 01:44:53 -0000 1.4 +++ openacs-4/packages/cms/sql/postgresql/cms-content-methods.sql 17 May 2003 10:22:35 -0000 1.5 @@ -125,7 +125,7 @@ -- create or replace package body content_method as -- function get_method -create function content_method__get_method (varchar) +create or replace function content_method__get_method (varchar) returns varchar as ' declare p_content_type alias for $1; @@ -173,7 +173,7 @@ -- function is_mapped -create function content_method__is_mapped (varchar,varchar) +create or replace function content_method__is_mapped (varchar,varchar) returns boolean as ' declare p_content_type alias for $1; @@ -193,7 +193,7 @@ -- procedure add_method -create function content_method__add_method (varchar,varchar,boolean) +create or replace function content_method__add_method (varchar,varchar,boolean) returns integer as ' declare p_content_type alias for $1; @@ -234,7 +234,7 @@ -- procedure add_all_methods -create function content_method__add_all_methods (varchar) +create or replace function content_method__add_all_methods (varchar) returns integer as ' declare p_content_type alias for $1; @@ -262,7 +262,7 @@ -- procedure set_default_method -create function content_method__set_default_method (varchar,varchar) +create or replace function content_method__set_default_method (varchar,varchar) returns integer as ' declare p_content_type alias for $1; @@ -284,7 +284,7 @@ -- procedure unset_default_method -create function content_method__unset_default_method (varchar) +create or replace function content_method__unset_default_method (varchar) returns integer as ' declare p_content_type alias for $1; @@ -299,7 +299,7 @@ -- procedure remove_method -create function content_method__remove_method (varchar,varchar) +create or replace function content_method__remove_method (varchar,varchar) returns integer as ' declare p_content_type alias for $1; Index: openacs-4/packages/cms/sql/postgresql/cms-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/sql/postgresql/cms-create.sql,v diff -u -N -r1.7 -r1.8 --- openacs-4/packages/cms/sql/postgresql/cms-create.sql 6 Jan 2003 02:05:18 -0000 1.7 +++ openacs-4/packages/cms/sql/postgresql/cms-create.sql 17 May 2003 10:22:35 -0000 1.8 @@ -14,7 +14,7 @@ \i cms-update.sql -create function inline_0 () +create or replace function inline_0 () returns integer as ' declare attr_id acs_attributes.attribute_id%TYPE; @@ -149,7 +149,7 @@ -- create or replace package body content_module -create function content_module__new (varchar,varchar,varchar,integer,integer) +create or replace function content_module__new (varchar,varchar,varchar,integer,integer) returns integer as ' declare p_name alias for $1; @@ -172,14 +172,14 @@ ); end;' language 'plpgsql'; -create function content_module__new (varchar,varchar,integer,integer,integer) +create or replace function content_module__new (varchar,varchar,integer,integer,integer) returns integer as ' begin return content_module__new ($1, $2, cast ($3 as varchar), $4, $5); end;' language 'plpgsql'; -- function new -create function content_module__new (varchar,varchar,varchar,integer,integer,integer,timestamp with time zone,integer,varchar,varchar) +create or replace function content_module__new (varchar,varchar,varchar,integer,integer,integer,timestamptz,integer,varchar,varchar) returns integer as ' declare p_name alias for $1; @@ -223,7 +223,7 @@ end;' language 'plpgsql'; -create function content_module__get_label (integer) returns varchar as ' +create or replace function content_module__get_label (integer) returns varchar as ' declare p_module_id alias for $1; v_name cm_modules.name%TYPE; @@ -241,7 +241,7 @@ end;' language 'plpgsql'; -- Insert the default modules -create function inline_1 () returns integer as ' +create or replace function inline_1 () returns integer as ' declare v_id integer; v_module_id integer; @@ -271,7 +271,7 @@ -- Get the alphabetical ordering of a string, based on the first -- character. Treat all non-alphabetical characters as before ''a'' -create function letter_placement (varchar) returns integer as ' +create or replace function letter_placement (varchar) returns integer as ' declare p_word alias for $1; v_letter varchar(1); Index: openacs-4/packages/cms/sql/postgresql/cms-fix.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/sql/postgresql/cms-fix.sql,v diff -u -N -r1.4 -r1.5 --- openacs-4/packages/cms/sql/postgresql/cms-fix.sql 22 May 2001 22:46:13 -0000 1.4 +++ openacs-4/packages/cms/sql/postgresql/cms-fix.sql 17 May 2003 10:22:35 -0000 1.5 @@ -13,7 +13,7 @@ -- content_module inherit from content_item -- this way it is possible to grant permissions on content modules -create function inline_0 () +create or replace function inline_0 () returns integer as ' declare v_user_id users.user_id%TYPE; Index: openacs-4/packages/cms/sql/postgresql/cms-forms.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/sql/postgresql/cms-forms.sql,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/cms/sql/postgresql/cms-forms.sql 8 Jan 2003 18:41:45 -0000 1.6 +++ openacs-4/packages/cms/sql/postgresql/cms-forms.sql 17 May 2003 10:22:35 -0000 1.7 @@ -120,99 +120,8 @@ order by object_type, sort_order; --- create or replace package cm_form_widget --- is --- --- procedure set_attribute_order ( --- --/** Update the sort_order column of acs_attributes. --- -- @author Karl Goldstein --- -- @param content_type The name of the content type --- -- @param attribute_name The name of the attribute --- -- @param sort_order The sort order. --- --*/ --- content_type in acs_attributes.object_type%TYPE, --- attribute_name in acs_attributes.attribute_name%TYPE, --- sort_order in acs_attributes.sort_order%TYPE --- ); --- --- procedure register_attribute_widget ( --- --/** Register a form widget to a content type attribute. The form widget --- -- uses the default values if none are set. If there is already a widget --- -- registered to the attribute, the new widget replaces the old widget, --- -- and all parameters are set to their default values. --- -- @author Karl Goldstein, Stanislav Freidin --- -- @param content_type The name of the content type --- -- @param attribute_name The name of the attribute --- -- @param widget The name of the form widget to use in metadata --- -- forms --- -- @param is_required Whether this form widget requires a value, --- -- defaults to 'f' --- -- @see /ats/form-procs.tcl/element_create, --- -- {cm_form_widget.set_attribute_param_value}, --- -- {cm_form_widget.unregister_attribute_widget} --- --*/ --- content_type in acs_attributes.object_type%TYPE, --- attribute_name in acs_attributes.attribute_name%TYPE, --- widget in cm_form_widgets.widget%TYPE, --- is_required in cm_attribute_widgets.is_required%TYPE default 'f' --- ); --- --- procedure unregister_attribute_widget ( --- --/** Unregister a form widget from a content type attribute. --- -- The attribute will no longer show up on the dynamic revision --- -- upload form.

If no widget is registered to the attribute, --- -- the procedure does nothing. --- -- @author Karl Goldstein, Stanislav Freidin --- -- @param content_type The name of the content type --- -- @param attribute_name The name of the attribute for which to --- -- unregister the widget --- -- @see {cm_form_widget.register_attribute_widget} --- --*/ --- content_type in acs_attributes.object_type%TYPE, --- attribute_name in acs_attributes.attribute_name%TYPE --- ); --- --- procedure set_attribute_param_value ( --- --/** Sets custom values for the param tag of a form widget that is --- -- registered to a content type attribute. Unless this procedure is --- -- called, the default form widget param values are used.

--- -- If the parameter already has a value associated with it, the old --- -- value is overwritten. --- -- @author Karl Goldstein, Stanislav Freidin --- -- @param content_type The name of the content type --- -- @param attribute_name The name of the attribute --- -- @param param The name of the form widget parameter. --- -- Can be an ATS 'element create' flag or an --- -- HTML form widget tag --- -- @param param_type The type of value the param tag expects. --- -- Can be 'onevalue','onelist', or 'multilist', --- -- defaults to 'onevalue' --- -- @param param_source How the param value is to be acquired, either --- -- 'literal', 'eval', or 'query', defaults to --- -- 'literal' --- -- @param value The value(s) or means or obtaining the value(s) --- -- for the param tag --- -- @see /ats/form-procs.tcl/element_create, --- -- {cm_form_widget.register_attribute_widget} --- --*/ --- content_type in acs_attributes.object_type%TYPE, --- attribute_name in acs_attributes.attribute_name%TYPE, --- param in cm_form_widget_params.param%TYPE, --- value in cm_attribute_widget_params.value%TYPE, --- param_type in cm_attribute_widget_params.param_type%TYPE --- default 'onevalue', --- param_source in cm_attribute_widget_params.param_source%TYPE --- default 'literal' --- ); --- --- end cm_form_widget; --- show errors - - --- create or replace package body cm_form_widget --- procedure register_attribute_widget -create function cm_form_widget__register_attribute_widget (varchar,varchar,varchar,boolean) +create or replace function cm_form_widget__register_attribute_widget (varchar,varchar,varchar,boolean) returns integer as ' declare p_content_type alias for $1; @@ -272,7 +181,7 @@ -- procedure set_attribute_order -create function cm_form_widget__set_attribute_order (varchar,varchar,integer) +create or replace function cm_form_widget__set_attribute_order (varchar,varchar,integer) returns integer as ' declare p_content_type alias for $1; @@ -295,7 +204,7 @@ -- procedure unregister_attribute_widget -create function cm_form_widget__unregister_attribute_widget (varchar,varchar) +create or replace function cm_form_widget__unregister_attribute_widget (varchar,varchar) returns integer as ' declare p_content_type alias for $1; @@ -337,7 +246,7 @@ -- procedure set_attribute_param_value -create function cm_form_widget__set_attribute_param_value (varchar,varchar,varchar,varchar,varchar,varchar) +create or replace function cm_form_widget__set_attribute_param_value (varchar,varchar,varchar,varchar,varchar,varchar) returns integer as ' declare p_content_type alias for $1; @@ -405,13 +314,12 @@ return 0; end;' language 'plpgsql'; -create function cm_form_widget__set_attribute_param_value (varchar,varchar,varchar,integer,varchar,varchar) + +create or replace function cm_form_widget__set_attribute_param_value (varchar,varchar,varchar,integer,varchar,varchar) returns integer as ' begin return cm_form_widget__set_attribute_param_value($1, $2, $3, cast ($4 as varchar), $5, $6); end;' language 'plpgsql'; --- show errors - \i cms-widgets.sql Index: openacs-4/packages/cms/sql/postgresql/cms-permissions.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/sql/postgresql/cms-permissions.sql,v diff -u -N -r1.10 -r1.11 --- openacs-4/packages/cms/sql/postgresql/cms-permissions.sql 23 Feb 2003 18:19:48 -0000 1.10 +++ openacs-4/packages/cms/sql/postgresql/cms-permissions.sql 17 May 2003 10:22:35 -0000 1.11 @@ -1,7 +1,7 @@ -- This file will eventually replace content-perms.sql -- Implements the CMS permission -create function inline_0 () +create or replace function inline_0 () returns integer as ' declare v_perms boolean default ''f''; @@ -213,7 +213,7 @@ -- create or replace package body cms_permission -- procedure update_permissions -create function cms_permission__update_permissions (integer,varchar) +create or replace function cms_permission__update_permissions (integer,varchar) returns integer as ' declare p_item_id alias for $1; @@ -304,7 +304,7 @@ -- function has_grant_authority -create function cms_permission__has_grant_authority (integer,integer,varchar) +create or replace function cms_permission__has_grant_authority (integer,integer,varchar) returns boolean as ' declare p_item_id alias for $1; @@ -328,7 +328,7 @@ -- function has_revoke_authority -create function cms_permission__has_revoke_authority (integer,integer,varchar,integer) +create or replace function cms_permission__has_revoke_authority (integer,integer,varchar,integer) returns boolean as ' declare p_item_id alias for $1; @@ -364,7 +364,7 @@ ); insert into v_items (value) values ('{0}'); -create function v_items_tr () returns opaque as ' +create or replace function v_items_tr () returns opaque as ' begin raise EXCEPTION ''Only updates are allowed on this table''; return null; @@ -379,7 +379,7 @@ ); insert into v_perms (value) values ('{''}'); -create function v_perms_tr () returns opaque as ' +create or replace function v_perms_tr () returns opaque as ' begin raise EXCEPTION ''Only updates are allowed on this table''; return null; @@ -391,7 +391,7 @@ -- procedure grant_permission -- FIXME: need to fix problem with defined types -create function cms_permission__grant_permission (integer,integer,varchar,integer,varchar) +create or replace function cms_permission__grant_permission (integer,integer,varchar,integer,varchar) returns integer as ' declare p_item_id alias for $1; @@ -480,7 +480,7 @@ -- procedure revoke_permission -create function cms_permission__revoke_permission (integer,integer,varchar,integer,varchar) +create or replace function cms_permission__revoke_permission (integer,integer,varchar,integer,varchar) returns integer as ' declare p_item_id alias for $1; @@ -576,7 +576,7 @@ -- function permission_p -create function cms_permission__permission_p (integer,integer,varchar) +create or replace function cms_permission__permission_p (integer,integer,varchar) returns boolean as ' declare p_item_id alias for $1; @@ -660,7 +660,7 @@ end;' language 'plpgsql'; -create function cms_permission__cm_admin_exists() returns boolean as ' +create or replace function cms_permission__cm_admin_exists() returns boolean as ' declare v_exists boolean; begin @@ -685,7 +685,7 @@ -- A trigger to automatically grant item creators the cm_write and cm_perm -- permissions -create function cr_items_permission_tr () returns opaque as ' +create or replace function cr_items_permission_tr () returns opaque as ' declare v_user_id parties.party_id%TYPE; begin @@ -801,7 +801,7 @@ -- create or replace package body content_permission -- procedure inherit_permissions -create function content_permission__inherit_permissions (integer,integer,integer) +create or replace function content_permission__inherit_permissions (integer,integer,integer) returns integer as ' declare p_parent_object_id alias for $1; @@ -814,7 +814,7 @@ -- function has_grant_authority -create function content_permission__has_grant_authority (integer,integer,varchar) +create or replace function content_permission__has_grant_authority (integer,integer,varchar) returns boolean as ' declare p_object_id alias for $1; @@ -829,7 +829,7 @@ -- procedure grant_permission_h -create function content_permission__grant_permission_h (integer,integer,varchar) +create or replace function content_permission__grant_permission_h (integer,integer,varchar) returns integer as ' declare p_object_id alias for $1; @@ -841,7 +841,7 @@ -- procedure grant_permission -create function content_permission__grant_permission (integer,integer,varchar,integer,varchar,varchar) +create or replace function content_permission__grant_permission (integer,integer,varchar,integer,varchar,varchar) returns integer as ' declare p_object_id alias for $1; @@ -860,7 +860,7 @@ -- function has_revoke_authority -create function content_permission__has_revoke_authority (integer,integer,varchar,integer) +create or replace function content_permission__has_revoke_authority (integer,integer,varchar,integer) returns boolean as ' declare p_object_id alias for $1; @@ -876,7 +876,7 @@ -- procedure revoke_permission_h -create function content_permission__revoke_permission_h (integer,integer,varchar) +create or replace function content_permission__revoke_permission_h (integer,integer,varchar) returns integer as ' declare p_object_id alias for $1; @@ -888,7 +888,7 @@ -- procedure revoke_permission -create function content_permission__revoke_permission (integer,integer,varchar,integer,varchar,varchar) +create or replace function content_permission__revoke_permission (integer,integer,varchar,integer,varchar,varchar) returns integer as ' declare p_object_id alias for $1; @@ -907,7 +907,7 @@ -- function permission_p -create function content_permission__permission_p (integer,integer,varchar) +create or replace function content_permission__permission_p (integer,integer,varchar) returns boolean as ' declare p_object_id alias for $1; Index: openacs-4/packages/cms/sql/postgresql/cms-publishing-wf.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/sql/postgresql/cms-publishing-wf.sql,v diff -u -N -r1.9 -r1.10 --- openacs-4/packages/cms/sql/postgresql/cms-publishing-wf.sql 30 Nov 2002 17:29:02 -0000 1.9 +++ openacs-4/packages/cms/sql/postgresql/cms-publishing-wf.sql 17 May 2003 10:22:35 -0000 1.10 @@ -6,7 +6,7 @@ references wf_cases ); -create function inline_0 () +create or replace function inline_0 () returns integer as ' declare v_workflow_key varchar(100); @@ -244,7 +244,7 @@ -- create or replace package body publishing_wf as -- function is_next -create function publishing_wf__is_next (integer,varchar,varchar,varchar,varchar,varchar) +create or replace function publishing_wf__is_next (integer,varchar,varchar,varchar,varchar,varchar) returns char as ' declare p_case_id alias for $1; @@ -268,7 +268,7 @@ end;' language 'plpgsql'; -create function inline_2 () +create or replace function inline_2 () returns integer as ' declare v_attribute_id acs_attributes.attribute_id%TYPE; Index: openacs-4/packages/cms/sql/postgresql/cms-update.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/sql/postgresql/cms-update.sql,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/cms/sql/postgresql/cms-update.sql 22 May 2001 22:46:13 -0000 1.3 +++ openacs-4/packages/cms/sql/postgresql/cms-update.sql 17 May 2003 10:22:35 -0000 1.4 @@ -1,6 +1,6 @@ -- Modify permissions to include the cm_relate permission -create function inline_0 () +create or replace function inline_0 () returns integer as ' declare v_exists integer; @@ -33,7 +33,7 @@ -- This parent_id column was not included in the cr_keywords table -- for RC 0. Ensure this column is there. -create function inline_1 () +create or replace function inline_1 () returns integer as ' begin @@ -63,7 +63,7 @@ -- show errors -- Drop the broken trigger, if any -create function inline_2 () +create or replace function inline_2 () returns integer as ' begin -- FIXME: DCW - can''t locate where this trigger is created. Need a table Index: openacs-4/packages/cms/sql/postgresql/cms-widgets.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/sql/postgresql/cms-widgets.sql,v diff -u -N -r1.4 -r1.5 --- openacs-4/packages/cms/sql/postgresql/cms-widgets.sql 8 Jun 2001 01:44:53 -0000 1.4 +++ openacs-4/packages/cms/sql/postgresql/cms-widgets.sql 17 May 2003 10:22:35 -0000 1.5 @@ -3,7 +3,7 @@ /* insert form widgets and params */ -create function inline_0 () +create or replace function inline_0 () returns integer as ' begin @@ -94,7 +94,7 @@ -- show errors -create function inline_1 () +create or replace function inline_1 () returns integer as ' begin @@ -123,7 +123,7 @@ -create function inline_2 () +create or replace function inline_2 () returns integer as ' begin @@ -188,7 +188,7 @@ /* Register attribute widgets for content_revision and image */ -create function inline_3 () +create or replace function inline_3 () returns integer as ' begin -- register form widgetes for content revision attributes @@ -302,7 +302,7 @@ -create function inline_4 () +create or replace function inline_4 () returns integer as ' begin Index: openacs-4/packages/cms/sql/postgresql/cms-workflow.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/sql/postgresql/cms-workflow.sql,v diff -u -N -r1.12 -r1.13 --- openacs-4/packages/cms/sql/postgresql/cms-workflow.sql 21 Dec 2002 22:29:41 -0000 1.12 +++ openacs-4/packages/cms/sql/postgresql/cms-workflow.sql 17 May 2003 10:22:35 -0000 1.13 @@ -340,7 +340,7 @@ -- create or replace package body content_workflow -- function is_overdue -create function content_workflow__is_overdue (integer) +create or replace function content_workflow__is_overdue (integer) returns boolean as ' declare p_task_id alias for $1; @@ -368,7 +368,7 @@ -- function is_overdue -create function content_workflow__is_overdue (integer,varchar) +create or replace function content_workflow__is_overdue (integer,varchar) returns boolean as ' declare p_case_id alias for $1; @@ -393,7 +393,7 @@ -- function get_holding_user_name -create function content_workflow__get_holding_user_name (integer) +create or replace function content_workflow__get_holding_user_name (integer) returns varchar as ' declare p_task_id alias for $1; @@ -417,7 +417,7 @@ -create function content_workflow__get_first_place() returns varchar as ' +create or replace function content_workflow__get_first_place() returns varchar as ' declare v_first_place wf_places.place_key%TYPE; begin @@ -441,7 +441,7 @@ end;' language 'plpgsql'; -- function get_this_place -create function content_workflow__get_this_place (varchar) +create or replace function content_workflow__get_this_place (varchar) returns varchar as ' declare p_transition_key alias for $1; @@ -470,7 +470,7 @@ -- function get_next_place -create function content_workflow__get_next_place (varchar) +create or replace function content_workflow__get_next_place (varchar) returns varchar as ' declare p_transition_key alias for $1; @@ -505,7 +505,7 @@ -- function get_previous_place -create function content_workflow__get_previous_place (varchar) +create or replace function content_workflow__get_previous_place (varchar) returns varchar as ' declare p_transition_key alias for $1; @@ -540,7 +540,7 @@ -- procedure checkout -create function content_workflow__checkout (integer,timestamp with time zone,integer,varchar,varchar) +create or replace function content_workflow__checkout (integer,timestamptz,integer,varchar,varchar) returns integer as ' declare p_task_id alias for $1; @@ -634,7 +634,7 @@ -- procedure checkin -create function content_workflow__checkin (integer,integer,varchar,varchar) +create or replace function content_workflow__checkin (integer,integer,varchar,varchar) returns integer as ' declare p_task_id alias for $1; @@ -694,7 +694,7 @@ -- procedure approve -create function content_workflow__approve (integer,integer,varchar,varchar) +create or replace function content_workflow__approve (integer,integer,varchar,varchar) returns integer as ' declare p_task_id alias for $1; @@ -770,7 +770,7 @@ -- procedure reject -create function content_workflow__reject (integer,integer,varchar,varchar,varchar) +create or replace function content_workflow__reject (integer,integer,varchar,varchar,varchar) returns integer as ' declare p_task_id alias for $1; @@ -877,7 +877,7 @@ -- procedure notify_of_checkout -create function content_workflow__notify_of_checkout (integer,integer,integer,varchar) +create or replace function content_workflow__notify_of_checkout (integer,integer,integer,varchar) returns integer as ' declare p_task_id alias for $1; @@ -937,7 +937,7 @@ -- function can_reject -create function content_workflow__can_reject (integer,integer) +create or replace function content_workflow__can_reject (integer,integer) returns boolean as ' declare p_task_id alias for $1; @@ -965,7 +965,7 @@ -- function can_approve -create function content_workflow__can_approve (integer,integer) +create or replace function content_workflow__can_approve (integer,integer) returns boolean as ' declare p_task_id alias for $1; @@ -989,7 +989,7 @@ -- function can_start -create function content_workflow__can_start (integer,integer) +create or replace function content_workflow__can_start (integer,integer) returns boolean as ' declare p_task_id alias for $1; @@ -1013,7 +1013,7 @@ -- function approve_string -create function content_workflow__approve_string (integer,integer) +create or replace function content_workflow__approve_string (integer,integer) returns varchar as ' declare p_task_id alias for $1; @@ -1049,7 +1049,7 @@ -- function count_finished_tasks -create function content_workflow__count_finished_tasks (integer) +create or replace function content_workflow__count_finished_tasks (integer) returns integer as ' declare p_case_id alias for $1; @@ -1086,7 +1086,7 @@ -- function count_unfinished_tasks -create function content_workflow__count_unfinished_tasks (integer) +create or replace function content_workflow__count_unfinished_tasks (integer) returns integer as ' declare p_case_id alias for $1; @@ -1114,7 +1114,7 @@ -- function is_active -create function content_workflow__is_active (integer,varchar) +create or replace function content_workflow__is_active (integer,varchar) returns boolean as ' declare p_case_id alias for $1; @@ -1136,7 +1136,7 @@ -- function is_finished -create function content_workflow__is_finished (integer,varchar) +create or replace function content_workflow__is_finished (integer,varchar) returns boolean as ' declare p_case_id alias for $1; @@ -1186,7 +1186,7 @@ -- function is_checked_out -create function content_workflow__is_checked_out (integer,varchar) +create or replace function content_workflow__is_checked_out (integer,varchar) returns boolean as ' declare p_case_id alias for $1; @@ -1209,7 +1209,7 @@ -- function is_checked_out -create function content_workflow__is_checked_out (integer,varchar,integer) +create or replace function content_workflow__is_checked_out (integer,varchar,integer) returns boolean as ' declare p_case_id alias for $1; @@ -1235,7 +1235,7 @@ -- function get_status -create function content_workflow__get_status (integer,varchar) +create or replace function content_workflow__get_status (integer,varchar) returns varchar as ' declare p_case_id alias for $1; @@ -1283,7 +1283,7 @@ -- function can_touch -create function content_workflow__can_touch (integer,integer) +create or replace function content_workflow__can_touch (integer,integer) returns boolean as ' declare p_item_id alias for $1; @@ -1342,7 +1342,7 @@ -- function unfinished_workflow_exists -create function content_workflow__unfinished_workflow_exists (integer) +create or replace function content_workflow__unfinished_workflow_exists (integer) returns boolean as ' declare p_item_id alias for $1; Index: openacs-4/packages/cms/sql/postgresql/rel-test.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/sql/postgresql/rel-test.sql,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/cms/sql/postgresql/rel-test.sql 22 May 2001 04:44:57 -0000 1.2 +++ openacs-4/packages/cms/sql/postgresql/rel-test.sql 17 May 2003 10:22:35 -0000 1.3 @@ -18,7 +18,7 @@ check (direction in ('in', 'out')) ); -create function inline_0 () returns integer as ' +create or replace function inline_0 () returns integer as ' declare attr_id integer; begin @@ -95,7 +95,7 @@ weight_b integer not null ); -create function inline_1 () returns integer as ' +create or replace function inline_1 () returns integer as ' declare attr_id integer; begin Index: openacs-4/packages/cms/sql/postgresql/upgrade/upgrade-4.6-4.6.1.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/sql/postgresql/upgrade/upgrade-4.6-4.6.1.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/cms/sql/postgresql/upgrade/upgrade-4.6-4.6.1.sql 17 May 2003 10:22:50 -0000 1.2 @@ -0,0 +1,146 @@ +-- DRB: Needed because workflow views were dependent on the party_approved_member_map +-- view (which is now a table) and because PG doesn't support CREATE OR REPLACE VIEW. + +-- function permission_p +create or replace function cms_permission__permission_p (integer,integer,varchar) +returns boolean as ' +declare + p_item_id alias for $1; + p_holder_id alias for $2; + p_privilege alias for $3; + v_workflow_count integer; + v_task_count integer; +begin + + -- Check permission the old-fashioned way first + if acs_permission__permission_p ( + p_item_id, p_holder_id, p_privilege + ) = ''f'' + then + return ''f''; + end if; + + -- Special case for workflow + + if p_privilege = ''cm_relate'' or + p_privilege = ''cm_write'' or + p_privilege = ''cm_new'' + then + + -- Check if the publishing workflow exists, and if it + -- is the only workflow that exists + select + count(case_id) into v_workflow_count + from + wf_cases + where + object_id = p_item_id; + + -- If there are multiple workflows / no workflows, do nothing + -- special + if v_workflow_count <> 1 then + return ''t''; + end if; + + -- Even if there is a workflow, the user can touch the item if he + -- has cm_item_workflow + if acs_permission__permission_p ( + p_item_id, p_holder_id, ''cm_item_workflow'' + ) = ''t'' + then + return ''t''; + end if; + + -- Check if the user holds the current task + if v_workflow_count = 0 then + return ''f''; + end if; + + select + count(task_id) into v_task_count + from + wf_user_tasks t, wf_cases c + where + t.case_id = c.case_id + and + c.workflow_key = ''publishing_wf'' + and + c.state = ''active'' + and + c.object_id = p_item_id + and + ( t.state = ''enabled'' + or + ( t.state = ''started'' and t.holding_user = p_holder_id )) + and + t.user_id = p_holder_id; + + -- is the user assigned a current task on this item + if v_task_count = 0 then + return ''f''; + end if; + + end if; + + return ''t''; + +end;' language 'plpgsql'; + +-- function can_touch +create or replace function content_workflow__can_touch (integer,integer) +returns boolean as ' +declare + p_item_id alias for $1; + p_user_id alias for $2; + v_workflow_count integer; + v_task_count integer; +begin + + -- cm_admin has highest precedence + if content_permission__permission_p( + p_item_id, p_user_id, ''cm_item_workflow'' ) = ''t'' then + return ''t''; + end if; + + select + count(case_id) into v_workflow_count + from + wf_cases + where + object_id = p_item_id; + + -- workflow must exist + if v_workflow_count = 0 then + return ''f''; + end if; + + select + count(task_id) into v_task_count + from + wf_user_tasks t, wf_cases c + where + t.case_id = c.case_id + and + c.workflow_key = ''publishing_wf'' + and + c.state = ''active'' + and + c.object_id = p_item_id + and + ( t.state = ''enabled'' + or + ( t.state = ''started'' and t.holding_user = p_user_id )) + and + t.user_id = p_user_id; + + + -- is the user assigned a current task on this item + if v_task_count = 0 then + return ''f''; + else + return ''t''; + end if; + + +end;' language 'plpgsql'; + Index: openacs-4/packages/cms/tcl/form-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/form-procs-oracle.xql,v diff -u -N -r1.15 -r1.16 --- openacs-4/packages/cms/tcl/form-procs-oracle.xql 25 Sep 2002 04:22:52 -0000 1.15 +++ openacs-4/packages/cms/tcl/form-procs-oracle.xql 17 May 2003 10:23:15 -0000 1.16 @@ -159,7 +159,7 @@ begin - :item_id := content_item.new( [join $params ","] ); + :1 := content_item.new( [join $params ","] ); end; @@ -186,8 +186,7 @@ update cr_revisions - set filename ='[cr_create_content_file $item_id $revision_id $tmpfile]', - content_length = [file size $tmpfile] + set filename =:file_path, content_length = :file_size where revision_id = :revision_id @@ -237,7 +236,7 @@ and content_item.is_subclass(:content_type, c.child_type) = 't' and - content_item.is_valid_child(:parent_id, c.child_type) = 't' + content_item.is_valid_child(:parent_id, c.child_type, relation_tag) = 't' @@ -277,8 +276,6 @@ ) types where object_type = ancestor - and - attribute_name <> 'ldap dn' order by type_order desc, sort_order Index: openacs-4/packages/cms/tcl/form-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/form-procs-postgresql.xql,v diff -u -N -r1.19 -r1.20 --- openacs-4/packages/cms/tcl/form-procs-postgresql.xql 30 Nov 2002 17:29:11 -0000 1.19 +++ openacs-4/packages/cms/tcl/form-procs-postgresql.xql 17 May 2003 10:23:15 -0000 1.20 @@ -182,14 +182,13 @@ - + update cr_revisions - set content = '[set file_path [cr_create_content_file $item_id $revision_id $tmpfile]]', - content_length = '[cr_file_size $file_path]' + set content = :file_path, content_length = :file_size where revision_id = :revision_id @@ -329,8 +328,6 @@ ) types where object_type = ancestor - and - attribute_name <> 'ldap dn' order by type_order desc, sort_order Index: openacs-4/packages/cms/tcl/form-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/form-procs.tcl,v diff -u -N -r1.21 -r1.22 --- openacs-4/packages/cms/tcl/form-procs.tcl 18 Sep 2002 03:58:40 -0000 1.21 +++ openacs-4/packages/cms/tcl/form-procs.tcl 17 May 2003 10:23:15 -0000 1.22 @@ -1,202 +1,202 @@ namespace eval content { - # namespace import seems to prevent content:: procs from being recognized - # namespace import ::template::query ::template::form ::template::element + # namespace import seems to prevent content:: procs from being recognized + # namespace import ::template::query ::template::form ::template::element } -ad_proc -public content::query_form_metadata { - {datasource_name rows} {datasource_type multirow} \ - {extra_where {}} {extra_orderby {}} +ad_proc -private content::query_form_metadata { + {datasource_name rows} + {datasource_type multirow} + {extra_where {}} + {extra_orderby {}} } { - - Helper proc: query out all the information neccessary to create - a custom form element based on stored metadata - Requires the variable content_type to be set in the calling frame - + Helper proc: query out all the information neccessary to create + a custom form element based on stored metadata + Requires the variable content_type to be set in the calling frame } { + # query for all attribute widget param values associated with a content + # the 3 nvl subqueries are necessary because we cannot outer join + # to more than one table without doing multiple subqueries (which is + # even less efficient than this way) + set query [db_map attributes_query_1] + + if { ![template::util::is_nil extra_where] } { + append query [db_map attributes_query_extra_where] + } - # query for all attribute widget param values associated with a content - # the 3 nvl subqueries are necessary because we cannot outer join - # to more than one table without doing multiple subqueries (which is - # even less efficient than this way) - - set query [db_map attributes_query_1] - - if { ![template::util::is_nil extra_where] } { - append query [db_map attributes_query_extra_where] - } - - append query " + append query " order by attributes.tree_level, attributes.sort_order desc, attributes.attribute_id, params.param_id" - - if { ![template::util::is_nil extra_orderby] } { - append query ", $extra_orderby" - } - if [string equal $datasource_type multirow] { - uplevel "db_multirow $datasource_name get_form_metadata \{$query\}" - } else { - uplevel "set $datasource_name [db_list_of_lists get_form_metadata {}]" - } + + if { ![template::util::is_nil extra_orderby] } { + append query ", $extra_orderby" + } + if [string equal $datasource_type multirow] { + uplevel "db_multirow $datasource_name get_form_metadata \{$query\}" + } else { + uplevel "set $datasource_name [db_list_of_lists get_form_metadata {}]" + } } -ad_proc -public content::assemble_form_element { datasource_ref the_attribute_name start_row {db {}}} { +ad_proc -private content::assemble_form_element { + datasource_ref the_attribute_name start_row {db {}} +} { - Process the query and assemble the "element create..." statement - PRE: uber-query has been run - POST: html_params, code_params set; returns the index of the next - available row + Process the query and assemble the "element create..." statement + PRE: uber-query has been run + POST: html_params, code_params set; returns the index of the next + available row } { - upvar "${datasource_ref}:rowcount" rowcount - upvar code_params code_params - upvar content_type content_type - upvar opts opts + upvar "${datasource_ref}:rowcount" rowcount + upvar code_params code_params + upvar content_type content_type + upvar opts opts - set code_params [list] - set html_params [list] + set code_params [list] + set html_params [list] - # Process the results of the query. - for { set i $start_row } { $i <= $rowcount } { incr i } { - upvar "${datasource_ref}:${i}" q_row + # Process the results of the query. + for { set i $start_row } { $i <= $rowcount } { incr i } { + upvar "${datasource_ref}:${i}" q_row - if { ![string equal $q_row(attribute_name) $the_attribute_name] } { - break - } + if { ![string equal $q_row(attribute_name) $the_attribute_name] } { + break + } - template::util::array_to_vars q_row + template::util::array_to_vars q_row - content::get_revision_create_element - } - set last_row $i + content::get_revision_create_element + } + set last_row $i - # All the neccessary variables should still be set - get_element_default_params + # All the neccessary variables should still be set + get_element_default_params - # eval the last "element create" string - if { [llength $html_params] } { - # widget has html parameters - lappend code_params -html $html_params - } + # eval the last "element create" string + if { [llength $html_params] } { + # widget has html parameters + lappend code_params -html $html_params + } - # Append any other parameters directly to the element create statement - foreach name {content_type revision_id item_id} { - if { [info exists opts($name)] } { - unset opts($name) + # Append any other parameters directly to the element create statement + foreach name {content_type revision_id item_id} { + if { [info exists opts($name)] } { + unset opts($name) + } } - } - foreach name [array names opts] { - lappend code_params "-${name}" $opts($name) - } + foreach name [array names opts] { + lappend code_params "-${name}" $opts($name) + } - return $last_row + return $last_row } ad_proc -public content::create_form_element { form_name attribute_name args } { - Create a form widget based on the given attribute. Query parameters - out of the database, override them with the passed-in parameters - if they exist. - If the -revision_id flag exists, fills in the value of the attribute from - the database, based on the given revision_id. - If the -content_type flag exists, uses the attribute for the given content - type (without inheritance). - If the -item_id flag is present, the live revision for the item will be - used. - If the -item_id and the -revision_id flags are missing, the -content_type - flag must be specified. - Example: - content::create_form_element my_form width -revision_id $image_id -size 10 + Create a form widget based on the given attribute. Query parameters + out of the database, override them with the passed-in parameters + if they exist. + If the -revision_id flag exists, fills in the value of the attribute from + the database, based on the given revision_id. + If the -content_type flag exists, uses the attribute for the given content + type (without inheritance). + If the -item_id flag is present, the live revision for the item will be + used. + If the -item_id and the -revision_id flags are missing, the -content_type + flag must be specified. + Example: + content::create_form_element my_form width -revision_id $image_id -size 10 This call will create an element representing the width attribute of the image type, with the textbox size set to 10 characters, and query the current value of the attribute out of the database. } { - template::util::get_opts $args + template::util::get_opts $args - # Get the revision id if the item id is specified, or if - # it is passed in directly - if { ![template::util::is_nil opts(revision_id)] } { - set revision_id $opts(revision_id) - - } elseif { ![template::util::is_nil opts(item_id)] } { - - set item_id $opts(item_id) - set revision_id [db_string get_revision_id ""] - } + # Get the revision id if the item id is specified, or if + # it is passed in directly + if { ![template::util::is_nil opts(revision_id)] } { + set revision_id $opts(revision_id) + + } elseif { ![template::util::is_nil opts(item_id)] } { + + set item_id $opts(item_id) + set revision_id [db_string get_revision_id ""] + } - if { [info exists opts(content_type)] } { - # The type is known: use it - set content_type $opts(content_type) - } else { - - # Figure out the type based on revision_id - if { ![info exists revision_id] } { - template::request error invalid_element_flags " + if { [info exists opts(content_type)] } { + # The type is known: use it + set content_type $opts(content_type) + } else { + + # Figure out the type based on revision_id + if { ![info exists revision_id] } { + template::request error invalid_element_flags " No revision_id, item_id or content_type specified in content::create_form_element for attribute ${form_name}:${attribute_name}" - return + return + } + + set content_type [db_string get_content_type ""] } - - set content_type [db_string get_content_type ""] - } - # Run the gigantic uber-query. This is somewhat wasteful; should - # be replaced by 2 smaller queries: one for the attribute_id, one - # for parameter types and values. - query_form_metadata params multirow "attribute_name = :attribute_name" - - if { ${params:rowcount} < 1} { - error "No widgets are registered for ${content_type}.${attribute_name}" - } + # Run the gigantic uber-query. This is somewhat wasteful; should + # be replaced by 2 smaller queries: one for the attribute_id, one + # for parameter types and values. + query_form_metadata params multirow "attribute_name = :attribute_name" + + if { ${params:rowcount} < 1} { + error "No widgets are registered for ${content_type}.${attribute_name}" + } - template::util::array_to_vars "params:1" - assemble_form_element params $attribute_name 1 + template::util::array_to_vars "params:1" + assemble_form_element params $attribute_name 1 - # If the -revision_id switch exists, look up the existing value for the - # element - if { ![template::util::is_nil revision_id] && [lsearch $code_params "-value"] < 0 } { - - # Handle custom datatypes... Basically, this is done so that - # the date widget will work :-/ - # In the future, upgrade the date widget and use acs_object.get_attribute + # If the -revision_id switch exists, look up the existing value for the + # element + if { ![template::util::is_nil revision_id] && [lsearch $code_params "-value"] < 0 } { + + # Handle custom datatypes... Basically, this is done so that + # the date widget will work :-/ + # In the future, upgrade the date widget and use acs_object.get_attribute - switch $datatype { - date { - set what [db_map cfe_attribute_name_to_char] - } + switch $datatype { + date { + set what [db_map cfe_attribute_name_to_char] + } - default { - set what [db_map cfe_attribute_name] - } + default { + set what [db_map cfe_attribute_name] + } + } + + set element [db_string get_element_value ""] + + lappend code_params -value $element_value -values [list $element_value] } - - set element [db_string get_element_value ""] - lappend code_params -value $element_value -values [list $element_value] - } + set form_element "template::element create $form_name $attribute_name $code_params" + if { ![string equal $is_required t] } { + append form_element " -optional" + } - set form_element "template::element create $form_name $attribute_name $code_params" - if { ![string equal $is_required t] } { - append form_element " -optional" - } - - eval $form_element + eval $form_element } - + ad_proc -public content::get_revision_form { - content_type item_id form_name {show_sections t} {element_override {}} + content_type item_id form_name {show_sections t} {element_override {}} } { - generate a form based on metadata + generate a form based on metadata } { @@ -244,10 +244,10 @@ lappend code_params -html $html_params } set form_element \ - "template::element create $form_name $last_attribute_name $code_params" - #ns_log notice "*** CREATING..." - #ns_log notice "*** ATTRIBUTE : $last_attribute_name" - #ns_log notice "*** TYPE_LABEL : $last_type" + "template::element create $form_name $last_attribute_name $code_params" + ns_log notice "*** CREATING..." + ns_log notice "*** ATTRIBUTE : $last_attribute_name" + ns_log notice "*** TYPE_LABEL : $last_type" eval $form_element set code_params [list] @@ -262,7 +262,7 @@ # evaluate the param get_revision_create_element if { [info exists overrides($last_attribute_name)] } { - set code_params [concat $code_params $overrides($last_attribute_name)] + set code_params [concat $code_params $overrides($last_attribute_name)] } set last_attribute_name $attribute_name @@ -277,46 +277,46 @@ } set form_element "template::element create $form_name $last_attribute_name $code_params" - #ns_log notice "***ELEMENT CREATE: $form_element" + ns_log notice "***ELEMENT CREATE: $form_element" eval $form_element # add some default form elements eval template::element create $form_name content_type \ - -widget hidden -datatype keyword -value $content_type + -widget hidden -datatype keyword -value $content_type if { ![string equal $item_id ""] } { eval template::element create $form_name item_id \ - -widget hidden -datatype integer -value $item_id + -widget hidden -datatype integer -value $item_id } } ad_proc -public content::get_element_default_params {} { - PRE: requires datatype, widget, attribute_label, is_required code_params - to be set in the calling frame - - POST: appends the list of params neccessary to create a new element to code_params + PRE: requires datatype, widget, attribute_label, is_required code_params + to be set in the calling frame + + POST: appends the list of params neccessary to create a new element to code_params } { - uplevel { - lappend code_params -datatype $datatype -widget $widget \ - -label $attribute_label - if { [string equal $is_required "f"] } { - lappend code_params -optional + uplevel { + lappend code_params -datatype $datatype -widget $widget \ + -label $attribute_label + if { [string equal $is_required "f"] } { + lappend code_params -optional + } } - } } ad_proc content::get_revision_create_element {} { - PRE: requires the following variables to be set in the uplevel scope: - db, code_params, html_params, - attribute_id, attribute_name, datatype, is_html, - param_source, param_type, value - POST: adds params to the 'element create' command + PRE: requires the following variables to be set in the uplevel scope: + db, code_params, html_params, + attribute_id, attribute_name, datatype, is_html, + param_source, param_type, value + POST: adds params to the 'element create' command } { upvar __sql sql @@ -371,7 +371,7 @@ ad_proc -public content::process_revision_form { form_name content_type item_id {db{}} } { - perform the appropriate DML based on metadata + perform the appropriate DML based on metadata } { @@ -402,8 +402,8 @@ upvar 0 "rows:${i}" row template::util::array_to_vars row - #ns_log notice "=========> $attribute_name" - #ns_log notice "=========> $table_name" + ns_log notice "=========> $attribute_name" + ns_log notice "=========> $table_name" if { ![string equal $last_table $table_name] } { if { $i != 1 } { @@ -416,18 +416,18 @@ # fetch the value of the attribute from the form if { ![template::util::is_nil attribute_name] } { set $attribute_name [template::element::get_value \ - $form_name $attribute_name] + $form_name $attribute_name] lappend columns $attribute_name # If the attribute is a date, get the date if { [string equal $datatype date] } { - set $attribute_name \ - [template::util::date::get_property sql_date [set $attribute_name]] - # Can't use bind vars because this will be a to_date call - lappend values "[set $attribute_name]" + set $attribute_name \ + [template::util::date::get_property sql_date [set $attribute_name]] + # Can't use bind vars because this will be a to_date call + lappend values "[set $attribute_name]" } else { - lappend values ":$attribute_name" + lappend values ":$attribute_name" } } set last_table $table_name @@ -441,9 +441,9 @@ ad_proc -public content::process_revision_form_dml {} { - helper function for process_revision_form - PRE: the following variables must be set in the uplevel scope: - columns, values, last_table + helper function for process_revision_form + PRE: the following variables must be set in the uplevel scope: + columns, values, last_table } { @@ -466,31 +466,31 @@ ad_proc -public content::insert_element_data { - form_name content_type exclusion_list id_value \ - {suffix ""} {extra_where ""} + form_name content_type exclusion_list id_value \ + {suffix ""} {extra_where ""} } { - Perform an insert for some form, adding all attributes of a - specific type - exclusion_list is a list of all object types for which the elements + Perform an insert for some form, adding all attributes of a + specific type + exclusion_list is a list of all object types for which the elements are NOT to be inserted - id_value is the revision_id + id_value is the revision_id } { set sql_exclusion [template::util::tcl_to_sql_list $exclusion_list] set id_value_ref id_value set query [db_map ied_get_objects_tree] - + if { ![template::util::is_nil extra_where] } { append query [db_map ied_get_objects_tree_extra_where] } append query [db_map ied_get_objects_tree_order_by] - #ns_log notice "$query" - + ns_log notice "insert_element_data: $query" + set last_table "" set last_id_column "" db_multirow rows insert_element_data $query @@ -499,8 +499,8 @@ upvar 0 "rows:${i}" row template::util::array_to_vars row - # ns_log notice "=========> $attribute_name" - # ns_log notice "=========> $table_name" + ns_log notice "=========> $attribute_name" + ns_log notice "=========> $table_name" if { ![string equal $last_table $table_name] } { if { $i != 1 } { @@ -514,18 +514,18 @@ if { ![template::util::is_nil attribute_name] } { set $attribute_name [template::element::get_value \ - $form_name "${attribute_name}${suffix}"] + $form_name "${attribute_name}${suffix}"] lappend columns $attribute_name # If the attribute is a date, get the date if { [string equal $datatype date] } { - set $attribute_name \ - [template::util::date::get_property sql_date [set $attribute_name]] - # Can't use bind vars because this will be a to_date call - lappend values "[set $attribute_name]" + set $attribute_name \ + [template::util::date::get_property sql_date [set $attribute_name]] + # Can't use bind vars because this will be a to_date call + lappend values "[set $attribute_name]" } else { - lappend values ":$attribute_name" + lappend values ":$attribute_name" } } set last_table $table_name @@ -538,9 +538,9 @@ ad_proc -public content::process_insert_statement {} { - helper function for process_revision_form - PRE: the following variables must be set in the uplevel scope: - columns, values, last_table, id_value_ref + helper function for process_revision_form + PRE: the following variables must be set in the uplevel scope: + columns, values, last_table, id_value_ref } { upvar last_table __last_table @@ -562,49 +562,49 @@ ad_proc -public content::assemble_passthrough { args } { - Assemble a passthrough list out of variables + Assemble a passthrough list out of variables } { - set result [list] - foreach varname $args { - upvar $varname var - lappend result [list $varname $var] - } - return $result + set result [list] + foreach varname $args { + upvar $varname var + lappend result [list $varname $var] + } + return $result } ad_proc -public content::url_passthrough { passthrough } { - Convert passthrough to a URL fragment + Convert passthrough to a URL fragment } { - set extra_url "" - foreach pair $passthrough { - append extra_url "&[lindex $pair 0]=[lindex $pair 1]" - } - return $extra_url + set extra_url "" + foreach pair $passthrough { + append extra_url "&[lindex $pair 0]=[lindex $pair 1]" + } + return $extra_url } ad_proc -public content::assemble_url { base_url args } { - Assemble a URL out of component parts + Assemble a URL out of component parts } { - set result $base_url - if { [string first $base_url "?"] == -1 } { - set joiner "?" - } else { - set joiner "&" - } - foreach fragment $args { - set fragment [string trimleft $fragment "&?"] - if { ![string equal $fragment {}] } { - append result $joiner $fragment - set joiner "&" + set result $base_url + if { [string first $base_url "?"] == -1 } { + set joiner "?" + } else { + set joiner "&" } - } - return $result + foreach fragment $args { + set fragment [string trimleft $fragment "&?"] + if { ![string equal $fragment {}] } { + append result $joiner $fragment + set joiner "&" + } + } + return $result } ################################################################# @@ -614,243 +614,294 @@ # Procedures for generating and processing content content creation # and editing forms.. -ad_proc -public content::new_item { form_name { storage_type text } { tmpfile "" } } { +ad_proc -public content::new_item { form_name { storage_type text } { tmpfile "" } {prefix {StArT}} } { - Create a new item, including the initial revision, based on a valid - form submission. + Create a new item, including the initial revision, based on a valid + form submission. - @param form_name Name of the form from which to obtain item - attributes, as well as attributes of the initial revision. The form - should include an item_id, name and revision_id. + @param form_name Name of the form from which to obtain item + attributes, as well as attributes of the initial revision. The form + should include an item_id, name and revision_id. - @param storage_type Method for storing content. Can be one of content_text, - content_lob, content_file. This is an openacs extension for allowing the - storage of content in the file-system. + @param storage_type Method for storing content. Can be one of content_text, + content_lob, content_file. This is an openacs extension for allowing the + storage of content in the file-system. - @param tmpfile Name of the temporary file containing the content to - upload for the initial revision. + @param tmpfile Name of the temporary file containing the content to + upload for the initial revision. - @see content::add_revision + @param prefix A prefix to remove from the form when looking up attributes + @see content::add_revision + } { + # Here we walk the item prefixes and create them all, unless the content_prefixes var + # does not exist or we are already handling the form + ns_log Warning "JCD: handling prefix $prefix" + if {[string equal "StArT" $prefix]} { + if {[template::element exists $form_name content_prefixes]} { + foreach prefix [template::element get_value $form_name content_prefixes] { + lappend item_id [content::new_item $form_name $storage_type $tmpfile $prefix] + } + return $item_id + } else { + set prefix {} + } + } + + if { [template::element exists $form_name ${prefix}item_id] } { + set item_id [template::element get_value $form_name ${prefix}item_id] + set exists [db_string item_id_exists "select count(*) from cr_items where item_id = :item_id"] + } else { + set exists 0 + } - array set defaults [list item_id "" locale "" parent_id "" content_type "content_revision"] + # If the item does not already exist build the call to create it. + if { !$exists } { + array set defaults [list item_id "" locale "" parent_id "" content_type "content_revision"] - foreach param { item_id name locale parent_id content_type } { + foreach param { item_id name locale parent_id content_type } { + + if { [template::element exists $form_name $prefix$param] } { + set $param [template::element get_value $form_name $prefix$param] - if { [template::element exists $form_name $param] } { - set $param [template::element get_value $form_name $param] + if { ! [string equal [set $param] {}] } { + # include the parameter if it is not null + # this for the oracle version, for postgres we just + # set param variables... + lappend params "$param => :$param" + } + } else { + set $param $defaults($param) + } + } - if { ! [string equal [set $param] {}] } { + lappend params "creation_user => [User::getID]" + lappend params "creation_ip => '[ns_conn peeraddr]'" + lappend params "storage_type => :storage_type" - # include the parameter if it is not null - lappend params "$param => :$param" - } - } else { - set $param $defaults($param) + # Use the correct relation tag, if specified + if { [template::element exists $form_name ${prefix}relation_tag] } { + set relation_tag [template::element get_value $form_name ${prefix}relation_tag] + lappend params "relation_tag => :relation_tag" + } else { + set relation_tag {} + } } - } - lappend params "creation_user => [User::getID]" - lappend params "creation_ip => '[ns_conn peeraddr]'" - lappend params "storage_type => :storage_type" - - # Use the correct relation tag, if specified - if { [template::element exists $form_name relation_tag] } { - set relation_tag [template::element get_value $form_name relation_tag] - lappend params "relation_tag => :relation_tag" - } - - db_transaction { - - set item_id [db_exec_plsql get_item_id " + db_transaction { + if {!$exists} { + set item_id [db_exec_plsql get_item_id " begin :1 := content_item.new( [join $params ","] ); end;"] + } + add_revision $form_name $tmpfile $prefix [expr !$exists] + } - add_revision $form_name $tmpfile - } + # flush the sitemap folder listing cache + #if { [template::element exists $form_name parent_id] } { + # set parent_id [template::element get_value $form_name parent_id] + # if { $parent_id == [cm::modules::sitemap::getRootFolderID] } { + # set parent_id "" + # } + # cms_folder::flush sitemap $parent_id + #} - # flush the sitemap folder listing cache - #if { [template::element exists $form_name parent_id] } { - # set parent_id [template::element get_value $form_name parent_id] - # if { $parent_id == [cm::modules::sitemap::getRootFolderID] } { - # set parent_id "" - # } - # cms_folder::flush sitemap $parent_id - #} - - return $item_id + return $item_id } -ad_proc -public content::add_revision { form_name { tmpfile "" } } { +ad_proc -public content::add_revision { form_name { tmpfile "" } {prefix {}} {new_p 1}} { - Create a new revision for an existing item based on a valid form - submission. Queries for attribute names and inserts a row into the - attribute input view for the appropriate content type. Inserts the - contents of a file into the content column of the cr_revisions table - for the revision as well. + Create a new revision for an existing item based on a valid form + submission. Queries for attribute names and inserts a row into the + attribute input view for the appropriate content type. Inserts the + contents of a file into the content column of the cr_revisions table + for the revision as well. - @param form_name Name of the form from which to obtain attribute - values. The form should include an item_id and revision_id. + @param form_name Name of the form from which to obtain attribute + values. The form should include an item_id and revision_id. - @param tmpfile Name of the temporary file containing the content to - upload. + @param tmpfile Name of the temporary file containing the content to + upload. + @param prefix A prefix to prepend when looking up attributes in the form data + + @param new_p Whether the revision is attached to a new cr_item or if previousrevision exist } { + ns_log Debug "JCD: add_revision $form_name $tmpfile $prefix $new_p" + # initialize an ns_set to hold bind values + set bind_vars [ns_set create] - # initialize an ns_set to hold bind values - set bind_vars [ns_set create] + # get the item_id and revision_id and content_method + foreach var {item_id revision_id content_method} { + set $var [template::element get_values $form_name ${prefix}$var] + } + ns_set put $bind_vars item_id $item_id + ns_set put $bind_vars revision_id $revision_id - # get the item_id and revision_id and content_method - template::form get_values $form_name item_id revision_id content_method - ns_set put $bind_vars item_id $item_id - ns_set put $bind_vars revision_id $revision_id + # query for content_type and table_name + db_1row addrev_get_content_type "" -column_array info - # query for content_type and table_name - db_1row addrev_get_content_type "" -column_array info + set insert_statement [attribute_insert_statement \ + $info(content_type) $info(table_name) $bind_vars $form_name $prefix $new_p] - set insert_statement [attribute_insert_statement \ - $info(content_type) $info(table_name) $bind_vars $form_name] + # if content exists, prepare it for insertion + if { [template::element exists $form_name ${prefix}content] } { + set filename [template::element get_value $form_name ${prefix}content] + set tmpfile [prepare_content_file $form_name] + } else { + set filename "" + } - # if content exists, prepare it for insertion - if { [template::element exists $form_name content] } { - set filename [template::element get_value $form_name content] - set tmpfile [prepare_content_file $form_name] - } else { - set filename "" - } + add_revision_dml $insert_statement $bind_vars $tmpfile $filename - add_revision_dml $insert_statement $bind_vars $tmpfile $filename - - # flush folder listing for item's parent because title may have changed - #template::query parent_id onevalue " - # select parent_id from cr_items where item_id = :item_id" - # - # if { $parent_id == [cm::modules::sitemap::getRootFolderID] } { - # set parent_id "" - #} - #cms_folder::flush sitemap $parent_id + # flush folder listing for item's parent because title may have changed + #template::query parent_id onevalue " + # select parent_id from cr_items where item_id = :item_id" + # + # if { $parent_id == [cm::modules::sitemap::getRootFolderID] } { + # set parent_id "" + #} + #cms_folder::flush sitemap $parent_id } ad_proc -private content::attribute_insert_statement { + content_type table_name bind_vars form_name {prefix {}} {new_p 1} +} { - content_type table_name bind_vars form_name } { + Prepare the insert statement into the attribute input view for a new + revision (see the content repository documentation for details about + the view). - Prepare the insert statement into the attribute input view for a new - revision (see the content repository documentation for details about - the view). + @param content_type The content type of the item for which a new + revision is being prepared. - @param content_type The content type of the item for which a new - revision is being prepared. + @param table_name The storage table of the content type. - @param table_name The storage table of the content type. + @param bind_vars The name of an ns_set in which to store the + attribute values for the revision. (Typically + duplicates the contents of [ns_getform]) + + @param form_name The name of the ATS form object used to process the + submission. - @param bind_vars The name of an ns_set in which to store the - attribute values for the revision. (Typically duplicates the contents - of [ns_getform]. - - @param form_name The name of the ATS form object used to process the - submission. - } { + # get creation_user and creation_ip + set creation_user [User::getID] + set creation_ip [ns_conn peeraddr] + ns_set put $bind_vars creation_user $creation_user + ns_set put $bind_vars creation_ip $creation_ip - # get creation_user and creation_ip - set creation_user [User::getID] - set creation_ip [ns_conn peeraddr] - ns_set put $bind_vars creation_user $creation_user - ns_set put $bind_vars creation_ip $creation_ip + # initialize the column and value list + set columns [list item_id revision_id creation_user creation_ip] + set values [list :item_id :revision_id :creation_user :creation_ip] + set default_columns [list] + set default_values [list] + set missing_columns [list] - # initialize the column and value list - set columns [list item_id revision_id creation_user creation_ip] - set values [list :item_id :revision_id :creation_user :creation_ip] + # query for attribute names and datatypes + foreach attribute [get_attributes $content_type attribute_name datatype default_value ancestor] { - # query for attribute names and datatypes - foreach attribute [get_attributes $content_type attribute_name datatype] { + foreach {attribute_name datatype default_value ancestor} $attribute { break } - set attribute_name [lindex $attribute 0] - set datatype [lindex $attribute 1] + # get the form value + if { [template::element exists $form_name $prefix$attribute_name] } { - # get the form value - if { [template::element exists $form_name $attribute_name] } { + set value [template::element get_value $form_name $prefix$attribute_name] - set value [template::element get_value $form_name $attribute_name] + # Convert dates to linear "YYYY MM DD HH24 MI SS" format + if { [string equal $datatype date] } { + set value [template::util::date get_property linear_date $value] + foreach i {1 2} { + if {[string equal [lindex $value $i] "00"]} { + set value [lreplace $value $i $i 01] + } + } + } + + if { ! [string equal $value {} ] } { + ns_set put $bind_vars $attribute_name $value - # Convert dates to linear "YYYY MM DD HH24 MI SS" format - if { [string equal $datatype date] } { - set value [template::util::date get_property linear_date $value] - } - - if { ! [string equal $value {} ] } { - - ns_set put $bind_vars $attribute_name $value - - lappend columns $attribute_name - lappend values [get_sql_value $attribute_name $datatype] - } + lappend columns $attribute_name + lappend values [get_sql_value $attribute_name $datatype] + } + } elseif { ![string equal $ancestor "acs_object"] + && ( ![string equal $ancestor "cr_revision"] + || [lsearch -exact {revision_id item_id publish_date} $attribute_name] == -1) } { + # We preserve attributes not in the form and not "special" like acs_object and some of cr_revision. + lappend missing_columns $attribute_name + if {$new_p && ![string equal $default_value {}]} { + ns_set put $bind_vars $attribute_name $default_value + + lappend default_columns $attribute_name + lappend default_values [get_sql_value $attribute_name $datatype] + } + } } - } + + if {$new_p} { + set insert_statement "insert into ${table_name}i ( [join [concat $columns $default_columns] ", "] )\nvalues ( [join [concat $values $default_values] ", "] )" + } else { + set insert_statement "insert into ${table_name}i ( [join [concat $columns $missing_columns] ", "] )\nselect [join [concat $values $missing_columns] ", "]\nfrom ${table_name}i\nwhere revision_id = content_item.get_latest_revision(:item_id)" + } - set insert_statement "insert into ${table_name}i - ( [join $columns ","] ) values ( [join $values ","] )" - - return $insert_statement + return $insert_statement } ad_proc -private content::add_revision_dml { statement bind_vars tmpfile filename } { - Perform the DML to insert a revision into the appropriate input view. + Perform the DML to insert a revision into the appropriate input view. - @param statement The DML for the insert statement, specifying a bind - variable for each column value. + @param statement The DML for the insert statement, specifying a bind + variable for each column value. - @param bind_vars An ns_set containing the values for all bind variables. + @param bind_vars An ns_set containing the values for all bind variables. - @param tmpfile The server-side name of the file containing the body of the - revision to upload into the content BLOB column of cr_revisions. + @param tmpfile The server-side name of the file containing the body of the + revision to upload into the content BLOB column of cr_revisions. - @param filename The client-side name of the file containing the body of - the revision to upload into the content BLOB column of cr_revisions + @param filename The client-side name of the file containing the body of + the revision to upload into the content BLOB column of cr_revisions - @see content::add_revision + @see content::add_revision } { + db_transaction { - db_transaction { + db_dml add_revision $statement -bind $bind_vars - db_dml add_revision $statement -bind $bind_vars + if { ![string equal $tmpfile {}] } { - if { ![string equal $tmpfile {}] } { - - set revision_id [ns_set get $bind_vars revision_id] - upload_content $revision_id $tmpfile $filename - - } - } + set revision_id [ns_set get $bind_vars revision_id] + upload_content $revision_id $tmpfile $filename + + } + } } ad_proc -public content::upload_content { revision_id tmpfile filename } { - @private upload_content + @private upload_content - Inserts content into the database from an uploaded file. - Does automatic mime_type updating - Parses text/html content and removes tags + Inserts content into the database from an uploaded file. + Does automatic mime_type updating + Parses text/html content and removes tags - @param db A db handle + @param db A db handle - @param revision_id The revision to which the content belongs + @param revision_id The revision to which the content belongs - @param tmpfile The server-side name of the file containing the body of the - revision to upload into the content BLOB column of cr_revisions. + @param tmpfile The server-side name of the file containing the body of the + revision to upload into the content BLOB column of cr_revisions. - @param filename The client-side name of the file containing the body of - the revision to upload into the content BLOB column of cr_revisions + @param filename The client-side name of the file containing the body of + the revision to upload into the content BLOB column of cr_revisions } { @@ -859,31 +910,29 @@ set mime_type [ns_guesstype $filename] ns_log Notice "guessed mime_type: $mime_type, filename = $filename" if { [string equal $mime_type text/html] } { - set text [template::util::read_file $tmpfile] - if { [regexp {]*>(.*?)} $text x body] } { + set text [template::util::read_file $tmpfile] + if { [regexp {]*>(.*?)} $text x body] } { set fd [open $tmpfile w] puts $fd $body close $fd - } + } } db_1row get_storage_type {select - storage_type, item_id - from - cr_items - where - item_id = (select - item_id - from - cr_revisions - where revision_id = :revision_id)} + storage_type, item_id + from + cr_items + where + item_id = (select + item_id + from + cr_revisions + where revision_id = :revision_id)} if {[string equal $storage_type file]} { - db_dml upload_file_revision " - update cr_revisions - set filename = '[cr_create_content_file $item_id $revision_id $tmpfile]', - content_length = [file size $tmpfile] - where revision_id = :revision_id" + set file_path [cr_create_content_file $item_id $revision_id $tmpfile] + set file_size [file size $tmpfile] + db_dml upload_file_revision {} } elseif {[string equal $storage_type text]} { # upload the file into the revision content db_dml upload_text_revision "update cr_revisions @@ -904,14 +953,14 @@ # this seems to abort the transaction even with the catch. # update mime_type to match the file -# if { [catch {db_dml update_mime_type " -# update cr_revisions -# set mime_type = :mime_type -# where revision_id = :revision_id"} errmsg] } { -# # if it fails, use user submitted mime_type -# ns_log notice "form-procs - add_revision_dml - using user mime_type -# instead of guessed mime type = $mime_type" -# } + # if { [catch {db_dml update_mime_type " + # update cr_revisions + # set mime_type = :mime_type + # where revision_id = :revision_id"} errmsg] } { + # # if it fails, use user submitted mime_type + # ns_log notice "form-procs - add_revision_dml - using user mime_type + # instead of guessed mime type = $mime_type" + # } # delete the tempfile ns_unlink $tmpfile @@ -920,630 +969,745 @@ ad_proc -private content::get_sql_value { name datatype } { - Return the sql statement for a column value in an insert or update - statement, using a bind variable for the actual value and wrapping it - in a conversion function where appropriate. + Return the sql statement for a column value in an insert or update + statement, using a bind variable for the actual value and wrapping it + in a conversion function where appropriate. - @param name The name of the column and bind variable (they should be - the same). + @param name The name of the column and bind variable (they should be + the same). - @param datatype The datatype of the column. + @param datatype The datatype of the column. } { - switch $datatype { - date { set wrapper [db_map string_to_timestamp] } - default { set wrapper ":$name" } - } + switch $datatype { + date { set wrapper [db_map string_to_timestamp] } + default { set wrapper ":$name" } + } - return $wrapper + return $wrapper } ad_proc -private content::prepare_content_file { form_name } { - Looks for an element named "content" in a form and prepares a - temporarily file in UTF-8 for uploading to the content repository. - Checks for a query variable named "content.tmpfile" to distinguish - between file uploads and text entry. If the type of the file is - text, then ensures that is in UTF-8. Does nothing if the uploaded - file is in binary format. + Looks for an element named "content" in a form and prepares a + temporarily file in UTF-8 for uploading to the content repository. + Checks for a query variable named "content.tmpfile" to distinguish + between file uploads and text entry. If the type of the file is + text, then ensures that is in UTF-8. Does nothing if the uploaded + file is in binary format. - @param form_name The name of the form object in which content was submitted. + @param form_name The name of the form object in which content was submitted. - @return The path of the temporary file containing the content, or an empty - string if the form does not include a content element or the value - of the element is null. + @return The path of the temporary file containing the content, or an empty + string if the form does not include a content element or the value + of the element is null. } { - - if { ! [template::element exists $form_name content] } { return "" } + + if { ! [template::element exists $form_name content] } { return "" } - template::form get_values $form_name content + template::form get_values $form_name content - # check for content.tmpfile - set tmpfile [ns_queryget content.tmpfile] - set is_text 0 + # check for content.tmpfile + set tmpfile [ns_queryget content.tmpfile] + set is_text 0 - if { ! [string equal $tmpfile {}] } { + if { ! [string equal $tmpfile {}] } { - # check for a text file based on the extension (not ideal) - if { [regexp {\.(htm|html|txt)$} $content] } { - ns_log Notice "Converting text file $content to UTF-8..." - set content [template::util::read_file $tmpfile] - set is_text 1 + # check for a text file based on the extension (not ideal) + if { [regexp {\.(htm|html|txt)$} $content] } { + ns_log Notice "Converting text file $content to UTF-8..." + set content [template::util::read_file $tmpfile] + set is_text 1 + } + + } else { + + # no temporary file so content contains text + set is_text 1 } - } else { - - # no temporary file so content contains text - set is_text 1 - } + if { $is_text && ! [string equal $content {}] } { + set tmpfile [string_to_file $content] + } - if { $is_text && ! [string equal $content {}] } { - set tmpfile [string_to_file $content] - } - - return $tmpfile + return $tmpfile } ad_proc -private content::string_to_file { s } { - Write a string in UTF-8 encoding to of temp file so it can be - uploaded into a BLOB (which is blind to character encodings). - Returns the name of the temp file. + Write a string in UTF-8 encoding to of temp file so it can be + uploaded into a BLOB (which is blind to character encodings). + Returns the name of the temp file. - @param s The string to write to the file. + @param s The string to write to the file. } { - set tmp_file [ns_tmpnam] + set tmp_file [ns_tmpnam] - set fd [open $tmp_file w] + set fd [open $tmp_file w] - fconfigure $fd -encoding utf-8 + fconfigure $fd -encoding utf-8 - puts $fd $s - - close $fd + puts $fd $s + + close $fd - return $tmp_file + return $tmp_file } # Form preparation procs namespace eval content { - variable columns - set columns [list object_type sort_order attribute_name param_type \ - param_source value \ - pretty_name widget param param_is_required widget_is_required \ - is_html default_value datatype] + variable columns + set columns [list object_type sort_order attribute_name param_type \ + param_source value \ + pretty_name widget param param_is_required widget_is_required \ + is_html default_value datatype] } ad_proc -public content::new_item_form { args } { - Adds elements to an ATS form object for creating an item and its - initial revision. If the form does not already exist, creates the - form object and sets its enctype to multipart/form-data to allow for - text entries greater than 4000 characters. + Adds elements to an ATS form object for creating an item and its + initial revision. If the form does not already exist, creates the + form object and sets its enctype to multipart/form-data to allow for + text entries greater than 4000 characters. - @option form_name The name of the ATS form object. Defaults to - "new_item". - @option content_type The content_type of the item. Defaults to - "content_revision". - @option content_method The method to use for uploading the content body. - Valid values are "no_content", "text_entry", - and "file_upload". - If the content type allows text, defaults to - text entry, otherwise defaults to file upload. - @option parent_id The item ID of the parent. Defaults to null (Parent - is the root folder). - @option name The default name of the item. Default is an empty - string (User must supply name). - @option attributes A list of attribute names for which to create form - elements. - @option action The URL to which the form should redirect following - a successful form submission. - + @option form_name The name of the ATS form object. Defaults to + "new_item". + @option content_type The content_type of the item. Defaults to + "content_revision". + @option content_method The method to use for uploading the content body. + Valid values are "no_content", "text_entry", and "file_upload". + If the content type allows text, defaults to + text entry, otherwise defaults to file upload. + @option parent_id The item ID of the parent. Defaults to null (Parent + is the root folder). + @option name The default name of the item. Default is an empty + string (User must supply name). + @option attributes A list of attribute names for which to create form + elements. + @option action The URL to which the form should redirect following + a successful form submission. + @option prefix a text prefix for the form variables added to the form + primarily intended to allow multiple content items in the + same form. + @option section a section name for the form. + @option exclude a list of object attributes to exclude from the form + @option hidden a list of attributes to hide but leave in form + @option item_id an item_id from which to draw the parameters + @option revision_id a revision_id from which to draw the parameters + (defaults to the latest revision of item_id if item_id is provided) } { - array set opts [list form_name new_item content_type content_revision \ - parent_id {} name {} content_method {}] - template::util::get_opts $args + array set opts [list form_name new_item content_type content_revision \ + parent_id {} name {} content_method {} section {} prefix {} \ + exclude {} hidden {} relation {} item_id {} revision_id {}] - if { ! [template::form exists $opts(form_name)] } { - template::form create $opts(form_name) \ - -html { enctype multipart/form-data } - } + template::util::get_opts $args + if { ! [template::form exists $opts(form_name)] } { + template::form create $opts(form_name) \ + -html { enctype multipart/form-data } + } - set name $opts(name) - set form_name $opts(form_name) + set name $opts(name) + set form_name $opts(form_name) - template::element create $opts(form_name) name \ - -datatype filename \ - -html { maxlength 400 } \ - -widget text \ - -label Name + if {![string equal {} $opts(section)] } { + template::form section $form_name $opts(section) + } else { + set id $opts(form_name) + template::form::get_reference + set opts(section) $form_properties(section) + } + + # If we are handling a new request and were passed an item_id + # get the revision_id if not provided - template::element create $opts(form_name) parent_id \ - -datatype integer \ - -widget hidden \ - -optional + if { [template::form is_request $opts(form_name)] + && ![string equal $opts(item_id) {}]} { + set item_id $opts(item_id) + + # we have to get name so get it and revision_id which might be overridden by the passed in data. + if {[db_0or1row latest_revision "select name, latest_revision as revision_id from cr_items where item_id = :item_id"]} { + if {[string equal $opts(revision_id) {}]} { + set opts(revision_id) $revision_id + } + } + } - # ATS doesn't like "-value -100" so use set_value to get around it - template::element set_value $opts(form_name) parent_id $opts(parent_id) + if { [string equal {} $opts(item_id)] } { + # Only add all this junk for + # new items. - template::element create $opts(form_name) content_type \ - -datatype keyword \ - -widget hidden \ - -value $opts(content_type) + if {[lsearch $opts(exclude) name] == -1} { + if {[lsearch $opts(hidden) name] == -1} { + template::element create $opts(form_name) "$opts(prefix)name" \ + -datatype filename \ + -html { maxlength 400 } \ + -widget text \ + -label Name + } else { + template::element create $opts(form_name) "$opts(prefix)name" \ + -datatype filename \ + -widget hidden \ + -sign + } + } - add_revision_form -form_name $opts(form_name) \ - -content_type $opts(content_type) \ - -content_method $opts(content_method) + if {[lsearch $opts(exclude) parent_id] == -1} { + template::element create $opts(form_name) "$opts(prefix)parent_id" \ + -datatype integer \ + -widget hidden \ + -optional \ + -sign + # ATS doesn't like "-value -100" so use set_value to get around it + template::element set_value $opts(form_name) "$opts(prefix)parent_id" $opts(parent_id) + } - if { [template::form is_request $opts(form_name)] } { + if {[lsearch $opts(exclude) relation_tag] == -1 && ![string equal {} $opts(relation)]} { + template::element create $opts(form_name) "$opts(prefix)relation_tag" \ + -datatype text \ + -widget hidden \ + -optional \ + -value $opts(relation) + } - set item_id [get_object_id] - template::element set_properties $opts(form_name) item_id -value $item_id + if {[lsearch $opts(exclude) parent_id] == -1} { + template::element create $opts(form_name) "$opts(prefix)content_type" \ + -datatype keyword \ + -widget hidden \ + -value $opts(content_type) \ + -sign + } + } - if { [template::util::is_nil name] } { - template::element set_value $opts(form_name) name "item$item_id" - } else { - template::element set_value $opts(form_name) name $name - } - } + add_revision_form -form_name $opts(form_name) \ + -content_type $opts(content_type) \ + -content_method $opts(content_method) \ + -prefix $opts(prefix) \ + -exclude $opts(exclude) \ + -item_id $opts(item_id) \ + -revision_id $opts(revision_id) \ + -hidden $opts(hidden) \ + -section $opts(section) - if { [info exists opts(action)] && \ - [template::form is_valid $opts(form_name)] } { - new_item $opts(form_name) - template::forward $opts(action) - } + if { [template::form is_request $opts(form_name)] } { + if {[template::util::is_nil item_id]} { + set item_id [get_object_id] + + template::element set_properties $opts(form_name) "$opts(prefix)item_id" -value $item_id + + if { [template::util::is_nil name] } { + template::element set_value $opts(form_name) "$opts(prefix)name" "item$item_id" + } else { + template::element set_value $opts(form_name) "$opts(prefix)name" $name + } + } + } + + if { [info exists opts(action)] && \ + [template::form is_valid $opts(form_name)] } { + new_item $opts(form_name) + template::forward $opts(action) + } } ad_proc -public content::add_revision_form { args } { - Adds elements to an ATS form object for adding a revision to an - existing item. If the item already exists, element values default a - previous revision (the latest one by default). If the form does not - already exist, creates the form object and sets its enctype to - multipart/form-data to allow for text entries greater than 4000 - characters. + Adds elements to an ATS form object for adding a revision to an + existing item. If the item already exists, element values default a + previous revision (the latest one by default). If the form does not + already exist, creates the form object and sets its enctype to + multipart/form-data to allow for text entries greater than 4000 + characters. - @option form_name The name of the ATS form object. Defaults to - "new_item". - @option content_type The content_type of the item. Defaults to - "content_revision". - @option content_method The method to use for uploading the content body. - If the content type is text, defaults to - text entry, otherwise defaults to file upload. - @option item_id The item ID of the revision. Defaults to null - (item_id must be set by the calling code). - @option revision_id The revision ID from which to draw default values. - Defaults to the latest revision - @option attributes A list of attribute names for which to create form - elements. - @option action The URL to which the form should redirect following - a successful form submission. - + @option form_name The name of the ATS form object. Defaults to + "new_item". + @option content_type The content_type of the item. Defaults to + "content_revision". + @option content_method The method to use for uploading the content body. + If the content type is text, defaults to + text entry, otherwise defaults to file upload. + @option item_id The item ID of the revision. Defaults to null + (item_id must be set by the calling code). + @option revision_id The revision ID from which to draw default values. + Defaults to the latest revision + @option attributes A list of attribute names for which to create form + elements. + @option action The URL to which the form should redirect following + a successful form submission. + @option prefix a text prefix for the form variables added to the form + primarily intended to allow multiple content items in the + same form. + @option section a section name for the added form elements. + @option exclude a list of object attributes to exclude from the form + @option hidden a list of attributes to hide but leave in form } { - array set opts [list form_name add_revision content_type content_revision \ - item_id {} content_method {} revision_id {}] - template::util::get_opts $args + array set opts [list form_name add_revision content_type content_revision \ + item_id {} content_method {} revision_id {} section {} prefix {} \ + hidden {} exclude {}] + template::util::get_opts $args - if { [string equal $opts(content_method) {}] } { - set opts(content_method) [get_default_content_method $opts(content_type)] - } + if { [string equal $opts(content_method) {}] } { + set opts(content_method) [get_default_content_method $opts(content_type)] + } - if { ! [template::form exists $opts(form_name)] } { - template::form create $opts(form_name) -html { enctype multipart/form-data } - } + if { ! [template::form exists $opts(form_name)] } { + template::form create $opts(form_name) \ + -html { enctype multipart/form-data } + } - if { ! [template::element exists $opts(form_name) item_id] } { - template::element create $opts(form_name) item_id -datatype integer \ - -widget hidden -value $opts(item_id) - } + if { ! [template::element exists $opts(form_name) "$opts(prefix)item_id"] } { + template::element create $opts(form_name) "$opts(prefix)item_id" \ + -datatype integer \ + -widget hidden \ + -section $opts(section) \ + -value $opts(item_id) \ + -sign + + } - if { ! [template::element exists $opts(form_name) revision_id] } { - template::element create $opts(form_name) revision_id -datatype integer \ - -widget hidden - } + if { ! [template::element exists $opts(form_name) "$opts(prefix)revision_id"] } { + template::element create $opts(form_name) "$opts(prefix)revision_id" \ + -datatype integer \ + -section $opts(section) \ + -widget hidden \ + -optional \ + -sign + } - set attributes [add_attribute_elements $opts(form_name) $opts(content_type)] + set attributes [add_attribute_elements $opts(form_name) $opts(content_type) {} $opts(prefix) $opts(section) $opts(exclude) $opts(hidden)] - add_content_element $opts(form_name) $opts(content_method) + ns_log Notice "JCD: add_revision_form content method $opts(content_method)" - if { [template::form is_request $opts(form_name)] } { + add_content_element $opts(form_name) $opts(content_method) $opts(prefix) - set revision_id [get_object_id] - template::element set_properties $opts(form_name) revision_id -value $revision_id + if { [template::form is_request $opts(form_name)]} { - if { [string equal $opts(revision_id) {}] } { - set opts(revision_id) [get_latest_revision $opts(item_id)] - } + # set revision_id [get_object_id] - if { ! [string equal $opts(revision_id) {}] } { - set_attribute_values $opts(form_name) $opts(content_type) \ - $opts(revision_id) $attributes - } + # template::element set_properties $opts(form_name) "$opts(prefix)revision_id" -value $revision_id - # if the content_method is text_entry, then retrieve the latest - # content from the database. - set revision_id $opts(revision_id) - if { ![template::util::is_nil revision_id] } { - if { [string equal $opts(content_method) text_entry] } { - set_content_value $opts(form_name) $opts(revision_id) - } + if { [string equal $opts(revision_id) {}] } { + set opts(revision_id) [get_latest_revision $opts(item_id)] + } + + if { ! [string equal $opts(revision_id) {}] } { + set_attribute_values $opts(form_name) $opts(content_type) \ + $opts(revision_id) $attributes $opts(prefix) + } + + # if the content_method is text_entry, then retrieve the latest + # content from the database. + set revision_id $opts(revision_id) + if { ![template::util::is_nil revision_id] } { + if { [string equal $opts(content_method) text_entry] } { + set_content_value $opts(form_name) $opts(revision_id) + } + } } - } - if { [info exists opts(action)] && [template::form is_valid $opts(form_name)] } { + if { [info exists opts(action)] && [template::form is_valid $opts(form_name)] } { - set tmpfile [prepare_content_file $opts(form_name)] + set tmpfile [prepare_content_file $opts(form_name)] - add_revision $opts(form_name) $tmpfile - template::forward $opts(action) - } + # JCD: need to check if this should be a new_p or not. + add_revision $opts(form_name) $tmpfile $prefix 1 + template::forward $opts(action) + } } -ad_proc -public content::add_attribute_elements { form_name content_type \ - { revision_id "" } } { +ad_proc -public content::add_attribute_elements { + form_name content_type { revision_id "" } {prefix {}} {section {}} {exclude {}} {hidden {}} +} { + + Add form elements to an ATS form object for all attributes of a + content type. - Add form elements to an ATS form object for all attributes of a - content type. - - @param form_name The name of the ATS form object to which objects - should be added. - @param content_type The content type keyword for which attribute - widgets should be added. - @param revision_id The revision from which default values should be + @param form_name The name of the ATS form object to which objects + should be added. + @param content_type The content type keyword for which attribute + widgets should be added. + @param revision_id The revision from which default values should be queried - @return The list of attributes that were added. + @param prefix a prefix for the form variables. + @param section a section name + + @option exclude a list of object attributes to exclude from the form + @option hidden a list of attributes to hide but leave in form - + @return The list of attributes that were added. } { - # query for attributes in the appropriate order - set attribute_list [get_attributes $content_type object_type attribute_name] + # query for attributes in the appropriate order + set attribute_list [get_attributes $content_type object_type attribute_name] - # get a lookup of object_types - foreach row $attribute_list { - set type_lookup([lindex $row 0]) 1 - } + # get a lookup of object_types + foreach row $attribute_list { + set type_lookup([lindex $row 0]) 1 + } - set attribute_data [eval get_type_attribute_params [array names type_lookup]] + set attribute_data [eval get_type_attribute_params [array names type_lookup]] - set attribute_names [list] - array set attributes_by_type $attribute_data + set attribute_names [list] + array set attributes_by_type $attribute_data - foreach row $attribute_list { + foreach row $attribute_list { - set object_type [lindex $row 0] - set attribute_name [lindex $row 1] + set object_type [lindex $row 0] + set attribute_name [lindex $row 1] - # look up attribute - if { ! [info exists attributes_by_type($object_type)] } { continue } + if {[lsearch $exclude $attribute_name] == -1} { + + # look up attribute + if { ! [info exists attributes_by_type($object_type)] } { continue } - array set attributes $attributes_by_type($object_type) - - if { ! [info exists attributes($attribute_name)] } { continue } + array set attributes $attributes_by_type($object_type) + + if { ! [info exists attributes($attribute_name)] } { continue } + + # JCD: check if the widget is on the hidden list. + if { [lsearch $hidden $attribute_name] == -1} { + set hidden_p 0 + } else { + set hidden_p 1 + } + + add_attribute_element $form_name $content_type $attribute_name \ + $attributes($attribute_name) $prefix $section $hidden_p - add_attribute_element $form_name $content_type $attribute_name \ - $attributes($attribute_name) + lappend attribute_names $attribute_name + } + } - lappend attribute_names $attribute_name - } + if { ![template::util::is_nil revision_id] } { + if { [template::form is_request $form_name] } { - if { ![template::util::is_nil revision_id] } { - if { [template::form is_request $form_name] } { + # set default values for attribute elements + set_attribute_values $form_name \ + $content_type $revision_id $attribute_names $prefix + } + } - # set default values for attribute elements - set_attribute_values $form_name \ - $content_type $revision_id $attribute_names - } - } - - return $attribute_names + return $attribute_names } ad_proc -public content::add_attribute_element { - form_name content_type attribute { attribute_data "" } } { + form_name content_type attribute { attribute_data "" } {prefix {}} {section {}} {hidden_p 0} +} { - Add a form element (possibly a compound widget) to an ATS form object. - for entering or editing an attribute value. + Add a form element (possibly a compound widget) to an ATS form object. + for entering or editing an attribute value. - @param form_name The name of the ATS form object to which the element - should be added. - @param content_type The content type keyword to which this attribute + @param form_name The name of the ATS form object to which the element + should be added. + @param content_type The content type keyword to which this attribute belongs. - @param attribute The name of the attribute, as represented in the - attribute_name column of the acs_attributes table. - @param attribute_data Optional nested list of parameter data for the + @param attribute The name of the attribute, as represented in the + attribute_name column of the acs_attributes table. + @param attribute_data Optional nested list of parameter data for the the attribute (generated by get_attribute_params). - + @param prefix The element name prefix + @param section The attribute section + @param hidden boolean whether to hide the element } { - variable columns + variable columns - set command [list "template::element" create $form_name $attribute] + set command [list "template::element" create $form_name "$prefix$attribute"] - if { [string equal $attribute_data {}] } { - set attribute_data [get_attribute_params $content_type $attribute] - } + if { [string equal $attribute_data {}] } { + set attribute_data [get_attribute_params $content_type $attribute] + } - array set is_html $attribute_data + array set is_html $attribute_data + # if there is a false entry for is_html, compile element options + if { [info exists is_html(f)] } { - # if there is a false entry for is_html, compile element options - if { [info exists is_html(f)] } { + foreach values $is_html(f) { - foreach values $is_html(f) { - - template::util::list_to_array $values param $columns - lappend command -$param(param) \ - [get_widget_param_value param $content_type] + template::util::list_to_array $values param $columns + lappend command -$param(param) \ + [get_widget_param_value param $content_type] + } } - } - # if there is a true entry for is_html, compile html options - if { [info exists is_html(t)] } { + # if there is a true entry for is_html, compile html options + if { [info exists is_html(t)] } { - foreach values $is_html(t) { + foreach values $is_html(t) { - template::util::list_to_array $values param $columns - lappend html_params $param(param) \ - [get_widget_param_value param $content_type] + template::util::list_to_array $values param $columns + lappend html_params $param(param) \ + [get_widget_param_value param $content_type] + } + lappend command -html $html_params } - lappend command -html $html_params - } - # if there is a null entry for is_html, the widget has no parameters - set null {{}} - set null2 {} - if { [info exists is_html($null)] || [info exists is_html($null2)] } { + # if there is a null entry for is_html, the widget has no parameters + set null {{}} + set null2 {} + if { [info exists is_html($null)] || [info exists is_html($null2)] } { - set values [lindex $is_html($null) 0] - template::util::list_to_array $values param $columns - } + set values [lindex $is_html($null) 0] + template::util::list_to_array $values param $columns + } - # special case - the search widget - #if { [string equal $param(widget) search] } { - # set param(datatype) search - #} + # special case - the search widget + #if { [string equal $param(widget) search] } { + # set param(datatype) search + #} + if { $hidden_p } { + set param(widget) hidden + } - # use any set of values for label and optional flag - lappend command -label $param(pretty_name) -widget $param(widget) \ - -datatype $param(datatype) - - # changed from widget_is_required to param_is_required (OpenACS - DanW) - if { [string equal $param(param_is_required) f] } { - lappend command -optional - } + # use any set of values for label and optional flag + lappend command -label $param(pretty_name) -widget $param(widget) \ + -datatype $param(datatype) -section $section + + # changed from widget_is_required to param_is_required (OpenACS - DanW) + if { [string equal $param(param_is_required) f] } { + lappend command -optional + } - #ns_log notice "--------------- command = $command" - eval $command + # ns_log Notice "content::add_attribute_element: command = $command" + + eval $command } - + ad_proc -public content::add_content_element { - form_name content_method { section_name "Content" } } { + form_name + content_method + { prefix {}} + { section "Content" } +} { - Adds a content input element to an ATS form object. + Adds a content input element to an ATS form object. - @param form_name The name of the form to which the object should be - added. - @param content_method One of no_content, text_entry or file_upload - + @param form_name The name of the form to which the object should be + added. + @param content_method One of no_content, text_entry or file_upload + @param section A section name for the added elements + @param prefix A prefix for the form element name } { + ns_log Notice "JCD: add_content_element content method $content_method" - template::element create $form_name content_method \ - -datatype keyword \ - -widget hidden \ - -value $content_method + template::element create $form_name "${prefix}content_method" \ + -datatype keyword \ + -widget hidden \ + -value $content_method - switch $content_method { + switch $content_method { + text_entry { - text_entry { + template::form section $form_name $section + template::element create $form_name "${prefix}content" \ + -widget textarea \ + -label {} \ + -datatype text \ + -html { cols 80 rows 20 wrap physical } - template::form section $form_name $section_name - template::element create $form_name content -widget textarea -label {} \ - -datatype text -html { cols 80 rows 20 wrap physical } + if { [template::element exists $form_name "${prefix}mime_type"] + && [template::element exists $form_name "${prefix}content_type"] } { + + set content_type \ + [template::element get_value $form_name "${prefix}content_type"] + + # change mime types select widget to only allow text MIME types + set text_mime_types [db_list_of_lists get_text_mime_types ""] + + template::element set_properties $form_name "${prefix}mime_type" \ + -options $text_mime_types + } - if { [template::element exists $form_name mime_type] && \ - [template::element exists $form_name content_type] } { - set content_type \ - [template::element get_value $form_name content_type] + } - # change mime types select widget to only allow text MIME types - set text_mime_types [db_list_of_lists get_text_mime_types ""] - - template::element set_properties $form_name mime_type \ - -options $text_mime_types - } + file_upload { + template::form section $form_name $section + template::element create $form_name "${prefix}content" \ + -widget file \ + -label "Upload Content" \ + -datatype text + } } - - file_upload { - - template::form section $form_name $section_name - template::element create $form_name content -widget file \ - -label "Upload Content" \ - -datatype text - - } - - } } ad_proc content::add_child_relation_element { form_name args } { - Add a select box listing all valid child relation tags. - The form must contain a parent_id element and a content_type element. - If the elements do not exist, or if there are no valid relation tags, - this proc does nothing. - - @param form_name The name of the form - - @option section {none} If present, creates a new form section + Add a select box listing all valid child relation tags. + The form must contain a parent_id element and a content_type element. + If the elements do not exist, or if there are no valid relation tags, + this proc does nothing. + + @param form_name The name of the form + + @option section {none} If present, creates a new form section for the element. - - @option label {Child relation tag} The label for the element + + @option label {Child relation tag} The label for the element } { - - # Process parameters + + # Process parameters - template::util::get_opts $args + template::util::get_opts $args - if { ![template::util::is_nil opts(label)] } { - set label $opts(label) - } else { - set label "Child relation tag" - } + if { ![template::util::is_nil opts(label)] } { + set label $opts(label) + } else { + set label "Child relation tag" + } - # Check form elements + # Check form elements - if { [template::element exists $form_name content_type] } { - set content_type [template::element get_value $form_name content_type] - } else { - return - } + if { [template::element exists $form_name content_type] } { + set content_type [template::element get_value $form_name content_type] + } else { + return + } - if { [template::element exists $form_name parent_id] } { - set parent_id [template::element get_value $form_name parent_id] - } else { - return - } + if { [template::element exists $form_name parent_id] } { + set parent_id [template::element get_value $form_name parent_id] + } else { + return + } - # Get the parent type. If the parent is not an item, abort - set parent_type [db_string get_parent_type ""] + # Get the parent type. If the parent is not an item, abort + set parent_type [db_string get_parent_type ""] - if { [template::util::is_nil parent_type] } { - return - } + if { [template::util::is_nil parent_type] } { + return + } - # Get a multilist of all valid relation tags - set options [db_list_of_lists get_all_valid_relation_tags ""] + # Get a multilist of all valid relation tags + set options [db_list_of_lists get_all_valid_relation_tags ""] - if { [template::util::is_nil options] } { - return - } + if { [template::util::is_nil options] } { + return + } - # Create the section, if specified - if { ![template::util::is_nil opts(section)] } { - set parent_title [db_string get_parent_title ""] + # Create the section, if specified + if { ![template::util::is_nil opts(section)] } { + set parent_title [db_string get_parent_title ""] - if { ![template::util::is_nil parent_title] } { - template::form section $form_name "Relationship to $parent_title" + if { ![template::util::is_nil parent_title] } { + template::form section $form_name "Relationship to $parent_title" + } } - } - # Create the element - set options [concat [list [list "(Default)" ""]] $options] + # Create the element + set options [concat [list [list "(Default)" ""]] $options] - template::element create $form_name relation_tag -label $label \ - -datatype text -widget select -options $options -optional + template::element create $form_name relation_tag -label $label \ + -datatype text -widget select -options $options -optional } ad_proc -private content::get_widget_param_value { - array_ref {content_type content_revision} + array_ref {content_type content_revision} } { - Utility procedure to return the value of a widget parameter + Utility procedure to return the value of a widget parameter - @param array_ref The name of an array in the calling frame - containing parameter data selected from the form - metadata. - @param content_type The current content type; defaults to content_revision + @param array_ref The name of an array in the calling frame + containing parameter data selected from the form + metadata. + @param content_type The current content type; defaults to content_revision } { - upvar $array_ref param - set value "" + upvar $array_ref param + set value "" - # a datatype of enumeration is a special case + # a datatype of enumeration is a special case - if { [string equal $param(datatype) enumeration] } { + if { [string equal $param(datatype) enumeration] } { - set value [get_attribute_enum_values $param(attribute_id)] + set value [get_attribute_enum_values $param(attribute_id)] - } else { + } else { - switch $param(param_source) { + switch $param(param_source) { - eval { - set value [eval $param(value)] - } - query { - #set content_type content_revision - set item_id {} - if [catch { - switch $param(param_type) { - - onevalue { - set value [db_string set_content_values $param(value)] + eval { + set value [eval $param(value)] + } + query { + #set content_type content_revision + set item_id {} + if [catch { + switch $param(param_type) { + + onevalue { + set value [db_string set_content_values $param(value)] + } + onelist { + set value [db_list set_content_values $param(value)] + } + multilist { + set value [db_list_of_lists set_content_values $param(value)] + } + } + }] { + set value "" } - onelist { - set value [db_list set_content_values $param(value)] + } + default { + set value $param(value) + if { [template::util::is_nil value] } { + set value $param(default_value) } - multilist { - set value [db_list_of_lists set_content_values $param(value)] - } } - }] { - set value "" } - } - default { - set value $param(value) - if { [template::util::is_nil value] } { - set value $param(default_value) - } - } + # end switch } - # end switch - } - return $value + return $value } ad_proc -private content::get_type_attribute_params { args } { - Query for attribute form metadata + Query for attribute form metadata - @param args Any number of object types + @param args Any number of object types - @return A list of attribute parameters nested by object_type, attribute_name - and the is_html flag. For attributes with no parameters, - there is a single entry with is_html as null. + @return A list of attribute parameters nested by object_type, attribute_name + and the is_html flag. For attributes with no parameters, + there is a single entry with is_html as null. } { - variable columns + variable columns - foreach object_type $args { - lappend in_list [ns_dbquotevalue $object_type] - } + foreach object_type $args { + lappend in_list [ns_dbquotevalue $object_type] + } - - template::query gtap_get_attribute_data attribute_data nestedlist " + + template::query gtap_get_attribute_data attribute_data nestedlist " select [join $columns ","] from @@ -1552,24 +1716,24 @@ object_type in ( [join $in_list ","] ) " -groupby { object_type attribute_name is_html } - return $attribute_data + return $attribute_data } ad_proc -private content::get_attribute_params { content_type attribute_name } { - Query for parameters associated with a particular attribute + Query for parameters associated with a particular attribute - @param content_type The content type keyword to which this attribute - belongs. - @param attribute_name The name of the attribute, as represented in the - attribute_name column of the acs_attributes table. + @param content_type The content type keyword to which this attribute + belongs. + @param attribute_name The name of the attribute, as represented in the + attribute_name column of the acs_attributes table. } { - variable columns + variable columns - template::query gap_get_attribute_data attribute_data nestedlist " + template::query gap_get_attribute_data attribute_data nestedlist " select [join $columns ","] from @@ -1580,95 +1744,97 @@ attribute_name = :attribute_name " -groupby { is_html } - return $attribute_data + return $attribute_data } -ad_proc -private content::set_attribute_values { form_name content_type revision_id \ - attributes } { +ad_proc -private content::set_attribute_values { + form_name content_type revision_id attributes + {prefix {}} +} { - Set the default values for attribute elements in ATS form object - based on a previous revision + Set the default values for attribute elements in ATS form object + based on a previous revision - @param form_name The name of the ATS form object containing - the attribute elements. - @param content_type The type of item being revised in the form. - @param revision_id The revision ID from where to get the default values - @param attributes The list of attributes whose values should be set. + @param form_name The name of the ATS form object containing + the attribute elements. + @param content_type The type of item being revised in the form. + @param revision_id The revision ID from where to get the default values + @param attributes The list of attributes whose values should be set. } { - if { [llength $attributes] == 0 } { - set attributes [get_attributes $content_type] - } + if { [llength $attributes] == 0 } { + set attributes [get_attributes $content_type] + } - # Assemble the list of columns to query, handling dates - # correctly + # Assemble the list of columns to query, handling dates + # correctly - set columns [list] - set attr_types [list] - foreach attr $attributes { - if { [template::element exists $form_name $attr] } { - set datatype [template::element get_property $form_name $attr datatype] - if { [string equal $datatype date] } { - lappend columns [db_map timestamp_to_string] - } else { - lappend columns $attr - } - - lappend attr_types [list $attr $datatype] + set columns [list] + set attr_types [list] + foreach attr $attributes { + if { [template::element exists $form_name "$prefix$attr"] } { + set datatype [template::element get_property $form_name "$prefix$attr" datatype] + if { [string equal $datatype date] } { + lappend columns [db_map timestamp_to_string] + } else { + lappend columns $attr + } + + lappend attr_types [list $attr $datatype] + } } - } - - # Query for values from a previous revision + + # Query for values from a previous revision - db_0or1row get_previous_version_values "" -column_array values + db_0or1row get_previous_version_values "" -column_array values - # Set the form values, handling dates with the date acquire function - foreach pair $attr_types { - set element_name [lindex $pair 0] - set datatype [lindex $pair 1] - - if { [info exists values($element_name)] } { + # Set the form values, handling dates with the date acquire function + foreach pair $attr_types { + set element_name [lindex $pair 0] + set datatype [lindex $pair 1] + + if { [info exists values($element_name)] } { - if { [string equal $datatype date] } { - set value [template::util::date acquire \ - sql_date $values($element_name)] - } else { - set value $values($element_name) - } - - template::element set_properties $form_name $element_name \ - -value $value -values [list $value] + if { [string equal $datatype date] } { + set value [template::util::date acquire \ + sql_date $values($element_name)] + } else { + set value $values($element_name) + } + + template::element set_properties $form_name $prefix$element_name \ + -value $value -values [list $value] + } } - } } ad_proc -private content::set_content_value { form_name revision_id } { - Set the default value for the content text area in an ATS form object - based on a previous revision + Set the default value for the content text area in an ATS form object + based on a previous revision - @param form_name The name of the ATS form object containing - the content element. - @param revision_id The revision ID of the content to revise + @param form_name The name of the ATS form object containing + the content element. + @param revision_id The revision ID of the content to revise } { - set content [get_content_value $revision_id] + set content [get_content_value $revision_id] - template::element set_properties $form_name content -value $content + template::element set_properties $form_name content -value $content } ad_proc -private content::get_default_content_method { content_type } { - Gets the content input method most appropriate for an content type, - based on the MIME types that are registered for that content type. + Gets the content input method most appropriate for an content type, + based on the MIME types that are registered for that content type. - @param content_type The content type for which an input method is needed. + @param content_type The content type for which an input method is needed. } { @@ -1690,76 +1856,80 @@ ad_proc -private content::get_type_info { object_type ref args } { - Return specified columns from the acs_object_types table. + Return specified columns from the acs_object_types table. - @param object_type Object type key for which info is required. - @param ref If no further arguments, name of the column value to - return. If further arguments are specified, name of - the array in which to store info in the calling - @param args Column names to query. + @param object_type Object type key for which info is required. + @param ref If no further arguments, name of the column value to + return. If further arguments are specified, name of + the array in which to store info in the calling + @param args Column names to query. } { - if { [llength $args] == 0 } { + if { [llength $args] == 0 } { - set info [db_string get_type_info_1 ""] + set info [db_string get_type_info_1 ""] - return $info + return $info - } else { - uplevel 1 "db_0or1row get_type_info_2 {} -column_array $ref" - } + } else { + uplevel 1 "db_0or1row get_type_info_2 {} -column_array $ref" + } } ad_proc -public content::get_object_id {} { - Grab an object ID for creating a new ACS object. + Grab an object ID for creating a new ACS object. } { - return [db_string nextval "select acs_object_id_seq.nextval from dual"] + return [db_string nextval "select acs_object_id_seq.nextval from dual"] } ad_proc -private content::get_attributes { content_type args } { - Returns columns from the acs_attributes table for all attributes - associated with a content type. + Returns columns from the acs_attributes table for all attributes + associated with a content type. - @param content_type The name of the content type (ACS Object Type) - for which to obtain the list of attributes. - @param args Names of columns to query. If no columns are specified, - returns a simple list of attribute names. + @param content_type The name of the content type (ACS Object Type) + for which to obtain the list of attributes. + @param args Names of columns to query. If no columns are specified, + returns a simple list of attribute names. } { - if { [llength $args] == 0 } { - set args [list attribute_name] - } + if { [llength $args] == 0 } { + set args [list attribute_name] + } - ### RBM: FIX ME (aD left this note. Probably should be fixed). - ### HACK ! What the hell is "ldap dn" ? + ### RBM: FIX ME (aD left this note. Probably should be fixed). + ### HACK ! What the hell is "ldap dn" ? + ### JCD: Someone at some point had "ldap dn" as and acs_datatype. + ### which was a very bad idea since datatypes are assumed to + ### be one token in a number of places. I removed the + ### code in the query that excluded "ldap dn" from the returned attrs. - if { [llength $args] == 1 } { - set type onelist - set attributes [db_list ga_get_attributes ""] - } else { - set type multilist - set attributes [db_list_of_lists ga_get_attributes ""] - } + if { [llength $args] == 1 } { + set type onelist + set attributes [db_list ga_get_attributes ""] + } else { + set type multilist + set attributes [db_list_of_lists ga_get_attributes ""] + } - return $attributes + return $attributes } ad_proc -public content::get_attribute_enum_values { attribute_id } { - Returns a list of { pretty_name enum_value } for an attribute of - datatype enumeration. + Returns a list of { pretty_name enum_value } for an attribute of + datatype enumeration. - @param attribute_id The primary key of the attribute as in the - attribute_id column of the acs_attributes table. + @param attribute_id The primary key of the attribute as in the + attribute_id column of the acs_attributes table. } { @@ -1770,9 +1940,9 @@ ad_proc -public content::get_latest_revision { item_id } { - Get the ID of the latest revision for the specified content item. + Get the ID of the latest revision for the specified content item. - @param item_id The ID of the content item. + @param item_id The ID of the content item. } { @@ -1784,73 +1954,73 @@ ad_proc -public content::add_basic_revision { item_id revision_id title args } { - Create a basic new revision using the content_revision PL/SQL API. + Create a basic new revision using the content_revision PL/SQL API. - @param item_id - @param revision_id - @param title + @param item_id + @param revision_id + @param title - @option description - @option mime_type - @option text - @option tmpfile + @option description + @option mime_type + @option text + @option tmpfile } { - template::util::get_opts $args + template::util::get_opts $args - set creation_ip [ns_conn peeraddr] - set creation_user [User::getID] + set creation_ip [ns_conn peeraddr] + set creation_user [User::getID] - set param_sql "" - array set defaults [list description "" mime_type "text/plain" text " "] - foreach param { description mime_type text } { + set param_sql "" + array set defaults [list description "" mime_type "text/plain" text " "] + foreach param { description mime_type text } { - if { [info exists opts($param)] } { - set $param $opts($param) - append param_sql ", $param => :$param" - } else { - set $param $defaults($param) + if { [info exists opts($param)] } { + set $param $opts($param) + append param_sql ", $param => :$param" + } else { + set $param $defaults($param) + } } - } - db_transaction { + db_transaction { - set revision_id [db_exec_plsql basic_get_revision_id "begin :1 := content_revision.new( + set revision_id [db_exec_plsql basic_get_revision_id "begin :1 := content_revision.new( item_id => content_symlink.resolve(:item_id), revision_id => :revision_id, title => :title, creation_ip => :creation_ip, creation_user => :creation_user $param_sql); end;"] - if { [info exists opts(tmpfile)] } { + if { [info exists opts(tmpfile)] } { - update_content_from_file $revision_id $opts(tmpfile) - } - } + update_content_from_file $revision_id $opts(tmpfile) + } + } } ad_proc -private content::update_content_from_file { revision_id tmpfile } { - Update the BLOB column of a revision with the contents of a file + Update the BLOB column of a revision with the contents of a file - @param revision_id The object ID of the revision to update. - @param tmpfile The name of a temporary file containing the content. - The file is deleted following the update. + @param revision_id The object ID of the revision to update. + @param tmpfile The name of a temporary file containing the content. + The file is deleted following the update. } { db_1row get_storage_type {select - storage_type, item_id - from - cr_items - where - item_id = (select - item_id - from - cr_revisions - where revision_id = :revision_id)} + storage_type, item_id + from + cr_items + where + item_id = (select + item_id + from + cr_revisions + where revision_id = :revision_id)} if {[string equal $storage_type file]} { db_dml upload_file_revision " @@ -1883,68 +2053,68 @@ ad_proc -public content::copy_content { revision_id_src revision_id_dest } { - Update the BLOB column of one revision with the content of another revision + Update the BLOB column of one revision with the content of another revision - @param revision_id_src The object ID of the revision with the content to be - copied. + @param revision_id_src The object ID of the revision with the content to be + copied. - @param revision_id_dest The object ID of the revision to be updated. - copied. + @param revision_id_dest The object ID of the revision to be updated. + copied. } { db_transaction { - # copy the content from the source to the target - db_exec_plsql cc_copy_content { - begin - content_revision.content_copy ( - revision_id => :revision_id_src, - revision_id_dest => :revision_id_dest - ); - end; - } - - # fetch the mime_type of the source revision + # copy the content from the source to the target + db_exec_plsql cc_copy_content { + begin + content_revision.content_copy ( + revision_id => :revision_id_src, + revision_id_dest => :revision_id_dest + ); + end; + } + + # fetch the mime_type of the source revision set mime_type [db_string cc_get_mime_type ""] - # copy the mime_type to the destination revision - db_dml cc_update_cr_revisions "" + # copy the mime_type to the destination revision + db_dml cc_update_cr_revisions "" } } ad_proc -public content::add_content { form_name revision_id } { - Update the BLOB column of a revision with content submitted in a form + Update the BLOB column of a revision with content submitted in a form - @param revision_id The object ID of the revision to be updated. + @param revision_id The object ID of the revision to be updated. } { # if content exists, prepare it for insertion if { [template::element exists $form_name content] } { - set filename [template::element get_value $form_name content] - set tmpfile [prepare_content_file $form_name] + set filename [template::element get_value $form_name content] + set tmpfile [prepare_content_file $form_name] } else { - set filename "" - set tmpfile "" + set filename "" + set tmpfile "" } if { ![string equal $tmpfile {}] } { - db_transaction { - upload_content $revision_id $tmpfile $filename - } + db_transaction { + upload_content $revision_id $tmpfile $filename + } } } ad_proc -public content::validate_name { form_name } { - Make sure that name is unique for the folder + Make sure that name is unique for the folder - @param form_name The name of the form (containing name and parent_id) - @return 0 if there are items with the same name, 1 otherwise + @param form_name The name of the form (containing name and parent_id) + @return 0 if there are items with the same name, 1 otherwise } { set name [template::element get_value $form_name name] @@ -1957,8 +2127,8 @@ } if { $same_name_count > 0 } { - return 0 + return 0 } else { - return 1 + return 1 } } Index: openacs-4/packages/cms/tcl/rel-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/rel-procs.tcl,v diff -u -N -r1.4 -r1.5 --- openacs-4/packages/cms/tcl/rel-procs.tcl 15 Aug 2002 03:39:34 -0000 1.4 +++ openacs-4/packages/cms/tcl/rel-procs.tcl 17 May 2003 10:23:15 -0000 1.5 @@ -1,12 +1,8 @@ - # @namespace cms_rel - # Procedures for managing relation items and child items namespace eval cms_rel {} - - ad_proc -public cms_rel::sort_related_item_order { item_id } { @public sort_related_item_order @@ -24,16 +20,13 @@ db_transaction { # grab all related items ordered by order_n, rel_id - set related_items [db_list srio_get_related_items ""] + set related_items [db_list get_related_items ""] # assign each related items a new order_n set i 0 foreach rel_id $related_items { - db_dml " - update cr_item_rels - set order_n = :i - where rel_id = :rel_id" + db_dml reorder {} incr i } @@ -59,16 +52,13 @@ db_transaction { # grab all related items ordered by order_n, rel_id - set child_items [db_list scio_get_child_order ""] + set child_items [db_list get_child_order ""] # assign each related items a new order_n set i 0 foreach rel_id $child_items { - db_dml " - update cr_child_rels - set order_n = :i - where rel_id = :rel_id" + db_dml reorder {} incr i } Index: openacs-4/packages/cms/tcl/rel-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/rel-procs.xql,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/cms/tcl/rel-procs.xql 11 Aug 2001 17:41:34 -0000 1.1 +++ openacs-4/packages/cms/tcl/rel-procs.xql 17 May 2003 10:23:15 -0000 1.2 @@ -1,7 +1,7 @@ - + select @@ -16,8 +16,17 @@ + + + + update cr_item_rels + set order_n = :i + where rel_id = :rel_id + + + - + select @@ -32,5 +41,12 @@ + + + update cr_child_rels + set order_n = :i + where rel_id = :rel_id + + Index: openacs-4/packages/cms/www/head.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/head.adp,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/cms/www/head.adp 12 Jun 2001 04:13:46 -0000 1.2 +++ openacs-4/packages/cms/www/head.adp 17 May 2003 10:24:03 -0000 1.3 @@ -17,8 +17,9 @@ My Workspace: @name@ - Help | - Preferences | + Sign Out Index: openacs-4/packages/cms/www/signin.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/Attic/signin.tcl,v diff -u -N -r1.4 -r1.5 --- openacs-4/packages/cms/www/signin.tcl 16 Aug 2002 00:25:33 -0000 1.4 +++ openacs-4/packages/cms/www/signin.tcl 17 May 2003 10:24:04 -0000 1.5 @@ -1,5 +1,3 @@ - - form create sign_in_user element create sign_in_user screen_name \ @@ -16,7 +14,6 @@ - if { [form is_valid sign_in_user] } { form get_values sign_in_user screen_name password Index: openacs-4/packages/cms/www/signin.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/Attic/signin.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/cms/www/signin.xql 17 May 2003 10:24:04 -0000 1.2 @@ -0,0 +1,14 @@ + + + + + + select user_id, salt, password + from users + where screen_name = :screen_name + + + + + + Index: openacs-4/packages/cms/www/modules/clipboard/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/clipboard/index.tcl,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/cms/www/modules/clipboard/index.tcl 12 Jun 2001 04:13:46 -0000 1.2 +++ openacs-4/packages/cms/www/modules/clipboard/index.tcl 17 May 2003 10:24:42 -0000 1.3 @@ -48,50 +48,52 @@ # Could fail because of some SQL error or because the procedure does not exist if { [catch { - set items:rowcount 0 - cm::modules::${id}::getSortedPaths items $item_id_list \ - [cm::modules::${id}::getRootFolderID] { - switch $row(item_type) { - content_template { - set row(url) "../templates/properties?id=$row(item_id)" + cm::modules::${id}::getSortedPaths items $item_id_list \ + [cm::modules::${id}::getRootFolderID] + + template::multirow extend items url + template::multirow foreach items { + switch $item_type { + content_template { + set url "../templates/properties?id=$item_id" + } + party { + set url "../$id/index?id=" + } + user { + set url "../$id/one-user?id=$item_id" + } + default { + set url "../$id/index?id=$item_id" + } } - party { - set row(url) "../$id/index?id=" - } - user { - set row(url) "../$id/one-user?id=$row(item_id)" - } - default { - set row(url) "../$id/index?id=$row(item_id)" - } - } - # this is for all items in the sitemap that need to be listed under the - # item folder - if {$id == "sitemap" && $row(item_type) != "content_folder"} { - set row(url) "../items/index?item_id=$row(item_id)" - } - append row(url) "&mount_point=$id" + # this is for all items in the sitemap that need to be listed under the + # item folder + if {$id == "sitemap" && $item_type != "content_folder"} { + set url "../items/index?item_id=$item_id" + } + append url "&mount_point=$id" } } errmsg ] } { - # Process the list manually. Path information will not be shown, but at least - # the names will be - ns_log notice "CLIPBOARD ERROR: $errmsg" - set items:rowcount 0 - foreach item_id $item_id_list { - incr items:rowcount - upvar 0 "items:${items:rowcount}" row - set row(rownum) ${items:rowcount} - set row(item_id) $item_id - if { [string equal $item_id "content_revision"] && [string equal $id "types"] } { - set link_id "" - set row(item_path) "Basic Item" - } else { - set link_id $row(item_id) - set row(item_path) [folderAccess name [getFolder $user_id $id $link_id state]] + # Process the list manually. Path information will not be shown, but at least + # the names will be + + ns_log Warning "CLIPBOARD ERROR: $errmsg" + template::multirow create items item_id item_path item_type url + + foreach item_id $item_id_list { + if { [string equal $item_id "content_revision"] && [string equal $id "types"] } { + set link_id "" + set item_path "Basic Item" + } else { + set link_id $item_id + set item_path [folderAccess name [getFolder $user_id $id $link_id state]] + } + set item_type "" + set url "../$id/index?id=$link_id" + + template::multirow append items $item_id $item_path $item_type $url } - set row(item_type) "" - set row(url) "../$id/index?id=$link_id" - } } } Index: openacs-4/packages/cms/www/modules/items/attributes-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/attributes-oracle.xql,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/cms/www/modules/items/attributes-oracle.xql 25 May 2001 04:56:36 -0000 1.1 +++ openacs-4/packages/cms/www/modules/items/attributes-oracle.xql 17 May 2003 10:25:07 -0000 1.2 @@ -44,7 +44,7 @@ where attr.object_type = types.object_type order by - types.inherit_level desc + types.inherit_level desc, attr.sort_order Index: openacs-4/packages/cms/www/modules/items/attributes-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/attributes-postgresql.xql,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/cms/www/modules/items/attributes-postgresql.xql 8 Dec 2001 01:18:00 -0000 1.2 +++ openacs-4/packages/cms/www/modules/items/attributes-postgresql.xql 17 May 2003 10:25:07 -0000 1.3 @@ -42,8 +42,7 @@ where attr.object_type = types.object_type order by - types.inherit_level desc - + types.inherit_level desc, attr.sort_order Index: openacs-4/packages/cms/www/modules/items/attributes.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/attributes.tcl,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/cms/www/modules/items/attributes.tcl 18 Sep 2002 03:58:43 -0000 1.6 +++ openacs-4/packages/cms/www/modules/items/attributes.tcl 17 May 2003 10:25:07 -0000 1.7 @@ -39,14 +39,16 @@ set content_type $type_info(object_type) -db_multirow attributes get_attributes "" { - +db_multirow -extend attribute_value attributes get_attributes "" { + if { [catch { set value $info($attribute_name) } errmsg] } { # catch - value doesn't exist set value "-" } - if { [string equal $value {}] } { set value "-" } + if { [string equal $value {}] } { + set value "-" + } set attribute_value $value } Index: openacs-4/packages/cms/www/modules/items/children-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/children-oracle.xql,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/cms/www/modules/items/children-oracle.xql 8 Jun 2001 01:44:53 -0000 1.1 +++ openacs-4/packages/cms/www/modules/items/children-oracle.xql 17 May 2003 10:25:07 -0000 1.2 @@ -7,7 +7,7 @@ select - t.pretty_name, c.child_type + distinct t.pretty_name, c.child_type from acs_object_types t, cr_type_children c where @@ -18,5 +18,32 @@ + + +select + r.rel_id, + r.child_id item_id, + t.pretty_name as type_name, + NVL(r.relation_tag, '-') as tag, + trim(NVL(content_item.get_title(r.child_id), i.name)) title, + ot.pretty_name as content_type + from + cr_child_rels r, acs_objects o, acs_object_types t, + cr_items i, acs_object_types ot + where + r.parent_id = :item_id + and + o.object_id = r.rel_id + and + t.object_type = o.object_type + and + i.item_id = r.child_id + and + ot.object_type = i.content_type + order by + order_n, title + + + Index: openacs-4/packages/cms/www/modules/items/children-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/children-postgresql.xql,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/cms/www/modules/items/children-postgresql.xql 8 Jun 2001 01:44:53 -0000 1.1 +++ openacs-4/packages/cms/www/modules/items/children-postgresql.xql 17 May 2003 10:25:07 -0000 1.2 @@ -7,7 +7,7 @@ select - t.pretty_name, c.child_type + distinct t.pretty_name, c.child_type from acs_object_types t, cr_type_children c where Index: openacs-4/packages/cms/www/modules/items/publish-status.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/publish-status.tcl,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/cms/www/modules/items/publish-status.tcl 19 Sep 2002 13:09:14 -0000 1.6 +++ openacs-4/packages/cms/www/modules/items/publish-status.tcl 17 May 2003 10:25:07 -0000 1.7 @@ -84,7 +84,7 @@ set difference [expr $min_n - $child_count] set direction more } - if { ![string equal $max_n -] && $child_count > $max_n } { + if { ![string equal {} $max_n] && $child_count > $max_n } { set row(is_fulfilled) f incr unpublishable_child_types set difference [expr $child_count - $max_n] @@ -116,7 +116,7 @@ set difference [expr $min_n - $rel_count] set direction more } - if { ![string equal $max_n -] && $rel_count > $max_n } { + if { ![string equal {} $max_n] && $rel_count > $max_n } { set is_fulfilled f incr unpublishable_rel_types set difference [expr $rel_count - $max_n] Index: openacs-4/packages/cms/www/modules/types/widget-register-1.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/types/widget-register-1.tcl,v diff -u -N -r1.4 -r1.5 --- openacs-4/packages/cms/www/modules/types/widget-register-1.tcl 20 Aug 2002 04:18:00 -0000 1.4 +++ openacs-4/packages/cms/www/modules/types/widget-register-1.tcl 17 May 2003 10:25:29 -0000 1.5 @@ -13,46 +13,44 @@ } -set form_widgets [db_list_of_lists get_form_widgets ""] +set form_widgets [db_list_of_lists get_form_widgets "" ] - element create widget_register widget \ - -datatype keyword \ - -widget select \ - -options $form_widgets \ - -label "Form Widget" + -datatype keyword \ + -widget select \ + -options $form_widgets \ + -label "Form Widget" element create widget_register is_required \ - -datatype keyword \ - -widget radio \ - -label "Is Required?" \ - -options { {Yes t} {No f} } + -datatype keyword \ + -widget radio \ + -label "Is Required?" \ + -options { {Yes t} {No f} } wizard submit widget_register -buttons { next } - - if { [form is_request widget_register] } { db_1row get_attr_info "" - db_1row get_reg_widget "" + db_0or1row get_reg_widget "" element set_properties widget_register content_type_pretty \ - -value $content_type_pretty + -value $content_type_pretty element set_properties widget_register attribute_name_pretty \ - -value $attribute_name_pretty + -value $attribute_name_pretty + element set_properties widget_register attribute_name \ - -value $attribute_name + -value $attribute_name element set_properties widget_register content_type \ - -value $content_type + -value $content_type if { ![template::util::is_nil registered_widget] } { element set_properties widget_register widget \ - -values $registered_widget + -values $registered_widget element set_properties widget_register is_required \ - -values $is_required + -values $is_required } } @@ -63,36 +61,32 @@ if { [form is_valid widget_register] } { form get_values widget_register \ - widget is_required attribute_name content_type + widget is_required attribute_name content_type db_transaction { - set already_registered [db_string registered "" -default ""] + set already_registered [db_string check_registered "" -default ""] # just update the is_required column if this widget is already registered # this way we don't overwrite the existing attribute widget params if { ![string equal $already_registered ""] && \ $already_registered } { - db_dml update_widgets " - update cm_attribute_widgets - set is_required = decode(is_required,'t','f','t') - where attribute_id = :attribute_id - and widget = :widget" + db_dml update_widgets "" } else { # (re)register a widget to an attribute - db_exec_plsql register_widget " - begin - cm_form_widget.register_attribute_widget( - content_type => :content_type, - attribute_name => :attribute_name, - widget => :widget, - is_required => :is_required - ); - end;" + db_exec_plsql register_widget "" } } wizard set_param widget $widget wizard forward +} else { + + db_1row get_attr_info "" + + element set_properties widget_register content_type_pretty \ + -value $content_type_pretty + element set_properties widget_register attribute_name_pretty \ + -value $attribute_name_pretty } Index: openacs-4/packages/cms/www/modules/types/widget-register-1.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/types/widget-register-1.xql,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/cms/www/modules/types/widget-register-1.xql 8 Jun 2001 01:44:53 -0000 1.2 +++ openacs-4/packages/cms/www/modules/types/widget-register-1.xql 17 May 2003 10:25:29 -0000 1.3 @@ -1,8 +1,15 @@ + + + select + widget, widget + from + cm_form_widgets + + - @@ -17,5 +24,31 @@ - + + + select + widget as registered_widget, is_required + from + cm_attribute_widgets + where + attribute_id = :attribute_id + + + + + + select + a.pretty_name as attribute_name_pretty, + t.pretty_name as content_type_pretty, + t.object_type as content_type, + a.attribute_name + from + acs_attributes a, acs_object_types t + where + a.object_type = t.object_type + and + a.attribute_id = :attribute_id + + + Index: openacs-4/packages/cms/www/modules/types/widget-register-3.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/types/widget-register-3.xql,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/cms/www/modules/types/widget-register-3.xql 25 May 2001 23:49:05 -0000 1.1 +++ openacs-4/packages/cms/www/modules/types/widget-register-3.xql 17 May 2003 10:25:29 -0000 1.2 @@ -26,7 +26,7 @@ - + select Index: openacs-4/packages/cms/www/modules/types/widget-register.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/types/widget-register.tcl,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/cms/www/modules/types/widget-register.tcl 20 Aug 2002 11:17:30 -0000 1.3 +++ openacs-4/packages/cms/www/modules/types/widget-register.tcl 17 May 2003 10:25:29 -0000 1.4 @@ -5,7 +5,7 @@ request set_param content_type -datatype keyword request set_param widget -datatype keyword -optional -seet module_id [db_string get_module_id ""] +set module_id [db_string get_module_id ""] # permissions check - need cm_write on types module to edit a widget content::check_access $module_id cm_write -user_id [User::getID] Index: openacs-4/packages/cms-news-demo/cms-news-demo.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms-news-demo/cms-news-demo.info,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/cms-news-demo/cms-news-demo.info 9 Mar 2002 02:00:02 -0000 1.3 +++ openacs-4/packages/cms-news-demo/cms-news-demo.info 17 May 2003 10:25:59 -0000 1.4 @@ -17,7 +17,7 @@ A demo news site built using CMS. - + Index: openacs-4/packages/cms-news-demo/templates/demo_articles/article-list.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms-news-demo/templates/demo_articles/article-list.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/cms-news-demo/templates/demo_articles/article-list.tcl 20 Apr 2001 20:51:11 -0000 1.1 +++ openacs-4/packages/cms-news-demo/templates/demo_articles/article-list.tcl 17 May 2003 10:26:20 -0000 1.2 @@ -16,7 +16,7 @@ request set_param article_link_color -datatype text -template::query articles multirow " +template::query articles articles multirow " select live_revision, location, title, name, content_item.get_path( i.item_id ) as url Index: openacs-4/packages/cms-news-demo/templates/demo_articles/article-template-1.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms-news-demo/templates/demo_articles/article-template-1.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/cms-news-demo/templates/demo_articles/article-template-1.tcl 20 Apr 2001 20:51:11 -0000 1.1 +++ openacs-4/packages/cms-news-demo/templates/demo_articles/article-template-1.tcl 17 May 2003 10:26:20 -0000 1.2 @@ -2,7 +2,7 @@ template::util::array_to_vars content -template::query links multirow " +template::query links links multirow " select relation_tag from @@ -13,4 +13,4 @@ parent_id = :item_id order by order_n -" \ No newline at end of file +" Index: openacs-4/packages/cms-news-demo/templates/demo_articles/article-template-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms-news-demo/templates/demo_articles/article-template-2.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/cms-news-demo/templates/demo_articles/article-template-2.tcl 20 Apr 2001 20:51:11 -0000 1.1 +++ openacs-4/packages/cms-news-demo/templates/demo_articles/article-template-2.tcl 17 May 2003 10:26:20 -0000 1.2 @@ -1,7 +1,7 @@ content::get_content template::util::array_to_vars content -template::query links multirow " +template::query links links multirow " select relation_tag from Index: openacs-4/packages/cms-news-demo/templates/demo_articles/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms-news-demo/templates/demo_articles/index.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/cms-news-demo/templates/demo_articles/index.tcl 20 Apr 2001 20:51:11 -0000 1.1 +++ openacs-4/packages/cms-news-demo/templates/demo_articles/index.tcl 17 May 2003 10:26:20 -0000 1.2 @@ -21,4 +21,4 @@ order by publish_date" -query items multirow $query +query items items multirow $query Index: openacs-4/packages/cms-news-demo/templates/demo_articles/master-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms-news-demo/templates/demo_articles/master-2.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/cms-news-demo/templates/demo_articles/master-2.tcl 20 Apr 2001 20:51:11 -0000 1.1 +++ openacs-4/packages/cms-news-demo/templates/demo_articles/master-2.tcl 17 May 2003 10:26:20 -0000 1.2 @@ -16,7 +16,7 @@ } -template::query articles multirow " +template::query articles articles multirow " select live_revision, location, title, name from @@ -42,4 +42,4 @@ } -set static_root [cms_news::get_static_content_root] \ No newline at end of file +set static_root [cms_news::get_static_content_root] Index: openacs-4/packages/cms-news-demo/www/install-wizard-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms-news-demo/www/install-wizard-2.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/cms-news-demo/www/install-wizard-2.tcl 20 Apr 2001 20:51:11 -0000 1.1 +++ openacs-4/packages/cms-news-demo/www/install-wizard-2.tcl 17 May 2003 10:26:34 -0000 1.2 @@ -11,11 +11,9 @@ # by checking if the demo_articles folder exists under the # templates root and the sitemap root -set db [template::get_db_handle] - -template::query demo_folders onevalue " +db_1row demo_folders { select - count(1) + count(1) as demo_folders from cr_items where @@ -26,7 +24,7 @@ name = 'demo_articles' and content_type = 'content_folder' -" -db $db +} if { $demo_folders != 2 } { set demo_folders_p f @@ -40,9 +38,9 @@ # of live templates in the /demo_articles folder under the # templates mount point -template::query published_templates onevalue " +db_1row published_templates { select - count(1) + count(1) as published_templates from cr_items where @@ -62,7 +60,7 @@ name = 'demo_articles' and content_type = 'content_folder' ) -" -db $db +} if { $published_templates < 8 } { set published_templates_p f @@ -71,10 +69,9 @@ } - # get the user id of a cm_admin -template::query cm_admin onevalue " +set cm_admin [db_string cm_admin " select distinct user_id from @@ -90,10 +87,8 @@ module_id, user_id, 'cm_admin') = 't' and user_id = [User::getID] -" -db $db +" -default ""] -template::release_db_handle - if { [template::util::is_nil cm_admin] } { template::forward install-wizard return @@ -115,22 +110,21 @@ set html "" - set db [template::begin_db_transaction] + db_transaction { # some root folders - template::query sitemap onevalue " - select content_item.get_root_folder from dual - " -db $db + db_1row sitemap " + select content_item.get_root_folder as sitemap from dual + " - template::query templates onevalue " - select content_template.get_root_folder from dual - " -db $db + db_1row templates " + select content_template.get_root_folder as templates from dual + " - # create demo_articles folder - ns_ora exec_plsql_bind $db " + set folder_id [db_exec_plsql demo_articles_folder_new " begin - :folder_id := content_folder.new ( + :1 := content_folder.new ( name => 'demo_articles', label => 'Demo Articles', description => 'Articles for publication', @@ -139,12 +133,12 @@ parent_id => :sitemap ); end; - " folder_id + "] append html "

  • Created /demo_articles folder under the sitemap." # register content types to demo_articles folder - ns_ora dml $db " + db_dml register_content_types " begin delete from cr_folder_type_map where folder_id = :folder_id; @@ -163,9 +157,9 @@ append html "
  • Registered content types to /demo_articles." # create article index - ns_ora exec_plsql_bind $db " + set item_id [db_exec_plsql article_index_new " begin - :item_id := content_item.new ( + :1 := content_item.new ( name => 'index', parent_id => :folder_id, content_type => 'content_revision', @@ -176,14 +170,14 @@ creation_ip => :creation_ip ); end; - " item_id + "] append html "
  • Created /demo_articles/index content item." # create demo templates folder and templates - ns_ora exec_plsql_bind $db " + set folder_id [db_exec_plsql folder_new " begin - :folder_id := content_folder.new ( + :1 := content_folder.new ( name => 'demo_articles', label => 'Demo Article Templates', description => 'Templates for demo articles and links', @@ -192,12 +186,12 @@ parent_id => :templates ); end; - " folder_id + "] append html "
  • Created /demo_articles folder under the templates mount point." # register content type to the folder - ns_ora dml $db " + db_dml register_content_type " begin content_folder.register_content_type ( folder_id => :folder_id, @@ -208,27 +202,27 @@ append html "
  • Registered templates to the /demo_articles folder." # create index template - ns_ora exec_plsql_bind $db " + set template_id [db_exec_plsql template_new " begin - :template_id := content_template.new ( + :1 := content_template.new ( name => 'index', parent_id => :folder_id, creation_user => :user_id, creation_ip => :creation_ip ); end; - " template_id + "] # make the index template an adp file - ns_ora dml $db " + db_dml index_template_new " update cr_revisions set mime_type = 'text/adp' where item_id = :template_id" append html "
  • Created /demo_articles/index template for articles index page." # register template index template to content_revision and index page - ns_ora dml $db " + db_dml register_template_index " begin content_type.register_template ( content_type => 'content_revision', @@ -248,34 +242,34 @@ # create more templates - ns_ora exec_plsql_bind $db " + set template_id [db_exec_plsql more_templates " begin - :template_id := content_template.new ( + :1 := content_template.new ( name => 'master-1', parent_id => :folder_id, creation_user => :user_id, creation_ip => :creation_ip ); end; - " template_id + "] append html "
  • Created /demo_articles/master-1 master template." - ns_ora exec_plsql_bind $db " + set template_id [db_exec_plsql article_template_1 " begin - :template_id := content_template.new ( + :1 := content_template.new ( name => 'article-template-1', parent_id => :folder_id, creation_user => :user_id, creation_ip => :creation_ip ); end; - " template_id + "] append html "
  • Created /demo_articles/article-template-1 article template." # register template to articles - ns_ora dml $db " + db_dml register_article_template_1 " begin content_type.register_template ( content_type => 'cr_demo_article', @@ -288,33 +282,33 @@ append html "
  • Registered the article template as the default for articles." # more article templates - ns_ora exec_plsql_bind $db " + set template_id [db_exec_plsql master_2 " begin - :template_id := content_template.new ( + :1 := content_template.new ( name => 'master-2', parent_id => :folder_id, creation_user => :user_id, creation_ip => :creation_ip ); end; - " template_id + "] append html "
  • Createed /demo_articles/master-2 master template." - ns_ora exec_plsql_bind $db " + set template_id [db_exec_plsql article_template_2 " begin - :template_id := content_template.new ( + :1 := content_template.new ( name => 'article-template-2', parent_id => :folder_id, creation_user => :user_id, creation_ip => :creation_ip ); end; - " template_id + "] append html "
  • Created /demo_articles/article-template-2 article template." - ns_ora dml $db " + db_dml register_article_template_2 " begin content_type.register_template ( content_type => 'cr_demo_article', @@ -327,35 +321,35 @@ append html "
  • Registered the 2nd article template to articles." # article list template - ns_ora exec_plsql_bind $db " + set template_id [db_exec_plsql article_list " begin - :template_id := content_template.new ( + :1 := content_template.new ( name => 'article-list', parent_id => :folder_id, creation_user => :user_id, creation_ip => :creation_ip ); end; - " template_id + "] append html "
  • Created /demo_articles/article-list template for listing articles." # multimedia link template - ns_ora exec_plsql_bind $db " + set template_id [db_exec_plsql article_link_template " begin - :template_id := content_template.new ( + :1 := content_template.new ( name => 'article-link-template', parent_id => :folder_id, creation_user => :user_id, creation_ip => :creation_ip ); end; - " template_id + "] append html "
  • Created /demo_articles/article-link-template." - ns_ora dml $db " + db_dml register_article_link_template " begin content_type.register_template ( content_type => 'cr_demo_link', @@ -369,20 +363,20 @@ to the cr_demo_link content type." # captioned image template - ns_ora exec_plsql_bind $db " + set template_id [db_exec_plsql cap_image_template " begin - :template_id := content_template.new ( + :1 := content_template.new ( name => 'captioned-image-template', parent_id => :folder_id, creation_user => :user_id, creation_ip => :creation_ip ); end; - " template_id + "] append html "
  • Created /demo_articles/captioned-image-template." - ns_ora dml $db " + db_dml register_cap_image_template " begin content_type.register_template ( content_type => 'cr_demo_article_image', @@ -396,20 +390,20 @@ to the cr_demo_article_image content type." # master template - ns_ora exec_plsql_bind $db " + set template_id [db_exec_plsql master " begin - :template_id := content_template.new ( + :1 := content_template.new ( name => 'master', parent_id => :templates, creation_user => :user_id, creation_ip => :creation_ip ); end; - " template_id + "] append html "
  • Created /master, the demo master template." - template::end_db_transaction + } } @@ -449,39 +443,39 @@ set revision_id [content::get_object_id] set tmpfile "$package_root/templates$template.adp" - set db [template::begin_db_transaction] + db_transaction { - template::query template_id onevalue " + db_1row template_id " select - content_item.get_id( :template, content_template.get_root_folder ) + content_item.get_id( :template, content_template.get_root_folder ) as template_id from dual - " -db $db - + " + # upload the template # this is safe because none of the templates exceeds the max size set adp_text [template::util::read_file $tmpfile] - template::query index_template onevalue " + db_1row index_template " select - item_id + item_id as index_template from cr_items where item_id = content_item.get_id( '/demo_articles/index', content_template.get_root_folder ) - " -db $db + " if { $template_id == $index_template } { set mime_type "text/adp" } else { set mime_type "text/html" } - ns_ora exec_plsql_bind $db " + set revision_id [db_exec_plsql get_revision_id " begin - :revision_id := content_revision.new ( + :1 := content_revision.new ( revision_id => :revision_id, item_id => :template_id, title => 'News Demo Template', @@ -491,15 +485,15 @@ creation_ip => :creation_ip ); end; - " revision_id + "] - ns_ora dml $db " + db_dml update_revision " update cr_items set live_revision = :revision_id, publish_status = 'live' where item_id = :template_id" - template::end_db_transaction + } # publish the template to the file system and set the live revision set text [content::get_content_value $revision_id] @@ -538,13 +532,13 @@ set tmpfile "$package_root/templates/demo_articles/index.tcl" set tcl_text [template::util::read_file $tmpfile] - publish::write_multiple_files "/demo_articles/index.tcl" $tcl_text + publish::write_multiple_files "[acs_root_dir]/templates/templates/demo_articles/index.tcl" $tcl_text append html2 "
  • Copied $path.tcl.
    " # publish the index item - template::query revision_id onevalue " + db_1row get_live_revision " select - live_revision + live_revision as revision_id from cr_items where Index: openacs-4/packages/cms-news-demo/www/install-wizard-3.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms-news-demo/www/install-wizard-3.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/cms-news-demo/www/install-wizard-3.tcl 20 Apr 2001 20:51:11 -0000 1.1 +++ openacs-4/packages/cms-news-demo/www/install-wizard-3.tcl 17 May 2003 10:26:34 -0000 1.2 @@ -7,12 +7,10 @@ -set db [template::get_db_handle] - # get the user id of a cm_admin -template::query cm_admin onevalue " +db_1row cm_admin " select - distinct user_id + distinct user_id as cm_admin from users u, cm_modules m where @@ -26,28 +24,25 @@ module_id, user_id, 'cm_admin') = 't' and user_id = [User::getID] -" -db $db +" # check if author, editor, and publisher users have been created -template::query demo_users onevalue " +db_1row demo_users " select - count(1) + count(1) as demo_users from users where screen_name in ('author','editor','publisher') -" -db $db +" if { $demo_users < 3 } { set demo_users_p f } else { set demo_users_p t } - -template::release_db_handle - if { [template::util::is_nil cm_admin] } { template::forward install-wizard return @@ -60,20 +55,14 @@ set creation_ip [ns_conn peeraddr] set user_id $cm_admin - - - - - # register demo users if not already registered: # author, editor, publisher set html "" if { $demo_users < 3 } { - set db [template::begin_db_transaction] - + db_transaction { set demo_user_list \ { {Author author} {Editor editor} {Publisher publisher} } @@ -82,14 +71,14 @@ set screen_name [lindex $demo_user 1] # check if the user exists already - template::query user_exists_p onevalue " + db_1row user_exists_p " select - count(1) + count(1) as user_exists_p from users where screen_name = :screen_name - " -db $db + " # if the user doesn't exists, create the user if { $user_exists_p == 0 } { @@ -101,7 +90,7 @@ set user_id [ad_user_new $email $name $name $password "" ""] - ns_ora dml $db " + db_dml update_users " update users set screen_name = :screen_name where user_id = :user_id" @@ -113,7 +102,7 @@ } } - template::end_db_transaction + } } @@ -129,4 +118,4 @@ template::forward install-wizard-4 -} \ No newline at end of file +} Index: openacs-4/packages/cms-news-demo/www/install-wizard-4.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms-news-demo/www/install-wizard-4.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/cms-news-demo/www/install-wizard-4.tcl 20 Apr 2001 20:51:11 -0000 1.1 +++ openacs-4/packages/cms-news-demo/www/install-wizard-4.tcl 17 May 2003 10:26:34 -0000 1.2 @@ -7,10 +7,8 @@ set html "" -set db [template::get_db_handle] - # get the user id of a cm_admin -template::query cm_admin onevalue " +set cm_admin [db_string cm_admin " select distinct user_id from @@ -26,11 +24,8 @@ module_id, user_id, 'cm_admin') = 't' and user_id = [User::getID] -" -db $db +" -default ""] - -template::release_db_handle - if { [template::util::is_nil cm_admin] } { template::forward install-wizard return @@ -44,48 +39,43 @@ set user_id $cm_admin - - - # grant permissions to demo users -set db [template::begin_db_transaction] +db_transaction { # some root folders -template::query sitemap onevalue " - select content_item.get_root_folder from dual -" -db $db +db_1row sitemap " + select content_item.get_root_folder as sitemap from dual +" -template::query templates onevalue " - select content_template.get_root_folder from dual -" -db $db +db_1row templates " + select content_template.get_root_folder as templates from dual +" # some user ID's -template::query author onevalue " - select user_id from users where screen_name = 'author' -" -db $db +db_1row author " + select user_id as author from users where screen_name = 'author' +" -template::query editor onevalue " - select user_id from users where screen_name = 'editor' -" -db $db +db_1row editor " + select user_id as editor from users where screen_name = 'editor' +" -template::query publisher onevalue " - select user_id from users where screen_name = 'publisher' -" -db $db +db_1row publisher " + select user_id as publisher from users where screen_name = 'publisher' +" - # some folder/module ID's -template::query demo_articles onevalue " - select content_item.get_id( '/demo_articles' ) from dual -" -db $db +db_1row demo_articles " + select content_item.get_id( '/demo_articles' ) as demo_articles from dual +" -template::query other_modules onelist " +set other_modules [db_list other_modules " select module_id from cm_modules where key ^= 'sitemap' -" -db $db +"] - # grant permissions -ns_ora dml $db " +db_dml grant_perms " begin cms_permission.grant_permission ( item_id => :sitemap, @@ -145,7 +135,7 @@ foreach module_id $other_modules { - ns_ora dml $db " + db_dml grant1 " begin cms_permission.grant_permission ( item_id => :module_id, @@ -160,7 +150,7 @@ append html "
  • Granted cm_examine to author on all other modules." foreach module_id $other_modules { - ns_ora dml $db " + db_dml grant2 " begin cms_permission.grant_permission ( item_id => :module_id, @@ -175,7 +165,7 @@ append html "
  • Granted cm_examine to editor on all other modules." foreach module_id $other_modules { - ns_ora dml $db " + db_dml grant3 " begin cms_permission.grant_permission ( item_id => :module_id, @@ -189,6 +179,5 @@ append html "
  • Granted cm_write to publisher on all other modules." -template::end_db_transaction +} - Index: openacs-4/packages/cms-news-demo/www/install-wizard.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms-news-demo/www/install-wizard.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/cms-news-demo/www/install-wizard.tcl 20 Apr 2001 20:51:11 -0000 1.1 +++ openacs-4/packages/cms-news-demo/www/install-wizard.tcl 17 May 2003 10:26:34 -0000 1.2 @@ -9,16 +9,14 @@ # by checking if the cr_demo_article, cr_demo_article_image, and cr_demo_link # content types exist -set db [template::get_db_handle] - -template::query news_demo_content_types onevalue " +db_1row news_demo_content_types " select - count(1) + count(1) news_demo_content_types from acs_object_types where object_type in ('cr_demo_article','cr_demo_article_image', 'cr_demo_link') -" -db $db +" if { $news_demo_content_types != 3 } { @@ -35,9 +33,9 @@ # check if a cm_admin user exists -- a user who has the 'cm_admin' privilege # on the CMS root folders and CMS modules -template::query cm_admin onevalue " +db_1row cm_admin " select - distinct user_id + distinct user_id cm_admin from users u, cm_modules m where @@ -51,10 +49,8 @@ module_id, user_id, 'cm_admin') = 't' and user_id = [User::getID] -" -db $db +" -template::release_db_handle - if { [template::util::is_nil cm_admin] } { set cm_admin_p f return