Index: openacs-4/packages/file-storage/sql/oracle/file-storage-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/sql/oracle/file-storage-create.sql,v diff -u -r1.17 -r1.18 --- openacs-4/packages/file-storage/sql/oracle/file-storage-create.sql 27 Mar 2004 15:40:41 -0000 1.17 +++ openacs-4/packages/file-storage/sql/oracle/file-storage-create.sql 19 Jun 2004 14:47:46 -0000 1.18 @@ -91,3 +91,5 @@ @ file-storage-package-create.sql @ file-storage-views-create.sql + +@ file-storage-notifications-create.sql Index: openacs-4/packages/file-storage/sql/oracle/file-storage-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/sql/oracle/file-storage-drop.sql,v diff -u -r1.10 -r1.11 --- openacs-4/packages/file-storage/sql/oracle/file-storage-drop.sql 30 Sep 2003 12:10:07 -0000 1.10 +++ openacs-4/packages/file-storage/sql/oracle/file-storage-drop.sql 19 Jun 2004 14:47:46 -0000 1.11 @@ -53,3 +53,5 @@ end; / show errors + +@ file-storage-notifications-drop.sql Index: openacs-4/packages/file-storage/sql/oracle/file-storage-notifications-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/sql/oracle/file-storage-notifications-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/file-storage/sql/oracle/file-storage-notifications-create.sql 19 Jun 2004 14:47:46 -0000 1.1 @@ -0,0 +1,46 @@ + +declare + impl_id integer; + v_foo integer; +begin + -- the notification type impl + impl_id := acs_sc_impl.new ( + 'NotificationType', + 'fs_fs_notif_type', + 'file_storage' + ); + + v_foo := acs_sc_impl.new_alias ( + 'NotificationType', + 'fs_fs_notif_type', + 'GetURL', + 'TCL' + ); + + acs_sc_binding.new ( + contract_name => 'NotificationType', + impl_name => 'fs_fs_notif_type' + ); + + v_foo:= notification_type.new ( + short_name => 'fs_fs_notif', + sc_impl_id => impl_id, + pretty_name => 'File-Storage Notification', + description => 'Notifications for File Storage', + creation_user => NULL, + creation_ip => NULL + ); + + -- enable the various intervals and delivery methods + insert into notification_types_intervals + (type_id, interval_id) + select v_foo, interval_id + from notification_intervals where name in ('instant','hourly','daily'); + + insert into notification_types_del_methods + (type_id, delivery_method_id) + select v_foo, delivery_method_id + from notification_delivery_methods where short_name in ('email'); +end; +/ +show errors Index: openacs-4/packages/file-storage/sql/oracle/file-storage-notifications-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/sql/oracle/file-storage-notifications-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/file-storage/sql/oracle/file-storage-notifications-drop.sql 19 Jun 2004 14:47:46 -0000 1.1 @@ -0,0 +1,10 @@ + +declare +begin + for row in (select type_id + from notification_types + where short_name in (''fs_fs_notif'')) + loop + notification_type.delete(row.type_id); + end loop; +end; Index: openacs-4/packages/file-storage/sql/postgresql/file-storage-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/sql/postgresql/file-storage-create.sql,v diff -u -r1.19 -r1.20 --- openacs-4/packages/file-storage/sql/postgresql/file-storage-create.sql 27 Mar 2004 15:40:41 -0000 1.19 +++ openacs-4/packages/file-storage/sql/postgresql/file-storage-create.sql 19 Jun 2004 14:47:48 -0000 1.20 @@ -94,3 +94,5 @@ \i file-storage-package-create.sql \i file-storage-views-create.sql + +\i file-storage-notifications-create.sql Index: openacs-4/packages/file-storage/sql/postgresql/file-storage-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/sql/postgresql/file-storage-drop.sql,v diff -u -r1.10 -r1.11 --- openacs-4/packages/file-storage/sql/postgresql/file-storage-drop.sql 15 Dec 2003 11:21:04 -0000 1.10 +++ openacs-4/packages/file-storage/sql/postgresql/file-storage-drop.sql 19 Jun 2004 14:47:48 -0000 1.11 @@ -50,6 +50,10 @@ 'f' -- drop_table_p ); +-- this data model added by file-storage patch number 146 from +-- openacs.org bugtracker +\i file-storage-notifications-drop.sql + -- this content type is created incorrectly tying the file_storage_root_folders -- table to file_storage_object -- so we drop these directly Index: openacs-4/packages/file-storage/sql/postgresql/file-storage-notifications-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/sql/postgresql/file-storage-notifications-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/file-storage/sql/postgresql/file-storage-notifications-create.sql 19 Jun 2004 14:47:48 -0000 1.1 @@ -0,0 +1,63 @@ +create function inline_0() returns integer as ' +declare + impl_id integer; + v_foo integer; +begin + -- the notification type impl + impl_id := acs_sc_impl__new ( + ''NotificationType'', + ''fs_fs_notif_type'', + ''file_storage'' + ); + + v_foo := acs_sc_impl_alias__new ( + ''NotificationType'', -- impl_contract_name + ''fs_fs_notif_type'', -- impl_name + ''GetURL'', -- impl_operation_name + ''fs::notification::get_url'', -- impl_alias + ''TCL'' -- impl_pl + ); + + v_foo := acs_sc_impl_alias__new ( + ''NotificationType'', + ''fs_fs_notif_type'', + ''ProcessReply'', + '' fs::notification::process_reply'', + ''TCL'' + ); + + PERFORM acs_sc_binding__new ( + ''NotificationType'', + ''fs_fs_notif_type'' + ); + + v_foo:= notification_type__new ( + NULL, + impl_id, + ''fs_fs_notif'', + ''File-Storage Notification'', + ''Notifications for File Storage'', + now(), + NULL, + NULL, + NULL + ); + + -- enable the various intervals and delivery methods + insert into notification_types_intervals + (type_id, interval_id) + select v_foo, interval_id + from notification_intervals where name in (''instant'',''hourly'',''daily''); + + insert into notification_types_del_methods + (type_id, delivery_method_id) + select v_foo, delivery_method_id + from notification_delivery_methods where short_name in (''email''); + + return (0); + +end; +' language 'plpgsql'; + +select inline_0(); +drop function inline_0(); Index: openacs-4/packages/file-storage/sql/postgresql/file-storage-notifications-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/sql/postgresql/file-storage-notifications-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/file-storage/sql/postgresql/file-storage-notifications-drop.sql 19 Jun 2004 14:47:48 -0000 1.1 @@ -0,0 +1,77 @@ +create function inline_0 () +returns integer as ' +declare + row record; +begin + for row in select type_id + from notification_types + where short_name in (''fs_fs_notif'') + loop + perform notification_type__delete(row.type_id); + end loop; + + return null; + +end; +' language 'plpgsql'; + +select inline_0(); +drop function inline_0(); +create function inline_0() returns integer as ' +declare + impl_id integer; + v_foo integer; +begin + + -- the notification type impl + impl_id := acs_sc_impl__get_id ( + ''NotificationType'', -- impl_contract_name + ''fs_fs_notif_type'' -- impl_name + ); + + PERFORM acs_sc_binding__delete ( + ''NotificationType'', + ''fs_fs_notif_type'' + ); + + v_foo := acs_sc_impl_alias__delete ( + ''NotificationType'', -- impl_contract_name + ''fs_fs_notif_type'', -- impl_name + ''GetURL'' -- impl_operation_name + ); + + v_foo := acs_sc_impl_alias__delete ( + ''NotificationType'', -- impl_contract_name + ''fs_fs_notif_type'', -- impl_name + ''ProcessReply'' -- impl_operation_name + ); + + select into v_foo type_id + from notification_types + where sc_impl_id = impl_id + and short_name = ''fs_fs_notif''; + + perform notification_type__delete (v_foo); + + delete from notification_types_intervals + where type_id = v_foo + and interval_id in ( + select interval_id + from notification_intervals + where name in (''instant'',''hourly'',''daily'') + ); + + delete from notification_types_del_methods + where type_id = v_foo + and delivery_method_id in ( + select delivery_method_id + from notification_delivery_methods + where short_name in (''email'') + ); + + return (0); +end; +' language 'plpgsql'; + +select inline_0(); +drop function inline_0(); Index: openacs-4/packages/file-storage/tcl/file-storage-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/file-storage-procs-oracle.xql,v diff -u -r1.28 -r1.29 --- openacs-4/packages/file-storage/tcl/file-storage-procs-oracle.xql 1 Jun 2004 22:54:19 -0000 1.28 +++ openacs-4/packages/file-storage/tcl/file-storage-procs-oracle.xql 19 Jun 2004 14:47:48 -0000 1.29 @@ -142,6 +142,22 @@ + + + select person.name(o.creation_user) as owner + from acs_objects o where o.object_id = :file_id + + + + + + select site_node.url(node_id) as path1 from site_nodes + where object_id = (select package_id + from fs_root_folders where + fs_root_folders.folder_id = :root_folder) + + + select content Index: openacs-4/packages/file-storage/tcl/file-storage-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/file-storage-procs-postgresql.xql,v diff -u -r1.39 -r1.40 --- openacs-4/packages/file-storage/tcl/file-storage-procs-postgresql.xql 1 Jun 2004 22:54:19 -0000 1.39 +++ openacs-4/packages/file-storage/tcl/file-storage-procs-postgresql.xql 19 Jun 2004 14:47:48 -0000 1.40 @@ -129,6 +129,22 @@ + + + select person__name(o.creation_user) as owner from + acs_objects o where o.object_id = :file_id + + + + + + select site_node__url(node_id) as path1 from site_nodes + where object_id = (select package_id + from fs_root_folders where + fs_root_folders.folder_id = :root_folder) + + + select lob Index: openacs-4/packages/file-storage/tcl/file-storage-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/file-storage-procs.tcl,v diff -u -r1.43 -r1.44 --- openacs-4/packages/file-storage/tcl/file-storage-procs.tcl 17 May 2004 15:15:14 -0000 1.43 +++ openacs-4/packages/file-storage/tcl/file-storage-procs.tcl 19 Jun 2004 14:47:48 -0000 1.44 @@ -777,4 +777,95 @@ return "" } -} \ No newline at end of file +} + +ad_proc -public fs::do_notifications { + {-folder_id:required} + {-filename:required} + {-file_id ""} + {-url_id ""} + -action + {-version_id ""} +} { + Send notifications for file-storage operations. + + Note that not all possible operations are implemented, e.g. move, copy etc. See documentation. + + @param action The kind of operation. One of: new_file, new_version, new_url, delete_file, delete_url +} { + set root_folder [fs_get_root_folder] + + if {[string equal $action "new_file"]} { + set action_type {New File Uploaded} + } elseif {[string equal $action "new_url"]} { + set action_type {New URL Uploaded} + set file_id $url_id + } elseif {[string equal $action "new_version"]} { + set action_type {New version of file uploaded} + } elseif {[string equal $action "delete_file"]} { + set action_type {File deleted} + } elseif {[string equal $action "delete_url"]} { + set action_type {URL deleted} + } else { + error "Unknown file-storage notification action: $action" + } + + set url "[ad_url]" + set new_content "" + if {[string equal $action "new_file"] || [string equal $action "new_url"] || [string equal $action "new_version"]} { + db_1row get_owner_name { } + + if {[string equal $action "new_version"]} { + set sql "select description as description from cr_revisions + where cr_revisions.revision_id = :version_id" + } else { + set sql "select description as description from cr_revisions + where cr_revisions.item_id = :file_id" + } + + db_0or1row description $sql + + } + db_1row path1 { } + + # Set email message body - "text only" for now + set text_version "" + append text_version "Notification for: File-Storage: $action_type\n" + append text_version "File-Storage folder: [fs_get_folder_name $folder_id]\n" + + if {[string equal $action "new_version"]} { + append text_version "New Version Uploaded for file: $filename\n" + } else { + append text_version "Name of the $action_type: $filename\n" + } + if {[info exists owner]} { + append text_version "Uploaded by: $owner\n" + } + if {[info exists description]} { + append text_version "Version Notes: $description\n" + } + + append text_version "View folder contents: $url$path1?folder_id=$folder_id \n\n" + set new_content $text_version + # Do the notification for the file-storage + + notification::new \ + -type_id [notification::type::get_type_id \ + -short_name fs_fs_notif] \ + -object_id $folder_id \ + -notif_subject {File Storage Notification} \ + -notif_text $new_content + + # walk through all folders up to the root folder + while {$folder_id != $root_folder} { + set parent_id [db_string parent_id " + select parent_id from cr_items where item_id = :folder_id"] + notification::new \ + -type_id [notification::type::get_type_id \ + -short_name fs_fs_notif] \ + -object_id $parent_id \ + -notif_subject {File Storage Notification} \ + -notif_text $new_content + set folder_id $parent_id + } +} Index: openacs-4/packages/file-storage/www/file-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/file-add.tcl,v diff -u -r1.9 -r1.10 --- openacs-4/packages/file-storage/www/file-add.tcl 17 May 2004 15:15:14 -0000 1.9 +++ openacs-4/packages/file-storage/www/file-add.tcl 19 Jun 2004 14:47:48 -0000 1.10 @@ -153,8 +153,7 @@ } - ad_returnredirect "./?[export_url_vars folder_id]" - ad_script_abort + fs::do_notifications -folder_id $folder_id -filename $title -file_id $file_id -action "new_file" } -edit_data { @@ -169,8 +168,13 @@ -description $description \ -package_id $package_id + fs::do_notifications -folder_id $folder_id -filename $title -file_id $file_id -action "new_version" + +} -after_submit { + ad_returnredirect "./?[export_url_vars folder_id]" ad_script_abort + } # if title isn't passed in ignore lock_title_p @@ -180,4 +184,4 @@ set unpack_available_p [expr ![empty_string_p [string trim [parameter::get -parameter UnzipBinary]]]] -ad_return_template \ No newline at end of file +ad_return_template Index: openacs-4/packages/file-storage/www/file-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/Attic/file-delete.tcl,v diff -u -r1.9 -r1.10 --- openacs-4/packages/file-storage/www/file-delete.tcl 16 Dec 2003 04:05:54 -0000 1.9 +++ openacs-4/packages/file-storage/www/file-delete.tcl 19 Jun 2004 14:47:48 -0000 1.10 @@ -52,7 +52,8 @@ file_storage.delete_file(:file_id); end;" - + fs::do_notifications -folder_id $parent_id -filename $title -file_id $file_id -action "delete_file" + ad_returnredirect "?folder_id=$parent_id" ad_script_abort Index: openacs-4/packages/file-storage/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/index.adp,v diff -u -r1.29 -r1.30 --- openacs-4/packages/file-storage/www/index.adp 17 May 2004 15:15:14 -0000 1.29 +++ openacs-4/packages/file-storage/www/index.adp 19 Jun 2004 14:47:48 -0000 1.30 @@ -9,6 +9,9 @@ + +

@notification_chunk;noquote@

+

#file-storage.Folder_available_via_WebDAV_at#

Index: openacs-4/packages/file-storage/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/index.tcl,v diff -u -r1.24 -r1.25 --- openacs-4/packages/file-storage/www/index.tcl 17 May 2004 15:15:14 -0000 1.24 +++ openacs-4/packages/file-storage/www/index.tcl 19 Jun 2004 14:47:48 -0000 1.25 @@ -76,6 +76,14 @@ -widget hidden \ -value $folder_id + +set notification_chunk [notification::display::request_widget \ + -type fs_fs_notif\ + -object_id $folder_id \ + -pretty_name $folder_name \ + -url [ad_conn url]?folder_id=$folder_id \ +] + if {[form is_valid n_past_days_form]} { form get_values n_past_days_form n_past_days folder_id } Index: openacs-4/packages/file-storage/www/simple-add-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/simple-add-2.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/file-storage/www/simple-add-2.tcl 17 May 2003 10:39:54 -0000 1.4 +++ openacs-4/packages/file-storage/www/simple-add-2.tcl 19 Jun 2004 14:47:48 -0000 1.5 @@ -34,5 +34,7 @@ permission::grant -party_id $user_id -object_id $item_id -privilege admin } +fs::do_notifications -folder_id $folder_id -filename $url -url_id $item_id -action "new_url" + ad_returnredirect "?folder_id=$folder_id" Index: openacs-4/packages/file-storage/www/simple-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/simple-delete.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/file-storage/www/simple-delete.tcl 17 May 2003 10:39:54 -0000 1.4 +++ openacs-4/packages/file-storage/www/simple-delete.tcl 19 Jun 2004 14:47:48 -0000 1.5 @@ -13,7 +13,15 @@ ad_require_permission $object_id delete # Delete -content_extlink::delete -extlink_id $object_id +db_transaction { + + fs::do_notifications -folder_id $folder_id -filename [content_extlink::extlink_name -item_id $object_id] -url_id $object_id -action "delete_url" + + content_extlink::delete -extlink_id $object_id + +} + + ad_returnredirect "./?folder_id=$folder_id" Index: openacs-4/packages/file-storage/www/version-add-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/Attic/version-add-2.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/file-storage/www/version-add-2.tcl 17 May 2003 10:39:54 -0000 1.5 +++ openacs-4/packages/file-storage/www/version-add-2.tcl 19 Jun 2004 14:47:48 -0000 1.6 @@ -64,7 +64,10 @@ ); end;"] + db_1row parent_folder { } + fs::do_notifications -folder_id $parent_folder -filename $filename -file_id $file_id -version_id $version_id -action "new_version" + if {$indb_p} { db_dml lob_content " Index: openacs-4/packages/file-storage/www/version-add-2.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/Attic/version-add-2.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/file-storage/www/version-add-2.xql 19 Jun 2004 14:47:48 -0000 1.1 @@ -0,0 +1,14 @@ + + + + + + + select parent_id as parent_folder + from cr_items where item_id = (select item_id from cr_revisions + where cr_revisions.revision_id = :version_id) + + + + + Index: openacs-4/packages/file-storage/www/version-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/version-delete.tcl,v diff -u -r1.9 -r1.10 --- openacs-4/packages/file-storage/www/version-delete.tcl 19 Jan 2004 14:43:40 -0000 1.9 +++ openacs-4/packages/file-storage/www/version-delete.tcl 19 Jun 2004 14:47:48 -0000 1.10 @@ -57,9 +57,10 @@ file_storage.delete_file(:item_id); end;" + fs::do_notifications -folder_id $parent_id -filename $version_name -file_id $item_id -action "delete_file" + # Redirect to the folder, instead of the latest revision (which does not exist anymore) ad_returnredirect "index?folder_id=$parent_id" - ad_script_abort } else {