Index: openacs-4/packages/notes/notes.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notes/notes.info,v
diff -u -N -r1.1 -r1.2
--- openacs-4/packages/notes/notes.info 20 Apr 2001 20:51:11 -0000 1.1
+++ openacs-4/packages/notes/notes.info 3 May 2001 18:23:34 -0000 1.2
@@ -18,17 +18,27 @@
This is a sample application for ACS 4.x.
+
+
+
+
+
+
+
+
+
+
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 -N -r1.1 -r1.2
--- openacs-4/packages/notes/sql/oracle/notes-create.sql 20 Apr 2001 20:51:11 -0000 1.1
+++ openacs-4/packages/notes/sql/oracle/notes-create.sql 3 May 2001 18:23:34 -0000 1.2
@@ -105,6 +105,12 @@
values
(v_note_id, owner_id, title, body);
+ acs_permission.grant_permission(
+ object_id => v_note_id,
+ grantee_id => owner_id,
+ privilege => 'admin'
+ );
+
return v_note_id;
end new;
@@ -113,6 +119,9 @@
)
is
begin
+ delete from acs_permissions
+ where object_id = note.delete.note_id;
+
delete from notes
where note_id = note.delete.note_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 -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/notes/sql/postgresql/notes-create.sql 3 May 2001 18:23:35 -0000 1.1
@@ -0,0 +1,241 @@
+--
+-- packages/notes/sql/notes-create.sql
+--
+-- @author rhs@mit.edu
+-- @creation-date 2000-10-22
+-- @cvs-id $Id: notes-create.sql,v 1.1 2001/05/03 18:23:35 vinodk Exp $
+--
+
+create function inline_0 ()
+returns integer as '
+begin
+ PERFORM acs_object_type__create_type (
+ ''note'',
+ ''Note'',
+ ''Notes'',
+ ''acs_object'',
+ ''notes'',
+ ''note_id'',
+ null,
+ ''f'',
+ null,
+ null
+ );
+
+ return 0;
+end;' language 'plpgsql';
+
+select inline_0 ();
+
+drop function inline_0 ();
+
+--begin
+-- acs_object_type.create_type (
+-- supertype => 'acs_object',
+-- object_type => 'note',
+-- pretty_name => 'Note',
+-- pretty_plural => 'Notes',
+-- table_name => 'NOTES',
+-- id_column => 'NOTE_ID'
+-- );
+--end;
+--/
+--show errors;
+
+create function inline_1 ()
+returns integer as '
+begin
+ PERFORM acs_attribute__create_attribute (
+ ''note'',
+ ''TITLE'',
+ ''string'',
+ ''Title'',
+ ''Titles'',
+ null,
+ null,
+ null,
+ 1,
+ 1,
+ null,
+ ''type_specific'',
+ ''f''
+ );
+
+ PERFORM acs_attribute__create_attribute (
+ ''note'',
+ ''BODY'',
+ ''string'',
+ ''Body'',
+ ''Bodies'',
+ null,
+ null,
+ null,
+ 1,
+ 1,
+ null,
+ ''type_specific'',
+ ''f''
+ );
+
+ return 0;
+end;' language 'plpgsql';
+
+select inline_1 ();
+
+drop function inline_1 ();
+
+--declare
+-- attr_id acs_attributes.attribute_id%TYPE;
+--
+--begin
+-- attr_id := acs_attribute.create_attribute (
+-- object_type => 'note',
+-- attribute_name => 'TITLE',
+-- pretty_name => 'Title',
+-- pretty_plural => 'Titles',
+-- datatype => 'string'
+-- );
+--
+-- attr_id := acs_attribute.create_attribute (
+-- object_type => 'note',
+-- attribute_name => 'BODY',
+-- pretty_name => 'Body',
+-- pretty_plural => 'Bodies',
+-- datatype => 'string'
+-- );
+--end;
+--/
+--show errors;
+
+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)
+);
+
+create function note__new (integer,integer,varchar,varchar,varchar,timestamp,integer,varchar,integer)
+returns integer as '
+declare
+ new__note_id alias for $1; -- default null
+ new__owner_id alias for $2; -- default null
+ new__title alias for $3;
+ new__body alias for $4;
+ new__object_type alias for $5; -- default ''note''
+ new__creation_date alias for $6; -- default now()
+ new__creation_user alias for $7; -- default null
+ new__creation_ip alias for $8; -- default null
+ new__context_id alias for $9; -- default null
+ v_note_id notes.note_id%TYPE;
+begin
+ v_note_id := acs_object__new (
+ new__note_id,
+ new__object_type,
+ new__creation_date,
+ new__creation_user,
+ new__creation_ip,
+ new__context_id
+ );
+
+ insert into notes
+ (note_id, owner_id, title, body)
+ values
+ (v_note_id, new__owner_id, new__title, new__body);
+
+ PERFORM acs_permission__grant_permission(
+ v_note_id,
+ new__owner_id,
+ ''admin''
+ );
+
+ return v_note_id;
+
+end;' language 'plpgsql';
+
+create function note__delete (integer)
+returns integer as '
+declare
+ delete__note_id alias for $1;
+begin
+ delete from acs_permissions
+ where object_id = delete__note_id;
+
+ delete from notes
+ where note_id = delete__note_id;
+
+ raise NOTICE ''Deleting note...'';
+ PERFORM acs_object__delete(delete__note_id);
+
+ return 0;
+
+end;' language 'plpgsql';
+
+--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 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 delete (
+-- note_id in notes.note_id%TYPE
+-- );
+--end note;
+--/
+--show errors
+--
+--create or replace package body 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 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, owner_id, title, body)
+-- values
+-- (v_note_id, owner_id, title, body);
+--
+-- return v_note_id;
+-- end new;
+--
+-- procedure delete (
+-- note_id in notes.note_id%TYPE
+-- )
+-- is
+-- begin
+-- delete from notes
+-- where note_id = note.delete.note_id;
+--
+-- acs_object.delete(note_id);
+-- end delete;
+--
+--end note;
+--/
+--show errors;
+
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 -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/notes/sql/postgresql/notes-drop.sql 3 May 2001 18:23:35 -0000 1.1
@@ -0,0 +1,24 @@
+--drop package note;
+drop function note__new (integer,integer,varchar,varchar,varchar,timestamp,integer,varchar,integer);
+drop function note__delete (integer);
+
+drop table notes;
+
+select acs_attribute__drop_attribute (
+ 'note',
+ 'TITLE'
+ );
+
+select acs_attribute__drop_attribute (
+ 'note',
+ 'BODY'
+ );
+
+
+--execute acs_object_type.drop_type('note');
+select acs_object_type__drop_type(
+ 'note',
+ 'f'
+ );
+
+--show errors
Index: openacs-4/packages/notes/www/add-edit-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notes/www/Attic/add-edit-oracle.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/notes/www/add-edit-oracle.xql 3 May 2001 18:23:35 -0000 1.1
@@ -0,0 +1,25 @@
+
+
+
+ oracle8.1.6
+
+
+
+
+ declare
+ id integer;
+ begin
+ id := note.new(
+ owner_id => :user_id,
+ title => :title,
+ body => :body,
+ creation_user => :user_id,
+ creation_ip => :peeraddr,
+ context_id => :package_id
+ );
+
+
+
+
+
+
Index: openacs-4/packages/notes/www/add-edit-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notes/www/Attic/add-edit-postgresql.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/notes/www/add-edit-postgresql.xql 3 May 2001 18:23:35 -0000 1.1
@@ -0,0 +1,25 @@
+
+
+
+ postgresql7.1
+
+
+
+
+ select note__new(
+ null,
+ :user_id,
+ :title,
+ :body,
+ 'note',
+ now(),
+ :user_id,
+ :peeraddr,
+ :package_id
+ );
+
+
+
+
+
+
Index: openacs-4/packages/notes/www/add-edit.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notes/www/add-edit.tcl,v
diff -u -N -r1.1 -r1.2
--- openacs-4/packages/notes/www/add-edit.tcl 20 Apr 2001 20:51:11 -0000 1.1
+++ openacs-4/packages/notes/www/add-edit.tcl 3 May 2001 18:23:35 -0000 1.2
@@ -66,7 +66,7 @@
where note_id = :note_id
}
} else {
- db_dml new_note {
+ db_exec_plsql new_note {
declare
id integer;
begin
@@ -78,12 +78,6 @@
creation_ip => :peeraddr,
context_id => :package_id
);
-
- acs_permission.grant_permission(
- object_id => id,
- grantee_id => :user_id,
- privilege => 'admin'
- );
end;
}
}
Index: openacs-4/packages/notes/www/add-edit.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notes/www/add-edit.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/notes/www/add-edit.xql 3 May 2001 18:23:35 -0000 1.1
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+ select title, body
+ from notes
+ where note_id = :note_id
+
+
+
+
+
+
+
+
+ update notes
+ set title = :title,
+ body = :body
+ where note_id = :note_id
+
+
+
+
+
+
Index: openacs-4/packages/notes/www/delete-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notes/www/delete-oracle.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/notes/www/delete-oracle.xql 3 May 2001 18:23:35 -0000 1.1
@@ -0,0 +1,17 @@
+
+
+
+ oracle8.1.6
+
+
+
+
+ begin
+ note.delete(:note_id);
+ end;
+
+
+
+
+
+
Index: openacs-4/packages/notes/www/delete-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notes/www/delete-postgresql.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/notes/www/delete-postgresql.xql 3 May 2001 18:23:35 -0000 1.1
@@ -0,0 +1,15 @@
+
+
+
+ postgresql7.1
+
+
+
+
+ select note__delete( :note_id );
+
+
+
+
+
+
Index: openacs-4/packages/notes/www/delete.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notes/www/delete.tcl,v
diff -u -N -r1.1 -r1.2
--- openacs-4/packages/notes/www/delete.tcl 20 Apr 2001 20:51:11 -0000 1.1
+++ openacs-4/packages/notes/www/delete.tcl 3 May 2001 18:23:35 -0000 1.2
@@ -11,11 +11,8 @@
ad_require_permission $note_id delete
-db_dml note_delete {
+db_exec_plsql note_delete {
begin
- delete from acs_permissions
- where object_id = :note_id;
-
note.delete(:note_id);
end;
}
Index: openacs-4/packages/notes/www/index-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notes/www/index-oracle.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/notes/www/index-oracle.xql 3 May 2001 18:23:35 -0000 1.1
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+ select note_id, owner_id, title, body,
+ decode(acs_permission.permission_p(note_id,
+ :user_id,
+ 'write'),
+ 't', 1,
+ 'f', 0) as write_p,
+ decode(acs_permission.permission_p(note_id,
+ :user_id,
+ 'admin'),
+ 't', 1,
+ 'f', 0) as admin_p,
+ decode(acs_permission.permission_p(note_id,
+ :user_id,
+ 'delete'),
+ 't', 1,
+ 'f', 0) as delete_p
+ from notes n, acs_objects o
+ where n.note_id = o.object_id
+ and o.context_id = :package_id
+ and acs_permission.permission_p(note_id, :user_id, 'read') = 't'
+ order by creation_date
+
+
+
+
+
+
Index: openacs-4/packages/notes/www/index-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notes/www/index-postgresql.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/notes/www/index-postgresql.xql 3 May 2001 18:23:35 -0000 1.1
@@ -0,0 +1,24 @@
+
+
+ postgresql7.1
+
+
+
+ select note_id, owner_id, title, body,
+ case when acs_permission__permission_p(note_id,:user_id,'write')='t'
+ then 1 else 0 end as write_p,
+ case when acs_permission__permission_p(note_id,:user_id,'admin')='t'
+ then 1 else 0 end as admin_p,
+ case when acs_permission__permission_p(note_id,:user_id,'delete')='t'
+ then 1 else 0 end as delete_p
+ from notes n, acs_objects o
+ where n.note_id = o.object_id
+ and o.context_id = :package_id
+ and acs_permission__permission_p(note_id, :user_id, 'read') = 't'
+ order by creation_date
+
+
+
+
+
+