file-storage-callback-procs.tcl

Callback procs for file storage

Location:
packages/file-storage/tcl/file-storage-callback-procs.tcl
Created:
2005-06-15
Author:
Malte Sussdorff <sussdorff@sussdorff.de>
CVS Identification:
$Id: file-storage-callback-procs.tcl,v 1.17.2.1 2021/03/31 11:32:54 gustafn Exp $

Procedures in this file

Detailed information

callback::application-track::getApplicationName::impl::file_storage (private)

 callback::application-track::getApplicationName::impl::file_storage

Callback implementation

See Also:
  • callback::application-track::getApplicationName::contract

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

callback::application-track::getGeneralInfo::impl::file_storage (private)

 callback::application-track::getGeneralInfo::impl::file_storage

Callback implementation

See Also:
  • callback::application-track::getGeneralInfo::contract

Partial Call Graph (max 5 caller/called nodes):
%3 db_1row db_1row (public) callback::application-track::getGeneralInfo::impl::file_storage callback::application-track::getGeneralInfo::impl::file_storage callback::application-track::getGeneralInfo::impl::file_storage->db_1row

Testcases:
No testcase defined.

callback::application-track::getSpecificInfo::impl::file_storage (private)

 callback::application-track::getSpecificInfo::impl::file_storage

Callback implementation

See Also:
  • callback::application-track::getSpecificInfo::contract

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

callback::datamanager::copy_folder::impl::datamanager (private)

 callback::datamanager::copy_folder::impl::datamanager \
    -object_id object_id -selected_community selected_community \
    [ -mode mode ]

Copy a folder to another class or community

Switches:
-object_id (required)
-selected_community (required)
-mode (optional, defaults to "both")
See Also:
  • callback::datamanager::copy_folder::contract

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

callback::fs::before_file_new::contract (private)

 callback::fs::before_file_new::contract -package_id package_id \
    -folder_id folder_id -cancel_url cancel_url -return_url return_url

This can be used to check for confirmation before upload to folder

Switches:
-package_id (required)
-folder_id (required)
-cancel_url (required)
-return_url (required)

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

callback::fs::file_delete::contract (private)

 callback::fs::file_delete::contract -package_id package_id \
    -file_id file_id

Append extra logics to file deletion.

Switches:
-package_id (required)
-file_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

callback::fs::file_edit::contract (private)

 callback::fs::file_edit::contract -package_id package_id \
    -file_id file_id

Append extra logics to file editing.

Switches:
-package_id (required)
-file_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

callback::fs::file_new::contract (private)

 callback::fs::file_new::contract -package_id package_id \
    -file_id file_id

Append extra logics to file creation.

Switches:
-package_id (required)
-file_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

callback::fs::file_revision_new::contract (private)

 callback::fs::file_revision_new::contract -package_id package_id \
    -file_id file_id -parent_id parent_id \
    [ -creation_user creation_user ] [ -creation_ip creation_ip ]

Callback executed when a new file revision is created

Switches:
-package_id (required)
Package_id of the file storage package
-file_id (required)
New file_id for the revision
-parent_id (required)
Usually, the folder the file was uploaded to.
-creation_user (optional)
User_id of the user creating the revision
-creation_ip (optional)
IP of the creation

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

callback::fs::folder_chunk::add_bulk_actions::contract (private)

 callback::fs::folder_chunk::add_bulk_actions::contract \
    -bulk_variable bulk_variable -folder_id folder_id \
    -var_export_list var_export_list

Insert additional bulk_action in folder-chunk UI list template

Switches:
-bulk_variable (required)
-folder_id (required)
-var_export_list (required)

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

callback::fs::folder_delete::contract (private)

 callback::fs::folder_delete::contract -package_id package_id \
    -folder_id folder_id

Append extra logics to folder deletion.

Switches:
-package_id (required)
-folder_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

callback::fs::folder_edit::contract (private)

 callback::fs::folder_edit::contract -package_id package_id \
    -folder_id folder_id

Append extra logics to folder editing.

Switches:
-package_id (required)
-folder_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

callback::fs::folder_new::contract (private)

 callback::fs::folder_new::contract -package_id package_id \
    -folder_id folder_id

Append extra logics to folder creation.

Switches:
-package_id (required)
-folder_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

callback::pm::project_new::impl::file_storage (private)

 callback::pm::project_new::impl::file_storage -package_id package_id \
    -project_id project_id

Create a new folder for each new project

Switches:
-package_id (required)
-project_id (required)
See Also:
  • callback::pm::project_new::contract

Partial Call Graph (max 5 caller/called nodes):
%3 application_data_link::new application_data_link::new (public) application_link::get_linked application_link::get_linked (public) fs::get_root_folder fs::get_root_folder (public) fs::new_folder fs::new_folder (public) callback::pm::project_new::impl::file_storage callback::pm::project_new::impl::file_storage callback::pm::project_new::impl::file_storage->application_data_link::new callback::pm::project_new::impl::file_storage->application_link::get_linked callback::pm::project_new::impl::file_storage->fs::get_root_folder callback::pm::project_new::impl::file_storage->fs::new_folder

Testcases:
No testcase defined.

callback::search::datasource::impl::file_storage_object (private)

 callback::search::datasource::impl::file_storage_object
Authors:
Dirk Gomez <openacs@dirkgomez.de>
Jowell S. Sabino <jowellsabino@netscape.net>
Created:
2005-06-13 Returns a datasource for the search package. This is the content that will be indexed by the full text search engine.
See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 db_0or1row db_0or1row (public) callback::search::datasource::impl::file_storage_object callback::search::datasource::impl::file_storage_object callback::search::datasource::impl::file_storage_object->db_0or1row

Testcases:
No testcase defined.

callback::search::url::impl::file_storage_object (private)

 callback::search::url::impl::file_storage_object -object_id object_id

Return the URL to the file_storage_object

Switches:
-object_id (required)
See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 ad_url ad_url (public) content::revision::item_id content::revision::item_id (public) db_string db_string (public) callback::search::url::impl::file_storage_object callback::search::url::impl::file_storage_object callback::search::url::impl::file_storage_object->ad_url callback::search::url::impl::file_storage_object->content::revision::item_id callback::search::url::impl::file_storage_object->db_string

Testcases:
No testcase defined.
[ hide source ] | [ make this the default ]

Content File Source

ad_library {

    Callback procs for file storage

    @author Malte Sussdorff (sussdorff@sussdorff.de)
    @creation-date 2005-06-15
    @cvs-id $Id: file-storage-callback-procs.tcl,v 1.17.2.1 2021/03/31 11:32:54 gustafn Exp $
}

# Define file storage callbacks

namespace eval fs:: {}

d_proc -public -callback fs::folder_new {
    {-package_id:required}
    {-folder_id:required}
} {
    Append extra logics to folder creation.
} -

d_proc -public -callback fs::folder_edit {
    {-package_id:required}
    {-folder_id:required}
} {
    Append extra logics to folder editing.
} -

d_proc -public -callback fs::folder_delete {
    {-package_id:required}
    {-folder_id:required}
} {
    Append extra logics to folder deletion.
} -

d_proc -public -callback fs::file_new {
    {-package_id:required}
    {-file_id:required}
} {
    Append extra logics to file creation.
} -

d_proc -public -callback fs::file_edit {
    {-package_id:required}
    {-file_id:required}
} {
    Append extra logics to file editing.
} -

d_proc -public -callback fs::file_delete {
    {-package_id:required}
    {-file_id:required}
} {
    Append extra logics to file deletion.
} -

namespace eval fs::folder_chunk {}

d_proc -public -callback fs::folder_chunk::add_bulk_actions {
    {-bulk_variable:required}
    {-folder_id:required}
    {-var_export_list:required}
} {
    Insert additional bulk_action in folder-chunk UI list template
} -

d_proc -public -callback fs::before_file_new {
    {-package_id:required}
    {-folder_id:required}
    {-cancel_url:required}
    {-return_url:required}
} {
    This can be used to check for confirmation before upload to folder
} -

d_proc -public -callback fs::file_revision_new {
    {-package_id:required}
    {-file_id:required}
    {-parent_id:required}
    {-creation_user ""}
    {-creation_ip ""}
} {
    Callback executed when a new file revision is created
    @param package_id Package_id of the file storage package
    @param file_id New file_id for the revision
    @param parent_id Usually, the folder the file was uploaded to.
    @param creation_user User_id of the user creating the revision
    @param creation_ip IP of the creation
} -


# Our callback implementations

d_proc -public -callback search::datasource -impl file_storage_object {} {

    @author Dirk Gomez (openacs@dirkgomez.de)
    @author Jowell S. Sabino (jowellsabino@netscape.net)
    @creation-date 2005-06-13

    Returns a datasource for the search package.
    This is the content that will be indexed by the full text
    search engine.

} {
    # We probably don't need the whole big query here. TODO: Review.
    db_0or1row dbqd.file-storage.tcl.file-storage-callback-procs.fs_datasource {} -column_array datasource

    return [list object_id $object_id \
                title $datasource(title) \
                content $datasource(content) \
                keywords {} \
                storage_type $datasource(storage_type) \
                mime $datasource(mime) ]
}

d_proc -public -callback search::url -impl file_storage_object {
    -object_id:required
} {
    Return the URL to the file_storage_object
} {
    set item_id [content::revision::item_id -revision_id $object_id]
    set name [db_string item {
        select name from cr_items where item_id = :item_id
    } -default ""]
    return "[ad_url]/file/$item_id/$name"
}

d_proc -public -callback datamanager::copy_folder -impl datamanager {
     -object_id:required
     -selected_community:required
     {-mode "both"}
} {
    Copy a folder to another class or community
} {
    #get the destiny's root folder
    set parent_id [dotlrn_fs::get_community_root_folder -community_id $selected_community]
    set new_folder_id [fs_folder_copy -old_folder_id $object_id -new_parent_id $parent_id -mode $mode]

    return $new_folder_id

}

d_proc -public -callback pm::project_new -impl file_storage {
    {-package_id:required}
    {-project_id:required}
} {
    Create a new folder for each new project
} {
    set pm_name [pm::project::name -project_item_id $project_id]

    foreach fs_package_id [application_link::get_linked -from_package_id $package_id -to_package_key "file-storage"] {
        set root_folder_id [fs::get_root_folder -package_id $fs_package_id]

        set folder_id [fs::new_folder \
            -name $root_folder_id \
            -pretty_name $pm_name \
            -parent_id $root_folder_id \
            -no_callback]

        application_data_link::new -this_object_id $project_id -target_object_id $folder_id
    }
}

#Callbacks for application-track

d_proc -callback application-track::getApplicationName -impl file_storage {} {
    Callback implementation
} {
    return "file_storage"
}

d_proc -callback application-track::getGeneralInfo -impl file_storage {} {
    Callback implementation
} {

    db_1row my_query {
        select count(1) as result
        from acs_objects a, acs_objects b
        where b.object_id = :comm_id
        and a.tree_sortkey between b.tree_sortkey
        and tree_right(b.tree_sortkey)
        and a.object_type = 'file_storage_object'
    }


    return "$result"
}

d_proc -callback application-track::getSpecificInfo -impl file_storage {} {
    Callback implementation
} {

    upvar $query_name my_query
    upvar $elements_name my_elements

    set my_query {

    SELECT f.name as name, f.file_id, f.type as type, f.content_size as size,
          fo.name as folder_name,
                   to_char(f.last_modified, 'YYYY-MM-DD HH24:MI:SS') as last_modified,
                   to_char(o.creation_date, 'YYYY-MM-DD HH24:MI:SS') as creation_date,
                   (select site_node__url(site_nodes.node_id)
                   from site_nodes, acs_objects
                   where site_nodes.object_id = file_storage__get_package_id(f.parent_id) and acs_objects.object_id = f.file_id) as url,
                   com.community_id as class_id
            FROM fs_files f,fs_folders fo,dotlrn_communities_full com,acs_objects o, acs_objects o2
            WHERE f.file_id = o.object_id
    and com.community_id=:class_instance_id
                  and o2.object_id= file_storage__get_package_id(f.parent_id)
                  and o2.context_id=com.package_id
                  and fo.folder_id = f.parent_id

    }

    set my_elements {
            name {
                label "Name"
                display_col name
                html {align center}

            }
            type {
                label "Type"
                display_col type
                html {align center}

            }
            folder {
                label "Folder"
                display_col folder_name
                html {align center}
            }
            size {
                label "Size (bytes)"
                display_col size
                html {align center}

            }
            last_modification_date {
                label "Last_Modification_Date"
                display_col last_modified
                html {align center}
            }
            post_date {
                label "Post_Date"
                display_col creation_date
                html {align center}

            }

    }
}

# Local variables:
#    mode: tcl
#    tcl-indent-level: 4
#    indent-tabs-mode: nil
# End: