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.34 -r1.35 --- openacs-4/packages/file-storage/tcl/file-storage-procs.tcl 15 Dec 2003 11:21:04 -0000 1.34 +++ openacs-4/packages/file-storage/tcl/file-storage-procs.tcl 5 Jan 2004 02:16:58 -0000 1.35 @@ -242,6 +242,7 @@ {-parent_id:required} {-creation_user ""} {-creation_ip ""} + {-description ""} } { Create a new folder. @@ -251,7 +252,7 @@ @param parent_id Where we create this folder @param creation_user Who created this folder @param creation_ip What is the ip address of the creation_user - + @param description of the folder. Not used in the current FS UI but might be used elsewhere. @return folder_id of the newly created folder } { if {[empty_string_p $creation_user]} { @@ -261,8 +262,9 @@ if {[empty_string_p $creation_ip]} { set creation_ip [ns_conn peeraddr] } - - return [db_exec_plsql new_folder {}] + set folder_id [db_exec_plsql new_folder {}] + fs::set_folder_description -folder_id $folder_id -description $description + return $folder_id } ad_proc -public fs::rename_folder { @@ -274,6 +276,15 @@ db_exec_plsql rename_folder {} } +ad_proc -public fs::set_folder_description { + {-folder_id:required} + {-description ""} +} { + sets the description for the given folder in cr_folders. Perhaps this shoudl be a CR proc? +} { + db_dml set_folder_description { *SQL* } +} + ad_proc -public fs::object_p { {-object_id:required} } { 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.14 -r1.15 --- openacs-4/packages/file-storage/tcl/file-storage-procs.xql 15 Dec 2003 11:21:04 -0000 1.14 +++ openacs-4/packages/file-storage/tcl/file-storage-procs.xql 5 Jan 2004 02:16:58 -0000 1.15 @@ -131,4 +131,11 @@ where item_id=:item_id + + + + update cr_folders set description=:description + where folder_id = :folder_id + + Index: openacs-4/packages/file-storage/www/folder-create.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/folder-create.adp,v diff -u -r1.6 -r1.7 --- openacs-4/packages/file-storage/www/folder-create.adp 22 May 2003 14:55:53 -0000 1.6 +++ openacs-4/packages/file-storage/www/folder-create.adp 5 Jan 2004 02:16:58 -0000 1.7 @@ -3,20 +3,6 @@ @context;noquote@ folder.folder_name + -
- - - - - - - - - - -
#file-storage.Folder_Name#
 
- -
- Index: openacs-4/packages/file-storage/www/folder-create.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/folder-create.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/file-storage/www/folder-create.tcl 5 Nov 2002 17:19:59 -0000 1.3 +++ openacs-4/packages/file-storage/www/folder-create.tcl 5 Jan 2004 02:16:58 -0000 1.4 @@ -1,29 +1,102 @@ ad_page_contract { - form to create a new folder + form to create or edit a new folder @author Kevin Scaldeferri (kevin@arsdigita.com) @creation-date 7 Nov 2000 + @author Caroline Meeks (caroline@meekshome.com) + @creation-date 4 Jan 2004 @cvs-id $Id$ } { - parent_id:integer,notnull + parent_id:integer,optional,notnull + folder_id:integer,optional,notnull } -validate { + file_id_or_folder_id { + if { ![exists_and_not_null folder_id] && ![exists_and_not_null parent_id] } { + ad_complain "Input error: Must either have a parent_id or a folder_id" + } + } valid_folder -requires {parent_id:integer} { if ![fs_folder_p $parent_id] { ad_complain "[_ file-storage.lt_The_specified_parent_]" } } } -properties { parent_id:onevalue + folder_id:onevalue context:onevalue } -# check that they have write permission on the parent folder +set user_id [ad_conn user_id] +set package_id [ad_conn package_id] +# check that they have write permission on the parent folder or this folder if its an edit. +if { [exists_and_not_null parent_id] } { + permission::require_permission \ + -object_id $parent_id \ + -party_id $user_id \ + -privilege "write" +} -ad_require_permission $parent_id write +if {![ad_form_new_p -key folder_id]} { + #editing an existing folder + permission::require_permission \ + -object_id $folder_id \ + -party_id $user_id \ + -privilege "write" + set context [fs_context_bar_list -final "[_ file-storage.Edit_Folder]" $folder_id] +} else { + #adding a new folder + set context [fs_context_bar_list -final "[_ file-storage.Create_New_Folder]" $parent_id] +} -# set templating datasources +ad_form -name "folder-ae" -html { enctype multipart/form-data } -export { parent_id } -form { + folder_id:key + {folder_name:text,optional {label \#file-storage.Title\#} {html {size 30}} } + {description:text(textarea),optional {label \#file-storage.Description\#} {html "rows 5 cols 35"}} +} -edit_request { + #For now I'm using the bCSM proc. We need to move it to somewhere its more accessible. + #But I hope we can avoid repeating the code in 2 places. + array set folder [bcms::folder::get_folder -folder_id $folder_id] -set context [fs_context_bar_list -final "[_ file-storage.Create_New_Folder]" $parent_id] + #Sigh, there seems to be no consitancy as to how name, title, label and pretty_name are used. + # cr_folders.label is the pretty name + # name is the url of the folder + set folder_name $folder(label) + set description $folder(description) + set parent_id $folder(parent_id) + +} -new_data { + + # strip out spaces from the name + # use - instead of _ which can get URLencoded + set name [string tolower [util_text_to_url -text $folder_name]] + #I want the transaction here for the error message. But fs::new_folder should not be used without a transaction if you are going to set the description. + + db_transaction { + set folder_id [fs::new_folder \ + -name $name \ + -pretty_name $folder_name \ + -parent_id $parent_id \ + -creation_user [ad_conn user_id] \ + -creation_ip [ad_conn peeraddr] \ + -description $description] + } on_error { + ns_log notice "AIGH! something bad happened! $errmsg" + ad_return_complaint 1 [_ file-storage.lt_Either_there_is_alrea [list folder_name $folder_name directory_url "index?folder_id=$parent_id"]] + + ad_script_abort + } + + ad_returnredirect "?folder_id=$folder_id" + ad_script_abort +} -edit_data { + db_transaction { + fs::rename_folder -folder_id $folder_id -name $folder_name + fs::set_folder_description -folder_id $folder_id -description $description + } + ad_returnredirect "?folder_id=$folder_id" + ad_script_abort +} + ad_return_template