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;
