- Publicity: Public Only All
file-storage-procs.tcl
Tcl library for the file-storage system (v.4)
- Location:
- packages/file-storage/tcl/file-storage-procs.tcl
- Created:
- 6 November 2000
- Author:
- Kevin Scaldeferri <kevin@arsdigita.com>
- CVS Identification:
$Id: file-storage-procs.tcl,v 1.90.2.42 2024/05/31 13:57:38 antoniop Exp $
Procedures in this file
- fs::add_created_file (public, deprecated)
- fs::add_created_version (public, deprecated)
- fs::add_file (public)
- fs::add_version (public)
- fs::delete_file (public)
- fs::delete_folder (public)
- fs::delete_version (public)
- fs::do_notifications (public)
- fs::file_copy (public)
- fs::folder_p (public)
- fs::get_archive_command (public, deprecated)
- fs::get_archive_extension (public, deprecated)
- fs::get_file_package_id (public)
- fs::get_file_system_safe_object_name (public)
- fs::get_folder (public)
- fs::get_folder_contents (public, deprecated)
- fs::get_folder_contents_count (public)
- fs::get_folder_objects (public)
- fs::get_folder_package_and_root (public)
- fs::get_item_id (public)
- fs::get_object_info (public)
- fs::get_object_name (public)
- fs::get_object_prettyname (public)
- fs::get_parent (public)
- fs::get_root_folder (public)
- fs::item_editable_info (public, deprecated)
- fs::item_editable_p (public, deprecated)
- fs::max_upload_size (public)
- fs::new_folder (public)
- fs::new_root_folder (public)
- fs::object_p (public)
- fs::publish_folder_to_file_system (public)
- fs::publish_object_to_file_system (public)
- fs::publish_url_to_file_system (public)
- fs::publish_versioned_object_to_file_system (public)
- fs::remove_special_file_system_characters (public, deprecated)
- fs::rename_folder (public)
- fs::set_folder_description (public)
- fs::webdav_url (public)
- fs_context_bar_list (public)
- fs_file_p (public)
- fs_folder_p (public)
- fs_get_folder_name (public)
- fs_get_root_folder (public)
- fs_version_p (public)
Detailed information
fs::add_created_file (public, deprecated)
fs::add_created_file [ -name name ] -parent_id parent_id \ -package_id package_id [ -item_id item_id ] \ [ -mime_type mime_type ] [ -creation_user creation_user ] \ [ -creation_ip creation_ip ] [ -title title ] \ [ -description description ] [ -content_body content_body ]
Deprecated. Invoking this procedure generates a warning.
Create a new file storage item or add a new revision if an item with the same name and parent folder already exists DEPRECATED: this proc was superseded by fs::add_file
- Switches:
- -name (optional)
- -parent_id (required)
- -package_id (required)
- -item_id (optional)
- -mime_type (optional)
- -creation_user (optional)
- -creation_ip (optional)
- -title (optional)
- -description (optional)
- -content_body (optional)
- Returns:
- revision_id
- See Also:
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
fs::add_created_version (public, deprecated)
fs::add_created_version -name name -content_body content_body \ -mime_type mime_type -item_id item_id \ [ -creation_user creation_user ] [ -creation_ip creation_ip ] \ [ -title title ] [ -description description ] \ [ -suppress_notify_p suppress_notify_p ] \ [ -storage_type storage_type ] [ -package_id package_id ] \ [ -storage_type storage_type ]
Deprecated. Invoking this procedure generates a warning.
Create a new version of a file storage item using the content passed in content_body DEPRECATED: this proc has been superseded by fs::add_version
- Switches:
- -name (required)
- -content_body (required)
- -mime_type (required)
- -item_id (required)
- -creation_user (optional)
- -creation_ip (optional)
- -title (optional)
- -description (optional)
- -suppress_notify_p (optional, defaults to
"f"
)- -storage_type (optional)
- -package_id (optional)
- -storage_type (optional)
- Returns:
- revision_id
- See Also:
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
fs::add_file (public)
fs::add_file -name name -parent_id parent_id -package_id package_id \ [ -item_id item_id ] [ -creation_user creation_user ] \ [ -creation_ip creation_ip ] [ -title title ] \ [ -description description ] [ -tmp_filename tmp_filename ] \ [ -mime_type mime_type ] [ -no_callback ] [ -no_notification ]
Create a new file storage item or add a new revision if an item with the same name and parent folder already exists
- Switches:
- -name (required)
- -parent_id (required)
- -package_id (required)
- -item_id (optional)
- -creation_user (optional)
- -creation_ip (optional)
- -title (optional)
- -description (optional)
- -tmp_filename (optional)
- -mime_type (optional)
- -no_callback (optional, boolean)
- -no_notification (optional, boolean)
- Returns:
- revision_id
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_publish_file, fs_add_delete_copy, fs_add_file_to_folder
fs::add_version (public)
fs::add_version -item_id item_id [ -name name ] \ [ -package_id package_id ] [ -mime_type mime_type ] \ [ -tmp_filename tmp_filename ] [ -content_body content_body ] \ [ -creation_user creation_user ] [ -creation_ip creation_ip ] \ [ -title title ] [ -description description ] \ [ -suppress_notify_p suppress_notify_p ] \ [ -storage_type storage_type ] [ -no_callback ]
Create a new version of a file storage item.
- Switches:
- -item_id (required)
- -name (optional)
- -package_id (optional)
- -mime_type (optional)
- -tmp_filename (optional)
- absolute path to a file on the filesystem. when specified, the new revision data will come from this file.
- -content_body (optional)
- Text content for the new revision. When 'tmp_filename' is missing, the new revision data will come from here.
- -creation_user (optional)
- -creation_ip (optional)
- -title (optional)
- -description (optional)
- -suppress_notify_p (optional, defaults to
"f"
)- -storage_type (optional)
- -no_callback (optional, boolean)
- Returns:
- revision_id
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_add_delete_copy, fs_add_file_to_folder
fs::delete_file (public)
fs::delete_file -item_id item_id [ -parent_id parent_id ] \ [ -no_callback ]
Deletes a file and all its revisions. Note that we do not perform filesystem operations here. A trigger on cr_revisions informs the content repository about the deletion and periodic cleanup of files to be deleted is performed in a scheduled procedure.
- Switches:
- -item_id (required)
- -parent_id (optional)
- -no_callback (optional, boolean)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_add_delete_copy, fs_add_file_to_folder
fs::delete_folder (public)
fs::delete_folder -folder_id folder_id [ -cascade_p cascade_p ] \ [ -parent_id parent_id ] [ -no_callback ] [ -no_notifications ]
Deletes a folder and all contents. Note that we do not perform filesystem operations here. A trigger on cr_revisions informs the content repository about the deletion and periodic cleanup of files to be deleted is performed in a scheduled procedure.
- Switches:
- -folder_id (required)
- -cascade_p (optional, defaults to
"t"
)- -parent_id (optional)
- -no_callback (optional, boolean)
- -no_notifications (optional, boolean)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_create_folder_using_api
fs::delete_version (public)
fs::delete_version -item_id item_id -version_id version_id
Deletes a revision. If it was the last revision, it deletes the file as well. Note that we do not perform filesystem operations here. A trigger on cr_revisions informs the content repository about the deletion and periodic cleanup of files to be deleted is performed in a scheduled procedure.
- Switches:
- -item_id (required)
- -version_id (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_add_delete_copy
fs::do_notifications (public)
fs::do_notifications -folder_id folder_id -filename filename \ -item_id item_id [ -package_id package_id ] -action action
Send notifications for file-storage operations. Note that not all possible operations are implemented, e.g. move, copy etc. See documentation.
- Switches:
- -folder_id (required)
- -filename (required)
- -item_id (required)
- -package_id (optional)
- -action (required)
- The kind of operation. One of: new_file, new_version, new_url, delete_file, delete_url, delete_folder
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_add_file_to_folder
fs::file_copy (public)
fs::file_copy -file_id file_id -target_folder_id target_folder_id \ [ -postfix postfix ] [ -symlink ]
copy file to target folder
- Switches:
- -file_id (required)
- Item_id of the file to be copied
- -target_folder_id (required)
- Folder ID of the folder to which the file is copied to
- -postfix (optional)
- Postfix will be added with "_" to the new filename (not title). Very useful if you want to avoid unique name constraints on cr_items.
- -symlink (optional, boolean)
- Defines if, instead of a full item, we should just add a symlink.
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_add_delete_copy
fs::folder_p (public)
fs::folder_p -object_id object_id
Is this object a folder?
- Switches:
- -object_id (required)
- Returns:
- true if object_id is a folder
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_create_folder_using_api
fs::get_archive_command (public, deprecated)
fs::get_archive_command [ -in_file in_file ] [ -out_file out_file ]
Deprecated. Invoking this procedure generates a warning.
return the archive command after replacing {in_file} and {out_file} with their respective values.
- Switches:
- -in_file (optional)
- -out_file (optional)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
fs::get_archive_extension (public, deprecated)
fs::get_archive_extension
Deprecated. Invoking this procedure generates a warning.
return the archive extension that should be added to the output file of an archive command DEPRECATED: this is a trivial wrapper over the parameter api
- See Also:
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
fs::get_file_package_id (public)
fs::get_file_package_id -file_id file_id
Returns the package_id for a passed-in file_id. This is useful when using symlinks to files whose real root_folder_id is not the root_folder_id of the package the user is in.
- Switches:
- -file_id (required)
- Returns:
- package_id
- Author:
- Stan Kaufman <skaufman@epimetrics.com>
- Created:
- 2005-09-07
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_publish_file
fs::get_file_system_safe_object_name (public)
fs::get_file_system_safe_object_name -object_id object_id
get the name of a file storage object and make it safe for writing to the filesystem
- Switches:
- -object_id (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_add_delete_copy
fs::get_folder (public)
fs::get_folder -name name -parent_id parent_id
Retrieve the folder_id of a folder given its name and parent folder.
- Switches:
- -name (required)
- Internal name of the folder, must be unique under a given parent_id
- -parent_id (required)
- The parent folder to look under
- Returns:
- folder_id of the folder, or null if no folder was found by that name
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_create_folder_using_api
fs::get_folder_contents (public, deprecated)
fs::get_folder_contents [ -folder_id folder_id ] [ -user_id user_id ] \ [ -n_past_days n_past_days ]
Deprecated. Invoking this procedure generates a warning.
WARNING: This proc is not scalable because it does too many permission checks. DRB: Not so true now that permissions are fast. However, it is now only used to clone files in dotLRN and for the somewhat brain-damaged syllabus package. At minimum the permission checks returned by the code can be removed. Most of the other fields as well. Oh well ... REMOVE WHEN SYLLABUS IS REWRITTEN TO FIND ITS FILE INTELLIGENTLY Retrieve the contents of the specified folder in the form of a list of ns_sets, one for each row returned. The keys for each row are as follows: object_id, name, live_revision, type, last_modified, new_p, content_size, file_upload_name write_p, delete_p, admin_p, DEPRECATED: this proc has been evidently the subject of controversy over the years. To this day (2023-03-17) no package seems to be using it. One can either query the database directly or use other existing apis to retrieve the folder children and then fetch the needed metadata via other means.
- Switches:
- -folder_id (optional)
- The folder for which to retrieve contents
- -user_id (optional)
- The viewer of the contents (to make sure they have permission)
- -n_past_days (optional, defaults to
"99999"
)- Mark files that are newer than the past N days as new
- See Also:
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
fs::get_folder_contents_count (public)
fs::get_folder_contents_count [ -folder_id folder_id ] \ [ -user_id user_id ]
Retrieve the count of contents of the specified folder.
- Switches:
- -folder_id (optional)
- The folder for which to retrieve contents
- -user_id (optional)
- DEPRECATED since commit 2002-02-22 by Yonatan Feldman (yon@milliped.com) this parameter doesn't have any effect. It was used to count only items where user had read permission, but was considered unscalable.
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_add_file_to_folder
fs::get_folder_objects (public)
fs::get_folder_objects -folder_id folder_id -user_id user_id
Return a list the object_ids contained by a file storage folder.
- Switches:
- -folder_id (required)
- The folder for which to retrieve contents
- -user_id (required)
- The viewer of the contents (to make sure they have permission)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_publish_file
fs::get_folder_package_and_root (public)
fs::get_folder_package_and_root folder_id
Returns a two-element Tcl list containing the package_id and root_folder_id for the passed-in folder_id.
- Parameters:
- folder_id (required)
- Author:
- Andrew Grumet <aegrumet@alum.mit.edu>
- Created:
- 15 March 2004
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_add_file_to_folder
fs::get_item_id (public)
fs::get_item_id -name name [ -folder_id folder_id ]
Get the item_id of a file
- Switches:
- -name (required)
- -folder_id (optional)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_add_file_to_folder
fs::get_object_info (public)
fs::get_object_info -file_id file_id [ -revision_id revision_id ]
Returns an array containing the fs object info.
- Switches:
- -file_id (required)
- Id of the file
- -revision_id (optional)
- Id of the revision
- Returns:
- Error:
- Author:
- Deds Castillo <deds@i-manila.com.ph>
- Created:
- 2004-07-03
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_add_delete_copy
fs::get_object_name (public)
fs::get_object_name -object_id object_id
Select the name of this object.
- Switches:
- -object_id (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_add_delete_copy, fs_add_file_to_folder
fs::get_object_prettyname (public)
fs::get_object_prettyname -object_id object_id
Select a pretty name for this object. If title is empty, returns name.
- Switches:
- -object_id (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_add_delete_copy
fs::get_parent (public)
fs::get_parent -item_id item_id
Get the parent of a given item.
- Switches:
- -item_id (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_add_file_to_folder
fs::get_root_folder (public)
fs::get_root_folder [ -package_id package_id ]
Get the root folder of a package instance.
- Switches:
- -package_id (optional)
- Package instance of the root folder to retrieve
- Returns:
- folder_id of the root folder retrieved
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_create_folder_using_api, fs_add_file_to_folder
fs::item_editable_info (public, deprecated)
fs::item_editable_info -item_id item_id
Deprecated. Invoking this procedure generates a warning.
Returns an array containing elements editable_p, mime_type, file_extension if an fs item is editable through the browser, editable_p is set to 1 DEPRECATED: it is unclear what editable is supposed to mean. As of 2023-03-16 file-storage does not offer inline editing and no package, including file-storage itself, appears to be using this api.
- Switches:
- -item_id (required)
- Returns:
- Error:
- Author:
- Deds Castillo <deds@i-manila.com.ph>
- Created:
- 2004-07-03
- See Also:
- nothing
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
fs::item_editable_p (public, deprecated)
fs::item_editable_p -item_id item_id
Deprecated. Invoking this procedure generates a warning.
returns 1 if item is editable via browser DEPRECATED: it is unclear what editable is supposed to mean. As of 2023-03-16 file-storage does not offer inline editing and no package, including file-storage itself, appears to be using this api.
- Switches:
- -item_id (required)
- Returns:
- Error:
- Author:
- Deds Castillo <deds@i-manila.com.ph>
- Created:
- 2004-07-03
- See Also:
- nothing
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
fs::max_upload_size (public)
fs::max_upload_size [ -package_id package_id ]
- Switches:
- -package_id (optional)
- id of the file-storage package instance. Will default to the connection package_id if not specified. Returns the maximum upload size for this file-storage instance. If the value from the parameter is empty, invalid, or bigger than the server-wide upload limit, the latter will take over.
- Returns:
- numeric value in bytes
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_add_file_to_folder
fs::new_folder (public)
fs::new_folder -name name -pretty_name pretty_name \ -parent_id parent_id [ -creation_user creation_user ] \ [ -creation_ip creation_ip ] [ -description description ] \ [ -package_id package_id ] [ -no_callback ]
Create a new folder.
- Switches:
- -name (required)
- Internal name of the folder, must be unique under a given parent_id
- -pretty_name (required)
- What we show to users of the system
- -parent_id (required)
- Where we create this folder
- -creation_user (optional)
- Who created this folder
- -creation_ip (optional)
- What is the IP address of the creation_user
- -description (optional)
- of the folder. Not used in the current FS UI but might be used elsewhere.
- -package_id (optional)
- Package_id of the package for which to create the new folder. Preferably a file storage package_id
- -no_callback (optional, boolean)
- defines if the callback should be called. Defaults to yes
- Returns:
- folder_id of the newly created folder
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_publish_file, fs_add_delete_copy, fs_create_folder_using_api, fs_add_file_to_folder
fs::new_root_folder (public)
fs::new_root_folder [ -package_id package_id ] \ [ -pretty_name pretty_name ] [ -description description ] \ [ -name name ]
Create a root folder for a package instance.
- Switches:
- -package_id (optional)
- Package instance associated with this root folder
- -pretty_name (optional)
- -description (optional)
- -name (optional)
- Returns:
- folder_id of the new root folder
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_add_delete_copy
fs::object_p (public)
fs::object_p -object_id object_id
is this a file storage object
- Switches:
- -object_id (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_add_delete_copy
fs::publish_folder_to_file_system (public)
fs::publish_folder_to_file_system -folder_id folder_id [ -path path ] \ [ -folder_name folder_name ] [ -user_id user_id ]
publish the contents of a file storage folder to the filesystem
- Switches:
- -folder_id (required)
- -path (optional)
- -folder_name (optional)
- -user_id (optional)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_publish_file
fs::publish_object_to_file_system (public)
fs::publish_object_to_file_system -object_id object_id [ -path path ] \ [ -file_name file_name ] [ -user_id user_id ]
publish a file storage object to the filesystem
- Switches:
- -object_id (required)
- -path (optional)
- -file_name (optional)
- -user_id (optional)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_publish_file
fs::publish_url_to_file_system (public)
fs::publish_url_to_file_system -object_id object_id [ -path path ] \ [ -file_name file_name ]
publish a URL object to the filesystem as a Windows shortcut (which at least KDE also knows how to handle)
- Switches:
- -object_id (required)
- -path (optional)
- -file_name (optional)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_publish_file
fs::publish_versioned_object_to_file_system (public)
fs::publish_versioned_object_to_file_system -object_id object_id \ [ -path path ] [ -file_name file_name ]
publish an object to the filesystem
- Switches:
- -object_id (required)
- -path (optional)
- -file_name (optional)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_publish_file
fs::remove_special_file_system_characters (public, deprecated)
fs::remove_special_file_system_characters -string string
Deprecated. Invoking this procedure generates a warning.
Remove unsafe filesystem characters. Useful if you want to use $string as the name of an object to write to disk.
- Switches:
- -string (required)
- See Also:
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
fs::rename_folder (public)
fs::rename_folder -folder_id folder_id -name name [ -no_callback ]
rename the given folder
- Switches:
- -folder_id (required)
- -name (required)
- -no_callback (optional, boolean)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_create_folder_using_api
fs::set_folder_description (public)
fs::set_folder_description -folder_id folder_id \ [ -description description ]
sets the description for the given folder in cr_folders. Perhaps this should be a CR proc?
- Switches:
- -folder_id (required)
- -description (optional)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_add_delete_copy
fs::webdav_url (public)
fs::webdav_url -item_id item_id [ -root_folder_id root_folder_id ] \ [ -package_id package_id ]
Provide URL for webdav access to file or folder
- Switches:
- -item_id (required)
- folder_id or item_id of file-storage folder or file
- -root_folder_id (optional)
- root folder to resolve URL from
- -package_id (optional)
- Returns:
- fully qualified URL for WebDAV access or empty string if item is not WebDAV enabled
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_publish_file
fs_context_bar_list (public)
fs_context_bar_list [ -root_folder_id root_folder_id ] \ [ -final final ] [ -folder_url folder_url ] [ -file_url file_url ] \ [ -extra_vars extra_vars ] item_id
Constructs the list to be fed to ad_context_bar appropriate for item_id. If -final is specified, that string will be the last item in the context bar. Otherwise, the name corresponding to item_id will be used.
- Switches:
- -root_folder_id (optional)
- -final (optional)
- -folder_url (optional, defaults to
"index"
)- -file_url (optional, defaults to
"file"
)- -extra_vars (optional)
- Parameters:
- item_id (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- attachments_url_api, fs_create_folder, fs_edit_folder, fs_add_file_to_folder
fs_file_p (public)
fs_file_p file_id
Returns 1 if the file_id corresponds to a file in the file-storage system. Returns 0 otherwise.
- Parameters:
- file_id (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_add_delete_copy
fs_folder_p (public)
fs_folder_p folder_id
Returns 1 if the folder_id corresponds to a folder in the file-storage system. Returns 0 otherwise.
- Parameters:
- folder_id (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_add_delete_copy
fs_get_folder_name (public)
fs_get_folder_name folder_id
Returns the name of a folder.
- Parameters:
- folder_id (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_create_folder_using_api
fs_get_root_folder (public)
fs_get_root_folder [ -package_id package_id ]
Returns the root folder for the file storage system.
- Switches:
- -package_id (optional)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_create_folder, fs_edit_folder, fs_add_file_to_folder
fs_version_p (public)
fs_version_p version_id
Returns 1 if the version_id corresponds to a version in the file-storage system. Returns 0 otherwise.
- Parameters:
- version_id (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_add_delete_copy