richtext::ckeditor4::ckfinder::file_attach (public)
richtext::ckeditor4::ckfinder::file_attach \ [ -import_file import_file ] [ -mime_type mime_type ] \ [ -object_id object_id ] [ -privilege privilege ] \ [ -user_id user_id ] [ -peeraddr peeraddr ] \ [ -package_id package_id ] [ -image ]
Defined in packages/richtext-ckeditor4/tcl/ckfinder-procs.tcl
Insert the provided file to the content repository as a new item and attach it to the specified object_id via the attachment API. This makes sure that the file will be deleted from the content repository, when the provided object_id is deleted. The user must have at least "read" privileges on the object, but other stronger privileges can be supplied via parameter.
- Switches:
- -import_file (optional)
- -mime_type (optional)
- -object_id (optional)
- -privilege (optional, defaults to
"read"
)- -user_id (optional)
- -peeraddr (optional)
- -package_id (optional)
- -image (optional, boolean)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: permission::require_permission -party_id $user_id -object_id $object_id -privilege $privilege if {$image_p} { # # Check if we can handle the mime type. Currently, only the # following four mime types are supported, since these are # supported by "ns_imgsize", which is used to determine the # dimensions of the image. # switch -- $mime_type { image/jpg - image/jpeg - image/gif - image/png { set ext .[lindex [split $mime_type /] 1] lassign [ns_imgsize $import_file] width height set success 1 } default { ns_log warning "file_attach: can't handle image type '$mime_type'" return [list success 0 errMsg "can't handle image type '$mime_type'"] } } } else { set width 0 set height 0 set success 1 } # # Create a new item without child_rels # set name $object_id-[clock clicks -microseconds] set item_id [::acs::dc call content_item new -name $name -parent_id [require_root_folder] -context_id $object_id -creation_user $user_id -creation_ip $peeraddr -item_subtype "content_item" -storage_type "file" -package_id $package_id -with_child_rels f] # # Create a revision for the fresh content_item # set revision_id [xo::dc nextval acs_object_id_seq] content::revision::new -revision_id $revision_id -item_id $item_id -title $name -is_live t -creation_user $user_id -creation_ip $peeraddr -content_type "content_revision" -package_id $package_id -tmp_filename $import_file -mime_type $mime_type # # Attach the file to the object via the attachments API # attachments::attach -object_id $object_id -attachment_id $revision_id return [list success $success name $name file_id $revision_id width $width height $height ]XQL Not present: Generic, PostgreSQL, Oracle