fs::do_notifications (public)

 fs::do_notifications -folder_id folder_id -filename filename \
    -item_id item_id [ -package_id package_id ] -action action

Defined in packages/file-storage/tcl/file-storage-procs.tcl

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):
%3 test_fs_add_file_to_folder fs_add_file_to_folder (test file-storage) fs::do_notifications fs::do_notifications test_fs_add_file_to_folder->fs::do_notifications _ _ (public) fs::do_notifications->_ acs_object::get_element acs_object::get_element (public) fs::do_notifications->acs_object::get_element ad_html_text_convert ad_html_text_convert (public) fs::do_notifications->ad_html_text_convert ad_url ad_url (public) fs::do_notifications->ad_url db_0or1row db_0or1row (public) fs::do_notifications->db_0or1row fs::add_created_file fs::add_created_file (public, deprecated) fs::add_created_file->fs::do_notifications fs::add_created_version fs::add_created_version (public, deprecated) fs::add_created_version->fs::do_notifications fs::add_file fs::add_file (public) fs::add_file->fs::do_notifications fs::add_version fs::add_version (public) fs::add_version->fs::do_notifications fs::delete_file fs::delete_file (public) fs::delete_file->fs::do_notifications

Testcases:
fs_add_file_to_folder
Source code:
    set package_and_root [fs::get_folder_package_and_root $folder_id]
    set root_folder [lindex $package_and_root 1]
    if {$package_id eq ""} {
        set package_id [lindex $package_and_root 0]
    }

    switch $action {
        "new_file" {
            set action_type "[_ file-storage.New_File_Uploaded]"
        }
        "new_url" {
            set action_type "[_ file-storage.New_URL_Uploaded]"
        }
        "new_version" {
            set action_type "[_ file-storage.lt_New_version_of_file_u]"
        }
        "delete_file" {
            set action_type "[_ file-storage.File_deleted]"
        }
        "delete_url" {
            set action_type "[_ file-storage.URL_deleted]"
        }
        "delete_folder" {
            set action_type "[_ file-storage.Folder_deleted]"
        }
        default {
            error "Unknown file-storage notification action: $action"
        }
    }

    set url "[ad_url]"
    set new_content ""
    set creation_user [acs_object::get_element  -object_id $item_id  -element creation_user]
    set owner [person::name -person_id $creation_user]

    if {$action in {"new_file" "new_url" "new_version"}} {

        if {$action eq "new_version"} {
            set sql "select description as description from cr_revisions
                           where cr_revisions.revision_id = :item_id"
        } else {
            set sql "select description as description from cr_revisions
                           where cr_revisions.item_id = :item_id"
        }

        db_0or1row description $sql

    }
    set root_folder_package_id [db_string get_package_id {
        select package_id from fs_root_folders
        where folder_id = :root_folder
    }]
    set path1 [site_node::get_url_from_object_id  -object_id $root_folder_package_id]

    # Set email message body - "text only" for now
    set text_version ""
    append text_version "[_ file-storage.lt_Notification_for_File]\n"
    set folder_name [fs_get_folder_name $folder_id]
    append text_version "[_ file-storage.lt_File-Storage_folder_f]\n"

    if {$action eq "new_version"} {
        append text_version "[_ file-storage.lt_New_Version_Uploaded_]\n"
    } else {
        append text_version "[_ file-storage.lt_Name_of_the_action_ty]\n"
    }
    if {[info exists owner]} {
        append text_version "[_ file-storage.Uploaded_by_ownern]\n"
    }
    if {[info exists description]} {
        append text_version "[_ file-storage.lt_Version_Notes_descrip]\n"
    }

    set url_version "$url$path1?folder_id=$folder_id"
    append text_version "[_ file-storage.lt_View_folder_contents_]\n"

    set html_version [ad_html_text_convert -from text/plain -to text/html -- $text_version]
    append html_version "<br><br>"
    # 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.lt_File_Storage_Notifica]"  -notif_text $text_version  -notif_html $html_version

    # 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.lt_File_Storage_Notifica]"  -notif_text $new_content  -notif_html $html_version
        set folder_id $parent_id
    }
Generic XQL file:
packages/file-storage/tcl/file-storage-procs.xql

PostgreSQL XQL file:
packages/file-storage/tcl/file-storage-procs-postgresql.xql

Oracle XQL file:
packages/file-storage/tcl/file-storage-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: