The Hubzilla
|
File/attach API with the potential for revision control. More...
Functions | |
z_mime_content_type ($filename) | |
Guess the mimetype from file ending. More... | |
attach_count_files ($channel_id, $observer, $hash= '', $filename= '', $filetype= '') | |
Count files/attachments. More... | |
attach_list_files ($channel_id, $observer, $hash= '', $filename= '', $filetype= '', $orderby= 'created desc', $start=0, $entries=0, $since= '', $until= '') | |
Returns a list of files/attachments. More... | |
attach_by_hash ($hash, $observer_hash, $rev=0) | |
Find an attachment by hash and revision. More... | |
attach_can_view_folder ($uid, $ob_hash, $folder_hash) | |
attach_by_hash_nodata ($hash, $observer_hash, $rev=0) | |
Find an attachment by hash and revision. More... | |
attach_store ($channel, $observer_hash, $options= '', $arr=null) | |
Stores an attachment from a POST file upload. More... | |
z_readdir ($channel_id, $observer_hash, $pathname, $parent_hash= '') | |
Read a virtual directory and return contents. More... | |
attach_mkdir ($channel, $observer_hash, $arr=null) | |
Create directory. More... | |
attach_mkdirp ($channel, $observer_hash, $arr=null) | |
Create directory (recursive). More... | |
attach_change_permissions ($channel_id, $resource, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $recurse=false, $sync=false) | |
Changes permissions of a file. More... | |
attach_delete ($channel_id, $resource, $is_photo=0) | |
Delete a file/directory from a channel. More... | |
attach_drop_photo ($channel_id, $resource) | |
get_cloudpath ($arr) | |
Returns path to file in cloud/. More... | |
get_cloud_url ($channel_id, $channel_name, $attachHash) | |
Returns path to parent folder in cloud/. This function cannot be used with mod/dav as it always returns a path valid under mod/cloud. More... | |
find_folder_hash_by_attach_hash ($channel_id, $attachHash, $recurse=false) | |
Return the hash of an attachment's folder. More... | |
find_folder_hash_by_path ($channel_id, $path) | |
Return the hash of an attachment's folder. More... | |
find_filename_by_hash ($channel_id, $attachHash) | |
Returns the filename of an attachment in a given channel. More... | |
pipe_streams ($in, $out, $bufsize=16384) | |
Pipes $in to $out in 16KB chunks. More... | |
file_activity ($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $verb, $notify) | |
Activity for files. More... | |
get_file_activity_object ($channel_id, $hash, $url) | |
Create file activity object. More... | |
attach_recursive_perms ($arr_allow_cid, $arr_allow_gid, $arr_deny_cid, $arr_deny_gid, $folder_hash) | |
Returns recursive permissions array or false if nobody has recursive permissions. More... | |
filepath_macro ($s) | |
attach_export_data ($channel, $resource_id, $deleted=false) | |
get_attach_binname ($s) | |
Strip off 'store/nickname/' from the provided path. More... | |
get_dirpath_by_cloudpath ($channel, $path) | |
get_filename_by_cloudname ($cloudname, $channel, $storepath) | |
copy_folder_to_cloudfiles ($channel, $observer_hash, $srcpath, $cloudpath) | |
recursively copy a directory into cloud files More... | |
attach_move ($channel_id, $resource_id, $new_folder_hash) | |
attach_folder_select_list ($channel_id) | |
attach_folder_rpaths ($all_folders, $that_folder) | |
attach_syspaths ($channel_id, $attach_hash) | |
Given a channel_id and attach_hash, return an array with the full relative path and os_path. More... | |
attach_upgrade () | |
save_chunk ($channel, $start, $end, $len) | |
File/attach API with the potential for revision control.
A filesystem storage abstraction which maintains security (and 'data' contains a system filename which is inaccessible from the web). This could get around PHP storage limits and store videos and larger items, using fread or OS methods or native code to read/write or chunk it through.
Also an 'append' option to the storage function might be a useful addition.
attach_by_hash | ( | $hash, | |
$observer_hash, | |||
$rev = 0 |
|||
) |
Find an attachment by hash and revision.
Returns the entire attach structure including data.
This could exhaust memory so most useful only when immediately sending the data.
string | $hash | |
string | $observer_hash | |
int | $rev | (optional) Revision default 0 |
Referenced by Zotlabs\Module\Attach\init(), Zotlabs\Module\Getfile\post(), and sync_files().
attach_by_hash_nodata | ( | $hash, | |
$observer_hash, | |||
$rev = 0 |
|||
) |
Find an attachment by hash and revision.
Returns the entire attach structure excluding data.
string | $hash | |
string | $observer_hash | |
int | $rev | (optional) revision default 0 |
Referenced by Zotlabs\Module\Photos\get(), Zotlabs\Module\Mail\post(), Zotlabs\Module\Item\post(), and send_message().
attach_can_view_folder | ( | $uid, | |
$ob_hash, | |||
$folder_hash | |||
) |
attach_change_permissions | ( | $channel_id, | |
$resource, | |||
$allow_cid, | |||
$allow_gid, | |||
$deny_cid, | |||
$deny_gid, | |||
$recurse = false , |
|||
$sync = false |
|||
) |
Changes permissions of a file.
int | $channel_id | The id of the channel |
array | $resource | |
string | $allow_cid | |
string | $allow_gid | |
string | $deny_cid | |
string | $deny_gid | |
boolean | $recurse | (optional) default false |
boolean | $sync | (optional) default false |
Referenced by Zotlabs\Module\Filestorage\post().
attach_count_files | ( | $channel_id, | |
$observer, | |||
$hash = '' , |
|||
$filename = '' , |
|||
$filetype = '' |
|||
) |
Count files/attachments.
int | $channel_id | |
string | $observer | |
string | $hash | (optional) |
string | $filename | (optional) |
string | $filetype | (optional) |
attach_delete | ( | $channel_id, | |
$resource, | |||
$is_photo = 0 |
|||
) |
Delete a file/directory from a channel.
If the provided resource hash is from a directory it will delete everything recursively under this directory.
int | $channel_id | The id of the channel |
string | $resource | The hash to delete |
int | $is_photo | (optional) default 0 |
Referenced by channel_remove(), Zotlabs\Module\Filestorage\get(), Zotlabs\Module\Photos\post(), and sync_files().
attach_drop_photo | ( | $channel_id, | |
$resource | |||
) |
Referenced by attach_delete().
attach_export_data | ( | $channel, | |
$resource_id, | |||
$deleted = false |
|||
) |
Referenced by api_file_export(), attach_change_permissions(), attach_store(), Zotlabs\Module\Filestorage\get(), Zotlabs\Module\Profile_photo\get(), Zotlabs\Module\File_upload\post(), Zotlabs\Module\Wall_attach\post(), Zotlabs\Module\Profile_photo\post(), Zotlabs\Module\Photos\post(), and Zotlabs\Daemon\Importfile\run().
attach_folder_rpaths | ( | $all_folders, | |
$that_folder | |||
) |
Referenced by attach_folder_select_list().
attach_folder_select_list | ( | $channel_id | ) |
Used to generate a select input box of all your folders
attach_list_files | ( | $channel_id, | |
$observer, | |||
$hash = '' , |
|||
$filename = '' , |
|||
$filetype = '' , |
|||
$orderby = 'created desc' , |
|||
$start = 0 , |
|||
$entries = 0 , |
|||
$since = '' , |
|||
$until = '' |
|||
) |
Returns a list of files/attachments.
$channel_id | |
$observer | |
$hash | (optional) |
$filename | (optional) |
$filetype | (optional) |
$orderby | |
$start | |
$entries |
Referenced by api_attach_list().
attach_mkdir | ( | $channel, | |
$observer_hash, | |||
$arr = null |
|||
) |
Create directory.
array | $channel | channel array of owner |
string | $observer_hash | hash of current observer |
array | $arr | parameter array to fulfil request
|
Referenced by attach_mkdirp(), attach_store(), and Zotlabs\Module\File_upload\post().
attach_mkdirp | ( | $channel, | |
$observer_hash, | |||
$arr = null |
|||
) |
Create directory (recursive).
array | $channel | channel array of owner |
string | $observer_hash | hash of current observer |
array | $arr | parameter array to fulfil request
|
Referenced by attach_store(), copy_folder_to_cloudfiles(), and Zotlabs\Module\Webpages\post().
attach_move | ( | $channel_id, | |
$resource_id, | |||
$new_folder_hash | |||
) |
This function performs an in place directory-to-directory move of a stored attachment or photo. The data is physically moved in the store/nickname storage location and the paths adjusted in the attach structure (and if applicable the photo table). The new 'album name' is recorded for photos and will show up immediately there. This takes a channel_id, attach.hash of the file to move (this is the same as a photo resource_id), and the attach.hash of the new parent folder, which must already exist. If $new_folder_hash is blank or empty, the file is relocated to the root of the channel's storage area.
int | $channel_id | |
int | $resource_id | |
string | $new_folder_hash |
Referenced by Zotlabs\Module\Photos\post().
attach_recursive_perms | ( | $arr_allow_cid, | |
$arr_allow_gid, | |||
$arr_deny_cid, | |||
$arr_deny_gid, | |||
$folder_hash | |||
) |
Returns recursive permissions array or false if nobody has recursive permissions.
array | $arr_allow_cid | |
array | $arr_allow_gid | |
array | $arr_deny_cid | |
array | $arr_deny_gid | |
string | $folder_hash |
Referenced by file_activity().
attach_store | ( | $channel, | |
$observer_hash, | |||
$options = '' , |
|||
$arr = null |
|||
) |
Stores an attachment from a POST file upload.
This function stores an attachment. It can be a new one, a replacement or a new revision depending on value set in $options.
array | $channel | channel array of owner |
string | $observer_hash | hash of current observer |
string | $options | (optional) one of update, replace, revision |
array | $arr | (optional) associative array |
Referenced by copy_folder_to_cloudfiles(), fix_attached_file_permissions(), Zotlabs\Module\File_upload\post(), Zotlabs\Module\Wall_attach\post(), Zotlabs\Module\Cover_photo\post(), Zotlabs\Module\Profile_photo\post(), Zotlabs\Module\Photos\post(), Zotlabs\Daemon\Importfile\run(), and send_message().
attach_syspaths | ( | $channel_id, | |
$attach_hash | |||
) |
Given a channel_id and attach_hash, return an array with the full relative path and os_path.
Referenced by attach_move(), and attach_upgrade().
attach_upgrade | ( | ) |
in earlier releases we did not fill in os_path and display_path in the attach DB structure. (It was not needed or used). Going forward we intend to make use of these fields. A cron task checks for empty values (as older attachments may have arrived at our site in a clone operation) and executes attach_syspaths() to generate these field values and correct the attach table entry. The operation is limited to 100 DB entries at a time so as not to overload the system in any cron run. Eventually it will catch up with old attach structures and switch into maintenance mode to correct any that might arrive in clone packets from older sites.
Referenced by Zotlabs\Daemon\Cron\run().
copy_folder_to_cloudfiles | ( | $channel, | |
$observer_hash, | |||
$srcpath, | |||
$cloudpath | |||
) |
recursively copy a directory into cloud files
array | $channel | |
string | $observer_hash | |
string | $srcpath | |
string | $cloudpath |
Referenced by Zotlabs\Module\Webpages\post().
file_activity | ( | $channel_id, | |
$object, | |||
$allow_cid, | |||
$allow_gid, | |||
$deny_cid, | |||
$deny_gid, | |||
$verb, | |||
$notify | |||
) |
Activity for files.
int | $channel_id | |
array | $object | |
string | $allow_cid | |
string | $allow_gid | |
string | $deny_cid | |
string | $deny_gid | |
string | $verb | |
boolean | $notify |
Referenced by attach_delete(), attach_store(), and Zotlabs\Module\Filestorage\post().
filepath_macro | ( | $s | ) |
Referenced by attach_store(), and Zotlabs\Module\Photos\get().
find_filename_by_hash | ( | $channel_id, | |
$attachHash | |||
) |
Returns the filename of an attachment in a given channel.
int | $channel_id | The id of the channel |
string | $attachHash | The hash of the attachment |
Referenced by get_cloud_url(), get_dirpath_by_cloudpath(), and get_filename_by_cloudname().
find_folder_hash_by_attach_hash | ( | $channel_id, | |
$attachHash, | |||
$recurse = false |
|||
) |
Return the hash of an attachment's folder.
int | $channel_id | The id of the channel |
string | $attachHash | The hash of the attachment |
boolean | $recurse | (optional) default false |
Referenced by attach_store(), and get_cloud_url().
find_folder_hash_by_path | ( | $channel_id, | |
$path | |||
) |
Return the hash of an attachment's folder.
int | $channel_id | |
string | $path |
get_attach_binname | ( | $s | ) |
Strip off 'store/nickname/' from the provided path.
string | $s |
Referenced by sync_files().
get_cloud_url | ( | $channel_id, | |
$channel_name, | |||
$attachHash | |||
) |
Returns path to parent folder in cloud/. This function cannot be used with mod/dav as it always returns a path valid under mod/cloud.
int | $channel_id | The id of the channel |
string | $channel_name | The name of the channel |
string | $attachHash |
Referenced by attach_delete(), Zotlabs\Module\Filestorage\get(), and Zotlabs\Module\Filestorage\post().
get_cloudpath | ( | $arr | ) |
Returns path to file in cloud/.
array | $arr | associative array with:
|
Referenced by Zotlabs\Module\Filestorage\get().
get_dirpath_by_cloudpath | ( | $channel, | |
$path | |||
) |
Referenced by Zotlabs\Module\Webpages\post(), and scan_webpage_elements().
get_file_activity_object | ( | $channel_id, | |
$hash, | |||
$url | |||
) |
Create file activity object.
int | $channel_id | |
string | $hash | |
string | $url |
Referenced by attach_delete(), attach_store(), and Zotlabs\Module\Filestorage\post().
get_filename_by_cloudname | ( | $cloudname, | |
$channel, | |||
$storepath | |||
) |
Referenced by scan_webpage_elements().
pipe_streams | ( | $in, | |
$out, | |||
$bufsize = 16384 |
|||
) |
Pipes $in to $out in 16KB chunks.
resource | $in | File pointer of input |
resource | $out | File pointer of output |
int | $bufsize | size of chunk, default 16384 |
Referenced by attach_store(), Zotlabs\Module\Attach\init(), Zotlabs\Module\Photo\init(), Zotlabs\Module\Getfile\post(), save_chunk(), Zotlabs\Thumbs\Video\Thumb(), and Zotlabs\Thumbs\Pdf\Thumb().
save_chunk | ( | $channel, | |
$start, | |||
$end, | |||
$len | |||
) |
Chunked uploader for integration with the blueimp jquery-uploader This is currently used.
Referenced by Zotlabs\Module\File_upload\post(), Zotlabs\Module\Wall_attach\post(), and Zotlabs\Module\Photos\post().
z_mime_content_type | ( | $filename | ) |
Guess the mimetype from file ending.
This function takes a file name and guess the mimetype from the filename extension.
string | $filename | a string filename |
Referenced by attach_store(), and Zotlabs\Daemon\Importdoc\update_docs_dir().
z_readdir | ( | $channel_id, | |
$observer_hash, | |||
$pathname, | |||
$parent_hash = '' |
|||
) |
Read a virtual directory and return contents.
Also checking permissions of all parent components.
integer | $channel_id | |
string | $observer_hash | hash of current observer |
string | $pathname | |
string | $parent_hash | (optional) |