Index: openacs-4/packages/attachments/attachments.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attachments/attachments.info,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/attachments/attachments.info 1 Jul 2002 20:16:23 -0000 1.1 @@ -0,0 +1,34 @@ + + + + + attachments + attachments + f + t + + + + oracle + postgresql + + Arjun Sanyal + attachments + OpenForce, Inc. + attachments + + + + + + + + + + + + + + + + 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 -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/attachments/sql/oracle/attachments-create.sql 1 Jul 2002 20:16:23 -0000 1.1 @@ -0,0 +1,41 @@ +-- +-- Copyright (C) 2001, 2002 OpenForce, Inc. +-- +-- 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 +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +-- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +-- details. +-- + +-- +-- attachments +-- +-- @author arjun (arjun@openforce.net) +-- @version $Id: attachments-create.sql,v 1.1 2002/07/01 20:16:23 ben Exp $ +-- + +create table attachments_fs_root_folder_map ( + package_id constraint attach_fldr_map_package_id_fk + references apm_packages (package_id) + constraint attach_fldr_map_package_id_un + unique, + folder_id constraint attach_fldr_map_folder_id_fk + references fs_root_folders (folder_id), + constraint attach_fldr_map_pk + primary key (package_id, folder_id) +); + +create table attachments ( + object_id constraint attachments_object_id_fk + references acs_objects(object_id) + on delete cascade, + item_id constraint attachments_item_id_fk + references cr_items(item_id), + constraint attachments_pk + primary key (object_id, item_id) +); Index: openacs-4/packages/attachments/sql/oracle/attachments-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attachments/sql/oracle/attachments-drop.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/attachments/sql/oracle/attachments-drop.sql 1 Jul 2002 20:16:23 -0000 1.1 @@ -0,0 +1,23 @@ +-- +-- Copyright (C) 2001, 2002 OpenForce, Inc. +-- +-- 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 +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +-- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +-- details. +-- + +-- +-- attachments +-- +-- @author arjun (arjun@openforce.net) +-- @version $Id: attachments-drop.sql,v 1.1 2002/07/01 20:16:23 ben Exp $ +-- + +drop table attachments; +drop table attachment_root_folders; 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 -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/attachments/tcl/attachments-procs.tcl 1 Jul 2002 20:16:23 -0000 1.1 @@ -0,0 +1,63 @@ +# Copyright (C) 2001, 2002 OpenForce, Inc. +# +# 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 +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# + +ad_library { + Attachments + + @author Arjun Sanyal (arjun@openforce.net) + @version $Id: attachments-procs.tcl,v 1.1 2002/07/01 20:16:23 ben Exp $ +} + +namespace eval attachments { + + ad_proc -public root_folder_p { + {-package_id:required} + } { + Returns 1 if the package_id has an fs_folder mapped to it + } { + return [db_string root_folder_p_select {} -default 0] + } + + ad_proc -public get_root_folder { + {-package_id:required} + } { + } { + return [db_1row get_root_folder_select {}] + } + + ad_proc -public root_folder_map_p { + {-package_id:required} + } { + Returns 1 if the package_id has an fs_folder mapped to it + } { + # this is a duplicate (Ben) + return [root_folder_p -package_id $package_id] + } + + ad_proc -public map_root_folder { + {-package_id:required} + {-folder_id:required} + } { + } { + db_dml map_root_folder_insert {} + } + + ad_proc -public unmap_root_folder { + {-package_id:required} + {-folder_id:required} + } { + } { + db_dml unmap_root_folder_delete {} + } + +} 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 -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/attachments/tcl/attachments-procs.xql 1 Jul 2002 20:16:23 -0000 1.1 @@ -0,0 +1,35 @@ + + + + + +select 1 from attachments_folder_map +where package_id = :package_id + + + + + +select folder_id from attachments_folder_map +where package_id = :package_id + + + + + +insert into attachments_folder_map +(package_id, folder_id) +values +(:package_id, :folder_id) + + + + + +delete from attachments_folder_map where +package_id = :package_id and +folder_id = :folder_id + + + + Index: openacs-4/packages/attachments/www/admin/new-root-folder-map-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attachments/www/admin/new-root-folder-map-2.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/attachments/www/admin/new-root-folder-map-2.tcl 1 Jul 2002 20:16:23 -0000 1.1 @@ -0,0 +1,39 @@ +# +# Copyright (C) 2002 OpenForce, Inc. +# +# 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 +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# + +ad_page_contract { + + Creates a new fs root folder and maps it to the passed in packge_id + + @author Arjun Sanyal (arjun@openforce.net) + @version $Id: new-root-folder-map-2.tcl,v 1.1 2002/07/01 20:16:23 ben Exp $ + +} -query { + {package_id:notnull} + {referer:notnull} +} + +# apm sucks +set instance_name [db_string instance_name_select "select instance_name from apm_packages where package_id = :package_id"] + +set folder_id [fs::new_root_folder \ + -package_id $package_id \ + -pretty_name "$instance_name's Attachments" \ + -description "Created by the attachments packge" +] + +attachments::map_root_folder -package_id $package_id -folder_id $folder_id + + +ad_returnredirect $referer Index: openacs-4/packages/attachments/www/admin/new-root-folder-map.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attachments/www/admin/new-root-folder-map.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/attachments/www/admin/new-root-folder-map.adp 1 Jul 2002 20:16:23 -0000 1.1 @@ -0,0 +1,22 @@ + +Add Attachment Folder Link + +

Add folder Link

+ + + No file-storage folders found to link to. Would you like to create one? +
+ + + +
+ +
+ + +
+ +
+ + Found file-storage folder XXX folder_name XXX ... would you like to link to it? + Index: openacs-4/packages/attachments/www/admin/new-root-folder-map.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attachments/www/admin/new-root-folder-map.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/attachments/www/admin/new-root-folder-map.tcl 1 Jul 2002 20:16:23 -0000 1.1 @@ -0,0 +1,71 @@ +# +# Copyright (C) 2002 OpenForce, Inc. +# +# 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 +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# + +ad_page_contract { + Tries to find an appropriate fs root folder for the passed in package_id. + If it can't find one, it prompts to make new one. + + @author Arjun Sanyal (arjun@openforce.net) + @version $Id: new-root-folder-map.tcl,v 1.1 2002/07/01 20:16:23 ben Exp $ + +} -query { + {package_id:notnull} + {referer:notnull} +} + +# can't use the get_root_folder proc since it creates +# a new one if one doesn't exist. A BUG. +set root_folder_id [db_string has_fs_root_folder_p_select \ + "select folder_id from fs_root_folders where package_id = :package_id" \ + -default 0 +] + +if {$root_folder_id == 0} { + # look for a fs root folder candidate, by looking for an file-storage + # sibling of our parent (uncle? or aunt? node). Should generalize sibling + # stuff, search by parent etc. + set parent_id [site_node::get_parent \ + -node_id [site_node::get_node_id_from_object_id -object_id $package_id] + ] + + # + # todo + # + + # if we found one, get that node's info and present it + # set root_folder_id xxx + + # else ask to create a new root folder + ad_return_template + + +} else { + if {[attachments::root_folder_p -pacakge_id $package_id]} { + # sanity check that the attachments_root_folder and fs_root_folder match + set attachments_root_folder [attachments::get_root_folder \ + -package_id $package_id + ] + + if {$attachments_root_folder != $root_folder_id} { + ad_return_complaint 1 "Error: Attachment root folder and fs root folder different!" + } else { + # since this pkg already has a root folder do the mapping and return + attachments::map_root_folder \ + -package_id $package_id \ + -folder_id $root_folder_id + + ad_returnredirect $referer + } + } +} Index: openacs-4/packages/attachments/www/admin/redirect.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attachments/www/admin/redirect.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/attachments/www/admin/redirect.tcl 1 Jul 2002 20:16:23 -0000 1.1 @@ -0,0 +1,23 @@ +# +# Copyright (C) 2002 OpenForce, Inc. +# +# 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 +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# + +ad_page_contract { + + @author Arjun Sanyal (arjun@openforce.net) + @version $Id: redirect.tcl,v 1.1 2002/07/01 20:16:23 ben Exp $ + +} -query { + {referer:notnull} +} +ad_returnredirect $referer