Index: openacs-4/packages/notes/notes.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notes/notes.info,v
diff -u -r1.7 -r1.8
--- openacs-4/packages/notes/notes.info	11 Dec 2003 21:40:08 -0000	1.7
+++ openacs-4/packages/notes/notes.info	10 Feb 2004 19:47:34 -0000	1.8
@@ -7,7 +7,7 @@
     <initial-install-p>f</initial-install-p>
     <singleton-p>t</singleton-p>
 
-    <version name="0.12d" url="http://openacs.org/repository/download/apm/notes-0.12d.apm">
+    <version name="0.13d" url="http://openacs.org/repository/download/apm/notes-0.13d.apm">
     <database-support>
         <database>oracle</database>
         <database>postgresql</database>
@@ -20,38 +20,10 @@
         <description format="text/plain">This is a sample application for OpenACS 4.x to show how applications should be built, unfortunately it
         has not kept pace with current best practices.</description>
 
-        <requires url="acs-kernel" version="5.0d13"/>
+        <provides url="notes" version="0.13d"/>
+        <requires url="acs-kernel" version="5.0.0"/>
         <requires url="acs-templating" version="4.1.2"/>
 
-        <files>
-            <file type="package_spec" path="notes.info"/>
-            <file type="data_model_create" db_type="oracle" path="sql/oracle/notes-create.sql"/>
-            <file type="data_model_drop" db_type="oracle" path="sql/oracle/notes-drop.sql"/>
-            <file type="data_model_create" db_type="postgresql" path="sql/postgresql/notes-create.sql"/>
-            <file type="data_model_drop" db_type="postgresql" path="sql/postgresql/notes-drop.sql"/>
-            <file type="data_model" db_type="postgresql" path="sql/postgresql/notes-sc-create.sql"/>
-            <file type="data_model" db_type="postgresql" path="sql/postgresql/notes-sc-drop.sql"/>
-            <file type="tcl_procs" path="tcl/notes-procs.tcl"/>
-            <file type="content_page" path="www/add-disabled.gif"/>
-            <file type="query_file" db_type="oracle" path="www/add-edit-oracle.xql"/>
-            <file type="query_file" db_type="postgresql" path="www/add-edit-postgresql.xql"/>
-            <file type="content_page" path="www/add-edit.adp"/>
-            <file type="content_page" path="www/add-edit.tcl"/>
-            <file type="query_file" path="www/add-edit.xql"/>
-            <file type="content_page" path="www/add.gif"/>
-            <file type="content_page" path="www/blank.gif"/>
-            <file type="query_file" db_type="oracle" path="www/delete-oracle.xql"/>
-            <file type="query_file" db_type="postgresql" path="www/delete-postgresql.xql"/>
-            <file type="content_page" path="www/delete.tcl"/>
-            <file type="query_file" db_type="oracle" path="www/index-oracle.xql"/>
-            <file type="query_file" db_type="postgresql" path="www/index-postgresql.xql"/>
-            <file type="content_page" path="www/index.adp"/>
-            <file type="content_page" path="www/index.tcl"/>
-            <file path="www/view-one.adp"/>
-            <file type="tcl_util" path="www/view-one.tcl"/>
-            <file type="content_page" path="www/x-disabled.gif"/>
-            <file type="content_page" path="www/x.gif"/>
-        </files>
         <parameters>
         <!-- No version parameters -->
         </parameters>
Index: openacs-4/packages/notes/sql/oracle/notes-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notes/sql/oracle/notes-create.sql,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/notes/sql/oracle/notes-create.sql	30 Sep 2003 12:10:08 -0000	1.4
+++ openacs-4/packages/notes/sql/oracle/notes-create.sql	10 Feb 2004 19:47:35 -0000	1.5
@@ -12,9 +12,9 @@
     object_type => 'note',
     pretty_name => 'Note',
     pretty_plural => 'Notes',
-    table_name => 'NOTES',
-    id_column => 'NOTE_ID',
-	name_method => 'NOTE.NAME'
+    table_name => 'notes',
+    id_column => 'note_id',
+	name_method => 'note.name'
   );
 end;
 /
@@ -25,15 +25,15 @@
 begin
   attr_id := acs_attribute.create_attribute (
     object_type => 'note',
-    attribute_name => 'TITLE',
+    attribute_name => 'title',
     pretty_name => 'Title',
     pretty_plural => 'Titles',
     datatype => 'string'
   );
 
   attr_id := acs_attribute.create_attribute (
     object_type => 'note',
-    attribute_name => 'BODY',
+    attribute_name => 'body',
     pretty_name => 'Body',
     pretty_plural => 'Bodies',
     datatype => 'string'
@@ -44,16 +44,14 @@
 
 create table notes (
     note_id    integer references acs_objects(object_id) primary key,
-    owner_id   integer references users(user_id),
     title      varchar(255) not null,
-    body       varchar(1024)
+    body       varchar(4000)
 );
 
 create or replace package note
 as
     function new (
         note_id             in notes.note_id%TYPE default null,
-	owner_id            in notes.owner_id%TYPE default null,
 	title               in notes.title%TYPE,
 	body                in notes.body%TYPE,
 	object_type         in acs_object_types.object_type%TYPE
@@ -81,7 +79,6 @@
 as
     function new (
         note_id             in notes.note_id%TYPE default null,
-        owner_id            in notes.owner_id%TYPE default null,
         title               in notes.title%TYPE,
         body                in notes.body%TYPE,
         object_type         in acs_object_types.object_type%TYPE
@@ -106,13 +103,13 @@
          );
 
          insert into notes
-          (note_id, owner_id, title, body)
+          (note_id, title, body)
          values
-          (v_note_id, owner_id, title, body);
+          (v_note_id, title, body);
 
 		 acs_permission.grant_permission(
            object_id => v_note_id,
-           grantee_id => owner_id,
+           grantee_id => creation_user,
            privilege => 'admin'
          );
 
Index: openacs-4/packages/notes/sql/oracle/upgrade/upgrade-0.12d-0.13d.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notes/sql/oracle/upgrade/upgrade-0.12d-0.13d.sql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/notes/sql/oracle/upgrade/upgrade-0.12d-0.13d.sql	10 Feb 2004 19:47:35 -0000	1.1
@@ -0,0 +1,99 @@
+create or replace package note
+as
+    function new (
+        note_id             in notes.note_id%TYPE default null,
+	title               in notes.title%TYPE,
+	body                in notes.body%TYPE,
+	object_type         in acs_object_types.object_type%TYPE
+			       default 'note',
+	creation_date       in acs_objects.creation_date%TYPE
+                               default sysdate,
+        creation_user       in acs_objects.creation_user%TYPE
+                               default null,
+        creation_ip         in acs_objects.creation_ip%TYPE default null,
+        context_id          in acs_objects.context_id%TYPE default null
+    ) return notes.note_id%TYPE;
+
+    procedure del (
+         note_id      in notes.note_id%TYPE
+    );
+
+	function name (
+		note_id			in notes.note_id%TYPE
+	) return notes.title%TYPE;
+end note;
+/
+show errors
+
+create or replace package body note
+as
+    function new (
+        note_id             in notes.note_id%TYPE default null,
+        title               in notes.title%TYPE,
+        body                in notes.body%TYPE,
+        object_type         in acs_object_types.object_type%TYPE
+			       default 'note',
+        creation_date       in acs_objects.creation_date%TYPE
+                                default sysdate,
+        creation_user       in acs_objects.creation_user%TYPE
+                                default null,
+        creation_ip         in acs_objects.creation_ip%TYPE default null,
+        context_id          in acs_objects.context_id%TYPE default null
+    ) return notes.note_id%TYPE
+    is
+        v_note_id integer;
+     begin
+        v_note_id := acs_object.new (
+            object_id => note_id,
+            object_type => object_type,
+            creation_date => creation_date,
+            creation_user => creation_user,
+            creation_ip => creation_ip,
+            context_id => context_id
+         );
+
+         insert into notes
+          (note_id, title, body)
+         values
+          (v_note_id, title, body);
+
+		 acs_permission.grant_permission(
+           object_id => v_note_id,
+           grantee_id => creation_user,
+           privilege => 'admin'
+         );
+
+         return v_note_id;
+     end new;
+
+     procedure del (
+         note_id      in notes.note_id%TYPE
+     )
+     is
+     begin
+		 delete from acs_permissions
+		 where object_id = note.del.note_id;
+         
+         delete from notes
+         where note_id = note.del.note_id;
+
+         acs_object.del(note_id);
+     end del;
+
+	 function name (
+		note_id			in notes.note_id%TYPE
+	 ) return notes.title%TYPE
+	 is
+		v_note_name		notes.title%TYPE;
+	 begin
+		select title into v_note_name
+			from notes
+			where note_id = name.note_id;
+
+		return v_note_name;
+	 end name;
+end note;
+/
+show errors;
+
+alter table notes drop column owner_id;
Index: openacs-4/packages/notes/sql/postgresql/notes-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notes/sql/postgresql/notes-create.sql,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/notes/sql/postgresql/notes-create.sql	17 May 2003 10:51:28 -0000	1.5
+++ openacs-4/packages/notes/sql/postgresql/notes-create.sql	10 Feb 2004 19:47:36 -0000	1.6
@@ -12,17 +12,17 @@
 returns integer as '
 begin
     PERFORM acs_object_type__create_type (
-	''note'',			-- object_type
-	''Note'',			-- pretty_name
-	''Notes'',			-- pretty_plural
-	''acs_object'',		-- supertype
-	''notes'',			-- table_name
-	''note_id'',		-- id_column
-	null,				-- package_name
-	''f'',				-- abstract_p
-	null,				-- type_extension_table
-	''note.name''		-- name_method
-	);
+    ''note'',                  -- object_type
+    ''Note'',                  -- pretty_name
+    ''Notes'',                 -- pretty_plural
+    ''acs_object'',            -- supertype
+    ''notes'',                 -- table_name
+    ''note_id'',               -- id_column
+    null,                      -- package_name
+    ''f'',                     -- abstract_p
+    null,                      -- type_extension_table
+    ''note.name''              -- name_method
+    );
 
     return 0;
 end;' language 'plpgsql';
@@ -35,36 +35,36 @@
 returns integer as '
 begin
     PERFORM acs_attribute__create_attribute (
-	  ''note'',				-- object_type
-	  ''TITLE'',			-- attribute_name
-	  ''string'',			-- datatype
-	  ''Title'',			-- pretty_name
-	  ''Titles'',			-- pretty_plural
-	  null,					-- table_name
-	  null,					-- column_name
-	  null,					-- default_value
-	  1,					-- min_n_values
-	  1,					-- max_n_values
-	  null,					-- sort_order
-	  ''type_specific'',	-- storage
-	  ''f''					-- static_p
-	);
+      ''note'',                -- object_type
+      ''title'',               -- attribute_name
+      ''string'',              -- datatype
+      ''Title'',               -- pretty_name
+      ''Titles'',              -- pretty_plural
+      null,                    -- table_name
+      null,                    -- column_name
+      null,                    -- default_value
+      1,                       -- min_n_values
+      1,                       -- max_n_values
+      null,                    -- sort_order
+      ''type_specific'',       -- storage
+      ''f''                    -- static_p
+    );
 
     PERFORM acs_attribute__create_attribute (
-	  ''note'',				-- object_type
-	  ''BODY'',				-- attribute_name
-	  ''string'',			-- datatype
-	  ''Body'',				-- pretty_name
-	  ''Bodies'',			-- pretty_plural
-	  null,					-- table_name
-	  null,					-- column_name
-	  null,					-- default_value
-	  1,					-- min_n_values
-	  1,					-- max_n_values
-	  null,					-- sort_order
-	  ''type_specific'',	-- storage
-	  ''f''					-- static_p
-	);
+      ''note'',                -- object_type
+      ''body'',                -- attribute_name
+      ''string'',              -- datatype
+      ''Body'',                -- pretty_name
+      ''Bodies'',              -- pretty_plural
+      null,                    -- table_name
+      null,                    -- column_name
+      null,                    -- default_value
+      1,                       -- min_n_values
+      1,                       -- max_n_values
+      null,                    -- sort_order
+      ''type_specific'',       -- storage
+      ''f''                    -- static_p
+    );
 
     return 0;
 end;' language 'plpgsql';
@@ -75,72 +75,72 @@
 
 create table notes (
     note_id    integer 
-			   constraint notes_note_id_fk
-			   references acs_objects(object_id) 
-			   constraint notes_note_id_pk
-			   primary key,
-    owner_id   integer 
-			   constraint notes_owner_id_fk
-			   references users(user_id),
+               constraint notes_note_id_fk
+               references acs_objects(object_id) 
+               constraint notes_note_id_pk
+               primary key,
     title      varchar(255) 
-			   constraint notes_title_nn
-			   not null,
-    body       varchar(1024)
+               constraint notes_title_nn
+               not null,
+    body       text
 );
 
-create function note__new (integer,integer,varchar,varchar,varchar,timestamptz,integer,varchar,integer)
+select define_function_args('note__new','note_id,title,body,object_type;note,creation_date;now,creation_user,creation_ip,context_id');
+
+create function note__new (integer,varchar,varchar,varchar,timestamptz,integer,varchar,integer)
 returns integer as '
 declare
-  p_note_id					alias for $1;       -- default null
-  p_owner_id				alias for $2;       -- default null
-  p_title					alias for $3;
-  p_body					alias for $4;
-  p_object_type				alias for $5;       -- default ''note''
-  p_creation_date			alias for $6;		-- default now()
-  p_creation_user			alias for $7;		-- default null
-  p_creation_ip				alias for $8;		-- default null
-  p_context_id				alias for $9;		-- default null
-  v_note_id					notes.note_id%TYPE;
+  p_note_id                    alias for $1;       -- default null
+  p_title                      alias for $2;
+  p_body                       alias for $3;
+  p_object_type                alias for $4;       -- default ''note''
+  p_creation_date              alias for $5;        -- default now()
+  p_creation_user              alias for $6;        -- default null
+  p_creation_ip                alias for $7;        -- default null
+  p_context_id                 alias for $8;        -- default null
+  v_note_id                    notes.note_id%TYPE;
 begin
-	v_note_id := acs_object__new (
-		p_note_id,
-		p_object_type,
-		p_creation_date,
-		p_creation_user,
-		p_creation_ip,
-		p_context_id
-	);
+    v_note_id := acs_object__new (
+        p_note_id,
+        p_object_type,
+        p_creation_date,
+        p_creation_user,
+        p_creation_ip,
+        p_context_id
+    );
 
-	insert into notes
-	  (note_id, owner_id, title, body)
-	values
-	  (v_note_id, p_owner_id, p_title, p_body);
+    insert into notes
+      (note_id, title, body)
+    values
+      (v_note_id, p_title, p_body);
 
-	PERFORM acs_permission__grant_permission(
+    PERFORM acs_permission__grant_permission(
           v_note_id,
-          p_owner_id,
+          p_creation_user,
           ''admin''
     );
 
-	return v_note_id;
+    return v_note_id;
 
 end;' language 'plpgsql';
 
-create function note__delete (integer)
+select define_function_args('note__del','note_id');
+
+create function note__del (integer)
 returns integer as '
 declare
-  p_note_id				alias for $1;
+  p_note_id                alias for $1;
 begin
     delete from acs_permissions
-		   where object_id = p_note_id;
+           where object_id = p_note_id;
 
-	delete from notes
-		   where note_id = p_note_id;
+    delete from notes
+           where note_id = p_note_id;
 
-	raise NOTICE ''Deleting note...'';
-	PERFORM acs_object__delete(p_note_id);
+    raise NOTICE ''Deleting note...'';
+    PERFORM acs_object__delete(p_note_id);
 
-	return 0;
+    return 0;
 
 end;' language 'plpgsql';
 
@@ -150,9 +150,9 @@
     p_note_id      alias for $1;
     v_note_name    notes.title%TYPE;
 begin
-	select title into v_note_name
-		from notes
-		where note_id = p_note_id;
+    select title into v_note_name
+        from notes
+        where note_id = p_note_id;
 
     return v_note_name;
 end;
Index: openacs-4/packages/notes/sql/postgresql/notes-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notes/sql/postgresql/notes-drop.sql,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/notes/sql/postgresql/notes-drop.sql	17 May 2003 10:51:28 -0000	1.6
+++ openacs-4/packages/notes/sql/postgresql/notes-drop.sql	10 Feb 2004 19:47:36 -0000	1.7
@@ -7,8 +7,8 @@
 \i notes-sc-drop.sql 
 
 --drop functions
-drop function note__new (integer,integer,varchar,varchar,varchar,timestamptz,integer,varchar,integer);
-drop function note__delete (integer);
+drop function note__new (integer,varchar,varchar,varchar,timestamptz,integer,varchar,integer);
+drop function note__del(integer);
 drop function note__name (integer);
 
 --drop permissions
Index: openacs-4/packages/notes/sql/postgresql/notes-sc-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notes/sql/postgresql/notes-sc-create.sql,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/notes/sql/postgresql/notes-sc-create.sql	30 Dec 2002 12:06:11 -0000	1.3
+++ openacs-4/packages/notes/sql/postgresql/notes-sc-create.sql	10 Feb 2004 19:47:36 -0000	1.4
@@ -33,21 +33,21 @@
 
 
 create function notes__itrg ()
-returns opaque as '
+returns trigger as '
 begin
     perform search_observer__enqueue(new.note_id,''INSERT'');
     return new;
 end;' language 'plpgsql';
 
 create function notes__dtrg ()
-returns opaque as '
+returns trigger as '
 begin
     perform search_observer__enqueue(old.note_id,''DELETE'');
     return old;
 end;' language 'plpgsql';
 
 create function notes__utrg ()
-returns opaque as '
+returns trigger as '
 begin
     perform search_observer__enqueue(old.note_id,''UPDATE'');
     return old;
@@ -62,8 +62,3 @@
 
 create trigger notes__utrg after update on notes
 for each row execute procedure notes__utrg (); 
-
-
-
-
-
Index: openacs-4/packages/notes/sql/postgresql/upgrade/upgrade-0.12d-0.13d.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notes/sql/postgresql/upgrade/upgrade-0.12d-0.13d.sql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/notes/sql/postgresql/upgrade/upgrade-0.12d-0.13d.sql	10 Feb 2004 19:47:36 -0000	1.1
@@ -0,0 +1,40 @@
+select define_function_args('note__new','note_id,title,body,object_type;note,creation_date;now,creation_user,creation_ip,context_id');
+
+create or replace function note__new (integer,varchar,varchar,varchar,timestamptz,integer,varchar,integer)
+returns integer as '
+declare
+  p_note_id                    alias for $1;       -- default null
+  p_title                      alias for $2;
+  p_body                       alias for $3;
+  p_object_type                alias for $4;       -- default ''note''
+  p_creation_date              alias for $5;        -- default now()
+  p_creation_user              alias for $6;        -- default null
+  p_creation_ip                alias for $7;        -- default null
+  p_context_id                 alias for $8;        -- default null
+  v_note_id                    notes.note_id%TYPE;
+begin
+    v_note_id := acs_object__new (
+        p_note_id,
+        p_object_type,
+        p_creation_date,
+        p_creation_user,
+        p_creation_ip,
+        p_context_id
+    );
+
+    insert into notes
+      (note_id, title, body)
+    values
+      (v_note_id, p_title, p_body);
+
+    PERFORM acs_permission__grant_permission(
+          v_note_id,
+          p_creation_user,
+          ''admin''
+    );
+
+    return v_note_id;
+
+end;' language 'plpgsql';
+
+alter table notes drop column owner_id;