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.25.2.5 -r1.25.2.6
--- openacs-4/packages/file-storage/tcl/file-storage-procs-oracle.xql 21 Jul 2004 22:37:18 -0000 1.25.2.5
+++ openacs-4/packages/file-storage/tcl/file-storage-procs-oracle.xql 26 Jul 2004 23:57:01 -0000 1.25.2.6
@@ -145,7 +145,7 @@
select person.name(o.creation_user) as owner
- from acs_objects o where o.object_id = :file_id
+ from acs_objects o where o.object_id = :item_id
@@ -191,6 +191,31 @@
+
+
+
+ begin
+ :1 := file_storage.delete_version(
+ :item_id,
+ :version_id
+ );
+ end;
+
+
+
+
+
+
+
+ begin
+ file_storage.delete_file(
+ :item_id
+ );
+ end;
+
+
+
+
begin
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.38.2.2 -r1.38.2.3
--- openacs-4/packages/file-storage/tcl/file-storage-procs-postgresql.xql 21 Jul 2004 22:37:18 -0000 1.38.2.2
+++ openacs-4/packages/file-storage/tcl/file-storage-procs-postgresql.xql 26 Jul 2004 23:57:01 -0000 1.38.2.3
@@ -132,7 +132,7 @@
select person__name(o.creation_user) as owner from
- acs_objects o where o.object_id = :file_id
+ acs_objects o where o.object_id = :item_id
@@ -173,6 +173,25 @@
+
+
+
+ select file_storage__delete_version(
+ :item_id,
+ :version_id
+ );
+
+
+
+
+
+
+ select file_storage__delete_file(
+ :item_id
+ );
+
+
+
begin
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.42.2.7 -r1.42.2.8
--- openacs-4/packages/file-storage/tcl/file-storage-procs.tcl 25 Jul 2004 14:45:28 -0000 1.42.2.7
+++ openacs-4/packages/file-storage/tcl/file-storage-procs.tcl 26 Jul 2004 23:57:01 -0000 1.42.2.8
@@ -258,6 +258,15 @@
return [db_exec_plsql get_root_folder {}]
}
+ad_proc -public fs::get_parent {
+ -item_id
+} {
+ Get the parent of a given item.
+} {
+ return [db_string get_parent_id ""]
+}
+
+
ad_proc -public fs::new_folder {
{-name:required}
{-pretty_name:required}
@@ -670,38 +679,44 @@
db_transaction {
if {[empty_string_p $item_id] || ![db_string item_exists ""]} {
set item_id [db_exec_plsql create_item ""]
-
+
if {![empty_string_p $creation_user]} {
- permission::grant -party_id $creation_user -object_id $item_id -privilege admin
+ permission::grant -party_id $creation_user -object_id $item_id -privilege admin
}
+ set do_notify_here_p "t"
+ } else {
+ set do_notify_here_p "f"
}
-
-
- set revision_id [fs::add_version \
- -name $name \
- -parent_id $parent_id \
- -tmp_filename $tmp_filename \
- -package_id $package_id \
- -item_id $item_id \
- -creation_user $creation_user \
- -creation_ip $creation_ip \
- -title $title \
- -description $description
- ]
+
+ set revision_id [fs::add_version \
+ -name $name \
+ -tmp_filename $tmp_filename \
+ -package_id $package_id \
+ -item_id $item_id \
+ -creation_user $creation_user \
+ -creation_ip $creation_ip \
+ -title $title \
+ -description $description \
+ -suppress_notify_p $do_notify_here_p
+ ]
+
+ if {[string is true $do_notify_here_p]} {
+ fs::do_notifications -folder_id $parent_id -filename $title -item_id $revision_id -action "new_file"
+ }
}
- return $revision_id
+ return $revision_id
}
ad_proc fs::add_version {
-name
- -parent_id
-tmp_filename
-package_id
{-item_id ""}
{-creation_user ""}
{-creation_ip ""}
{-title ""}
{-description ""}
+ {-suppress_notify_p "f"}
} {
Create a new version of a file storage item
@@ -716,6 +731,7 @@
set mime_type [cr_filename_to_mime_type -create $name]
set tmp_size [file size $tmp_filename]
+ set parent_id [get_parent -item_id $item_id]
set revision_id [cr_import_content \
-item_id $item_id \
@@ -735,9 +751,44 @@
db_dml set_live_revision ""
db_exec_plsql update_last_modified ""
+ if {[string is false $suppress_notify_p]} {
+ fs::do_notifications -folder_id $parent_id -filename $title -item_id $revision_id -action "new_version"
+ }
+
return $revision_id
}
+ad_proc fs::delete_file {
+ -item_id
+ {-parent_id ""}
+} {
+ Deletes a file and all its revisions
+} {
+ set version_name [get_object_name -object_id $item_id]
+ db_exec_plsql delete_file ""
+
+ if {[empty_string_p $parent_id]} {
+ set parent_id [get_parent -item_id $item_id]
+ }
+
+ fs::do_notifications -folder_id $parent_id -filename $version_name -item_id $item_id -action "delete_file"
+}
+
+ad_proc fs::delete_version {
+ -item_id
+ -version_id
+} {
+ Deletes a revision. If it was the last revision, it deletes
+ the file as well.
+} {
+ set parent_id [db_exec_plsql delete_version ""]
+
+ if {$parent_id > 0} {
+ delete_file -item_id $item_id -parent_id $parent_id
+ }
+ return $parent_id
+}
+
ad_proc fs::webdav_url {
-item_id
{-root_folder_id ""}
@@ -782,10 +833,8 @@
ad_proc -public fs::do_notifications {
{-folder_id:required}
{-filename:required}
- {-file_id ""}
- {-url_id ""}
+ {-item_id:required}
-action
- {-version_id ""}
} {
Send notifications for file-storage operations.
@@ -799,7 +848,6 @@
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"]} {
@@ -813,14 +861,15 @@
set url "[ad_url]"
set new_content ""
if {[string equal $action "new_file"] || [string equal $action "new_url"] || [string equal $action "new_version"]} {
+ ns_log notice "getting owner for $item_id"
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"
+ where cr_revisions.revision_id = :item_id"
} else {
set sql "select description as description from cr_revisions
- where cr_revisions.item_id = :file_id"
+ where cr_revisions.item_id = :item_id"
}
db_0or1row description $sql
Index: openacs-4/packages/file-storage/tcl/file-storage-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/file-storage-procs.xql,v
diff -u -r1.15 -r1.15.2.1
--- openacs-4/packages/file-storage/tcl/file-storage-procs.xql 5 Jan 2004 02:16:58 -0000 1.15
+++ openacs-4/packages/file-storage/tcl/file-storage-procs.xql 26 Jul 2004 23:57:01 -0000 1.15.2.1
@@ -125,13 +125,30 @@
+
+
+ select parent_id from cr_items where item_id=:item_id;
+
+
+
update cr_items set live_revision=:revision_id
where item_id=:item_id
+
+
+
+ select i.name as title, r.title as version_name
+ from cr_items i, cr_revisions r
+ where i.item_id = r.item_id
+ and r.revision_id = :version_id
+
+
+
+
update cr_folders set description=:description
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.8.2.3 -r1.8.2.4
--- openacs-4/packages/file-storage/www/file-add.tcl 21 Jul 2004 22:37:18 -0000 1.8.2.3
+++ openacs-4/packages/file-storage/www/file-add.tcl 26 Jul 2004 23:57:01 -0000 1.8.2.4
@@ -8,6 +8,7 @@
file_id:integer,optional,notnull
folder_id:integer,optional,notnull
upload_file:trim,optional
+ return_url:optional
upload_file.tmpfile:tmpfile,optional
{title ""}
{lock_title_p 1}
@@ -20,7 +21,7 @@
} -validate {
file_id_or_folder_id {
if {[exists_and_not_null file_id] && ![exists_and_not_null folder_id]} {
- set folder_id [db_string get_folder_id "" -default ""]
+ set folder_id [db_string get_folder_id "select parent_id as folder_id from cr_items where item_id=:file_id;" -default ""]
}
if {![fs_folder_p $folder_id]} {
ad_complain "The specified parent folder is not valid."
@@ -49,7 +50,7 @@
-object_id $file_id \
-party_id $user_id \
-privilege "write"
-set context [fs_context_bar_list -final "[_ file-storage.Add_Revision]" $folder_id]
+ set context [fs_context_bar_list -final "[_ file-storage.Add_Revision]" $folder_id]
} else {
set context [fs_context_bar_list -final "[_ file-storage.Add_File]" $folder_id]
@@ -64,6 +65,12 @@
{upload_file:file {label \#file-storage.Upload_a_file\#} {html "size 30"}}
}
+if {[exists_and_not_null return_url]} {
+ ad_form -extend -form {
+ {return_url:text(hidden) {value $return_url}}
+ }
+}
+
if {$lock_title_p} {
ad_form -extend -form {
{title_display:text(inform) {label \#file-storage.Title\#} }
@@ -77,59 +84,59 @@
ad_form -extend -form {
{description:text(textarea),optional {label \#file-storage.Description\#} {html "rows 5 cols 35"}}
-
+
}
if {[ad_form_new_p -key file_id]} {
ad_form -extend -form {
- {unpack_p:boolean(checkbox),optional {label \#file-storage.Multiple_files\#} {html {onclick "javascript:UnpackChanged(this);"}} {options { {\#file-storage.lt_This_is_a_ZIP\# t} }} }
+ {unpack_p:boolean(checkbox),optional {label \#file-storage.Multiple_files\#} {html {onclick "javascript:UnpackChanged(this);"}} {options { {\#file-storage.lt_This_is_a_ZIP\# t} }} }
}
}
ad_form -extend -form {} -select_query_name {get_file} -new_data {
-
-
-set unpack_p [template::util::is_true $unpack_p]
-set unzip_binary [string trim [parameter::get -parameter UnzipBinary]]
-
-if { $unpack_p && ![empty_string_p $unzip_binary] } {
- set path [ns_tmpnam]
- file mkdir $path
-
- catch { exec $unzip_binary -jd $path ${upload_file.tmpfile} } errmsg
+ set unpack_p [template::util::is_true $unpack_p]
+ set unzip_binary [string trim [parameter::get -parameter UnzipBinary]]
- # More flexible parameter design could be:
- # zip {unzip -jd {out_path} {in_file}} tar {tar xf {in_file} {out_path}} tgz {tar xzf {in_file} {out_path}}
-
- set upload_files [list]
- set upload_tmpfiles [list]
-
- foreach file [glob -nocomplain "$path/*"] {
- lappend upload_files [file tail $file]
- lappend upload_tmpfiles $file
+ if { $unpack_p && ![empty_string_p $unzip_binary] } {
+
+ set path [ns_tmpnam]
+ file mkdir $path
+
+
+ catch { exec $unzip_binary -jd $path ${upload_file.tmpfile} } errmsg
+
+ # More flexible parameter design could be:
+ # zip {unzip -jd {out_path} {in_file}} tar {tar xf {in_file} {out_path}} tgz {tar xzf {in_file} {out_path}}
+
+ set upload_files [list]
+ set upload_tmpfiles [list]
+
+ foreach file [glob -nocomplain "$path/*"] {
+ lappend upload_files [file tail $file]
+ lappend upload_tmpfiles $file
+ }
+
+ } else {
+ set upload_files [list [template::util::file::get_property filename $upload_file]]
+ set upload_tmpfiles [list [template::util::file::get_property tmp_filename $upload_file]]
}
-
-} else {
- set upload_files [list [template::util::file::get_property filename $upload_file]]
- set upload_tmpfiles [list [template::util::file::get_property tmp_filename $upload_file]]
-}
-
+
foreach upload_file $upload_files tmpfile $upload_tmpfiles {
set this_file_id $file_id
set this_title $title
# upload a new file
# if the user choose upload from the folder view
# and the file with the same name already exists
# we create a new revision
-
+
if {[string equal $this_title ""]} {
set this_title $upload_file
}
set existing_item_id [fs::get_item_id -name $upload_file -folder_id $folder_id]
-
+
if {![empty_string_p $existing_item_id]} {
# file with the same name already exists
# in this folder, create a new revision
@@ -150,29 +157,28 @@
-title $this_title \
-description $description \
-package_id $package_id
-
+
}
- fs::do_notifications -folder_id $folder_id -filename $title -file_id $file_id -action "new_file"
-
} -edit_data {
fs::add_version \
-name [template::util::file::get_property filename $upload_file] \
-tmp_filename [template::util::file::get_property tmp_filename $upload_file] \
-item_id $file_id \
- -parent_id $folder_id \
-creation_user $user_id \
-creation_ip [ad_conn peeraddr] \
-title $title \
-description $description \
- -package_id $package_id
-
- fs::do_notifications -folder_id $folder_id -filename $title -file_id $file_id -action "new_version"
-
+ -package_id $package_id \
+
} -after_submit {
- ad_returnredirect "./?[export_url_vars folder_id]"
+ if {[exists_and_not_null return_url]} {
+ ad_returnredirect $return_url
+ } else {
+ ad_returnredirect "./?[export_url_vars folder_id]"
+ }
ad_script_abort
}
Fisheye: Tag 1.1 refers to a dead (removed) revision in file `openacs-4/packages/file-storage/www/file-add.xql'.
Fisheye: No comparison available. Pass `N' to diff?
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.2.1 -r1.9.2.2
--- openacs-4/packages/file-storage/www/file-delete.tcl 21 Jul 2004 22:37:18 -0000 1.9.2.1
+++ openacs-4/packages/file-storage/www/file-delete.tcl 26 Jul 2004 23:57:01 -0000 1.9.2.2
@@ -46,14 +46,9 @@
if {[string equal $blocked_p "f"] } {
# they confirmed that they want to delete the file
- db_1row parent_id "select parent_id from cr_items where item_id = :file_id"
- db_exec_plsql delete_file "
- begin
- file_storage.delete_file(:file_id);
- end;"
+ set parent_id [fs::get_parent -item_id $file_id]
+ fs::delete_file -item_id $file_id -parent_id $parent_id
- 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/file.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/file.tcl,v
diff -u -r1.18.2.4 -r1.18.2.5
--- openacs-4/packages/file-storage/www/file.tcl 11 Jul 2004 13:36:57 -0000 1.18.2.4
+++ openacs-4/packages/file-storage/www/file.tcl 26 Jul 2004 23:57:01 -0000 1.18.2.5
@@ -42,7 +42,9 @@
} else {
set show_versions [db_map show_live_version]
}
-set actions [list "Upload Revision" version-add?[export_vars file_id] "Upload a new version of this file" \
+set return_url [ad_conn url]?[export_vars file_id]
+
+set actions [list "Upload Revision" file-add?[export_vars [list file_id return_url]] "Upload a new version of this file" \
"Rename File" file-edit?[export_vars file_id] "Rename file" \
"Copy File" file-copy?[export_vars file_id] "Copy file" \
"Move File" file-move?[export_vars file_id] "Move file" \
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.4.1 -r1.4.4.2
--- openacs-4/packages/file-storage/www/simple-add-2.tcl 21 Jul 2004 22:37:18 -0000 1.4.4.1
+++ openacs-4/packages/file-storage/www/simple-add-2.tcl 26 Jul 2004 23:57:01 -0000 1.4.4.2
@@ -34,7 +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"
+fs::do_notifications -folder_id $folder_id -filename $url -item_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.4.1 -r1.4.4.2
--- openacs-4/packages/file-storage/www/simple-delete.tcl 21 Jul 2004 22:37:18 -0000 1.4.4.1
+++ openacs-4/packages/file-storage/www/simple-delete.tcl 26 Jul 2004 23:57:01 -0000 1.4.4.2
@@ -16,7 +16,7 @@
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"
+ fs::do_notifications -folder_id $folder_id -filename [content_extlink::extlink_name -item_id $object_id] -item_id $object_id -action "delete_url"
content_extlink::delete -extlink_id $object_id
Fisheye: Tag 1.2.10.1 refers to a dead (removed) revision in file `openacs-4/packages/file-storage/www/version-add-2-oracle.xql'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.3.10.1 refers to a dead (removed) revision in file `openacs-4/packages/file-storage/www/version-add-2-postgresql.xql'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.5.4.2 refers to a dead (removed) revision in file `openacs-4/packages/file-storage/www/version-add-2.tcl'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `openacs-4/packages/file-storage/www/version-add-2.xql'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.8.2.1 refers to a dead (removed) revision in file `openacs-4/packages/file-storage/www/version-add.adp'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.6.2.1 refers to a dead (removed) revision in file `openacs-4/packages/file-storage/www/version-add.tcl'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.2.10.1 refers to a dead (removed) revision in file `openacs-4/packages/file-storage/www/version-add.xql'.
Fisheye: No comparison available. Pass `N' to diff?