Index: openacs-4/packages/attachments/attachments.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attachments/attachments.info,v diff -u -r1.5 -r1.6 --- openacs-4/packages/attachments/attachments.info 12 Jul 2002 14:19:06 -0000 1.5 +++ openacs-4/packages/attachments/attachments.info 30 Aug 2002 14:44:04 -0000 1.6 @@ -7,25 +7,28 @@ f t - + oracle postgresql Arjun Sanyal Attachments + 2002-08-29 OpenForce, Inc. Attachments - + + + @@ -54,6 +57,7 @@ + Index: openacs-4/packages/attachments/sql/oracle/attachments-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attachments/sql/oracle/attachments-create.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/attachments/sql/oracle/attachments-create.sql 9 Aug 2002 20:51:49 -0000 1.3 +++ openacs-4/packages/attachments/sql/oracle/attachments-create.sql 30 Aug 2002 14:44:06 -0000 1.4 @@ -32,11 +32,17 @@ create table attachments ( object_id constraint attachments_object_id_fk - references acs_objects(object_id) + references acs_objects (object_id) on delete cascade, item_id constraint attachments_item_id_fk - references acs_objects(object_id) + references acs_objects (object_id) on delete cascade, + approved_p char(1) + default 't' + constraint attachments_approved_p_ck + check (approved_p in ('t', 'f')) + constraint attachments_approved_p_nn + not null, constraint attachments_pk primary key (object_id, item_id) ); Index: openacs-4/packages/attachments/sql/oracle/upgrade/upgrade-0.1d-0.2.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attachments/sql/oracle/upgrade/upgrade-0.1d-0.2.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/attachments/sql/oracle/upgrade/upgrade-0.1d-0.2.sql 30 Aug 2002 14:44:07 -0000 1.1 @@ -0,0 +1,16 @@ +-- +-- upgrade attachments to include approved_p column +-- +-- @author yon@openforce.net +-- @creation-date 2002-08-29 +-- @version $Id: upgrade-0.1d-0.2.sql,v 1.1 2002/08/30 14:44:07 arjun Exp $ +-- + +alter table attachments add ( + approved_p char(1) + default 't' + constraint attachments_approved_p_ck + check (approved_p in ('t', 'f')) + constraint attachments_approved_p_nn + not null +); Index: openacs-4/packages/attachments/sql/postgresql/attachments-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attachments/sql/postgresql/attachments-create.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/attachments/sql/postgresql/attachments-create.sql 9 Aug 2002 20:51:49 -0000 1.2 +++ openacs-4/packages/attachments/sql/postgresql/attachments-create.sql 30 Aug 2002 14:44:08 -0000 1.3 @@ -41,6 +41,12 @@ constraint attachments_item_id_fk references acs_objects(object_id) on delete cascade, + approved_p char(1) + default 't' + constraint attachments_approved_p_ck + check (approved_p in ('t', 'f')) + constraint attachments_approved_p_nn + not null, constraint attachments_pk primary key (object_id, item_id) ); Index: openacs-4/packages/attachments/tcl/attachments-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attachments/tcl/Attic/attachments-procs-oracle.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/attachments/tcl/attachments-procs-oracle.xql 2 Jul 2002 19:41:20 -0000 1.1 +++ openacs-4/packages/attachments/tcl/attachments-procs-oracle.xql 30 Aug 2002 14:44:08 -0000 1.2 @@ -1,12 +1,25 @@ -oracle8.1.6 + oracle8.1.6 - - -select item_id, acs_object.name(item_id) from attachments -where object_id= :object_id - - + + + select item_id, + acs_object.name(item_id) + from attachments + where object_id = :object_id + and approved_p = 't' + + + + + select item_id, + acs_object.name(item_id), + approved_p + from attachments + where object_id = :object_id + + + Index: openacs-4/packages/attachments/tcl/attachments-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attachments/tcl/Attic/attachments-procs-postgresql.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/attachments/tcl/attachments-procs-postgresql.xql 12 Jul 2002 14:19:26 -0000 1.1 +++ openacs-4/packages/attachments/tcl/attachments-procs-postgresql.xql 30 Aug 2002 14:44:08 -0000 1.2 @@ -1,12 +1,25 @@ -postgresql7.1 + postgresql7.1 - - -select item_id, acs_object__name(item_id) from attachments -where object_id= :object_id - - + + + select item_id, + acs_object__name(item_id) + from attachments + where object_id = :object_id + and approved_p = 't' + + + + + select item_id, + acs_object__name(item_id), + approved_p + from attachments + where object_id = :object_id + + + Index: openacs-4/packages/attachments/tcl/attachments-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attachments/tcl/attachments-procs.tcl,v diff -u -r1.7 -r1.8 --- openacs-4/packages/attachments/tcl/attachments-procs.tcl 9 Aug 2002 20:51:49 -0000 1.7 +++ openacs-4/packages/attachments/tcl/attachments-procs.tcl 30 Aug 2002 14:44:08 -0000 1.8 @@ -1,11 +1,10 @@ -# Copyright (C) 2001, 2002 MIT # -# this is free software; you can redistribute it and/or modify it under the +# This is free software; you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later # version. # -# this is distributed in the hope that it will be useful, but WITHOUT ANY +# This is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. @@ -69,6 +68,7 @@ ad_proc -public attach { {-object_id:required} {-attachment_id:required} + {-approved_p t} } { perform the attachment } { @@ -84,6 +84,20 @@ db_dml delete_attachment {} } + ad_proc -public toggle_approved { + {-object_id:required} + {-item_id:required} + {-approved_p ""} + } { + toggle approved_p for attachment + } { + if {[empty_string_p $approved_p]} { + set approved_p [ad_decode [db_string select_attachment_approved_p {}] f t f] + } + + db_dml toggle_approved_p {} + } + ad_proc -public get_package_key {} { return attachments } @@ -125,7 +139,7 @@ {-object_id:required} {-base_url ""} } { - returns a list of attachment ids and names + returns a list of attachment ids and names which are approved: {item_id name url} } { set lst [db_list_of_lists select_attachments {}] set lst_with_urls [list] @@ -138,6 +152,23 @@ return $lst_with_urls } + ad_proc -public get_all_attachments { + {-object_id:required} + {-base_url ""} + } { + returns a list of attachment ids and names: {item_id name approved_p url} + } { + set lst [db_list_of_lists select_attachments {}] + set lst_with_urls [list] + + foreach el $lst { + set append_lst [list [goto_attachment_url -object_id $object_id -attachment_id [lindex $el 0] -base_url $base_url]] + lappend lst_with_urls [concat $el $append_lst] + } + + return $lst_with_urls + } + ad_proc -public context_bar { {-folder_id:required} {-final ""} Index: openacs-4/packages/attachments/tcl/attachments-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attachments/tcl/attachments-procs.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/attachments/tcl/attachments-procs.xql 2 Jul 2002 19:41:20 -0000 1.2 +++ openacs-4/packages/attachments/tcl/attachments-procs.xql 30 Aug 2002 14:44:08 -0000 1.3 @@ -1,58 +1,76 @@ - - -select 1 from attachments_fs_root_folder_map -where package_id = :package_id - - + + + select 1 + from attachments_fs_root_folder_map + where package_id = :package_id + + - - -select folder_id from attachments_fs_root_folder_map -where package_id = :package_id - - + + + select folder_id + from attachments_fs_root_folder_map + where package_id = :package_id + + - - -insert into attachments_fs_root_folder_map -(package_id, folder_id) -values -(:package_id, :folder_id) - - + + + insert + into attachments_fs_root_folder_map + (package_id, folder_id) + values + (:package_id, :folder_id) + + - - -delete from attachments_fs_root_folder_map where -package_id = :package_id and -folder_id = :folder_id - - + + + delete + from attachments_fs_root_folder_map + where package_id = :package_id and + folder_id = :folder_id + + - - -insert into attachments -(object_id, item_id) values -(:object_id, :attachment_id) - - + + + insert + into attachments + (object_id, item_id, approved_p) + values + (:object_id, :attachment_id, :approved_p) + + - - -delete from attachments -where object_id = :object_id and -item_id = :attachment_id - - + + + delete + from attachments + where object_id = :object_id + and item_id = :attachment_id + + - - -select item_id, acs_object.name(item_id) from attachments -where object_id= :object_id - - - + + + select approved_p + from attachments + where object_id = :object_id + and item_id = :item_id + + + + + + update attachments + set approved_p = :approved_p + where object_id = :object_id + and item_id = :item_id + + + Index: openacs-4/packages/attachments/www/toggle-approved.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attachments/www/toggle-approved.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/attachments/www/toggle-approved.tcl 30 Aug 2002 14:44:09 -0000 1.1 @@ -0,0 +1,16 @@ +ad_page_contract { + + @author yon@openforce.net + @creation-date 2002-08-29 + @version $Id: toggle-approved.tcl,v 1.1 2002/08/30 14:44:09 arjun Exp $ + +} -query { + {object_id:integer,notnull} + {item_id:integer,notnull} + {approved_p ""} + {return_url:notnull} +} + +attachments::toggle_approved -object_id $object_id -item_id $item_id -approved_p $approved_p + +ad_returnredirect $return_url