Index: openacs.org-dev/readme.txt
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/readme.txt,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/readme.txt	9 Jul 2002 17:34:56 -0000	1.1.1.1
+++ openacs.org-dev/readme.txt	25 Jul 2002 18:46:42 -0000	1.1.1.2
@@ -4,7 +4,7 @@
 building scalable, community-oriented web applications.
 
 The original ACS, which formed the foundation of OpenACS is described
-in http://photo.net/wtr/thebook/community.html
+in http://philip.greenspun.com/panda/community
 
 The original ACS was Copyright (C) 1995-2000 ArsDigita Corporation
 and, in some cases, individual authors.
@@ -45,7 +45,6 @@
 The release notes for this release are available at
 packages/acs-core-docs/www/release-notes/.
 
-This is an early development version of OpenACS 4.x.  Production use
-is NOT recommended.  Please report bugs via http://openacs.org/sdm
+Please report bugs via http://openacs.org/sdm
 
 
Index: openacs.org-dev/packages/acs-content-repository/tcl/content-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-content-repository/tcl/content-procs.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-content-repository/tcl/content-procs.tcl	9 Jul 2002 17:34:56 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-content-repository/tcl/content-procs.tcl	25 Jul 2002 18:46:44 -0000	1.1.1.2
@@ -56,23 +56,33 @@
 
 # lifted from new-file-storage (DanW - OpenACS)
 
-ad_proc -public cr_create_content_file {item_id revision_id client_filename} {
-
+ad_proc -public cr_create_content_file {
+    -move:boolean
+    item_id 
+    revision_id 
+    client_filename
+} {
     Copies the file passed by client_filename to the content repository file
     storage area, and it returns the relative file path from the root of the
     content repository file storage area..
 
+    if the -move flag is given the file is renamed instead
 } {
-
     set content_file [cr_create_content_file_path $item_id $revision_id]
 
-    set ifp [open $client_filename r]
-    set ofp [open [cr_fs_path]$content_file w]
+    if { $move_p } { 
+        file rename -- $client_filename [cr_fs_path]$content_file
+    } else { 
+        # JCD: not sure why ns_cpfp is used.  tcl file copy is better 
+        # since it is smarter about buffer sizes.
+        set ifp [open $client_filename r]
+        set ofp [open [cr_fs_path]$content_file w]
+        
+        ns_cpfp $ifp $ofp
+        close $ifp
+        close $ofp
+    }
 
-    ns_cpfp $ifp $ofp
-    close $ifp
-    close $ofp
-
     return $content_file
 }
 
Index: openacs.org-dev/packages/acs-content-repository/tcl/filter-procs-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-content-repository/tcl/filter-procs-oracle.xql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-content-repository/tcl/filter-procs-oracle.xql	9 Jul 2002 17:34:56 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-content-repository/tcl/filter-procs-oracle.xql	25 Jul 2002 18:46:44 -0000	1.1.1.2
@@ -2,6 +2,15 @@
 <queryset>
    <rdbms><type>oracle</type><version>8.1.6</version></rdbms>
 
+
+<partialquery name="item::get_content.content_as_text">
+	<querytext>
+
+	, content.blob_to_string(content) as text
+
+	</querytext>
+</partialquery>
+
 <fullquery name="content::get_folder_labels.get_url">      
       <querytext>
 
Index: openacs.org-dev/packages/acs-content-repository/tcl/filter-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-content-repository/tcl/filter-procs-postgresql.xql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-content-repository/tcl/filter-procs-postgresql.xql	9 Jul 2002 17:34:56 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-content-repository/tcl/filter-procs-postgresql.xql	25 Jul 2002 18:46:44 -0000	1.1.1.2
@@ -2,6 +2,14 @@
 <queryset>
    <rdbms><type>postgresql</type><version>7.1</version></rdbms>
 
+<partialquery name="item::get_content.content_as_text">
+	<querytext>
+
+	, content as text
+
+	</querytext>
+</partialquery>
+
 <fullquery name="content::get_folder_labels.get_url">      
       <querytext>
 
Index: openacs.org-dev/packages/acs-content-repository/tcl/filter-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-content-repository/tcl/filter-procs.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-content-repository/tcl/filter-procs.tcl	9 Jul 2002 17:34:56 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-content-repository/tcl/filter-procs.tcl	25 Jul 2002 18:46:44 -0000	1.1.1.2
@@ -95,7 +95,7 @@
   }  
 
   if { [string equal [lindex [split $mime_type "/"] 0] "text"] } {
-    set text_sql ",\n    content.blob_to_string(content) as text"
+    set text_sql [db_map content_as_text]
   } else {
     set text_sql ""
   }
Index: openacs.org-dev/packages/acs-datetime/tcl/acs-calendar-2-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-datetime/tcl/acs-calendar-2-procs-postgresql.xql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-datetime/tcl/acs-calendar-2-procs-postgresql.xql	9 Jul 2002 17:34:57 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-datetime/tcl/acs-calendar-2-procs-postgresql.xql	25 Jul 2002 18:46:46 -0000	1.1.1.2
@@ -35,10 +35,10 @@
 as saturday_date,
 to_char(next_day(to_date(:current_date, 'yyyy-mm-dd')-7, 'Sunday') + 6,'J') 
 as saturday_julian,
-:current_date - '7 days'::reltime as last_week,
-to_char(:current_date - '7'days'::reltime, 'Month DD, YYYY') as last_week_pretty,
-:current_date + '7 days'::reltime as next_week,
-to_char(:current_date + '7'days'::reltime, 'Month DD, YYYY') as next_week_pretty
+:current_date::timestamp - '7 days'::timespan as last_week,
+to_char(:current_date::timestamp - '7 days'::timespan, 'Month DD, YYYY') as last_week_pretty,
+:current_date::timestamp + '7 days'::timespan as next_week,
+to_char(:current_date::timestamp + '7 days'::timespan, 'Month DD, YYYY') as next_week_pretty
 from     dual
 </querytext>
 </fullquery>
Index: openacs.org-dev/packages/acs-datetime/tcl/acs-calendar-2-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-datetime/tcl/acs-calendar-2-procs.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-datetime/tcl/acs-calendar-2-procs.tcl	9 Jul 2002 17:34:57 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-datetime/tcl/acs-calendar-2-procs.tcl	25 Jul 2002 18:46:46 -0000	1.1.1.2
@@ -226,7 +226,7 @@
     for {set hour $start_hour} {$hour <= $end_hour} {incr hour} {
         if {$max_n_events < $n_events($hour)} {
             set max_n_events $n_events($hour)
-            #ns_log Notice "BMA-DEBUG-CAL: Setting max_n_events to $max_n_events"
+            ns_log Notice "BMA-DEBUG-CAL: Setting max_n_events to $max_n_events"
         }
     }
     
@@ -358,9 +358,15 @@
         }
 
         if {$n_processed_events == 0 || ($n_events($hour) < $max_n_events && $must_complete_p)} {
-            for {set i 0} {$i < [expr "$max_n_events - $n_events($hour)"]} {incr i} {
-                append return_html "<td colspan=\"1\" bgcolor=\"#dddddd\">&nbsp;</td>"
-            }
+            if {$n_events($hour) == 0 || $n_events($hour) == $n_processed_events} {
+		append return_html "<td colspan=\"[expr $max_n_events - $n_events($hour)]\" bgcolor=\"#dddddd\">&nbsp;</td>"
+	    } else {
+		for {set i 0} {$i < [expr "$max_n_events - $n_events($hour)"]} {incr i} {
+		    append return_html "<td colspan=\"1\" bgcolor=\"#dddddd\">&nbsp;</td>"
+		}
+	    }
+	    
+
         }
 
         append return_html "</tr>\n"
Index: openacs.org-dev/packages/acs-events/sql/postgresql/oracle-compat-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-events/sql/postgresql/oracle-compat-create.sql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-events/sql/postgresql/oracle-compat-create.sql	9 Jul 2002 17:34:58 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-events/sql/postgresql/oracle-compat-create.sql	25 Jul 2002 18:46:46 -0000	1.1.1.2
@@ -78,14 +78,14 @@
        integer,
        varchar
 )
-returns interval as '	
+returns timespan as '	
 declare    
        interval__number	     alias for $1;
        interval__units	     alias for $2;
 begin
 
 	-- We should probably do unit checking at some point
-	return '''''''' || interval__number || '' '' || interval__units || '''''''' || ''::interval'';
+	return ('''''''' || interval__number || '' '' || interval__units || '''''''')::timespan;
 
 end;' language 'plpgsql';
 
Index: openacs.org-dev/packages/acs-kernel/sql/postgresql/apm-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-kernel/sql/postgresql/apm-create.sql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-kernel/sql/postgresql/apm-create.sql	9 Jul 2002 17:34:58 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-kernel/sql/postgresql/apm-create.sql	25 Jul 2002 18:46:47 -0000	1.1.1.2
@@ -1846,7 +1846,7 @@
 
 create function apm_package__parent_id (integer) returns integer as '
 declare
-    apm_package__parent_id__package_id alias foreign key $1;
+    apm_package__parent_id__package_id alias for $1;
     v_package_id apm_packages.package_id%TYPE;
 begin
     select sn1.object_id
Index: openacs.org-dev/packages/acs-kernel/sql/postgresql/postgresql.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-kernel/sql/postgresql/postgresql.sql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-kernel/sql/postgresql/postgresql.sql	9 Jul 2002 17:34:58 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-kernel/sql/postgresql/postgresql.sql	25 Jul 2002 18:46:47 -0000	1.1.1.2
@@ -692,18 +692,20 @@
 
 create function create_user_col_comments() returns boolean as '
 begin
+  -- in version 7.1 col_description was missing but is present in 7.2
+  -- does it exist in 7.0?
   if version() like ''%7.1%'' then
     execute ''
       create view user_col_comments as
         select upper(c.relname) as table_name,
-      	 upper(a.attname) as column_name,
-      	 d.description as comments
+         upper(a.attname) as column_name,
+         d.description as comments
           from pg_class c,
                pg_attribute a
                  left outer join pg_description d on (a.oid = d.objoid)
          where c.oid = a.attrelid
            and a.attnum > 0'';
-  else
+  else 
     execute ''
       create view user_col_comments as
         select upper(c.relname) as table_name, 
@@ -723,17 +725,42 @@
 
 -- PG substitute for Oracle user_col_comments view
 
-create view user_tab_comments as
-  select upper(c.relname) as table_name,
+create function create_user_tab_comments() returns boolean as '
+begin
+  if version() like ''%7.2%'' then
+    execute ''
+    create view user_tab_comments as
+      select upper(c.relname) as table_name,
 	 case
-	   when c.relkind = 'r' then 'TABLE'
-	   when c.relkind = 'v' then 'VIEW'
+	   when c.relkind = ''''r'''' then ''''TABLE''''
+	   when c.relkind = ''''v'''' then ''''VIEW''''
 	   else c.relkind::text
 	 end as table_type,
 	 d.description as comments
     from pg_class c
-           left outer join pg_description d on (c.oid = d.objoid);
+           left outer join pg_description d on (c.oid = d.objoid)
+       where d.objsubid = 0'';
+  else
+    execute ''
+    create view user_tab_comments as
+      select upper(c.relname) as table_name,
+	 case
+	   when c.relkind = ''''r'''' then ''''TABLE''''
+	   when c.relkind = ''''v'''' then ''''VIEW''''
+	   else c.relkind::text
+	 end as table_type,
+	 d.description as comments
+    from pg_class c
+           left outer join pg_description d on (c.oid = d.objoid)'';
+  end if;
+  return ''t'';
+end;' language 'plpgsql';
 
+select create_user_tab_comments();
+
+drop function create_user_tab_comments();
+
+
 -- Table for storing PL/PGSQL function arguments
 
 create table acs_function_args (
Index: openacs.org-dev/packages/acs-kernel/sql/postgresql/site-node-object-map-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-kernel/sql/postgresql/site-node-object-map-create.sql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-kernel/sql/postgresql/site-node-object-map-create.sql	9 Jul 2002 17:34:58 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-kernel/sql/postgresql/site-node-object-map-create.sql	25 Jul 2002 18:46:47 -0000	1.1.1.2
@@ -35,6 +35,8 @@
     (object_id, node_id)
     values
     (p_object_id, p_node_id);
+
+    return 0;
 end;
 ' language 'plpgsql';
 
@@ -47,6 +49,8 @@
 begin
     delete
     from site_node_object_mappings
-    where object_id = p__object_id;
+    where object_id = p_object_id;
+
+    return 0;
 end;
 ' language 'plpgsql';
Index: openacs.org-dev/packages/acs-lang/sql/oracle/ad-locales-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-lang/sql/oracle/ad-locales-drop.sql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-lang/sql/oracle/ad-locales-drop.sql	9 Jul 2002 17:34:58 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-lang/sql/oracle/ad-locales-drop.sql	25 Jul 2002 18:46:47 -0000	1.1.1.2
@@ -1,7 +1,7 @@
 --
 -- packages/language/sql/language-create.sql
 --
--- @author Jeff Davis (davis@arsdigita.com)
+-- @author Jeff Davis (davis@xarg.net)
 -- @creation-date 2000-09-10
 -- @cvs-id $Id$
 --
Index: openacs.org-dev/packages/acs-lang/sql/oracle/ad-locales.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-lang/sql/oracle/ad-locales.sql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-lang/sql/oracle/ad-locales.sql	9 Jul 2002 17:34:58 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-lang/sql/oracle/ad-locales.sql	25 Jul 2002 18:46:47 -0000	1.1.1.2
@@ -1,7 +1,7 @@
 --
 -- packages/language/sql/language-create.sql
 --
--- @author Jeff Davis (davis@arsdigita.com)
+-- @author Jeff Davis (davis@xarg.net)
 -- @creation-date 2000-09-10
 -- @cvs-id $Id$
 --
Index: openacs.org-dev/packages/acs-lang/sql/oracle/message-catalog-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-lang/sql/oracle/message-catalog-drop.sql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-lang/sql/oracle/message-catalog-drop.sql	9 Jul 2002 17:34:58 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-lang/sql/oracle/message-catalog-drop.sql	25 Jul 2002 18:46:47 -0000	1.1.1.2
@@ -1,7 +1,7 @@
 --
 -- packages/language/sql/language-drop.sql
 --
--- @author davis@arsdigita.com
+-- @author davis@xarg.net
 -- @creation-date 2000-09-10
 -- @cvs-id $Id$
 --
Index: openacs.org-dev/packages/acs-lang/sql/oracle/message-catalog.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-lang/sql/oracle/message-catalog.sql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-lang/sql/oracle/message-catalog.sql	9 Jul 2002 17:34:58 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-lang/sql/oracle/message-catalog.sql	25 Jul 2002 18:46:47 -0000	1.1.1.2
@@ -1,7 +1,7 @@
 --
 -- packages/acs-i18n/sql/language-create.sql
 --
--- @author Jeff Davis (davis@arsdigita.com)
+-- @author Jeff Davis (davis@xarg.net)
 -- @creation-date 2000-09-10
 -- @cvs-id $Id$
 --
Index: openacs.org-dev/packages/acs-lang/sql/postgresql/ad-locales-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-lang/sql/postgresql/ad-locales-drop.sql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-lang/sql/postgresql/ad-locales-drop.sql	9 Jul 2002 17:34:58 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-lang/sql/postgresql/ad-locales-drop.sql	25 Jul 2002 18:46:47 -0000	1.1.1.2
@@ -1,7 +1,7 @@
 --
 -- packages/language/sql/language-create.sql
 --
--- @author Jeff Davis (davis@arsdigita.com)
+-- @author Jeff Davis (davis@xarg.net)
 -- @creation-date 2000-09-10
 -- @cvs-id $Id$
 --
Index: openacs.org-dev/packages/acs-lang/sql/postgresql/ad-locales.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-lang/sql/postgresql/ad-locales.sql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-lang/sql/postgresql/ad-locales.sql	9 Jul 2002 17:34:58 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-lang/sql/postgresql/ad-locales.sql	25 Jul 2002 18:46:47 -0000	1.1.1.2
@@ -1,7 +1,7 @@
 --
 -- packages/language/sql/language-create.sql
 --
--- @author Jeff Davis (davis@arsdigita.com)
+-- @author Jeff Davis (davis@xarg.net)
 -- @creation-date 2000-09-10
 -- @cvs-id $Id$
 --
Index: openacs.org-dev/packages/acs-lang/sql/postgresql/message-catalog-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-lang/sql/postgresql/message-catalog-drop.sql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-lang/sql/postgresql/message-catalog-drop.sql	9 Jul 2002 17:34:58 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-lang/sql/postgresql/message-catalog-drop.sql	25 Jul 2002 18:46:47 -0000	1.1.1.2
@@ -1,7 +1,7 @@
 --
 -- packages/language/sql/language-drop.sql
 --
--- @author davis@arsdigita.com
+-- @author davis@xarg.net
 -- @creation-date 2000-09-10
 -- @cvs-id $Id$
 --
Index: openacs.org-dev/packages/acs-lang/sql/postgresql/message-catalog.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-lang/sql/postgresql/message-catalog.sql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-lang/sql/postgresql/message-catalog.sql	9 Jul 2002 17:34:58 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-lang/sql/postgresql/message-catalog.sql	25 Jul 2002 18:46:47 -0000	1.1.1.2
@@ -1,7 +1,7 @@
 --
 -- packages/acs-i18n/sql/language-create.sql
 --
--- @author Jeff Davis (davis@arsdigita.com)
+-- @author Jeff Davis (davis@xarg.net)
 -- @creation-date 2000-09-10
 -- @cvs-id $Id$
 --
Index: openacs.org-dev/packages/acs-lang/tcl/lang-init.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-lang/tcl/lang-init.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-lang/tcl/lang-init.tcl	9 Jul 2002 17:34:58 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-lang/tcl/lang-init.tcl	25 Jul 2002 18:46:47 -0000	1.1.1.2
@@ -10,7 +10,7 @@
     http://www.fsf.org/copyleft/gpl.html
 
     @creation-date 10 September 2000
-    @author Jeff Davis (davis@arsdigita.com)
+    @author Jeff Davis (davis@xarg.net)
     @cvs-id $Id$
 }
 
Index: openacs.org-dev/packages/acs-lang/tcl/lang-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-lang/tcl/lang-procs.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-lang/tcl/lang-procs.tcl	9 Jul 2002 17:34:58 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-lang/tcl/lang-procs.tcl	25 Jul 2002 18:46:47 -0000	1.1.1.2
@@ -8,7 +8,7 @@
     http://www.fsf.org/copyleft/gpl.html
 
     @creation-date 10 September 2000
-    @author Jeff Davis (davis@arsdigita.com)
+    @author Jeff Davis (davis@xarg.net)
     @cvs-id $Id$
 }
 
@@ -19,7 +19,7 @@
     Inserts the message into the table lang_messages
     if it does not exist and updates if it does.
 
-    @author Jeff Davis (davis@arsdigita.com)
+    @author Jeff Davis (davis@xarg.net)
     
     @param lang    Abbreviation for language of the message. Taken from ad_locales table.
     @param key     Unique identifier for this message. Will be the same identifier
@@ -38,7 +38,7 @@
     Inserts the message into the table lang_messages
     if it does not exist and updates if it does.
 
-    @author Jeff Davis (davis@arsdigita.com)
+    @author Jeff Davis (davis@xarg.net)
     @see _mr
     
     @param lang    Locale or language of the message. If a language is supplied,
@@ -91,7 +91,7 @@
     If the user is a translator, inserts tags to link to the translator
     interface. This allows a translator to work from the context of a web page.
 
-    @author Jeff Davis (davis@arsdigita.com)
+    @author Jeff Davis (davis@xarg.net)
     
     @param locale    Abbreviation for language of the message. Taken from ad_locales table.
     @param key     Unique identifier for this message. Will be the same identifier
@@ -120,7 +120,7 @@
 
     4. Lookup is tried with language and key without package prefix.
 
-    @author Jeff Davis (davis@arsdigita.com), Henry Minsky (hqm@arsdigita.com)
+    @author Jeff Davis (davis@xarg.net), Henry Minsky (hqm@arsdigita.com)
     @see _
     
     @param locale  Locale (e.g., "en_US") or language (e.g., "en") string.
@@ -181,7 +181,7 @@
 
 
 
-    @author Jeff Davis (davis@arsdigita.com)
+    @author Jeff Davis (davis@xarg.net)
     @return        Number of files loaded
 
 } { 
@@ -237,7 +237,7 @@
     insert into lang_testsort values ('lzim');  
     </pre>
 
-    @author Jeff Davis (davis@arsdigita.com)
+    @author Jeff Davis (davis@xarg.net)
 
     @param field       Name of Oracle column
     @param locale      Locale for sorting. 
@@ -371,7 +371,7 @@
     &lt;trn key=&quot;hello&quot; type=&quot;user&quot;&gt;Hello&lt;/trn&gt;
     </pre>
 
-    @author Jeff Davis (davis@arsdigita.com)
+    @author Jeff Davis (davis@xarg.net)
     @see lang_message_lookup
     @see lang_message_register
     @see ad_locale
Index: openacs.org-dev/packages/acs-lang/tcl/localization-data-init.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-lang/tcl/localization-data-init.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-lang/tcl/localization-data-init.tcl	9 Jul 2002 17:34:58 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-lang/tcl/localization-data-init.tcl	25 Jul 2002 18:46:48 -0000	1.1.1.2
@@ -6,7 +6,7 @@
     Add new entries to support additional locales.
 
     @creation-date 10 September 2000
-    @author Jeff Davis (davis@arsdigita.com)
+    @author Jeff Davis (davis@xarg.net)
     @cvs-id $Id$
 }
 
Index: openacs.org-dev/packages/acs-lang/tcl/localization-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-lang/tcl/localization-procs.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-lang/tcl/localization-procs.tcl	9 Jul 2002 17:34:58 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-lang/tcl/localization-procs.tcl	25 Jul 2002 18:46:48 -0000	1.1.1.2
@@ -8,7 +8,7 @@
     http://www.fsf.org/copyleft/gpl.html
 
     @creation-date 30 September 2000
-    @author Jeff Davis (davis@arsdigita.com) 
+    @author Jeff Davis (davis@xarg.net) 
     @author Ashok Argent-Katwala (akatwala@arsdigita.com)
     @cvs-id $Id$
 }
Index: openacs.org-dev/packages/acs-subsite/tcl/group-type-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-subsite/tcl/group-type-procs-postgresql.xql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-subsite/tcl/group-type-procs-postgresql.xql	9 Jul 2002 17:34:59 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-subsite/tcl/group-type-procs-postgresql.xql	25 Jul 2002 18:46:49 -0000	1.1.1.2
@@ -64,7 +64,7 @@
       begin
         insert into group_type_rels 
 	       (group_rel_type_id, rel_type, group_type)
-	       select acs_object_id_seq.nextval, r.rel_type, :group_type
+	       select nextval('t_acs_object_id_seq'), r.rel_type, :group_type
 	         from group_type_rels r
 	        where r.group_type = :supertype;
         return null;
Index: openacs.org-dev/packages/acs-subsite/www/admin/index.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-subsite/www/admin/index.adp,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-subsite/www/admin/index.adp	9 Jul 2002 17:34:59 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-subsite/www/admin/index.adp	25 Jul 2002 18:46:49 -0000	1.1.1.2
@@ -9,6 +9,7 @@
   <li><a href=rel-segments/>Relational Segments</a>
   <li><a href=rel-types/>Relationship Types</a>
   <li><a href=host-node-map/>Host-Node Map</a>
+  <li><a href=object-types/>Object Types</a>
 </ul>
 
 <if @acs_admin_available_p@ eq "t">
Index: openacs.org-dev/packages/acs-subsite/www/pvt/home.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-subsite/www/pvt/home.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-subsite/www/pvt/home.tcl	9 Jul 2002 17:34:59 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-subsite/www/pvt/home.tcl	25 Jul 2002 18:46:51 -0000	1.1.1.2
@@ -64,10 +64,10 @@
 if { ! $user_exists_p } {
     if {$user_id == 0} {
 	ad_redirect_for_registration
-	return
+        ad_script_abort
     }
     ad_return_error "Account Unavailable" "We can't find you (user #$user_id) in the users table.  Probably your account was deleted for some reason.  You can visit <a href=\"/register/logout\">the log out page</a> and then start over."
-    return
+    ad_script_abort
 }
 
 if { ![empty_string_p $first_names] || ![empty_string_p $last_name] } {
Index: openacs.org-dev/packages/acs-subsite/www/register/email-password-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-subsite/www/register/email-password-2.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-subsite/www/register/email-password-2.tcl	9 Jul 2002 17:34:59 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-subsite/www/register/email-password-2.tcl	25 Jul 2002 18:46:51 -0000	1.1.1.2
@@ -35,7 +35,7 @@
 set ask_question_p 0
 if {!$validated_p} {
     if {[exists_and_not_null answer]} {
-        if {[db_string select_answer_matches_p {}} {
+        if {[db_string select_answer_matches_p {}]} {
             set validated_p 1
         }
     } else {
Index: openacs.org-dev/packages/acs-subsite/www/register/email-password.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-subsite/www/register/email-password.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-subsite/www/register/email-password.tcl	9 Jul 2002 17:34:59 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-subsite/www/register/email-password.tcl	25 Jul 2002 18:46:51 -0000	1.1.1.2
@@ -16,7 +16,7 @@
     return
 }
 
-if {![ad_parameter "RequireQuestionForPasswordResetP"]} {
+if {![ad_parameter "RequireQuestionForPasswordResetP" security 0]} {
     ad_returnredirect "./email-password-2?user_id=$user_id&validated_p=1"
     ad_script_abort
 }
Index: openacs.org-dev/packages/acs-tcl/acs-tcl.info
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-tcl/acs-tcl.info,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-tcl/acs-tcl.info	9 Jul 2002 17:34:59 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-tcl/acs-tcl.info	25 Jul 2002 18:46:51 -0000	1.1.1.2
@@ -7,17 +7,17 @@
     <initial-install-p>t</initial-install-p>
     <singleton-p>t</singleton-p>
 
-    <version name="4.1.2" url="http://www.arsdigita.com/acs-repository/download/apm/acs-tcl-4.1.2.apm">
+    <version name="4.5" url="http://www.openacs.org/repository/download/apm/acs-tcl-4.5.apm">
     <database-support>
         <database>oracle</database>
         <database>postgresql</database>
     </database-support>
-        <owner url="mailto:acs@arsdigita.com">ACS Core Team</owner>
+        <owner>ACS Core Team</owner>
         <summary>The Tcl library procedures that comprise the ACS Kernel.</summary>
-        <release-date>2001-03-06</release-date>
-        <vendor url="http://www.arsdigita.com/">ArsDigita Corporation</vendor>
+        <release-date>2002-05-15</release-date>
+        <vendor url="http://www.openacs.org/">OpenACS</vendor>
 
-        <provides url="acs-tcl" version="4.1"/>
+        <provides url="acs-tcl" version="4.5"/>
         <requires url="acs-bootstrap-installer" version="4.2"/>
         <requires url="acs-kernel" version="4.1"/>
 
@@ -108,6 +108,8 @@
             <file type="query_file" path="tcl/security-procs.xql"/>
             <file type="tcl_procs" path="tcl/server-cluster-procs.tcl"/>
             <file type="tcl_procs" path="tcl/set-operation-procs.tcl"/>
+            <file type="tcl_procs" path="tcl/site-node-apm-integration-procs.tcl"/>
+            <file type="query_file" path="tcl/site-node-apm-integration-procs.xql"/>
             <file type="query_file" db_type="oracle" path="tcl/site-node-object-map-procs-oracle.xql"/>
             <file type="query_file" db_type="postgresql" path="tcl/site-node-object-map-procs-postgresql.xql"/>
             <file type="tcl_procs" path="tcl/site-node-object-map-procs.tcl"/>
Index: openacs.org-dev/packages/acs-tcl/tcl/form-processing-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-tcl/tcl/form-processing-procs.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-tcl/tcl/form-processing-procs.tcl	9 Jul 2002 17:34:59 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-tcl/tcl/form-processing-procs.tcl	25 Jul 2002 18:46:52 -0000	1.1.1.2
@@ -72,7 +72,7 @@
         return
     }
 
-    gp_return_template
+    ad_return_template
 
     </pre></blockquote>
 
@@ -85,7 +85,7 @@
 
     <p>
 
-    The call to gp_return_template then renders the page - it is your responsibility to render the form
+    The call to ad_return_template then renders the page - it is your responsibility to render the form
     in your template by use of the ATS formtemplate tag.
  
     <p>
@@ -360,10 +360,9 @@
         return -code error "No \"form\" block has been specified for form \"$form_name\""
     }
 
-    # If we're not extending
+    # If we're not extending - this needs integration with the ATS form builder ...
     if { !$extend_p } {
-        global gp_conn
-        incr gp_conn(form_count)
+        # incr ad_conn(form_count)
     }
 
     ####################
@@ -739,7 +738,7 @@
             foreach {element_name validate_expr error_message} $validate_element {
                 if { ![template::element error_p $form_name $element_name] && \
                     ![uplevel #$level [list expr $validate_expr]] } {
-                    template::element set_error $form_name $element_name $error_message
+                    template::element set_error $form_name $element_name [subst $error_message]
                 }
             }
         }
@@ -854,9 +853,9 @@
     foreach arg $args {
         if { [llength $arg] == 1 } {
             upvar $arg value
-            gp_set_element_value -element $arg $value
+            ad_set_element_value -element $arg $value
         } else {
-            gp_set_element_value -element [lindex $arg 0] [lindex $arg 1]
+            ad_set_element_value -element [lindex $arg 0] [lindex $arg 1]
         }
     }
 }
Index: openacs.org-dev/packages/acs-tcl/tcl/navigation-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-tcl/tcl/navigation-procs.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-tcl/tcl/navigation-procs.tcl	9 Jul 2002 17:34:59 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-tcl/tcl/navigation-procs.tcl	25 Jul 2002 18:46:52 -0000	1.1.1.2
@@ -12,11 +12,16 @@
 }
 
 
-ad_proc ad_context_bar { args } {
+ad_proc ad_context_bar { 
+    -node_id
+    args
+} {
 
     Returns a Yahoo-style hierarchical navbar. Includes "Your Workspace" or "Administration"
     if applicable, and the subsite if not global.
 
+    @param node_id If provided work up from this node, otherwise the current node
+
 } {
 
   set context [list]
@@ -25,7 +30,10 @@
       lappend context [list "[ad_pvt_home]" "[ad_pvt_home_name]"]
   }
 
-  set node_id [ad_conn node_id]
+  if { ![info exists node_id] } {
+      set node_id [ad_conn node_id]
+  }
+
   db_foreach context {
     select site_node.url(node_id) as url, object_id,
            acs_object.name(object_id) as object_name,
Index: openacs.org-dev/packages/acs-tcl/tcl/request-processor-init.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-tcl/tcl/request-processor-init.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-tcl/tcl/request-processor-init.tcl	9 Jul 2002 17:34:59 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-tcl/tcl/request-processor-init.tcl	25 Jul 2002 18:46:52 -0000	1.1.1.2
@@ -8,7 +8,7 @@
 }
 
 # These procedures are dynamically defined at startup to alleviate
-# lock contention. Thanks to davis@arsdigita.com.
+# lock contention. Thanks to davis@xarg.net.
 
 proc ad_acs_admin_id_mem {} {
     return [db_string acs_kernel_id_get {
Index: openacs.org-dev/packages/acs-tcl/tcl/site-nodes-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-tcl/tcl/site-nodes-procs.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-tcl/tcl/site-nodes-procs.tcl	9 Jul 2002 17:34:59 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-tcl/tcl/site-nodes-procs.tcl	25 Jul 2002 18:46:52 -0000	1.1.1.2
@@ -32,29 +32,6 @@
         return $node_id
     }
 
-    ad_proc -public new_with_package {
-        {-name:required}
-        {-parent_id:required}
-        {-package_key:required}
-        {-instance_name:required}
-        {-context_id:required}
-    } {
-        create site node, instantiate package, mount package at new site node
-    } {
-        set node_id [new -name $name -parent_id $parent_id]
-
-        set package_id [apm_package_create_instance $instance_name $context_id $package_key]
-
-        mount -node_id $node_id -object_id $package_id
-
-        update_cache -node_id $node_id
-
-        # call post instantiation proc for the package
-        apm_package_call_post_instantiation_proc $package_id $package_key
-
-        return $package_id
-    }
-
     ad_proc -public delete {
         {-node_id:required}
     } {
@@ -219,7 +196,7 @@
     } {
         return the site node associated with the given object_id
     } {
-        return [get -url [get_url_from_object_id -object_id $object_id]]
+        return [get -url [lindex [get_url_from_object_id -object_id $object_id] 0]]
     }
 
     ad_proc -public get_url {
@@ -238,9 +215,10 @@
     ad_proc -public get_url_from_object_id {
         {-object_id:required}
     } {
-        return the url of the site node associated with the given object
+        returns a list of urls for site_nodes that have the given object
+        mounted or the empty list if there are none
     } {
-        return [db_string select_url_from_object_id {} -default ""]
+        return [db_list select_url_from_object_id {}]
     }
 
     ad_proc -public get_node_id {
@@ -257,7 +235,7 @@
     } {
         return the site node id associated with the given object_id
     } {
-        return [get_node_id -url [get_url_from_object_id -object_id $object_id]]
+        return [get_node_id -url [lindex [get_url_from_object_id -object_id $object_id] 0]]
     }
 
     ad_proc -public get_parent_id {
@@ -389,7 +367,7 @@
         set context_id $parent_node_id
     }
 
-    return [site_node::new_with_package \
+    return [site_node_apm_integration::new_site_node_and_package \
         -name $instance_name \
         -parent_id $parent_node_id \
         -package_key $package_key \
@@ -537,5 +515,5 @@
 	return $default
     }
 
-    return [site_node::get_url_from_object_id -object_id $subsite_pkg_id]
+    return [lindex [site_node::get_url_from_object_id -object_id $subsite_pkg_id] 0]
 }
Index: openacs.org-dev/packages/acs-tcl/tcl/text-html-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-tcl/tcl/text-html-procs.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-tcl/tcl/text-html-procs.tcl	9 Jul 2002 17:34:59 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-tcl/tcl/text-html-procs.tcl	25 Jul 2002 18:46:52 -0000	1.1.1.2
@@ -133,7 +133,7 @@
     @param break_hard the number of characters you want the html fragment 
     truncated to. Will truncate, regardless of what tag is currently in action.
 
-    @author Jeff Davis (davis@arsdigita.com)
+    @author Jeff Davis (davis@xarg.net)
     
 } {
     set frag $html_fragment 
Index: openacs.org-dev/packages/acs-templating/acs-templating.info
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-templating/acs-templating.info,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-templating/acs-templating.info	9 Jul 2002 17:34:59 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-templating/acs-templating.info	25 Jul 2002 18:46:52 -0000	1.1.1.2
@@ -30,7 +30,12 @@
             <file path="resources/assets/corners/lower-right.gif"/>
             <file path="resources/assets/corners/upper-left.gif"/>
             <file path="resources/assets/corners/upper-right.gif"/>
+            <file path="resources/forms/confirm-button.adp"/>
+            <file path="resources/forms/confirm-button.tcl"/>
             <file path="resources/forms/grid.adp"/>
+            <file path="resources/forms/lars-standard.adp"/>
+            <file path="resources/forms/plain.adp"/>
+            <file path="resources/forms/plainest.adp"/>
             <file path="resources/forms/standard.adp"/>
             <file path="resources/forms/tabbed-dialog.adp"/>
             <file path="resources/forms/wizard.adp"/>
@@ -57,6 +62,7 @@
             <file type="tcl_procs" path="tcl/doc-procs.tcl"/>
             <file type="tcl_procs" path="tcl/doc-tcl-procs.tcl"/>
             <file type="tcl_procs" path="tcl/element-procs.tcl"/>
+            <file type="tcl_procs" path="tcl/file-procs.tcl"/>
             <file type="tcl_procs" path="tcl/filter-procs.tcl"/>
             <file type="tcl_procs" path="tcl/form-procs.tcl"/>
             <file type="tcl_procs" path="tcl/mime-procs.tcl"/>
Index: openacs.org-dev/packages/acs-templating/resources/forms/confirm-button.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-templating/resources/forms/confirm-button.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-templating/resources/forms/confirm-button.tcl	9 Jul 2002 17:34:59 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-templating/resources/forms/confirm-button.tcl	25 Jul 2002 18:46:52 -0000	1.1.1.2
@@ -12,7 +12,6 @@
 # There's one exception - we set the special form element "__confirmed_p" true.  This
 # informs ad_form that the use has indeed confirmed the submission.
 
-ns_log Notice "Huh?"
 multirow create __form_contents__ __key__ __value__
 
 if { ![empty_string_p [set __form__ [ns_getform]]] } {
@@ -31,5 +30,3 @@
     }
 
 }
-
-ns_log Notice "Huh? done"
Index: openacs.org-dev/packages/acs-templating/resources/forms/plain.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-templating/resources/forms/plain.adp,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-templating/resources/forms/plain.adp	9 Jul 2002 17:34:59 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-templating/resources/forms/plain.adp	25 Jul 2002 18:46:52 -0000	1.1.1.2
@@ -7,7 +7,7 @@
   <multiple name=elements>
 
     <if @elements.section@ not nil>
-      <tr><td colspan="2" style="background: #eeeeee"><span style="font-weight: bold">@elements.section@</span></td></tr>
+      <tr><td colspan="2"><span style="font-weight: bold">@elements.section@</span></td></tr>
     </if>
 
     <group column="section">
Index: openacs.org-dev/packages/acs-templating/tcl/0-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-templating/tcl/0-procs.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-templating/tcl/0-procs.tcl	9 Jul 2002 17:34:59 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-templating/tcl/0-procs.tcl	25 Jul 2002 18:46:52 -0000	1.1.1.2
@@ -33,6 +33,7 @@
   namespace eval util {
     namespace eval date {}
     namespace eval currency {}
+    namespace eval file {}
   }
 
   namespace eval element {
@@ -98,13 +99,6 @@
 
   # specify what procs can be accessed directly
   namespace export form element request
-
-  # get the path to the system templates directory
-  proc get_resource_path {} {
-
-    set path "ns/server/[ns_info server]/ats"
-    return [ns_config $path ResourcePath [ns_info pageroot]/ats/resources]
-  }
 }
 
 # Generic wrapper for registered tag handlers.
Index: openacs.org-dev/packages/acs-templating/tcl/date-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-templating/tcl/date-procs.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-templating/tcl/date-procs.tcl	9 Jul 2002 17:34:59 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-templating/tcl/date-procs.tcl	25 Jul 2002 18:46:52 -0000	1.1.1.2
@@ -249,6 +249,17 @@
       }
       return $ret
     }
+    linear_date_no_time {
+      # Return a date in format "YYYY MM DD"
+      set clipped_date [lrange $date 0 2]
+      set ret [list]
+      set pad "0000"
+      foreach fragment $clipped_date {
+        lappend ret "[string range $pad [string length $fragment] end]$fragment"
+        set pad "00"
+      }
+      return $ret
+    }
     display_date {
 
       # Return a beautified date.  It should use the widget format string but DRB
Index: openacs.org-dev/packages/acs-templating/tcl/tag-init.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-templating/tcl/tag-init.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/acs-templating/tcl/tag-init.tcl	9 Jul 2002 17:34:59 -0000	1.1.1.1
+++ openacs.org-dev/packages/acs-templating/tcl/tag-init.tcl	25 Jul 2002 18:46:52 -0000	1.1.1.2
@@ -144,22 +144,25 @@
 
   if { ![template::util::is_nil value] } {
 
-    template::adp_append_code "\nset __ats_list_value \[list $value\]\n"
+    set name [ns_set iget $params name]
+    if { [empty_string_p $name] } {
+      set name "__ats_list_value"
+    }
 
-    set name "__ats_list_value"
-    template::adp_append_code "\nset $name:rowcount [llength $value]\n"
+    template::adp_append_code "\nset $name \[eval list $value\]\n"
+    template::adp_append_code "\nset $name:rowcount \[llength \$$name\]\n"
 
   } else {
 
     # Expect a data source from the tcl script
     set name [template::get_attribute list $params name]
-    template::adp_append_code "\nset $name:rowcount \[llength \$$name\]\n"
+    template::adp_append_code "\nset {$name:rowcount} \[llength \${$name}\]\n"
   }
   
   template::adp_append_code "
 
   for { set __ats_i 0 } { \$__ats_i < \${$name:rowcount} } { incr __ats_i } {
-    set $name:item \[lindex \$$name \$__ats_i\]
+    set $name:item \[lindex \${$name} \$__ats_i\]
     set $name:rownum \[expr \$__ats_i + 1\]
   "
   template::adp_compile_chunk $chunk
Index: openacs.org-dev/packages/attachments/attachments.info
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/attachments/attachments.info,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/attachments/attachments.info	9 Jul 2002 17:35:01 -0000	1.1.1.1
+++ openacs.org-dev/packages/attachments/attachments.info	25 Jul 2002 18:46:57 -0000	1.1.1.2
@@ -2,8 +2,8 @@
 <!-- Generated by the OpenACS Package Manager -->
 
 <package key="attachments" url="&quot;http://software.openforce.net/openacs/packages/attachments" type="apm_application">
-    <package-name>attachments</package-name>
-    <pretty-plural>attachments</pretty-plural>
+    <package-name>Attachments</package-name>
+    <pretty-plural>Attachments</pretty-plural>
     <initial-install-p>f</initial-install-p>
     <singleton-p>t</singleton-p>
 
@@ -13,9 +13,9 @@
         <database>postgresql</database>
     </database-support>
         <owner url="mailto:arjun@openforce.net">Arjun Sanyal</owner>
-        <summary>attachments</summary>
+        <summary>Attachments</summary>
         <vendor url="http://openforce.biz">OpenForce, Inc.</vendor>
-        <description format="text/plain">attachments</description>
+        <description format="text/plain">Attachments</description>
 
         <provides url="attachmens" version="0.1d"/>
         <requires url="file-storage" version="4.1"/>
@@ -24,7 +24,10 @@
             <file type="package_spec" path="attachments.info"/>
             <file type="data_model_create" db_type="oracle" path="sql/oracle/attachments-create.sql"/>
             <file type="data_model_drop" db_type="oracle" path="sql/oracle/attachments-drop.sql"/>
+            <file type="data_model_create" db_type="postgresql" path="sql/postgresql/attachments-create.sql"/>
+            <file type="data_model_drop" db_type="postgresql" path="sql/postgresql/attachments-drop.sql"/>
             <file type="query_file" db_type="oracle" path="tcl/attachments-procs-oracle.xql"/>
+            <file type="query_file" db_type="postgresql" path="tcl/attachments-procs-postgresql.xql"/>
             <file type="tcl_procs" path="tcl/attachments-procs.tcl"/>
             <file type="query_file" path="tcl/attachments-procs.xql"/>
             <file type="content_page" path="www/admin/new-root-folder-map-2.tcl"/>
@@ -46,11 +49,14 @@
             <file type="query_file" path="www/go-to-attachment.xql"/>
             <file type="content_page" path="www/graphics/file.gif"/>
             <file type="content_page" path="www/graphics/folder.gif"/>
+            <file type="content_page" path="www/master.adp"/>
+            <file type="content_page" path="www/master.tcl"/>
             <file type="content_page" path="www/simple-add-2.tcl"/>
             <file type="content_page" path="www/simple-add.adp"/>
             <file type="content_page" path="www/simple-add.tcl"/>
         </files>
         <parameters>
+            <parameter datatype="string"  min_n_values="1"  max_n_values="1"  name="RelativeUrl"  default="attach" description="The relative url of this package when mounted under a client."/>
             <parameter datatype="number"  min_n_values="1"  max_n_values="1"  name="MaximumFileSize"  default="4096000" description="maximum file size for upload"/>
         </parameters>
 
Index: openacs.org-dev/packages/attachments/tcl/attachments-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/attachments/tcl/attachments-procs.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/attachments/tcl/attachments-procs.tcl	9 Jul 2002 17:35:01 -0000	1.1.1.1
+++ openacs.org-dev/packages/attachments/tcl/attachments-procs.tcl	25 Jul 2002 18:46:57 -0000	1.1.1.2
@@ -84,30 +84,35 @@
         db_dml delete_attachment {}
     }
 
+    ad_proc -public get_url {
+    } {
+        return [parameter::get  \
+            -package_id [apm_package_id_from_key attachments] \
+            -parameter RelativeUrl
+        ]
+    }
+
     ad_proc -public add_attachment_url {
         {-package_id ""}
         {-object_id:required}
         {-return_url ""}
         {-pretty_name ""}
     } {
-        # FIXME: absolute URL here!!
-        return "attach/attach?pretty_object_name=[ns_urlencode $pretty_name]&object_id=$object_id&return_url=[ns_urlencode $return_url]"
+        return "[attachments::get_url]/attach?pretty_object_name=[ns_urlencode $pretty_name]&object_id=$object_id&return_url=[ns_urlencode $return_url]"
     }
 
     ad_proc -public goto_attachment_url {
         {-package_id ""}
         {-object_id:required}
         {-attachment_id:required}
     } {
-        # FIXME: absolute URL!
-        return "attach/go-to-attachment?object_id=$object_id&attachment_id=$attachment_id"
+        return "[attachments::get_url]/go-to-attachment?object_id=$object_id&attachment_id=$attachment_id"
     }
 
     ad_proc -public graphic_url {
         {-package_id ""}
     } {
-        # FIXME: absolute URL!
-        return "<img valign=bottom src=\"attach/graphics/file.gif\">"
+        return "<img valign=bottom src=\"[attachments::get_url]/graphics/file.gif\">"
     }
 
     ad_proc -public get_attachments {
Index: openacs.org-dev/packages/attachments/www/attach-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/attachments/www/attach-2.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/attachments/www/attach-2.tcl	9 Jul 2002 17:35:01 -0000	1.1.1.1
+++ openacs.org-dev/packages/attachments/www/attach-2.tcl	25 Jul 2002 18:46:57 -0000	1.1.1.2
@@ -14,8 +14,13 @@
 # Perms
 permission::require_permission -object_id $object_id -privilege write
 
-# Perform the attachment
-attachments::attach -object_id $object_id -attachment_id $item_id
+if {[catch {
+    # Perform the attachment
+    attachments::attach -object_id $object_id -attachment_id $item_id
+} errmsg]} {
+    # Attachment already exists, just keep going
+    ns_log Notice "Attachment $item_id to Object $object_id already exists"
+}
 
 ad_returnredirect $return_url
 
Index: openacs.org-dev/packages/attachments/www/attach.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/attachments/www/attach.adp,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/attachments/www/attach.adp	9 Jul 2002 17:35:01 -0000	1.1.1.1
+++ openacs.org-dev/packages/attachments/www/attach.adp	25 Jul 2002 18:46:57 -0000	1.1.1.2
@@ -2,13 +2,18 @@
 <property name="title">Attach A File to @pretty_object_name@</property>
 <property name="context_bar">@context_bar@</property>
 
-You are attaching a document to @pretty_object_name@.<p>
+You are attaching a document to @pretty_object_name@.
 
-Choose a location for your attachment. If your attachment already
-exists in the file storage folder, simply select it.<br>
-Otherwise, you
-may upload a new attachment.
+<p>
 
+<small>
+To attach a file already in a folder, open the folder by clicking the
+folder's name, then click the &quot;[ Choose ]&quot; link next to the file. To
+upload a new file into a folder, open the folder by clicking the
+folder's name, then click the appropriate  &quot;Attach a new: File | URL&quot;
+link
+</small>
+
 <p>
 @fs_context_bar_html@
 <p>
Index: openacs.org-dev/packages/attachments/www/attach.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/attachments/www/attach.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/attachments/www/attach.tcl	9 Jul 2002 17:35:01 -0000	1.1.1.1
+++ openacs.org-dev/packages/attachments/www/attach.tcl	25 Jul 2002 18:46:57 -0000	1.1.1.2
@@ -24,10 +24,15 @@
 }
 
 # Load up file storage information
-
 set root_folder_id [attachments::get_root_folder]
 if {[empty_string_p $folder_id]} {
     set folder_id $root_folder_id
+} 
+
+# sanity check
+if {[empty_string_p $folder_id]} {
+    ad_return_complaint 1 "Error: empty folder_id!"
+    ad_script_abort
 }
 
 # Check permission
Index: openacs.org-dev/packages/attachments/www/file-add.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/attachments/www/file-add.adp,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/attachments/www/file-add.adp	9 Jul 2002 17:35:01 -0000	1.1.1.1
+++ openacs.org-dev/packages/attachments/www/file-add.adp	25 Jul 2002 18:46:57 -0000	1.1.1.2
@@ -2,7 +2,7 @@
 <property name="title">Upload New Attachment</property>
 <property name="context_bar">@context_bar@</property>
 
-You are attaching a document to @pretty_object_name@.<p>
+You are attaching a <b>new</b> document to @pretty_object_name@.<p>
 
 <form enctype=multipart/form-data method=POST action="file-add-2">
 <input type=hidden name="folder_id" value="@folder_id@">
Index: openacs.org-dev/packages/attachments/www/simple-add.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/attachments/www/simple-add.adp,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/attachments/www/simple-add.adp	9 Jul 2002 17:35:01 -0000	1.1.1.1
+++ openacs.org-dev/packages/attachments/www/simple-add.adp	25 Jul 2002 18:46:58 -0000	1.1.1.2
@@ -2,7 +2,7 @@
 <property name="title">Attach URL</property>
 <property name="context_bar">@context_bar@</property>
 
-You are attaching a document to @pretty_object_name@.<p>
+You are attaching a <b>new url</b> to @pretty_object_name@.<p>
 
 <form method=POST action="simple-add-2">
 <input type=hidden name="folder_id" value="@folder_id@">
Index: openacs.org-dev/packages/bookmarks/sql/postgresql/bookmarks-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/bookmarks/sql/postgresql/bookmarks-create.sql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/bookmarks/sql/postgresql/bookmarks-create.sql	9 Jul 2002 17:35:01 -0000	1.1.1.1
+++ openacs.org-dev/packages/bookmarks/sql/postgresql/bookmarks-create.sql	25 Jul 2002 18:46:59 -0000	1.1.1.2
@@ -420,13 +420,13 @@
 BEGIN
 
  	FOR c_bookmark_id_tree IN 
-	    select bookmark_id,
+	    select bm.bookmark_id,
 	    (select case when count(*)=0 then 1 else 0 end from 
 	    bm_bookmarks where parent_id = bm.bookmark_id) as is_leaf_p
 	    from bm_bookmarks bm, bm_bookmarks bm2
             where bm2.bookmark_id = p_bookmark_id
 	      and bm.tree_sortkey between bm2.tree_sortkey and tree_right(bm2.tree_sortkey)
-            order by tree_level(tree_sortkey) desc, is_leaf_p desc, tree_sortkey
+            order by tree_level(bm.tree_sortkey) desc, is_leaf_p desc, bm.tree_sortkey
  	LOOP
 
             -- DRB: This query is insane in both its PG and Oracle versions but I do not
Index: openacs.org-dev/packages/bug-tracker/www/bug-add.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/bug-tracker/www/bug-add.adp,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/bug-tracker/www/bug-add.adp	9 Jul 2002 17:35:01 -0000	1.1.1.1
+++ openacs.org-dev/packages/bug-tracker/www/bug-add.adp	25 Jul 2002 18:46:59 -0000	1.1.1.2
@@ -1,7 +1,7 @@
 <master src="../lib/master">
 <property name="title">@page_title@</property>
 <property name="context_bar">@context_bar@</property>
-<property name="focus">bug.component</property>
+<property name="focus">bug.component_id</property>
 
 <formtemplate id="bug" style="standard-lars"></formtemplate>
 
Index: openacs.org-dev/packages/bug-tracker/www/bug-add.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/bug-tracker/www/bug-add.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/bug-tracker/www/bug-add.tcl	9 Jul 2002 17:35:01 -0000	1.1.1.1
+++ openacs.org-dev/packages/bug-tracker/www/bug-add.tcl	25 Jul 2002 18:46:59 -0000	1.1.1.2
@@ -12,7 +12,7 @@
 # If the user hit cancel, ignore everything else
 if { [exists_and_not_null cancel] } {
     ad_returnredirect $return_url
-    return
+    ad_script_abort
 }
 
 ad_require_permission [ad_conn package_id] create
@@ -153,7 +153,7 @@
     bt_bug_notify $bug_id "open" $description $desc_format
 
     ad_returnredirect $return_url
-    return
+    ad_script_abort
 }
 
 ad_return_template
Index: openacs.org-dev/packages/bug-tracker/www/bug.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/bug-tracker/www/bug.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/bug-tracker/www/bug.tcl	9 Jul 2002 17:35:01 -0000	1.1.1.1
+++ openacs.org-dev/packages/bug-tracker/www/bug.tcl	25 Jul 2002 18:46:59 -0000	1.1.1.2
@@ -19,7 +19,7 @@
 # If the user hit cancel, ignore everything else
 if { [exists_and_not_null cancel] } {
     ad_returnredirect $return_url
-    return
+    ad_script_abort
 }
 
 ad_require_permission [ad_conn package_id] read
@@ -433,7 +433,7 @@
     bt_bug_notify $bug_id $mode $description $desc_format
 
     ad_returnredirect $return_url
-    return
+    ad_script_abort
 }
 
 ad_return_template
Index: openacs.org-dev/packages/bug-tracker/www/prefs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/bug-tracker/www/prefs.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/bug-tracker/www/prefs.tcl	9 Jul 2002 17:35:01 -0000	1.1.1.1
+++ openacs.org-dev/packages/bug-tracker/www/prefs.tcl	25 Jul 2002 18:47:00 -0000	1.1.1.2
@@ -13,7 +13,7 @@
 # If the user hit cancel, ignore everything else
 if { [exists_and_not_null cancel] } {
     ad_returnredirect $return_url
-    return
+    ad_script_abort
 }
 
 # User needs to be logged in here
Index: openacs.org-dev/packages/bug-tracker/www/admin/component-ae.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/bug-tracker/www/admin/component-ae.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/bug-tracker/www/admin/component-ae.tcl	9 Jul 2002 17:35:01 -0000	1.1.1.1
+++ openacs.org-dev/packages/bug-tracker/www/admin/component-ae.tcl	25 Jul 2002 18:47:00 -0000	1.1.1.2
@@ -13,7 +13,7 @@
 
 if { [exists_and_not_null cancel] } {
     ad_returnredirect $return_url
-    return
+    ad_script_abort
 }
 
 set project_name [bt_conn project_name]
@@ -91,7 +91,7 @@
     }
 
     ad_returnredirect $return_url
-    return
+    ad_script_abort
 }
 
 ad_return_template
\ No newline at end of file
Index: openacs.org-dev/packages/bug-tracker/www/admin/project-edit.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/bug-tracker/www/admin/project-edit.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/bug-tracker/www/admin/project-edit.tcl	9 Jul 2002 17:35:01 -0000	1.1.1.1
+++ openacs.org-dev/packages/bug-tracker/www/admin/project-edit.tcl	25 Jul 2002 18:47:00 -0000	1.1.1.2
@@ -13,7 +13,7 @@
 
 if { [exists_and_not_null cancel] } {
     ad_returnredirect $return_url
-    return
+    ad_script_abort
 }
 
 set project_name [bt_conn project_name]
@@ -59,7 +59,7 @@
     }
     
     ad_returnredirect $return_url
-    return
+    ad_script_abort
 }
 
 ad_return_template
Index: openacs.org-dev/packages/bug-tracker/www/admin/project-maintainer-edit.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/bug-tracker/www/admin/project-maintainer-edit.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/bug-tracker/www/admin/project-maintainer-edit.tcl	9 Jul 2002 17:35:01 -0000	1.1.1.1
+++ openacs.org-dev/packages/bug-tracker/www/admin/project-maintainer-edit.tcl	25 Jul 2002 18:47:00 -0000	1.1.1.2
@@ -12,7 +12,7 @@
 
 if { [exists_and_not_null cancel] } {
     ad_returnredirect $return_url
-    return
+    ad_script_abort
 }
 
 set project_name [bt_conn project_name]
@@ -23,35 +23,31 @@
 
 set context_bar [ad_context_bar $page_title]
 
-template::form create project_maintainer
+form create project_maintainer
 
-template::element create project_maintainer return_url -datatype text -widget hidden -value $return_url
+element create project_maintainer return_url -datatype text -widget hidden -value $return_url
 
-template::element create project_maintainer maintainer \
+element create project_maintainer maintainer \
         -datatype integer \
         -widget select \
         -label "Project Maintainer" \
+        -options [concat {{ "--None--" "" }} [db_list_of_lists users { select first_names || ' ' || last_name, user_id from cc_users }]] \
         -optional
 
-if { ![template::form is_valid project_maintainer] } {
-    template::element set_properties project_maintainer maintainer \
-            -options [concat {{ "--None--" "" }} [db_list_of_lists users { select first_names || ' ' || last_name, user_id from cc_users }]] 
-}
-
-if { [template::form is_request project_maintainer] } {
-    template::element set_properties project_maintainer maintainer \
+if { [form is_request project_maintainer] } {
+    element set_properties project_maintainer maintainer \
             -value [db_string maintainer { select maintainer from bt_projects where project_id = :package_id }]
 }
 
-if { [template::form is_valid project_maintainer] } {
+if { [form is_valid project_maintainer] } {
     db_dml project_maintainer_update {
         update bt_projects
         set    maintainer = :maintainer
         where  project_id = :package_id
     }
 
     ad_returnredirect $return_url
-    return
+    ad_script_abort
 }
 
 ad_return_template
\ No newline at end of file
Index: openacs.org-dev/packages/bug-tracker/www/admin/version-ae.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/bug-tracker/www/admin/version-ae.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/bug-tracker/www/admin/version-ae.tcl	9 Jul 2002 17:35:01 -0000	1.1.1.1
+++ openacs.org-dev/packages/bug-tracker/www/admin/version-ae.tcl	25 Jul 2002 18:47:00 -0000	1.1.1.2
@@ -11,7 +11,7 @@
 
 if { [exists_and_not_null cancel] } {
     ad_returnredirect $return_url
-    return
+    ad_script_abort
 }
 
 set project_name [bt_conn project_name]
@@ -119,6 +119,6 @@
     }
 
     ad_returnredirect $return_url
-    return
+    ad_script_abort
 }
 
Index: openacs.org-dev/packages/bulk-mail/www/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/bulk-mail/www/index.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/bulk-mail/www/index.tcl	9 Jul 2002 17:35:01 -0000	1.1.1.1
+++ openacs.org-dev/packages/bulk-mail/www/index.tcl	25 Jul 2002 18:47:00 -0000	1.1.1.2
@@ -22,7 +22,7 @@
 set table_def {
     {send_date {Send Date} {bulk_mail_messages.send_date $order} {<td width="10%">[util_AnsiDatetoPrettyDate $send_date]</td>}}
     {from_addr From {bulk_mail_messages.from_addr $order} {<td width="15%">$from_addr</td>}}
-    {subject Subject {bulk_mail_messages.subject $order} {<td><a href="[site_node::get_url_from_object_id -object_id $package_id]one?bulk_mail_id=$bulk_mail_id">$subject</a></td>}}
+    {subject Subject {bulk_mail_messages.subject $order} {<td><a href="[lindex [site_node::get_url_from_object_id -object_id $package_id] 0]one?bulk_mail_id=$bulk_mail_id">$subject</a></td>}}
     {sent_p {Sent?} {bulk_mail_messages.sent_p $order} {<td width="10%" align="center">[ad_decode $sent_p t Yes No]</td>}}
 }
 
Index: openacs.org-dev/packages/calendar/calendar.info
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/calendar/calendar.info,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/calendar/calendar.info	9 Jul 2002 17:35:01 -0000	1.1.1.1
+++ openacs.org-dev/packages/calendar/calendar.info	25 Jul 2002 18:47:00 -0000	1.1.1.2
@@ -38,7 +38,9 @@
             <file type="data_model_create" db_type="postgresql" path="sql/postgresql/calendar-create.sql"/>
             <file type="data_model_drop" db_type="postgresql" path="sql/postgresql/calendar-drop.sql"/>
             <file type="query_file" db_type="oracle" path="tcl/cal-item-2-procs-oracle.xql"/>
+            <file type="query_file" db_type="postgresql" path="tcl/cal-item-2-procs-postgresql.xql"/>
             <file type="tcl_procs" path="tcl/cal-item-2-procs.tcl"/>
+            <file type="query_file" path="tcl/cal-item-2-procs.xql"/>
             <file type="query_file" db_type="oracle" path="tcl/cal-item-procs-oracle.xql"/>
             <file type="query_file" db_type="postgresql" path="tcl/cal-item-procs-postgresql.xql"/>
             <file type="tcl_procs" path="tcl/cal-item-procs.tcl"/>
@@ -96,6 +98,7 @@
             <file type="query_file" db_type="postgresql" path="www/cal-item-delete-confirm-postgresql.xql"/>
             <file type="content_page" path="www/cal-item-delete-confirm.adp"/>
             <file type="content_page" path="www/cal-item-delete-confirm.tcl"/>
+            <file type="content_page" path="www/cal-item-delete.tcl"/>
             <file type="content_page" path="www/cal-item-edit.adp"/>
             <file type="content_page" path="www/cal-item-edit.tcl"/>
             <file type="content_page" path="www/cal-item-new.adp"/>
@@ -133,6 +136,7 @@
             <file type="documentation" path="www/doc/regressionTest.htm"/>
             <file type="documentation" path="www/doc/requirements.html"/>
             <file type="documentation" path="www/doc/thesisUsabilityTest.htm"/>
+            <file type="content_page" path="www/ics/index.vuh"/>
             <file type="content_page" path="www/index.adp"/>
             <file type="content_page" path="www/index.tcl"/>
             <file type="content_page" path="www/item-type-delete.tcl"/>
Index: openacs.org-dev/packages/calendar/sql/postgresql/cal-item-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/calendar/sql/postgresql/cal-item-create.sql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/calendar/sql/postgresql/cal-item-create.sql	9 Jul 2002 17:35:01 -0000	1.1.1.1
+++ openacs.org-dev/packages/calendar/sql/postgresql/cal-item-create.sql	25 Jul 2002 18:47:00 -0000	1.1.1.2
@@ -194,12 +194,13 @@
 RETURNS integer AS '
 declare
     delete__recurrence_id		alias for $1;
-    v_event_id                          integer;
+    v_event                             RECORD;
 begin
-    for v_event_id in (select event_id from acs_events
-                      where recurrence_id= delete__recurrence_id)
+    for v_event in 
+	select event_id from acs_events
+        where recurrence_id= delete__recurrence_id
     LOOP
-        PERFORM cal_item__delete(v_event_id);
+        PERFORM cal_item__delete(v_event.event_id);
     END LOOP;
 
     PERFORM recurrence__delete(delete__recurrence_id);
Index: openacs.org-dev/packages/calendar/tcl/cal-item-2-procs-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/calendar/tcl/cal-item-2-procs-oracle.xql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/calendar/tcl/cal-item-2-procs-oracle.xql	9 Jul 2002 17:35:02 -0000	1.1.1.1
+++ openacs.org-dev/packages/calendar/tcl/cal-item-2-procs-oracle.xql	25 Jul 2002 18:47:00 -0000	1.1.1.2
@@ -10,9 +10,15 @@
             cal_items.cal_item_id,
             0 as n_attachments,
             to_char(start_date,'HH:MIpm')as start_time,
+            to_char(start_date,'D') as day_of_week,
+            to_char(start_date,'Day') as pretty_day_of_week,
+            to_char(start_date,'DD') as day_of_month,
             start_date as start_date,
             to_char(start_date, 'MM/DD/YYYY') as pretty_short_start_date,
             to_char(end_date, 'HH:MIpm') as end_time,
+            end_date as end_date,
+            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,
             nvl(e.name, a.name) as name,
             nvl(e.description, a.description) as description,
             recurrence_id,
@@ -41,9 +47,15 @@
             cal_items.cal_item_id,
             (select count(*) from attachments where object_id = cal_item_id) as n_attachments,
             to_char(start_date,'HH:MIpm')as start_time,
+            to_char(start_date,'D') as day_of_week,
+            to_char(start_date,'Day') as pretty_day_of_week,
+            to_char(start_date,'DD') as day_of_month,
             start_date as start_date,
             to_char(start_date, 'MM/DD/YYYY') as pretty_short_start_date,
             to_char(end_date, 'HH:MIpm') as end_time,
+            end_date as end_date,
+            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,
             nvl(e.name, a.name) as name,
             nvl(e.description, a.description) as description,
             recurrence_id,
@@ -65,4 +77,23 @@
 </querytext>
 </fullquery>
 
+<fullquery name="calendar::item::add_recurrence.create_recurrence">
+<querytext>
+begin
+   :1 := recurrence.new(interval_type => :interval_type,
+    	every_nth_interval => :every_n,
+    	days_of_week => :days_of_week,
+    	recur_until => :recur_until);
+end;
+</querytext>
+</fullquery>
+
+<fullquery name="calendar::item::add_recurrence.insert_instances">
+<querytext>
+begin
+   acs_event.insert_instances(event_id => :cal_item_id);
+end;
+</querytext>
+</fullquery>
+
 </queryset>
Index: openacs.org-dev/packages/calendar/tcl/cal-item-2-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/calendar/tcl/cal-item-2-procs-postgresql.xql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/calendar/tcl/cal-item-2-procs-postgresql.xql	9 Jul 2002 17:35:02 -0000	1.1.1.1
+++ openacs.org-dev/packages/calendar/tcl/cal-item-2-procs-postgresql.xql	25 Jul 2002 18:47:00 -0000	1.1.1.2
@@ -9,6 +9,9 @@
          i.cal_item_id,
          0 as n_attachments,
          to_char(start_date,'HH:MIpm') as start_time,
+	 to_char(start_date,'D') as day_of_week,
+         to_char(start_date,'Day') as pretty_day_of_week,
+         to_char(start_date,'DD') as day_of_month,
          to_char(start_date, 'YYYY-MM-DD HH:MI:SS') as start_date,
          to_char(start_date, 'MM/DD/YYYY') as pretty_short_start_date,
          to_char(end_date, 'HH:MIpm') as end_time,
@@ -40,6 +43,9 @@
          i.cal_item_id,
          (select count(*) from attachments where object_id = cal_item_id) as n_attachments,
          to_char(start_date,'HH:MIpm') as start_time,
+	 to_char(start_date,'D') as day_of_week,
+         to_char(start_date,'Day') as pretty_day_of_week,
+         to_char(start_date,'DD') as day_of_month,
          to_char(start_date, 'YYYY-MM-DD HH:MI:SS') as start_date,
          to_char(start_date, 'MM/DD/YYYY') as pretty_short_start_date,
          to_char(end_date, 'HH:MIpm') as end_time,
@@ -65,4 +71,20 @@
      </querytext>
    </fullquery>
 
+<fullquery name="calendar::item::add_recurrence.create_recurrence">
+<querytext>
+select recurrence__new(:interval_type,
+    	:every_n,
+    	:days_of_week,
+    	:recur_until,
+	NULL)
+</querytext>
+</fullquery>
+
+<fullquery name="calendar::item::add_recurrence.insert_instances">
+<querytext>
+select acs_event__insert_instances(:cal_item_id, NULL);
+</querytext>
+</fullquery>
+
 </queryset>
Index: openacs.org-dev/packages/calendar/tcl/cal-item-2-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/calendar/tcl/cal-item-2-procs.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/calendar/tcl/cal-item-2-procs.tcl	9 Jul 2002 17:35:02 -0000	1.1.1.1
+++ openacs.org-dev/packages/calendar/tcl/cal-item-2-procs.tcl	25 Jul 2002 18:47:00 -0000	1.1.1.2
@@ -38,6 +38,32 @@
         db_1row $query_name {} -column_array row
     }
         
+    ad_proc -public add_recurrence {
+	{-cal_item_id:required}
+	{-interval_type:required}
+	{-every_n:required}
+	{-days_of_week ""}
+	{-recur_until ""}
+    } {
+	Adds a recurrence for a calendar item
+    } {
+	# We do things in a transaction
+	db_transaction {
+	    # Create the recurrence
+	    set recurrence_id [db_exec_plsql create_recurrence {}]
+	    
+	    # Update the events table
+	    db_dml update_event {}
+	    
+	    # Insert instances
+	    db_exec_plsql insert_instances {}
+	    
+	    # Make sure they're all in the calendar!
+	    db_dml insert_cal_items {}
+	}
+    }
+    
+
     ad_proc -public edit {
         {-cal_item_id:required}
         {-start_date:required}
Index: openacs.org-dev/packages/calendar/tcl/calendar-2-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/calendar/tcl/calendar-2-procs.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/calendar/tcl/calendar-2-procs.tcl	9 Jul 2002 17:35:02 -0000	1.1.1.1
+++ openacs.org-dev/packages/calendar/tcl/calendar-2-procs.tcl	25 Jul 2002 18:47:00 -0000	1.1.1.2
@@ -185,9 +185,9 @@
     }
 
     ad_proc -public attachments_enabled_p {} {
-        check if attachments enabled
-    } {
-        return [apm_package_registered_p attachments]        
+        set package_id [site_node_apm_integration::child_package_exists_p \
+            -package_key attachments
+        ]
     }
 
 }
Index: openacs.org-dev/packages/calendar/tcl/calendar-display-procs-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/calendar/tcl/calendar-display-procs-oracle.xql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/calendar/tcl/calendar-display-procs-oracle.xql	9 Jul 2002 17:35:02 -0000	1.1.1.1
+++ openacs.org-dev/packages/calendar/tcl/calendar-display-procs-oracle.xql	25 Jul 2002 18:47:00 -0000	1.1.1.2
@@ -12,7 +12,11 @@
 	         nvl(e.name, a.name) as name,
 	         nvl(e.description, a.description) as description,
                  nvl(e.status_summary, a.status_summary) as status_summary,
-	         e.event_id as item_id
+	         e.event_id as item_id,
+		 (select on_which_calendar from cal_items where cal_item_id = e.event_id) as calendar_id,
+		 (select calendar_name from calendars 
+		 where calendar_id = (select on_which_calendar from cal_items where cal_item_id= e.event_id))
+		 as calendar_name
 	from     acs_activities a,
 	         acs_events e,
 	         timespans s,
@@ -24,7 +28,7 @@
 	in       (
 	         select  cal_item_id
 	         from    cal_items
-	         where   on_which_calendar = :calendar_id
+	         where   on_which_calendar in ([join $calendar_id_list ","])
          )
          order by start_date,end_date
 	
@@ -55,7 +59,11 @@
          nvl(e.name, a.name) as name,
          nvl(e.status_summary, a.status_summary) as status_summary,
          e.event_id as item_id,
-         (select type from cal_item_types where item_type_id= cal_items.item_type_id) as item_type
+         (select type from cal_item_types where item_type_id= cal_items.item_type_id) as item_type,
+	 on_which_calendar as calendar_id,
+	 (select calendar_name from calendars 
+	 where calendar_id = on_which_calendar)
+	 as calendar_name
 from     acs_activities a,
          acs_events e,
          timespans s,
@@ -72,7 +80,7 @@
 in       (
          select  cal_item_id
          from    cal_items
-         where   on_which_calendar = :calendar_id
+         where   on_which_calendar in ([join $calendar_id_list ","])
          )
 order by start_date
 </querytext>
@@ -88,7 +96,11 @@
          nvl(e.name, a.name) as name,
          nvl(e.status_summary, a.status_summary) as status_summary,
          e.event_id as item_id,
-         (select type from cal_item_types where item_type_id= cal_items.item_type_id) as item_type
+         (select type from cal_item_types where item_type_id= cal_items.item_type_id) as item_type,
+	 on_which_calendar as calendar_id,
+	 (select calendar_name from calendars 
+	 where calendar_id = on_which_calendar)
+	 as calendar_name
 from     acs_activities a,
          acs_events e,
          timespans s,
@@ -105,7 +117,7 @@
 in       (
          select  cal_item_id
          from    cal_items
-         where   on_which_calendar = :calendar_id
+         where   on_which_calendar in ([join $calendar_id_list ","])
          )
 	
 </querytext>
Index: openacs.org-dev/packages/calendar/tcl/calendar-display-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/calendar/tcl/calendar-display-procs-postgresql.xql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/calendar/tcl/calendar-display-procs-postgresql.xql	9 Jul 2002 17:35:02 -0000	1.1.1.1
+++ openacs.org-dev/packages/calendar/tcl/calendar-display-procs-postgresql.xql	25 Jul 2002 18:47:00 -0000	1.1.1.2
@@ -12,7 +12,11 @@
 	         coalesce(e.name, a.name) as name,
 	         coalesce(e.description, a.description) as description,
                  coalesce(e.status_summary, a.status_summary) as status_summary,
-	         e.event_id as item_id
+	         e.event_id as item_id,
+		 (select on_which_calendar from cal_items where cal_item_id = e.event_id) as calendar_id,
+		 (select calendar_name from calendars 
+		 where calendar_id = (select on_which_calendar from cal_items where cal_item_id= e.event_id))
+		 as calendar_name
 	from     acs_activities a,
 	         acs_events e,
 	         timespans s,
@@ -24,7 +28,7 @@
 	in       (
 	         select  cal_item_id
 	         from    cal_items
-	         where   on_which_calendar = :calendar_id
+	         where   on_which_calendar in ([join $calendar_id_list ","])
          )
          order by start_date,end_date	
       </querytext>
@@ -35,9 +39,9 @@
 <querytext>
         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'::timespan, 'Sunday'), 'D')
+        to_char(next_day(to_date(:current_date, 'yyyy-mm-dd')- '1 week'::timespan, 'Sunday'), 'YYYY-MM-DD')
         as       sunday_of_the_week,
-        to_char(next_day(to_date(:current_date, 'yyyy-mm-dd'), 'Saturday'), 'D')
+        to_char(next_day(to_date(:current_date, 'yyyy-mm-dd'), 'Saturday'), 'YYYY-MM-DD')
         as       saturday_of_the_week
         from     dual
 </querytext>
@@ -46,15 +50,19 @@
 
 <fullquery name="calendar::one_week_display.select_week_items">
 <querytext>
-select   to_char(start_date, 'J') as start_date,
+select   to_char(start_date, 'J') as start_date_julian,
          to_char(start_date, 'HH:MIpm') as pretty_start_date,
          to_char(end_date, 'HH:MIpm') as pretty_end_date,
          to_char(start_date,'HH24:MI') as start_date,
          to_char(end_date,'HH24:MI') as 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,
-         (select type from cal_item_types where item_type_id= cal_items.item_type_id) as item_type
+         (select type from cal_item_types where item_type_id= cal_items.item_type_id) as item_type,
+	 (select on_which_calendar from cal_items where cal_item_id = e.event_id) as calendar_id,
+	 (select calendar_name from calendars 
+	 where calendar_id = (select on_which_calendar from cal_items where cal_item_id= e.event_id))
+	 as calendar_name
 from     acs_activities a,
          acs_events e,
          timespans s,
@@ -71,7 +79,7 @@
 in       (
          select  cal_item_id
          from    cal_items
-         where   on_which_calendar = :calendar_id
+         where   on_which_calendar in ([join $calendar_id_list ","])
          )
 </querytext>
 </fullquery>
@@ -86,7 +94,11 @@
          coalesce(e.name, a.name) as name,
          coalesce(e.status_summary, a.status_summary) as status_summary,
          e.event_id as item_id,
-         (select type from cal_item_types where item_type_id= cal_items.item_type_id) as item_type
+         (select type from cal_item_types where item_type_id= cal_items.item_type_id) as item_type,
+	 on_which_calendar as calendar_id,
+	 (select calendar_name from calendars 
+	 where calendar_id = on_which_calendar)
+	 as calendar_name
 from     acs_activities a,
          acs_events e,
          timespans s,
@@ -103,7 +115,7 @@
 in       (
          select  cal_item_id
          from    cal_items
-         where   on_which_calendar = :calendar_id
+         where   on_which_calendar in ([join $calendar_id_list ","])
          )
 	
 </querytext>
Index: openacs.org-dev/packages/calendar/tcl/calendar-display-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/calendar/tcl/calendar-display-procs.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/calendar/tcl/calendar-display-procs.tcl	9 Jul 2002 17:35:02 -0000	1.1.1.1
+++ openacs.org-dev/packages/calendar/tcl/calendar-display-procs.tcl	25 Jul 2002 18:47:00 -0000	1.1.1.2
@@ -44,41 +44,49 @@
         
         set items [ns_set create]
         
-        # Loop through calendars
-        foreach calendar_id $calendar_id_list {
-            set calendar_name [calendar_get_name $calendar_id]
+	
+	db_foreach select_monthly_items {} {
+	    # Calendar name now set in query
+	    # set calendar_name [calendar_get_name $calendar_id]
+	    
+	    # reset url stub
+	    set url_stub ""
 
-            # In case we need to dispatch to a different URL (ben)
-            if {![empty_string_p $url_stub_callback]} {
-                set url_stub [$url_stub_callback $calendar_id]
-            }
+	    # In case we need to dispatch to a different URL (ben)
+	    if {![empty_string_p $url_stub_callback]} {
+		# Cache the stuff
+		if {![info exists url_stubs($calendar_id)]} {
+		    set url_stubs($calendar_id) [$url_stub_callback $calendar_id]
+		}
 
-            db_foreach select_monthly_items {} {
-                set item "$name"
-                set item "[subst $item_template]"
+		set url_stub $url_stubs($calendar_id)
+	    }
+	    
+	    set item "$name"
+	    set item "[subst $item_template]"
+	    
+	    if {![dt_no_time_p -start_time $start_time -end_time $end_time]} {
+		set item "<font size=-2><b>$start_time</b></font> $item"
+	    }
+	    
+	    if {$show_calendar_name_p} {
+		append item " <font size=-2>($calendar_name)</font>"
+	    }
+	    
+	    # DRB: This ugly hack was added for dotlrn-events, to give us a way to
+	    # flag event status in red in accordance with the spec.  When calendar
+	    # is rewritten we should come up with a way for objects derived from
+	    # acs-events to render their own name summary and full descriptions.
+	    
+	    if { [string length $status_summary] > 0 } {
+		append item " <font color=\"red\">$status_summary</font> "
+	    }
+	    
+	    append item "<br>"
+	    
+	    ns_set put $items $start_date $item
+	}            
 
-                if {![dt_no_time_p -start_time $start_time -end_time $end_time]} {
-                    set item "<font size=-2><b>$start_time</b></font> $item"
-                }
-                
-                if {$show_calendar_name_p} {
-                    append item " <font size=-2>($calendar_name)</font>"
-                }
-
-                # DRB: This ugly hack was added for dotlrn-events, to give us a way to
-                # flag event status in red in accordance with the spec.  When calendar
-                # is rewritten we should come up with a way for objects derived from
-                # acs-events to render their own name summary and full descriptions.
-
-                if { [string length $status_summary] > 0 } {
-                    append item " <font color=\"red\">$status_summary</font> "
-                }
-
-                append item "<br>"
-
-                ns_set put $items $start_date $item
-            }            
-        }
         
         # Display stuff
         if {[empty_string_p $item_add_template]} {
@@ -140,39 +148,43 @@
         db_1row select_weekday_info {}
 
         # Loop through the calendars
-        foreach calendar_id $calendar_id_list {
-            set calendar_name [calendar_get_name $calendar_id]
+	db_foreach select_week_items {} {
+	    ns_log Notice "ONE WEEK ITEM"
 
-            # In case we need to dispatch to a different URL (ben)
-            if {![empty_string_p $url_stub_callback]} {
-                set url_stub [$url_stub_callback $calendar_id]
-            }
+	    # now selected from the query
+	    # set calendar_name [calendar_get_name $calendar_id]
+	    
+	    # In case we need to dispatch to a different URL (ben)
+	    if {![empty_string_p $url_stub_callback]} {
+		# Cache the stuff
+		if {![info exists url_stubs($calendar_id)]} {
+		    set url_stubs($calendar_id) [$url_stub_callback $calendar_id]
+		}
 
-            db_foreach select_week_items {} {
-                set item "$name"
-                set item_details "[subst $item_template]"
-                
-                # Add time details
-                if {[dt_no_time_p -start_time $start_date -end_time $end_date]} {
-                    set time_details ""
-                } else {
-                    set time_details "<b>$pretty_start_date - $pretty_end_date</b>:"
-                }
-
-                set item "$time_details $item_details"
-
-                if {$show_calendar_name_p} {
-                    append item "<font size=-1>($calendar_name)</font><br>"
-                }
-
-                if { [string length $status_summary] > 0 } {
-                    append item " <font color=\"red\">$status_summary</font> "
-                }
-                # ns_log Notice "CALENDAR-WEEK: one item $item"
-
-                ns_set put $items $start_date_julian $item
-            }
-
+		set url_stub $url_stubs($calendar_id)
+	    }
+	    
+	    set item "$name"
+	    set item_details "[subst $item_template]"
+	    
+	    # Add time details
+	    if {[dt_no_time_p -start_time $start_date -end_time $end_date]} {
+		set time_details ""
+	    } else {
+		set time_details "<b>$pretty_start_date - $pretty_end_date</b>:"
+	    }
+	    
+	    set item "$time_details $item_details"
+	    
+	    if {$show_calendar_name_p} {
+		append item "<font size=-1>($calendar_name)</font><br>"
+	    }
+	    
+	    if { [string length $status_summary] > 0 } {
+		append item " <font color=\"red\">$status_summary</font> "
+	    }
+	    
+	    ns_set put $items $start_date_julian $item
         }
 
         # display stuff
@@ -226,57 +238,59 @@
         set items [ns_set create]
 
         # Loop through the calendars
-        foreach calendar_id $calendar_id_list {
-            set calendar_name [calendar_get_name $calendar_id]
-            # ns_log Notice "bma: one calendar $calendar_name"
+	db_foreach select_day_items {} {
+	    # Not needed anymore
+            # set calendar_name [calendar_get_name $calendar_id]
 
             # In case we need to dispatch to a different URL (ben)
             if {![empty_string_p $url_stub_callback]} {
-                set url_stub [$url_stub_callback $calendar_id]
-            }
+		# Cache the stuff
+		if {![info exists url_stubs($calendar_id)]} {
+		    set url_stubs($calendar_id) [$url_stub_callback $calendar_id]
+		}
 
-            db_foreach select_day_items {} {
-                set item_details ""
-
-                if {$show_calendar_name_p} {
-                    append item_details $calendar_name
-                }
-
-                if {![empty_string_p $item_type]} {
-                    if {![empty_string_p $item_details]} {
-                        append item_details " - "
-                    }
-
-                    append item_details "$item_type"
-                }
-
-                set item $name
-                set item_subst [subst $item_template]
-
-                if {[dt_no_time_p -start_time $pretty_start_date -end_time $pretty_end_date]} {
-                    # Hack for no-time items
-                    set item "$item_subst"
-                    if {![empty_string_p $item_details]} {
-                        append item " <font size=-1>($item_details)</font>"
-                    }
-
-                    set ns_set_pos "X"
-                } else {
-                    set item "<b>$pretty_start_date - $pretty_end_date</b>: $item_subst"
-                    if {![empty_string_p $item_details]} {
-                        append item " <font size=-1>($item_details)</font>"
-                    }
-                    set ns_set_pos $start_hour
-                }
-
-                if { [string length $status_summary] > 0 } {
-                    append item " <font color=\"red\">$status_summary</font> "
-                }
-
-                # ns_log Notice "bma-calendar: adding $item at $start_hour"
-                ns_set put $items $ns_set_pos [list $start_date $end_date $item]
+		set url_stub $url_stubs($calendar_id)
             }
+	    
+	    set item_details ""
 
+	    if {$show_calendar_name_p} {
+		append item_details $calendar_name
+	    }
+	    
+	    if {![empty_string_p $item_type]} {
+		if {![empty_string_p $item_details]} {
+		    append item_details " - "
+		}
+		
+		append item_details "$item_type"
+	    }
+	    
+	    set item $name
+	    set item_subst [subst $item_template]
+	    
+	    if {[dt_no_time_p -start_time $pretty_start_date -end_time $pretty_end_date]} {
+		# Hack for no-time items
+		set item "$item_subst"
+		if {![empty_string_p $item_details]} {
+		    append item " <font size=-1>($item_details)</font>"
+		}
+		
+		set ns_set_pos "X"
+	    } else {
+		set item "<b>$pretty_start_date - $pretty_end_date</b>: $item_subst"
+		if {![empty_string_p $item_details]} {
+		    append item " <font size=-1>($item_details)</font>"
+		}
+		set ns_set_pos $start_hour
+	    }
+	    
+	    if { [string length $status_summary] > 0 } {
+		append item " <font color=\"red\">$status_summary</font> "
+	    }
+	    
+	    # ns_log Notice "bma-calendar: adding $item at $start_hour"
+	    ns_set put $items $ns_set_pos [list $start_date $end_date $item]
         }
 
         set hour {$display_hour}
Index: openacs.org-dev/packages/calendar/tcl/calendar-outlook-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/calendar/tcl/calendar-outlook-procs.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/calendar/tcl/calendar-outlook-procs.tcl	9 Jul 2002 17:35:02 -0000	1.1.1.1
+++ openacs.org-dev/packages/calendar/tcl/calendar-outlook-procs.tcl	25 Jul 2002 18:47:00 -0000	1.1.1.2
@@ -22,6 +22,15 @@
 
 namespace eval calendar::outlook {
    
+    ad_proc -private adjust_timezone {
+        {-timestamp:required}
+        {-server_tz "US/Eastern"}
+        {-user_tz "US/Eastern"}
+        {-format "YYYY-MM-DD HH24:MI:SS"}
+    } {
+        return [db_string adjust_timezone {}]
+    }
+
     ad_proc ics_timestamp_format {
         {-timestamp:required}
     } {
@@ -52,7 +61,7 @@
 
     ad_proc -public format_item {
         {-cal_item_id:required}
-        {-all_occurences_p:boolean 0}
+        {-all_occurences_p 0}
         {-client_timezone 0}
     } {
         the cal_item_id is obvious.
@@ -63,253 +72,79 @@
     } {
         set date_format "YYYY-MM-DD HH24:MI:SS"
 
-        # Select the item information
-        db_1row select_calendar_item {}
-
+        calendar::item::get -cal_item_id $cal_item_id -array cal_item
         # If necessary, select recurrence information
 
+        # Convert some dates for timezone
+        set cal_item(full_start_date) [adjust_timezone -timestamp $cal_item(full_start_date) -format $date_format -user_tz "Universal"]
+        set cal_item(full_end_date) [adjust_timezone -timestamp $cal_item(full_end_date) -format $date_format -user_tz "Universal"]
+
         # Here we have some fields
         # start_time end_time title description
         
         # For now we don't do recurrence
 
-        set DTSTART [ics_timestamp_format -timestamp $start_date]
-        set DTEND [ics_timestamp_format -timestamp $end_date]
+        set DTSTART [ics_timestamp_format -timestamp $cal_item(full_start_date)]
+        set DTEND [ics_timestamp_format -timestamp $cal_item(full_end_date)]
 
         # Put it together
         set ics_event "BEGIN:VCALENDAR\r\nPRODID:-//OpenACS//OpenACS 4.5 MIMEDIR//EN\r\nVERSION:2.0\r\nMETHOD:PUBLISH\r\nBEGIN:VEVENT\r\nDTSTART:$DTSTART\r\nDTEND:$DTEND\r\n"
 
-        regexp {^([0-9]*)T} $DTSTART all creation_date
-        set DESCRIPTION $description
-        set title $name
+        # Recurrence stuff
+        if {![empty_string_p $cal_item(recurrence_id)] && $all_occurences_p} {
 
-        append ics_event "LOCATION:Not Listed\r\nTRANSP:OPAQUE\r\nSEQUENCE:0\r\nUID:$cal_item_id\r\nDTSTAMP:$creation_date\r\nDESCRIPTION:$DESCRIPTION\r\nSUMMARY:$title\r\nPRIORITY:5\r\nCLASS:PUBLIC\r\n"
-
-        append ics_event "END:VEVENT\r\nEND:VCALENDAR\r\n"
-
-        return $ics_event
-    }
-        
-
-    ad_proc cal_output_outlook_event {} "the proc to deliver outlook formatted calendar events, registered to .ics" {
-        # grab the event_id
-        ad_page_contract {
-            converts data to .ics format for msoutlook
-            
-            @param item_id
-            @param all_occurences_p
-            @parem client_timezone
-            @author Walter McGinnis (wtem@olywa.net), Don Baccus (dhogaza@pacifier.com)
-            @creation-date 2001-06-13
-            @cvs-id $Id$
-            
-        } {
-            item_id:integer
-            {all_occurences_p:boolean 0}
-            client_timezone
-        }
-
-        set logged_in_user_id [ad_verify_and_get_user_id]
-
-        # determine what the difference between the user's client timezone is
-        # and gmt
-        # then set up the math for oracle to do when selecting date_time
-        # a note on client_timezone:
-        # it is minutes difference from gmt
-        # either negative or positive
-        # east of gmt is negative
-        # positive values don't return a "+" before them, 
-        # so we only have to look for "-"
-        # the funny thing is that we want to substract positive values 
-        # and add positive ones
-
-        regexp -- {(-)*([0-9]+)} $client_timezone match dash digits 
-        
-        # there is an old Mac OS time_date issue
-        # where the time is offset up to 1440 
-        # rather than having a neg. value for timezones east of gmt
-        # if this is the case we reset the variables accordingly as a workaround
-
-        # i think this correct, but it may be the problem
-        if {$digits >= 720} {
-            set digits [expr 1440 - $digits] 
-            set dash "-"
-        }
-
-        set hours [expr $digits / 60]
-        
-        # this sets up the sql for creating gmt times for the event's date_times
-        
-        # grap applicable data and translate calendar data to outlook format
-        
-        ## THIS NEEDS TO CHANGE
-        db_1row cal_get_outlook_event "select
-        to_char(i.start_date [cal_outlook_gmt_sql $hours $dash], 'YYYYMMDD-HH24MISS') as dtstart,
-        to_char(i.end_date [cal_outlook_gmt_sql $hours $dash], 'YYYYMMDD-HH24MISS') as dtend,
-        to_char(i.start_date + 1 [cal_outlook_gmt_sql $hours $dash], 'YYYYMMDD') as dtstart_plus_one,
-        to_char(trunc(i.start_date) [cal_outlook_gmt_sql $hours $dash], 'YYYYMMDD-HH24MISS') as dtstart_midnight,
-        to_char(trunc(i.start_date) + 1 [cal_outlook_gmt_sql $hours $dash], 'YYYYMMDD-HH24MISS') as dtstart_plus_one_midnight,
-        nvl(to_char(ii.creation_date [cal_outlook_gmt_sql $hours $dash], 'YYYYMMDD'), to_char(i.creation_date, 'YYYYMMDD')) as creation_date,
-        nvl(i.title, ii.title) as title,
-        nvl(i.related_link_url, ii.related_link_url) as related_link_url,
-        i.description as child_description,
-        ii.description as parent_description,
-        ii.html_p as parent_html_p, 
-        i.html_p as child_html_p,
-        ii.interval_type, ii.every_nth_interval, ii.days_of_week,
-        to_char(ii.repeat_until [cal_outlook_gmt_sql $hours $dash], 'YYYYMMDD') as repeat_until
-        from cal_items i, cal_items ii
-        where i.item_id = :item_id
-        and i.parent_id = ii.item_id(+)
-        "
-        
-        # resolve parent and child description, html_p
-        if {[string equal $parent_html_p "t"] && ![empty_string_p $parent_description]} {
-            set parent_description [ad_html_to_text $parent_description]
-        }
-
-        if {[string equal $child_html_p "t"] && ![empty_string_p $child_description]} {
-            set child_description [ad_html_to_text $child_description]
-        } 
-
-        # make sure that whitespace isn't being mistaken as a non-empty-string
-        set parent_description [string trim $parent_description]
-        set child_description [string trim $child_description]
-
-        set description ""
-        if {![empty_string_p $parent_description] && ![string equal $parent_description $child_description] && ![empty_string_p $child_description]} {
-            # both are set, just combine them
-            set description "$parent_description
-            $child_description" 
-        } elseif {![empty_string_p $parent_description] && [empty_string_p $child_description]} {
-            set description $parent_description
-        } else {
-            set description $child_description
-        }
-
-        if ![empty_string_p [string trim $related_link_url]] {
-            set DESCRIPTION "$description
-            $related_link_url"
-        } else {
-            set DESCRIPTION $description
-        }
-
-        # format date_times
-
-        if { [empty_string_p $dtend] } {
-
-            #DRB: If it's a recurring event we need to kludge around the fact
-            #that we're not generating full timezone information by passing the
-            #a DATETIME to Outlook for "no time specified" events.  OpenACS 4
-            #should fix this, read RFC2445 for information.  With proper timezone
-            #information, the DATE form should be used.  This current hack, done
-            #for Sloan, only works for folks who are in the same timezone as the
-            #server.
-
-            if { $all_occurences_p && ![empty_string_p $interval_type] } {
-                set DTSTART ":[cal_ics_date_time_format $dtstart_midnight]"
-                set DTEND ":[cal_ics_date_time_format $dtstart_plus_one_midnight]"
-            } else {
-                set DTSTART ";VALUE=DATE:[string range $dtstart 0 7]"
-                set DTEND ";VALUE=DATE:[string range $dtstart_plus_one 0 7]"
-            }
-        } else {
-            set DTSTART ":[cal_ics_date_time_format $dtstart]"
-            set DTEND ":[cal_ics_date_time_format $dtend]"
-        }
-        
-        # making the CLASS=Public for now, but perhaps it should default to private
-        # this is ugly, but it might help get this working
-
-        # DRB: removed the ORGANIZER:MAILTO: line as Outlook would complain when
-        # importing a file containing the line if it weren't already open.  When open
-        # Outlook would import the file just fine - presumably there are two separate
-        # paths within Outlook to handle the two cases.
-
-        set ics_event "
-        BEGIN:VCALENDAR\r\nPRODID:-//ArsDigita//ACES 3.4 MIMEDIR//EN\r\nVERSION:2.0\r\nMETHOD:PUBLISH\r\nBEGIN:VEVENT\r\nDTSTART$DTSTART\r\n"
-
-        if { [info exists DTEND] } {
-            append ics_event "DTEND$DTEND\r\n"
-        }
-
-        if { $all_occurences_p && ![empty_string_p $interval_type] } {
-
             set recur_rule "RRULE:FREQ="
 
-            switch -glob $interval_type {
+            # Select recurrence info
+            set recurrence_id $cal_item(recurrence_id)
+            db_1row select_recurrence {} -column_array recurrence
+
+            switch -glob $recurrence(interval_name) {
                 day { append recur_rule "DAILY" }
                 week { append recur_rule "WEEKLY" }
                 *month* { append recur_rule "MONTHLY"}
                 year { append recur_rule "YEARLY"}
             }
 
-            if { $interval_type == "week" && ![empty_string_p $days_of_week] } {
-
+            if { $recurrence(interval_name) == "week" && ![empty_string_p $recurrence(days_of_week)] } {
+                
                 #DRB: Standard indicates ordinal week days are OK, but Outlook
                 #only takes two-letter abbreviation form.
 
                 append recur_rule ";BYDAY="
                 set week_list [list "SU" "MO" "TU" "WE" "TH" "FR" "SA" "SU"]
                 set sep ""
-                set day_list [split $days_of_week " "]
+                set day_list [split $recurrence(days_of_week) " "]
                 foreach day $day_list {
                     append recur_rule "$sep[lindex $week_list $day]"
                     set sep ","
                 }
             }
 
-            if { ![empty_string_p $every_nth_interval] } {
-                append recur_rule ";INTERVAL=$every_nth_interval"
+            if { ![empty_string_p $recurrence(every_nth_interval)] } {
+                append recur_rule ";INTERVAL=$recurrence(every_nth_interval)"
             }
 
-            if { ![empty_string_p $repeat_until] } {
+            if { ![empty_string_p $recurrence(recur_until)] } {
                 #DRB: this should work with a DATE: type but doesn't with Outlook at least.
-                append recur_rule ";UNTIL=$repeat_until"
+                append recur_rule ";UNTIL=$recurrence(recur_until)"
                 append recur_rule "T000000Z"
             }
 
             append ics_event "$recur_rule\r\n"
+
         }
 
-        append ics_event "LOCATION:Not Listed\r\nTRANSP:OPAQUE\r\nSEQUENCE:0\r\nUID:$item_id\r\nDTSTAMP:$creation_date\r\nDESCRIPTION:$DESCRIPTION\r\nSUMMARY:$title\r\nPRIORITY:5\r\nCLASS:PUBLIC\r\n"
+        ns_log Notice "DTSTART = $DTSTART"
+        regexp {^([0-9]*)T} $DTSTART all CREATION_DATE
+        set DESCRIPTION $cal_item(description)
+        set TITLE $cal_item(name)
 
-        db_foreach cal_item_db_row_map_fs_select "
-        select /*+ RULE */ c.on_what_id as file_id, 
-        fs.file_title as file_title,
-        fs.parent_id as parent_id,
-        fs2.file_title as parent_title,
-        fsvl.version_id as version_id,
-        fsvl.client_file_name,
-        fsvl.n_bytes,
-        fsvl.url,
-        lower(fsvl.file_type) as file_type
-        from cal_item_db_row_map c, fs_files fs, 
-        fs_versions_latest fsvl, fs_files fs2
-        where fs2.file_id(+) = fs.parent_id
-        and fs2.deleted_p = 'f'
-        and c.item_id=:item_id
-        and c.on_what_id=fs.file_id
-        and fs.file_id=fsvl.file_id
-        and c.on_which_table='FS_FILES'
-        and (ad_general_permissions.user_has_row_permission_p ( :logged_in_user_id, 'read', fsvl.version_id, 'FS_VERSIONS' ) = 't'
-        or fs.owner_id = :logged_in_user_id)
-        and fs.deleted_p='f'
-        " {
-            if { [empty_string_p $n_bytes] } {
-                append ics_event "ATTACH:$url\r\n"
-            } else {
-                regsub -all {[^-_.0-9a-zA-Z]+} $client_file_name "_" pretty_file_name
-                append ics_event "ATTACH:[ad_url]/file-storage/download/$version_id/$pretty_file_name\r\n"
-            }
-        }
+        append ics_event "LOCATION:Not Listed\r\nTRANSP:OPAQUE\r\nSEQUENCE:0\r\nUID:$cal_item_id\r\nDTSTAMP:$CREATION_DATE\r\nDESCRIPTION:$DESCRIPTION\r\nSUMMARY:$TITLE\r\nPRIORITY:5\r\nCLASS:PUBLIC\r\n"
 
-        #append ics_event "LOCATION:Not Listed\r\nTRANSP:OPAQUE\r\nSEQUENCE:0\r\nUID:040000008200E00074C5B7101A82E00800000000502D2C0B6B82C0010000000000000000100 00000C738CA6EDDB4DD46850DE477678FF368\r\nDTSTAMP:$creation_date\r\nDESCRIPTION:$DESCRIPTION\r\nSUMMARY:$title\r\nPRIORITY:5\r\nCLASS:PUBLIC\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"
         append ics_event "END:VEVENT\r\nEND:VCALENDAR\r\n"
-        ns_return 200 application/x-msoutlook $ics_event
-    }
 
-    # ad_register_proc GET /*.ics cal_output_outlook_event
-    # ad_register_proc POST /*.ics cal_output_outlook_event
-
+        return $ics_event
+    }
+        
 }
Index: openacs.org-dev/packages/calendar/tcl/calendar-outlook-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/calendar/tcl/calendar-outlook-procs.xql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/calendar/tcl/calendar-outlook-procs.xql	9 Jul 2002 17:35:02 -0000	1.1.1.1
+++ openacs.org-dev/packages/calendar/tcl/calendar-outlook-procs.xql	25 Jul 2002 18:47:00 -0000	1.1.1.2
@@ -1,21 +1,24 @@
 <?xml version="1.0"?>
 <queryset>
 
-<fullquery name="calendar::outlook::format_item.select_calendar_item">      
+<fullquery name="calendar::outlook::adjust_timezone.adjust_timezone">
 <querytext>
+select to_char(timezone.utc_to_local(tz_id, utc_time), :format)
+from timezones,
+(select timezone.local_to_utc(tz_id, to_date(:timestamp,:format)) as utc_time
+from timezones where tz= :server_tz)
+where tz= :user_tz
+</querytext>
+</fullquery>
+
+<fullquery name="calendar::outlook::format_item.select_recurrence">      
+<querytext>
 select 
-to_char(start_date, :date_format) as start_date,
-to_char(end_date, :date_format) as end_date,
-nvl(e.name,a.name) as name,
-nvl(e.description, a.description) as description,
-recurrence_id,
-item_type_id
-from acs_activities a, acs_events e, timespans s, time_intervals t, cal_items
-	where    e.timespan_id = s.timespan_id
-	and      s.interval_id = t.interval_id
-	and      e.activity_id = a.activity_id
-	and      e.event_id = :cal_item_id
-        and      cal_items.cal_item_id = :cal_item_id
+recurrence_id, recurrences.interval_type, interval_name,
+every_nth_interval, days_of_week, recur_until
+from recurrences, recurrence_interval_types
+where recurrence_id= :recurrence_id
+and recurrences.interval_type = recurrence_interval_types.interval_type
 </querytext>
 </fullquery>
 
Index: openacs.org-dev/packages/calendar/www/cal-item-create-recurrence-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/calendar/www/cal-item-create-recurrence-2.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/calendar/www/cal-item-create-recurrence-2.tcl	9 Jul 2002 17:35:02 -0000	1.1.1.1
+++ openacs.org-dev/packages/calendar/www/cal-item-create-recurrence-2.tcl	25 Jul 2002 18:47:00 -0000	1.1.1.2
@@ -21,6 +21,6 @@
 ad_require_permission $cal_item_id cal_item_write
 
 # Set up the recurrence
-calendar_item_add_recurrence -cal_item_id $cal_item_id -interval_type $interval_type -every_n $every_n -days_of_week $days_of_week -recur_until [calendar_make_datetime [array get recur_until]]
+calendar::item::add_recurrence -cal_item_id $cal_item_id -interval_type $interval_type -every_n $every_n -days_of_week $days_of_week -recur_until [calendar_make_datetime [array get recur_until]]
 
 ad_returnredirect $return_url
Index: openacs.org-dev/packages/calendar/www/cal-item-create-recurrence.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/calendar/www/cal-item-create-recurrence.adp,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/calendar/www/cal-item-create-recurrence.adp	9 Jul 2002 17:35:02 -0000	1.1.1.1
+++ openacs.org-dev/packages/calendar/www/cal-item-create-recurrence.adp	25 Jul 2002 18:47:00 -0000	1.1.1.2
@@ -7,28 +7,28 @@
 -->
 
 
-<master>
-<property name="title">Calendars: Recurrence</property>
-<property name="context_bar">Add Recurrence</property>
+<master src="master">
+<property name="title">Calendars: Repeating Event</property>
+<property name="context_bar">Repeat</property>
 
 You are choosing to make this event recurrent, so that it appears more
 than once in your calendar. The event's details are:
 <p>
-<b>Date:</b> @start_date@<br>
-<b>Time:</b> @start_time@ - @end_time@<br>
-<b>Details:</b> @description@
+<b>Date:</b> @cal_item.start_date@<br>
+<b>Time:</b> @cal_item.start_time@ - @cal_item.end_time@<br>
+<b>Details:</b> @cal_item.description@
 <p>
 
 <FORM method=post action=cal-item-create-recurrence-2>
-<INPUT TYPE=hidden name=cal_item_id value=@cal_item_id@>
+<INPUT TYPE=hidden name=cal_item_id value=@cal_item.cal_item_id@>
 <INPUT TYPE=hidden name=return_url value="@return_url@">
 
 Repeat every <INPUT TYPE=text name=every_n value=1 size=3>:<br>
 <INPUT TYPE=radio name=interval_type value=day> day (s)<br>
 <INPUT TYPE=radio name=interval_type value=week> 
 <%
 foreach dow {{Sunday 0} {Monday 1} {Tuesday 2} {Wednesday 3} {Thursday 4} {Friday 5} {Saturday 6}} {
-        if {[lindex $dow 1] == [expr "$day_of_week -1"]} {
+        if {[lindex $dow 1] == [expr "$cal_item(day_of_week) -1"]} {
                 set checked_html "CHECKED"
         } else {
                 set checked_html ""
@@ -39,8 +39,8 @@
 %>
 of the week <br>
 <INPUT TYPE=radio name=interval_type value=month_by_date> day
-@day_of_month@ of the month <br>
-<INPUT TYPE=radio name=interval_type value=month_by_day> same @pretty_day_of_week@ of
+@cal_item.day_of_month@ of the month <br>
+<INPUT TYPE=radio name=interval_type value=month_by_day> same @cal_item.pretty_day_of_week@ of
 the month <br>
 <INPUT TYPE=radio name=interval_type value=year> year<br>
 Repeat this event until: <%= [dt_widget_datetime -default [dt_systime] recur_until] %>
Index: openacs.org-dev/packages/calendar/www/cal-item-create-recurrence.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/calendar/www/cal-item-create-recurrence.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/calendar/www/cal-item-create-recurrence.tcl	9 Jul 2002 17:35:02 -0000	1.1.1.1
+++ openacs.org-dev/packages/calendar/www/cal-item-create-recurrence.tcl	25 Jul 2002 18:47:00 -0000	1.1.1.2
@@ -17,23 +17,7 @@
 ad_require_permission $cal_item_id cal_item_write
 
 # Select basic information about the event
-db_1row get_item_data { 
-    select   to_char(start_date,'HH24:MI')as start_time,
-    to_char(start_date, 'MM/DD/YYYY') as start_date,
-    to_char(end_date, 'HH24:MI') as end_time,
-    nvl(a. name, e.name) as name,
-    nvl(e.description, a.description) as description,
-    calendar_name,
-    to_char(start_date, 'D') as day_of_week,
-    to_char(start_date, 'Day') as pretty_day_of_week,
-    to_char(start_date, 'DD') as day_of_month
-    from     acs_activities a, acs_events e, timespans s, time_intervals t, calendars c, cal_items ci
-    where    e.timespan_id = s.timespan_id
-    and      s.interval_id = t.interval_id
-    and      e.activity_id = a.activity_id
-    and      e.event_id = :cal_item_id
-    and      ci.cal_item_id= :cal_item_id
-    and      ci.on_which_calendar= c.calendar_id
-}
+calendar::item::get -cal_item_id $cal_item_id -array cal_item
 
-# Select information about which day of the week it is, etc...
+ad_return_template
+
Index: openacs.org-dev/packages/calendar/www/cal-item-view.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/calendar/www/cal-item-view.adp,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/calendar/www/cal-item-view.adp	9 Jul 2002 17:35:02 -0000	1.1.1.1
+++ openacs.org-dev/packages/calendar/www/cal-item-view.adp	25 Jul 2002 18:47:00 -0000	1.1.1.2
@@ -37,7 +37,7 @@
     <if @edit_p@ eq 1><a href="cal-item-edit?cal_item_id=@cal_item_id@&return_url=@return_url@">edit</a> | <a href="./cal-item-delete?cal_item_id=@cal_item_id@&return_url=@return_url@">delete</a> @attachment_options@
 </if>
 <p>
-<a href="ics/@cal_item_id@.ics">sync with Outlook</a>
+sync with Outlook: <a href="ics/@cal_item_id@.ics">single event</a> <if @cal_item.recurrence_id@ not nil>| <a href="ics/@cal_item_id@.ics?all_occurences_p=1">all events</a></if>
     </td>
   </tr>
 </table>
Index: openacs.org-dev/packages/calendar/www/ics/index.vuh
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/calendar/www/ics/index.vuh,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/calendar/www/ics/index.vuh	9 Jul 2002 17:35:02 -0000	1.1.1.1
+++ openacs.org-dev/packages/calendar/www/ics/index.vuh	25 Jul 2002 18:47:01 -0000	1.1.1.2
@@ -7,6 +7,8 @@
     @author Ben Adida (ben@openforce)
     @creation-date June 20, 2002
     @cvs-id $Id$
+} {
+    {all_occurences_p 0}
 }
 
 set path [ad_conn path_info]
@@ -20,6 +22,9 @@
 # Permission (FIXME: ben)
 # ad_require_permission $cal_item_id read 
 
-set ics_stuff [calendar::outlook::format_item -cal_item_id $cal_item_id]
+set ics_stuff [calendar::outlook::format_item -cal_item_id $cal_item_id -all_occurences_p $all_occurences_p]
 
 ns_return 200 application/x-msoutlook $ics_stuff
+
+# This is for testing
+# ns_return 200 text/plain $ics_stuff
Index: openacs.org-dev/packages/ecommerce/www/admin/tools/form-custom.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/ecommerce/www/admin/tools/form-custom.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/ecommerce/www/admin/tools/form-custom.tcl	9 Jul 2002 17:35:08 -0000	1.1.1.1
+++ openacs.org-dev/packages/ecommerce/www/admin/tools/form-custom.tcl	25 Jul 2002 18:47:13 -0000	1.1.1.2
@@ -5,7 +5,7 @@
 #
 # on succes it does an ns_returnredirect to return_url
 #
-# davis@arsdigita.com 20000105
+# davis@xarg.net 20000105
 
 set internals {item item_group return_url item_original delete_the_set}
 ad_page_variables {item item_group return_url {item_original {}} {delete_the_set 0}}
Index: openacs.org-dev/packages/ecommerce/www/admin/tools/sort-custom.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/ecommerce/www/admin/tools/sort-custom.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/ecommerce/www/admin/tools/sort-custom.tcl	9 Jul 2002 17:35:08 -0000	1.1.1.1
+++ openacs.org-dev/packages/ecommerce/www/admin/tools/sort-custom.tcl	25 Jul 2002 18:47:13 -0000	1.1.1.2
@@ -5,7 +5,7 @@
 #
 # on succes it does an ns_returnredirect to return_url&$item_group=$item
 #
-# davis@arsdigita.com 20000105
+# davis@xarg.net 20000105
 
 ad_page_variables {item item_group return_url {delete_the_sort 0} {col -multiple-list} {dir -multiple-list} {item_original {}}}
 
Index: openacs.org-dev/packages/ecommerce/www/admin/tools/table-custom.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/ecommerce/www/admin/tools/table-custom.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/ecommerce/www/admin/tools/table-custom.tcl	9 Jul 2002 17:35:08 -0000	1.1.1.1
+++ openacs.org-dev/packages/ecommerce/www/admin/tools/table-custom.tcl	25 Jul 2002 18:47:13 -0000	1.1.1.2
@@ -4,7 +4,7 @@
 #
 # on succes it does an ns_returnredirect to return_url&$item_group=$item
 #
-# davis@arsdigita.com 20000105
+# davis@xarg.net 20000105
 
 ad_page_variables {item item_group return_url {delete_the_view 0} {col -multiple-list} {item_original {}}}
 
Index: openacs.org-dev/packages/faq/faq.info
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/faq/faq.info,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/faq/faq.info	9 Jul 2002 17:35:08 -0000	1.1.1.1
+++ openacs.org-dev/packages/faq/faq.info	25 Jul 2002 18:47:14 -0000	1.1.1.2
@@ -1,14 +1,16 @@
 <?xml version="1.0"?>
-<!-- Generated by the ACS Package Manager -->
+<!-- Generated by the OpenACS Package Manager -->
 
 <package key="faq" url="http://www.arsdgita.com/acs-repository/apm/packages/faq" type="apm_application">
     <package-name>FAQ</package-name>
     <pretty-plural>FAQs</pretty-plural>
+    <initial-install-p>f</initial-install-p>
     <singleton-p>f</singleton-p>
 
     <version name="4.0" url="http://www.arsdigita.com/acs-repository/download/apm/faq-4.0.apm">
     <database-support>
         <database>oracle</database>
+        <database>postgresql</database>
     </database-support>
         <owner url="mailto:wirth@ybos.net">Elizabeth Wirth</owner>
         <owner url="mailto:jennie@ybos.net">Jennie Kim Housman</owner>
@@ -23,12 +25,16 @@
             <file type="package_spec" path="faq.info"/>
             <file type="data_model_create" db_type="oracle" path="sql/oracle/faq-create.sql"/>
             <file type="data_model_drop" db_type="oracle" path="sql/oracle/faq-drop.sql"/>
+            <file type="data_model_create" db_type="postgresql" path="sql/postgresql/faq-create.sql"/>
+            <file type="data_model_drop" db_type="postgresql" path="sql/postgresql/faq-drop.sql"/>
             <file type="template" path="templates/first/master.adp"/>
             <file type="template" path="templates/first/one-faq.adp"/>
+            <file type="query_file" db_type="postgresql" path="www/admin/faq-delete-postgresql.xql"/>
             <file type="content_page" path="www/admin/faq-delete.tcl"/>
             <file type="content_page" path="www/admin/faq-edit-2.tcl"/>
             <file type="content_page" path="www/admin/faq-edit.adp"/>
             <file type="content_page" path="www/admin/faq-edit.tcl"/>
+            <file type="query_file" db_type="postgresql" path="www/admin/faq-new-2-postgresql.xql"/>
             <file type="content_page" path="www/admin/faq-new-2.tcl"/>
             <file type="content_page" path="www/admin/faq-new.adp"/>
             <file type="content_page" path="www/admin/faq-new.tcl"/>
@@ -39,10 +45,12 @@
             <file type="content_page" path="www/admin/one-faq.tcl"/>
             <file type="content_page" path="www/admin/one-question.adp"/>
             <file type="content_page" path="www/admin/one-question.tcl"/>
+            <file type="query_file" db_type="postgresql" path="www/admin/q_and_a-delete-postgresql.xql"/>
             <file type="content_page" path="www/admin/q_and_a-delete.tcl"/>
             <file type="content_page" path="www/admin/q_and_a-edit-2.tcl"/>
             <file type="content_page" path="www/admin/q_and_a-edit.adp"/>
             <file type="content_page" path="www/admin/q_and_a-edit.tcl"/>
+            <file type="query_file" db_type="postgresql" path="www/admin/q_and_a-new-2-postgresql.xql"/>
             <file type="content_page" path="www/admin/q_and_a-new-2.tcl"/>
             <file type="content_page" path="www/admin/q_and_a-new.adp"/>
             <file type="content_page" path="www/admin/q_and_a-new.tcl"/>
Index: openacs.org-dev/packages/file-storage/sql/oracle/file-storage-package-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/file-storage/sql/oracle/file-storage-package-create.sql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/file-storage/sql/oracle/file-storage-package-create.sql	9 Jul 2002 17:35:08 -0000	1.1.1.1
+++ openacs.org-dev/packages/file-storage/sql/oracle/file-storage-package-create.sql	25 Jul 2002 18:47:14 -0000	1.1.1.2
@@ -35,6 +35,7 @@
         -- Create a file in CR in preparation for actual storage
         -- Wrapper for content_item.new
         --
+        item_id in cr_items.item_id%TYPE default null,
         title in cr_items.name%TYPE,
         folder_id in cr_items.parent_id%TYPE,
         creation_user in acs_objects.creation_user%TYPE,
@@ -263,6 +264,7 @@
         -- Create a file in CR in preparation for actual storage
         -- Wrapper for content_item.new
         --
+        item_id in cr_items.item_id%TYPE default null,
         title in cr_items.name%TYPE,
         folder_id in cr_items.parent_id%TYPE,
         creation_user in acs_objects.creation_user%TYPE,
@@ -275,6 +277,7 @@
         if new_file.indb_p = 't'
         then
             v_item_id := content_item.new(
+                item_id => new_file.item_id,
                 name => new_file.title,
                 parent_id => new_file.folder_id,
                 creation_user => new_file.creation_user,
Index: openacs.org-dev/packages/file-storage/sql/oracle/file-storage-simple-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/file-storage/sql/oracle/file-storage-simple-create.sql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/file-storage/sql/oracle/file-storage-simple-create.sql	9 Jul 2002 17:35:08 -0000	1.1.1.1
+++ openacs.org-dev/packages/file-storage/sql/oracle/file-storage-simple-create.sql	25 Jul 2002 18:47:14 -0000	1.1.1.2
@@ -44,7 +44,8 @@
         pretty_name => 'File Storage Simple Object',
         pretty_plural => 'File Storage Simple Objects',
         table_name => 'fs_simple_objects',
-        id_column => 'object_id'
+        id_column => 'object_id',
+        name_method => 'fs_simple_object.name'
     );
 
     -- links
Index: openacs.org-dev/packages/file-storage/sql/oracle/file-storage-simple-package-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/file-storage/sql/oracle/file-storage-simple-package-create.sql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/file-storage/sql/oracle/file-storage-simple-package-create.sql	9 Jul 2002 17:35:08 -0000	1.1.1.1
+++ openacs.org-dev/packages/file-storage/sql/oracle/file-storage-simple-package-create.sql	25 Jul 2002 18:47:14 -0000	1.1.1.2
@@ -12,6 +12,7 @@
 
 create or replace package fs_simple_object
 as
+
     function new (
         object_id in fs_simple_objects.object_id%TYPE default NULL,
         object_type in acs_objects.object_type%TYPE default 'fs_simple_object',
@@ -27,12 +28,18 @@
     procedure delete (
         object_id in fs_simple_objects.object_id%TYPE
     );
+
+    function name (
+        object_id in fs_simple_objects.object_id%TYPE
+    ) return fs_simple_objects.name%TYPE;
+
 end fs_simple_object;
 /
 show errors
 
 create or replace package body fs_simple_object
 as
+
     function new (
         object_id in fs_simple_objects.object_id%TYPE default NULL,
         object_type in acs_objects.object_type%TYPE default 'fs_simple_object',
@@ -45,7 +52,7 @@
         context_id in acs_objects.context_id%TYPE
     ) return fs_simple_objects.object_id%TYPE
     is
-        v_object_id  acs_objects.object_id%TYPE;
+        v_object_id                 acs_objects.object_id%TYPE;
     begin
         v_object_id:= acs_object.new (
             object_id => object_id,
@@ -73,12 +80,27 @@
         acs_object.delete(object_id);
     end delete;
 
+    function name (
+        object_id in fs_simple_objects.object_id%TYPE
+    ) return fs_simple_objects.name%TYPE
+    is
+        v_name                      fs_simple_objects.name%TYPE;
+    begin
+        select name
+        into v_name
+        from fs_simple_objects
+        where object_id = fs_simple_object.name.object_id;
+
+        return v_name;
+    end name;
+
 end fs_simple_object;
 /
 show errors
 
 create or replace package fs_url
 as
+
     function new (
         url_id in fs_urls.url_id%TYPE default NULL,
         object_type in acs_objects.object_type%TYPE default 'fs_url',
@@ -107,6 +129,7 @@
 
 create or replace package body fs_url
 as
+
     function new (
         url_id in fs_urls.url_id%TYPE default NULL,
         object_type in acs_objects.object_type%TYPE default 'fs_url',
Index: openacs.org-dev/packages/file-storage/sql/postgresql/file-storage-package-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/file-storage/sql/postgresql/file-storage-package-create.sql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/file-storage/sql/postgresql/file-storage-package-create.sql	9 Jul 2002 17:35:08 -0000	1.1.1.1
+++ openacs.org-dev/packages/file-storage/sql/postgresql/file-storage-package-create.sql	25 Jul 2002 18:47:14 -0000	1.1.1.2
@@ -155,18 +155,22 @@
        -- Create a file in CR in preparation for actual storage
        -- Wrapper for content_item__new
        --
+       -- DRB: I added this version to allow one to predefine item_id, among other things to
+       -- make it easier to use with ad_form
        varchar,		-- cr_items.name%TYPE,
        integer,		-- cr_items.parent_id%TYPE,
        integer,		-- acs_objects.creation_user%TYPE,
        varchar,		-- acs_objects.creation_ip%TYPE,
-       boolean		-- store in db? 
+       boolean,		-- store in db? 
+       integer          -- cr_items.item_id%TYPE,
 ) returns integer as ' -- cr_items.item_id%TYPE
 declare
 	new_file__title			alias for $1;
 	new_file__folder_id		alias for $2;
 	new_file__user_id		alias for $3;
 	new_file__creation_ip		alias for $4;
 	new_file__indb_p		alias for $5;
+        new_file__item_id               alias for $6;
         v_item_id                       cr_items.item_id%TYPE;
 begin
 
@@ -175,7 +179,7 @@
 	    select content_item__new (
                         new_file__title,	    -- name
                         new_file__folder_id,      -- parent_id
-                        null,			    -- item_id (default)
+                        new_file__item_id,	  -- item_id (default)
                         null,			    -- locale (default)
                         now(),		    -- creation_date (default)
                         new_file__user_id,        -- creation_user
@@ -194,7 +198,7 @@
 	    select content_item__new (
                         new_file__title,	    -- name
                         new_file__folder_id,	    -- parent_id
-                        null,			    -- item_id (default)
+                        new_file__item_id,	    -- item_id (default)
                         null,			    -- locale (default)
                         now(),		    -- creation_date (default)
                         new_file__user_id,	    -- creation_user
@@ -218,8 +222,35 @@
         return v_item_id;
 
 end;' language 'plpgsql';
+    
 
+create function file_storage__new_file(
+       varchar,		-- cr_items.name%TYPE,
+       integer,		-- cr_items.parent_id%TYPE,
+       integer,		-- acs_objects.creation_user%TYPE,
+       varchar,		-- acs_objects.creation_ip%TYPE,
+       boolean		-- store in db? 
+) returns integer as ' -- cr_items.item_id%TYPE
+declare
+	new_file__title			alias for $1;
+	new_file__folder_id		alias for $2;
+	new_file__user_id		alias for $3;
+	new_file__creation_ip		alias for $4;
+	new_file__indb_p		alias for $5;
+begin
 
+        return file_storage__new_file(
+             new_file__title,
+             new_file__folder_id,
+             new_file__user_id,
+             new_file__creation_ip,
+             new_file__indb_p,
+             null
+        );
+
+end;' language 'plpgsql';
+
+
 create function file_storage__delete_file (
        --
        -- Delete a file and all its version
Index: openacs.org-dev/packages/file-storage/sql/postgresql/file-storage-simple-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/file-storage/sql/postgresql/file-storage-simple-create.sql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/file-storage/sql/postgresql/file-storage-simple-create.sql	9 Jul 2002 17:35:08 -0000	1.1.1.1
+++ openacs.org-dev/packages/file-storage/sql/postgresql/file-storage-simple-create.sql	25 Jul 2002 18:47:14 -0000	1.1.1.2
@@ -46,7 +46,7 @@
         NULL,
         'f',
         NULL,
-        NULL
+        'fs_simple_object.name'
 );
 
 -- links
Index: openacs.org-dev/packages/file-storage/sql/postgresql/file-storage-simple-package-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/file-storage/sql/postgresql/file-storage-simple-package-create.sql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/file-storage/sql/postgresql/file-storage-simple-package-create.sql	9 Jul 2002 17:35:08 -0000	1.1.1.1
+++ openacs.org-dev/packages/file-storage/sql/postgresql/file-storage-simple-package-create.sql	25 Jul 2002 18:47:14 -0000	1.1.1.2
@@ -10,12 +10,8 @@
 -- @cvs-id $Id$
 --
 
-
 select define_function_args('fs_simple_object__new','object_id,object_type;fs_simple_object,folder_id,name,description,creation_date,creation_user,creation_ip,context_id');
 
-select define_function_args('fs_simple_object__delete','object_id');
-
-
 create function fs_simple_object__new(integer,varchar,integer,varchar,varchar,timestamp,integer,varchar,integer)
 returns integer as '
 DECLARE
@@ -42,16 +38,16 @@
         insert into fs_simple_objects
         (object_id, folder_id, name, description) values
         (v_object_id, p_folder_id, p_name, p_description);
-         
+
         acs_object__update_last_modified(p_folder_id);
 
         return v_object_id;
-     
+
 END;
 ' language 'plpgsql';
 
+select define_function_args('fs_simple_object__delete','object_id');
 
-
 create function fs_simple_object__delete(integer)
 returns integer as '
 DECLARE
@@ -63,15 +59,25 @@
 END;
 ' language 'plpgsql';
 
+select define_function_args('fs_simple_object__name', 'object_id');
 
+create function fs_simple_object__name(integer)
+returns integer as '
+declare
+    p_object_id                     alias from $1;
+begin
+    return name
+    from fs_simple_objects
+    where object_id = p_object_id;
+end;
+' language 'plpgsql';
 
 select define_function_args('fs_url__new','url_id,object_type;fs_url,url,folder_id,name,description,creation_date,creation_user,creation_ip,context_id');
 
 select define_function_args('fs_url__delete','url_id');
 
 select define_function_args('fs_url__copy','url_id;target_object_id');
 
-
 create function fs_url__new(integer,varchar,varchar,integer,varchar,varchar,timestamp,integer,varchar,integer)
 returns integer as '
 DECLARE
@@ -98,7 +104,7 @@
             p_creation_ip,
             p_context_id
         );
-           
+
         insert into fs_urls
         (url_id, url) values
         (v_url_id, p_url);
@@ -171,7 +177,7 @@
             v_creation_ip,
             p_target_folder_id
         );
-           
+
         return v_new_url_id;
 END;
 ' language 'plpgsql';
Index: openacs.org-dev/packages/file-storage/tcl/file-storage-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/file-storage/tcl/file-storage-procs-postgresql.xql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/file-storage/tcl/file-storage-procs-postgresql.xql	9 Jul 2002 17:35:08 -0000	1.1.1.1
+++ openacs.org-dev/packages/file-storage/tcl/file-storage-procs-postgresql.xql	25 Jul 2002 18:47:14 -0000	1.1.1.2
@@ -33,14 +33,12 @@
 
     <fullquery name="fs::rename_folder.rename_folder">
         <querytext>
-            begin
-                select content_folder__rename(
-                    :folder_id,
-                    null,
-                    :name,
-                    null
-                );
-            end;
+            select content_folder__rename(
+                :folder_id,
+                null,
+                :name,
+                null
+            );
         </querytext>
     </fullquery>
 
@@ -56,7 +54,7 @@
                          fs_objects.url,
                          fs_objects.key,
                          fs_objects.sort_key,
-                         case when fs_objects.last_modified >= (now() - :n_past_days) then 1 else 0 end as new_p,
+                         case when fs_objects.last_modified >= (now() - :n_past_days::timespan) then 1 else 0 end as new_p,
                          acs_permission__permission_p(fs_objects.object_id, :user_id, 'admin') as admin_p,
                          acs_permission__permission_p(fs_objects.object_id, :user_id, 'delete') as delete_p,
                          acs_permission__permission_p(fs_objects.object_id, :user_id, 'write') as write_p
Index: openacs.org-dev/packages/file-storage/www/file-move-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/file-storage/www/file-move-2.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/file-storage/www/file-move-2.tcl	9 Jul 2002 17:35:08 -0000	1.1.1.1
+++ openacs.org-dev/packages/file-storage/www/file-move-2.tcl	25 Jul 2002 18:47:14 -0000	1.1.1.2
@@ -71,9 +71,5 @@
     return
 }
 
-
 ad_returnredirect "?folder_id=$parent_id"
 
-
-
-
Index: openacs.org-dev/packages/forums/sql/oracle/forums-search-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/forums/sql/oracle/forums-search-create.sql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/forums/sql/oracle/forums-search-create.sql	9 Jul 2002 17:35:09 -0000	1.1.1.1
+++ openacs.org-dev/packages/forums/sql/oracle/forums-search-create.sql	25 Jul 2002 18:47:15 -0000	1.1.1.2
@@ -71,6 +71,7 @@
 show errors
 
 grant execute on s_index_message to yon;
+grant execute on ctx_ddl to yon;
 
 -- as normal user
 connect yon/yon;
@@ -88,13 +89,16 @@
 begin
     dbms_job.submit(
         job => v_job,
-        what => 'ctx_ddl.sync_index(''forums_content_idx'');',
+        what => 'ctxsys.ctx_ddl.sync_index(''forums_content_idx'');',
         interval => 'sysdate + 1/24'
     );
 end;
 /
 show errors
 
+-- as normal user
+connect yon/yon;
+
 -- ripped off from site-wide-search
 
 -- if we pass in a very long string to im_convert, we will end up with internal 
@@ -106,47 +110,48 @@
 --    2. increase the max length from 256 to 1024
 -- mbryzek@arsdigita.com, 7/6/2000
 create or replace procedure im_convert_length_check ( 
-    p_string IN varchar2,
-    p_number_chars_to_append IN number,
-    p_max_length IN number, 
-    p_variable_name IN varchar2 
+    p_string in varchar2,
+    p_number_chars_to_append in number,
+    p_max_length in number, 
+    p_variable_name in varchar2 
 )
 is
 begin
-    if nvl(length(p_string),0) + p_number_chars_to_append > p_max_length then
+    if nvl(length(p_string),0) + p_number_chars_to_append > p_max_length
+    then
 	raise_application_error(-20000, 'Variable "' || p_variable_name || '" exceeds ' || p_max_length || ' character declaration');
     end if;
 end;
 /
 show errors;
 
--- Query to take free text user entered query and from it into something
--- that will make interMedia happy. Provided by Oracle.
+-- this proc takes user supplied free text and transforms it into an interMedia
+-- friendly query string. (provided by oracle).
 create or replace function im_convert (
     query in varchar2 default null
 ) return varchar2
 is
-    i   number :=0;
-    len number :=0;
+    i number := 0;
+    len number := 0;
     char varchar2(1);
     minusString varchar2(256) := '';
     plusString varchar2(256) := ''; 
     mainString varchar2(256) := ''; 
     mainAboutString varchar2(500) := ''; 
     finalString varchar2(500) := ''; 
-    hasMain number :=0;
-    hasPlus number :=0;
-    hasMinus number :=0;
+    hasMain number := 0;
+    hasPlus number := 0;
+    hasMinus number := 0;
     token varchar2(256);
-    tokenStart number :=1;
-    tokenFinish number :=0;
-    inPhrase number :=0;
-    inPlus number :=0;
-    inWord number :=0;
-    inMinus number :=0;
-    completePhrase number :=0;
-    completeWord number :=0;
-    code number :=0;  
+    tokenStart number := 1;
+    tokenFinish number := 0;
+    inPhrase number := 0;
+    inPlus number := 0;
+    inWord number := 0;
+    inMinus number := 0;
+    completePhrase number := 0;
+    completeWord number := 0;
+    code number := 0;  
 begin
   
     len := length(query);
Index: openacs.org-dev/packages/forums/sql/oracle/forums-search-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/forums/sql/oracle/forums-search-drop.sql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/forums/sql/oracle/forums-search-drop.sql	9 Jul 2002 17:35:09 -0000	1.1.1.1
+++ openacs.org-dev/packages/forums/sql/oracle/forums-search-drop.sql	25 Jul 2002 18:47:15 -0000	1.1.1.2
@@ -37,7 +37,7 @@
 begin
     for row in (select job
                 from user_jobs
-                where what like '%forums_content_idx%')
+                where what like '%yon.forums_content_idx%')
     loop
         dbms_job.remove(job => row.job);
     end loop;
Index: openacs.org-dev/packages/forums/sql/postgresql/forums-forums-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/forums/sql/postgresql/forums-forums-create.sql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/forums/sql/postgresql/forums-forums-create.sql	9 Jul 2002 17:35:09 -0000	1.1.1.1
+++ openacs.org-dev/packages/forums/sql/postgresql/forums-forums-create.sql	25 Jul 2002 18:47:15 -0000	1.1.1.2
@@ -10,34 +10,32 @@
 --
 
 -- privileges
-create function inline_0 ()
-returns integer as '
-begin
+begin;
     -- moderate and post are new privileges
     -- the rest are obvious inheritance
     -- forum creation on a package allows a user to create forums
     -- forum creation on a forum allows a user to create new threads
-    perform acs_privilege__create_privilege(''forum_create'',null,null);
-    perform acs_privilege__create_privilege(''forum_write'',null,null);
-    perform acs_privilege__create_privilege(''forum_delete'',null,null);
-    perform acs_privilege__create_privilege(''forum_read'',null,null);
-    perform acs_privilege__create_privilege(''forum_post'',null,null);
-    perform acs_privilege__create_privilege(''forum_moderate'',null,null);
+    select acs_privilege__create_privilege('forum_create',null,null);
+    select acs_privilege__create_privilege('forum_write',null,null);
+    select acs_privilege__create_privilege('forum_delete',null,null);
+    select acs_privilege__create_privilege('forum_read',null,null);
+    select acs_privilege__create_privilege('forum_post',null,null);
+    select acs_privilege__create_privilege('forum_moderate',null,null);
 
     -- temporarily drop this trigger to avoid a data-change violation 
     -- on acs_privilege_hierarchy_index while updating the child privileges.
 
     drop trigger acs_priv_hier_ins_del_tr on acs_privilege_hierarchy;
 
     -- add children
-    perform acs_privilege__add_child(''create'',''forum_create'');
-    perform acs_privilege__add_child(''write'',''forum_write'');
-    perform acs_privilege__add_child(''delete'',''forum_delete'');
-    perform acs_privilege__add_child(''admin'',''forum_moderate'');
-    perform acs_privilege__add_child(''forum_moderate'',''forum_read'');
-    perform acs_privilege__add_child(''forum_moderate'',''forum_post'');
-    perform acs_privilege__add_child(''forum_write'',''forum_read'');
-    perform acs_privilege__add_child(''forum_write'',''forum_post'');
+    select acs_privilege__add_child('create','forum_create');
+    select acs_privilege__add_child('write','forum_write');
+    select acs_privilege__add_child('delete','forum_delete');
+    select acs_privilege__add_child('admin','forum_moderate');
+    select acs_privilege__add_child('forum_moderate','forum_read');
+    select acs_privilege__add_child('forum_moderate','forum_post');
+    select acs_privilege__add_child('forum_write','forum_read');
+    select acs_privilege__add_child('forum_write','forum_post');
     
     -- re-enable the trigger before the last insert to force the 
     -- acs_privilege_hierarchy_index table to be updated.
@@ -47,14 +45,11 @@
     execute procedure acs_priv_hier_ins_del_tr ();
 
     -- the last one that will cause all the updates
-    perform acs_privilege__add_child(''read'',''forum_read'');
+    select acs_privilege__add_child('read','forum_read');
 
-    return null;
-end;' language 'plpgsql';
+    --return null;
+end;
 
-select inline_0();
-drop function inline_0 ();
-
 create table forums_forums (
     forum_id                        integer
                                     constraint forums_forum_id_nn
Index: openacs.org-dev/packages/forums/sql/postgresql/forums-notifications-sanitize.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/forums/sql/postgresql/forums-notifications-sanitize.sql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/forums/sql/postgresql/forums-notifications-sanitize.sql	9 Jul 2002 17:35:09 -0000	1.1.1.1
+++ openacs.org-dev/packages/forums/sql/postgresql/forums-notifications-sanitize.sql	25 Jul 2002 18:47:15 -0000	1.1.1.2
@@ -25,3 +25,112 @@
 
 select inline_0();
 drop function inline_0 ();
+
+--
+-- Service contract drop stuff was missing - Roberto Mello 
+--
+
+create function inline_0() returns integer as '
+declare
+        impl_id integer;
+        v_foo   integer;
+begin
+
+        -- the notification type impl
+        impl_id := acs_sc_impl__get_id (
+                      ''NotificationType'',		-- impl_contract_name
+                      ''forums_forum_notif_type''	-- impl_name
+        );
+
+        PERFORM acs_sc_binding__delete (
+                    ''NotificationType'',
+                    ''forums_forum_notif_type''
+        );
+
+        v_foo := acs_sc_impl_alias__delete (
+                    ''NotificationType'',		-- impl_contract_name	
+                    ''forums_forum_notif_type'',	-- impl_name
+                    ''GetURL''				-- impl_operation_name
+        );
+
+        v_foo := acs_sc_impl_alias__delete (
+                    ''NotificationType'',		-- impl_contract_name	
+                    ''forums_forum_notif_type'',	-- impl_name
+                    ''ProcessReply''			-- impl_operation_name
+        );
+
+	select into v_foo type_id 
+	  from notification_types
+	 where sc_impl_id = impl_id
+	  and short_name = ''forums_forum_notif'';
+
+	perform notification_type__delete (v_foo);
+
+	delete from notification_types_intervals
+	 where type_id = v_foo 
+	   and interval_id in ( 
+		select interval_id
+		  from notification_intervals 
+		 where name in (''instant'',''hourly'',''daily'')
+	);
+
+	delete from notification_types_del_methods
+	 where type_id = v_foo
+	   and delivery_method_id in (
+		select delivery_method_id
+		  from notification_delivery_methods 
+		 where short_name in (''email'')
+	);
+
+        -- the notification type impl
+        impl_id := acs_sc_impl__get_id (
+                      ''NotificationType'',
+                      ''forums_message_notif_type''
+                   );
+
+        PERFORM acs_sc_binding__delete (
+                    ''NotificationType'',
+                    ''forums_message_notif_type''
+        );
+
+        v_foo := acs_sc_impl_alias__delete (
+                    ''NotificationType'',
+                    ''forums_message_notif_type'',
+                    ''GetURL''
+        );
+
+        v_foo := acs_sc_impl_alias__delete (
+                    ''NotificationType'',
+                    ''forums_message_notif_type'',
+                    ''ProcessReply''
+        );
+
+	select into v_foo type_id 
+	  from notification_types
+	 where sc_impl_id = impl_id
+	   and short_name = ''forums_message_notif'';
+
+	perform notification_type__delete (v_foo);
+
+	delete from notification_types_intervals
+	 where type_id = v_foo 
+	   and interval_id in ( 
+		select interval_id
+		  from notification_intervals 
+		 where name in (''instant'',''hourly'',''daily'')
+	);
+
+	delete from notification_types_del_methods
+	 where type_id = v_foo
+	   and delivery_method_id in (
+		select delivery_method_id
+		  from notification_delivery_methods 
+		 where short_name in (''email'')
+	);
+
+	return (0);
+end;
+' language 'plpgsql';
+
+select inline_0();
+drop function inline_0();
Index: openacs.org-dev/packages/forums/tcl/forums-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/forums/tcl/forums-procs.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/forums/tcl/forums-procs.tcl	9 Jul 2002 17:35:09 -0000	1.1.1.1
+++ openacs.org-dev/packages/forums/tcl/forums-procs.tcl	25 Jul 2002 18:47:15 -0000	1.1.1.2
@@ -42,7 +42,9 @@
     }
 
     ad_proc -public attachments_enabled_p {} {
-        return [apm_package_registered_p attachments]
+        set package_id [site_node_apm_integration::child_package_exists_p \
+            -package_key attachments
+        ]
     }
 
     ad_proc -public list_forums {
Index: openacs.org-dev/packages/forums/tcl/messages-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/forums/tcl/messages-procs.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/forums/tcl/messages-procs.tcl	9 Jul 2002 17:35:09 -0000	1.1.1.1
+++ openacs.org-dev/packages/forums/tcl/messages-procs.tcl	25 Jul 2002 18:47:15 -0000	1.1.1.2
@@ -114,11 +114,13 @@
         # Select the info into the upvar'ed Tcl Array
         upvar $array row
 
-        if {[forum::attachments_enabled_p]} {
-            db_1row select_message_with_attachment {} -column_array row
-        } else {
-            db_1row select_message {} -column_array row
+        set query select_message
+
+        if {[ad_conn isconnected] && [forum::attachments_enabled_p]} {
+            set query select_message_with_attachment
         }
+
+        db_1row $query {} -column_array row
     }
 
     ad_proc -private set_state {
Index: openacs.org-dev/packages/forums/www/forum-view.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/forums/www/forum-view.adp,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/forums/www/forum-view.adp	9 Jul 2002 17:35:09 -0000	1.1.1.1
+++ openacs.org-dev/packages/forums/www/forum-view.adp	25 Jul 2002 18:47:15 -0000	1.1.1.2
@@ -35,7 +35,7 @@
 
     <tr>
       <td colspan="4">
-        @notification_chunk@
+        <nobr>@notification_chunk@</nobr>
         <br><br>
         <if @post_p@>
           <nobr><small>[ <a href="message-post?forum_id=@forum_id@">Post a New Message</a> ]</small></nobr>
Index: openacs.org-dev/packages/forums/www/message-attachment-chunk.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/forums/www/message-attachment-chunk.adp,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/forums/www/message-attachment-chunk.adp	9 Jul 2002 17:35:09 -0000	1.1.1.1
+++ openacs.org-dev/packages/forums/www/message-attachment-chunk.adp	25 Jul 2002 18:47:15 -0000	1.1.1.2
@@ -1,6 +1,12 @@
+    <tr bgcolor="@bgcolor@">
+      <td colspan="4">
+        Attachments:
+        <ul>
 <% 
-foreach attachment $attachments {
-   template::adp_puts "<a href=\"[lindex $attachment 2]\">$attachment_graphic</a> &nbsp;"
-}
+    foreach attachment $attachments {
+        template::adp_puts "<li><a href=\"[lindex $attachment 2]\">[lindex $attachment 1]</a></li>"
+    }
 %>
-
+        </ul>
+      </td>
+    </tr>
Index: openacs.org-dev/packages/forums/www/message-attachment-chunk.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/forums/www/message-attachment-chunk.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/forums/www/message-attachment-chunk.tcl	9 Jul 2002 17:35:09 -0000	1.1.1.1
+++ openacs.org-dev/packages/forums/www/message-attachment-chunk.tcl	25 Jul 2002 18:47:15 -0000	1.1.1.2
@@ -1,4 +1,3 @@
-
 ad_page_contract {
     a message attachment chunk to be included to display attachments
 
@@ -11,6 +10,10 @@
     ad_return_complaint 1 "need to provide a message to display attachments!"
 }
 
+if {![exists_and_not_null bgcolor]} {
+    set bgcolor "#ffffff"
+}
+
 # get the attachments
 set attachments [attachments::get_attachments -object_id $message(message_id)]
 
Index: openacs.org-dev/packages/forums/www/message-chunk.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/forums/www/message-chunk.adp,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/forums/www/message-chunk.adp	9 Jul 2002 17:35:09 -0000	1.1.1.1
+++ openacs.org-dev/packages/forums/www/message-chunk.adp	25 Jul 2002 18:47:15 -0000	1.1.1.2
@@ -1,5 +1,12 @@
     <tr bgcolor="@bgcolor@">
-      <td><b><a href="message-view?message_id=@message.message_id@">@message.subject@</a></b> <if @message.n_attachments@ not nil and @message.n_attachments@ gt 0><include src="message-attachment-chunk" &message="message"></if></td>
+      <td>
+        <table bgcolor="@bgcolor@">
+          <tr bgcolor="@bgcolor@">
+            <td>
+              <b><a href="message-view?message_id=@message.message_id@">@message.subject@</a></b>
+            </td>
+          </tr>
+        </table>
       <td width="15%"><a href="user-history?user_id=@message.user_id@">@message.user_name@</a></td>
       <td align="center" width="20%">@message.posting_date@</td>
       <td align="right" width="25%">
@@ -31,3 +38,6 @@
     <tr bgcolor="@bgcolor@">
       <td colspan="4"><blockquote>@message.content@</blockquote></td>
     </tr>
+<if @message.n_attachments@ not nil and @message.n_attachments@ gt 0>
+  <include src="message-attachment-chunk" &message="message" bgcolor=@bgcolor@>
+</if>
Index: openacs.org-dev/packages/forums/www/message-view-flat.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/forums/www/message-view-flat.adp,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/forums/www/message-view-flat.adp	9 Jul 2002 17:35:09 -0000	1.1.1.1
+++ openacs.org-dev/packages/forums/www/message-view-flat.adp	25 Jul 2002 18:47:15 -0000	1.1.1.2
@@ -7,7 +7,7 @@
   <table cellpadding="5" width="95%">
     <tr>
       <td colspan="4">
-        @notification_chunk@
+        <nobr>@notification_chunk@</nobr>
 <if @post_p@>
         <nobr><small>[
           <a href="message-post?forum_id=@forum_id@">Post a New Message</a>
Index: openacs.org-dev/packages/forums/www/message-view.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/forums/www/message-view.adp,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/forums/www/message-view.adp	9 Jul 2002 17:35:09 -0000	1.1.1.1
+++ openacs.org-dev/packages/forums/www/message-view.adp	25 Jul 2002 18:47:15 -0000	1.1.1.2
@@ -7,7 +7,7 @@
   <table cellpadding="4" width="95%">
     <tr>
       <td colspan="4">
-        @notification_chunk@
+        <nobr>@notification_chunk@</nobr>
 <if @post_p@>
         <nobr><small>[
           <a href="message-post?forum_id=@forum_id@">Post a New Message</a>
Index: openacs.org-dev/packages/general-comments/www/comment-ae.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/general-comments/www/comment-ae.adp,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/general-comments/www/comment-ae.adp	9 Jul 2002 17:35:09 -0000	1.1.1.1
+++ openacs.org-dev/packages/general-comments/www/comment-ae.adp	25 Jul 2002 18:47:15 -0000	1.1.1.2
@@ -1,11 +1,12 @@
 <master src="master">
 <property name="page_title">@page_title@</property>
 <property name="context_bar">@context_bar@</property>
+<property name="focus">comment.title</property>
 
 @page_title@
 
 <blockquote>
-<form action="@target@" method=post>
+<form action="@target@" method="post" name="comment">
 <%= [export_form_vars comment_id object_id object_name context_id return_url] %>
 Title:<br>
 <input type=text name=title maxlength=200 size=50 value="@title@">
Index: openacs.org-dev/packages/general-comments/www/master.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/general-comments/www/master.adp,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/general-comments/www/master.adp	9 Jul 2002 17:35:09 -0000	1.1.1.1
+++ openacs.org-dev/packages/general-comments/www/master.adp	25 Jul 2002 18:47:16 -0000	1.1.1.2
@@ -1,5 +1,6 @@
 <master>
 <property name="title">@page_title@</property>
+<if @focus@ not nil><property name="focus">@focus@</property></if>
 
 <h2>@page_title@</h2>
 <%= [eval ad_context_bar $context_bar] %>
Index: openacs.org-dev/packages/news/sql/postgresql/news-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/news/sql/postgresql/news-create.sql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/news/sql/postgresql/news-create.sql	9 Jul 2002 17:35:09 -0000	1.1.1.1
+++ openacs.org-dev/packages/news/sql/postgresql/news-create.sql	25 Jul 2002 18:47:17 -0000	1.1.1.2
@@ -649,6 +649,72 @@
 ' language 'plpgsql';
 
 
+
+-- Incomplete for want of blob_to_string() in postgres 16 july 2000
+
+create function news__clone (integer, integer)
+returns integer as '
+declare
+ p_new_package_id   alias for $1;   --default null,
+ p_old_package_id   alias for $2;   --default null
+ one_news		record;	 
+begin
+        for one_news in select
+                            publish_date,
+                            cr.content as text,
+                            cr.nls_language,
+                            cr.title as title,
+                            cr.mime_type,
+                            cn.package_id,
+                            archive_date,
+                            approval_user,
+                            approval_date,
+                            approval_ip,
+                            ao.creation_date,
+                            ao.creation_ip,
+                            ao.creation_user
+                        from 
+                            cr_items ci, 
+                            cr_revisions cr,
+                            cr_news cn,
+                            acs_objects ao
+                        where
+                            (ci.item_id = cr.item_id
+                            and ci.live_revision = cr.revision_id 
+                            and cr.revision_id = cn.news_id 
+                            and cr.revision_id = ao.object_id)
+                        or (ci.live_revision is null 
+                            and ci.item_id = cr.item_id
+                            and cr.revision_id = content_item__get_latest_revision(ci.item_id)
+                            and cr.revision_id = cn.news_id
+                            and cr.revision_id = ao.object_id)
+
+        loop
+            perform news__new(
+                				one_news.publish_date,
+                				one_news.text,
+                				one_news.nls_language,
+                				one_news.title,
+                				one_news.mime_type,
+                				new_package_id,
+                				one_news.archive_date,
+                				one_news.approval_user,
+                				one_news.approval_date,
+                				one_news.approval_ip,
+                				one_news.creation_date,
+                				one_news.creation_ip,
+                				one_news.creation_user
+            );
+
+        end loop;
+ return 0;
+end;
+' language 'plpgsql';
+
+
+
+
+
 -- currently not used, because we want to audit revisions
 create function news__revision_delete (integer)
 returns integer as '
Index: openacs.org-dev/packages/news/sql/postgresql/news-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/news/sql/postgresql/news-drop.sql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/news/sql/postgresql/news-drop.sql	9 Jul 2002 17:35:09 -0000	1.1.1.1
+++ openacs.org-dev/packages/news/sql/postgresql/news-drop.sql	25 Jul 2002 18:47:17 -0000	1.1.1.2
@@ -73,6 +73,7 @@
        integer,boolean);
 drop function news__revision_set_active (integer);
 drop function news__revision_delete (integer);
+drop function news__clone (integer,integer);
 
 
 -- delete news views
Index: openacs.org-dev/packages/notifications/sql/postgresql/notifications-package-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/notifications/sql/postgresql/notifications-package-create.sql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/notifications/sql/postgresql/notifications-package-create.sql	9 Jul 2002 17:35:10 -0000	1.1.1.1
+++ openacs.org-dev/packages/notifications/sql/postgresql/notifications-package-create.sql	25 Jul 2002 18:47:18 -0000	1.1.1.2
@@ -58,7 +58,7 @@
 returns integer as '
 declare
     p_delivery_method_id            alias for $1;
-    p_sc_impl_id		    alias for $2;
+    p_sc_impl_id                    alias for $2;
     p_short_name                    alias for $3;
     p_pretty_name                   alias for $4;
     p_creation_date                 alias for $5;
@@ -90,10 +90,10 @@
 create function notification_delivery_method__delete(integer)
 returns integer as '
 DECLARE
-	p_delivery_method_id		alias for $1;
+        p_delivery_method_id            alias for $1;
 BEGIN
-	perform acs_object__delete(p_delivery_method_id);
-	return 0;
+        perform acs_object__delete(p_delivery_method_id);
+        return 0;
 END;
 ' language 'plpgsql';
 
@@ -109,24 +109,24 @@
 create function notification_type__new (integer,integer,varchar,varchar,varchar,timestamp,integer,varchar,integer)
 returns integer as '
 DECLARE
-	p_type_id			alias for $1;
+        p_type_id                       alias for $1;
         p_sc_impl_id                    alias for $2;
-	p_short_name			alias for $3;
-	p_pretty_name			alias for $4;
-	p_description			alias for $5;
-	p_creation_date			alias for $6;
-	p_creation_user			alias for $7;
-	p_creation_ip			alias for $8;
-	p_context_id			alias for $9;
-	v_type_id			integer;
+        p_short_name                    alias for $3;
+        p_pretty_name                   alias for $4;
+        p_description                   alias for $5;
+        p_creation_date                 alias for $6;
+        p_creation_user                 alias for $7;
+        p_creation_ip                   alias for $8;
+        p_context_id                    alias for $9;
+        v_type_id                       integer;
 BEGIN
-	v_type_id:= acs_object__new (
-				    p_type_id,
-				    ''notification_type'',
-				    p_creation_date,
-				    p_creation_user,
-				    p_creation_ip,
-				    p_context_id);
+        v_type_id:= acs_object__new (
+                                    p_type_id,
+                                    ''notification_type'',
+                                    p_creation_date,
+                                    p_creation_user,
+                                    p_creation_ip,
+                                    p_context_id);
 
       insert into notification_types
       (type_id, sc_impl_id, short_name, pretty_name, description) values
@@ -150,30 +150,30 @@
 
 select define_function_args ('notification_request__new','request_id,object_type;notification_request,type_id,user_id,object_id,interval_id,delivery_method_id,format,creation_date,creation_user,creation_ip,context_id');
 
-create function notification_request__new (integer,varchar,integer,integer,integer,integer,varchar,timestamp,integer,varchar,integer)
+create function notification_request__new (integer,varchar,integer,integer,integer,integer,integer,varchar,timestamp,integer,varchar,integer)
 returns integer as '
 DECLARE
-	p_request_id				alias for $1;
-	p_object_type				alias for $2;
-	p_type_id				alias for $3;
-	p_user_id				alias for $4;
-	p_object_id				alias for $5;
-	p_interval_id				alias for $6;
-	p_delivery_method_id			alias for $7;
-	p_format				alias for $8;
-	p_creation_date				alias for $9;
-	p_creation_user				alias for $10;
-	p_creation_ip				alias for $11;
-	p_context_id				alias for $12;
-	v_request_id				integer;
+        p_request_id                            alias for $1;
+        p_object_type                           alias for $2;
+        p_type_id                               alias for $3;
+        p_user_id                               alias for $4;
+        p_object_id                             alias for $5;
+        p_interval_id                           alias for $6;
+        p_delivery_method_id                    alias for $7;
+        p_format                                alias for $8;
+        p_creation_date                         alias for $9;
+        p_creation_user                         alias for $10;
+        p_creation_ip                           alias for $11;
+        p_context_id                            alias for $12;
+        v_request_id                            integer;
 BEGIN
-	v_request_id:= acs_object__new (
-				       p_request_id,
-				       p_object_type,
-				       p_creation_date,
-				       p_creation_user,
-				       p_creation_ip,
-				       p_context_id);
+        v_request_id:= acs_object__new (
+                                       p_request_id,
+                                       p_object_type,
+                                       p_creation_date,
+                                       p_creation_user,
+                                       p_creation_ip,
+                                       p_context_id);
 
       insert into notification_requests
       (request_id, type_id, user_id, object_id, interval_id, delivery_method_id, format) values
Index: openacs.org-dev/packages/notifications/tcl/notification-email-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/notifications/tcl/notification-email-procs.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/notifications/tcl/notification-email-procs.tcl	9 Jul 2002 17:35:10 -0000	1.1.1.1
+++ openacs.org-dev/packages/notifications/tcl/notification-email-procs.tcl	25 Jul 2002 18:47:18 -0000	1.1.1.2
@@ -32,7 +32,7 @@
     ad_proc -private qmail_mail_queue_dir {} {
         return [get_parameter -name "EmailQmailQueue"]
     }
-    
+
     ad_proc -private parse_email_address {email} {
         if {![regexp {<([^>]*)>} $email all clean_email]} {
             return $email
@@ -68,7 +68,6 @@
         return [list $object_id $type_id]
     }
 
-
     ad_proc -public send {
         to_user_id
         reply_object_id
@@ -91,12 +90,12 @@
     ad_proc -private load_qmail_mail_queue {
         {-queue_dir:required}
     } {
-        Scans qmail incoming email queue and queues up messages 
-        using acs-mail.  
+        Scans qmail incoming email queue and queues up messages
+        using acs-mail.
 
         @Author dan.wickstrom@openforce.net, ben@openforce
         @creation-date 22 Sept, 2001
-    
+
         @param queue_dir The location of the qmail mail queue in
         the file-system.
     } {
@@ -109,7 +108,7 @@
 
         set list_of_reply_ids [list]
         set new_messages_p 0
-        
+
         foreach msg $messages {
             ns_log Notice "opening file: $msg"
             if [catch {set f [open $msg r]}] {
@@ -118,13 +117,13 @@
             set file [read $f]
             close $f
             set file [split $file "\n"]
-            
+
             set new_messages 1
             set end_of_headers_p 0
             set i 0
             set line [lindex $file $i]
             set headers [list]
-            
+
             # walk through the headers and extract each one
             while ![empty_string_p $line] {
                 set next_line [lindex $file [expr $i + 1]]
@@ -134,31 +133,31 @@
                 if {[regexp {^([^:]+):[ ]+(.+)$} $line match name value]} {
                     # join headers that span more than one line (e.g. Received)
                     if { ![regexp {^([^:]+):[ ]+(.+)$} $next_line match] && !$end_of_headers_p} {
-		        append line $next_line
-		        incr i
+                append line $next_line
+                incr i
                     }
                     lappend headers [string tolower $name] $value
-                    
+
                     if {$end_of_headers_p} {
-		        incr i
-		        break
+                incr i
+                break
                     }
                 } else {
                     # The headers and the body are delimited by a null line as specified by RFC822
                     if {[regexp {^[ ]*$} $line match]} {
-		        incr i
-		        break
+                incr i
+                break
                     }
                 }
                 incr i
-                set line [lindex $file $i]	    
+                set line [lindex $file $i]
             }
             set body "\n[join [lrange $file $i end] "\n"]"
-            
-            # okay now we have a list of headers and the body, let's 
+
+            # okay now we have a list of headers and the body, let's
             # put it into notifications stuff
             array set email_headers $headers
-            
+
             if [catch {set from $email_headers(from)}] {
                 set from ""
             }
@@ -180,7 +179,7 @@
                 }
                 continue
             }
-            
+
             set to_stuff [parse_reply_address -reply_address $to]
 
             # We don't accept a bad incoming email address
@@ -202,15 +201,15 @@
                         -from_user $from_user \
                         -subject $email_headers(subject) \
                         -content $body]
-                
-                catch {ns_unlink $msg}	
 
+                catch {ns_unlink $msg}
+
                 lappend list_of_reply_ids $reply_id
             } on_error {
                 ns_log Error "Error inserting incoming email into the queue"
             }
         }
-        
+
         return $list_of_reply_ids
     }
 
Index: openacs.org-dev/packages/notifications/tcl/notification-request-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/notifications/tcl/notification-request-procs-postgresql.xql,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/notifications/tcl/notification-request-procs-postgresql.xql	9 Jul 2002 17:35:10 -0000	1.1.1.1
+++ openacs.org-dev/packages/notifications/tcl/notification-request-procs-postgresql.xql	25 Jul 2002 18:47:18 -0000	1.1.1.2
@@ -9,4 +9,10 @@
         </querytext>
     </fullquery>
 
+    <fullquery name="notification::request::delete_all.delete_all_requests">
+        <querytext>
+            select notification_request__delete_all(:object_id);
+        </querytext>
+    </fullquery>
+
 </queryset>
Index: openacs.org-dev/packages/notifications/tcl/sweep-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/notifications/tcl/sweep-procs.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/notifications/tcl/sweep-procs.tcl	9 Jul 2002 17:35:10 -0000	1.1.1.1
+++ openacs.org-dev/packages/notifications/tcl/sweep-procs.tcl	25 Jul 2002 18:47:18 -0000	1.1.1.2
@@ -120,7 +120,7 @@
                     # Send it
                     notification::delivery::send -to_user_id [ns_set get $notif user_id] \
                             -notification_type_id [ns_set get $notif type_id] \
-                            -subject "\[[ad_system_name] - [ns_set get $notif object_name]\] [ns_set get $notif notif_subject]" \
+                            -subject "\[[ns_set get $notif object_name]\] [ns_set get $notif notif_subject]" \
                             -content [ns_set get $notif notif_text] \
                             -reply_object_id [ns_set get $notif response_id] \
                             -delivery_method_id [ns_set get $notif delivery_method_id]
Index: openacs.org-dev/packages/wp-slim/www/serve-slide.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/wp-slim/www/serve-slide.tcl,v
diff -u -r1.1.1.1 -r1.1.1.2
--- openacs.org-dev/packages/wp-slim/www/serve-slide.tcl	9 Jul 2002 17:35:19 -0000	1.1.1.1
+++ openacs.org-dev/packages/wp-slim/www/serve-slide.tcl	25 Jul 2002 18:47:44 -0000	1.1.1.2
@@ -88,6 +88,8 @@
 	# this is the only slide.
 	set href_back ""
 	set href_forward "<a href=\"$subsite_name/display/$pres_item_id\">top</a>"
+    } else { 
+        set href_forward {}
     }
 } else {
     set href_forward "<a href=\"$subsite_name/display/$pres_item_id/${next_slide_item_id}.wimpy\">next</a>"