The Red Matrix
 All Classes Namespaces Files Functions Variables Pages
attach.php File Reference

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)
 Returns a list of files/attachments. More...
 
 attach_by_hash ($hash, $rev=0)
 Find an attachment by hash and revision. More...
 
 attach_by_hash_nodata ($hash, $rev=0)
 Find an attachment by hash and revision. More...
 
 attach_store ($channel, $observer_hash, $options= '', $arr=null)
 
 z_readdir ($channel_id, $observer_hash, $pathname, $parent_hash= '')
 
 attach_mkdir ($channel, $observer_hash, $arr=null)
 Create directory. More...
 
 attach_change_permissions ($channel_id, $resource, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $recurse=false)
 Changes permissions of a file. More...
 
 attach_delete ($channel_id, $resource)
 Delete a file. More...
 
 get_cloudpath ($arr)
 Returns path to file in cloud/. More...
 
 get_parent_cloudpath ($channel_id, $channel_name, $attachHash)
 Returns path to parent folder in cloud/. More...
 
 find_folder_hash_by_attach_hash ($channel_id, $attachHash)
 
 find_filename_by_hash ($channel_id, $attachHash)
 
 pipe_streams ($in, $out)
 

Detailed Description

File/attach API with the potential for revision control.

TODO: 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.

Function Documentation

attach_by_hash (   $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.

Parameters
$hash
$rev

Referenced by attach_init().

attach_by_hash_nodata (   $hash,
  $rev = 0 
)

Find an attachment by hash and revision.

Returns the entire attach structure excluding data.

See Also
attach_by_hash()
Parameters
$hash
$ref

Referenced by item_post(), and send_message().

attach_change_permissions (   $channel_id,
  $resource,
  $allow_cid,
  $allow_gid,
  $deny_cid,
  $deny_gid,
  $recurse = false 
)

Changes permissions of a file.

Parameters
$channel_id
$resource
$allow_cid
$allow_gid
$deny_cid
$deny_gid
$recurse

Referenced by filestorage_post().

attach_count_files (   $channel_id,
  $observer,
  $hash = '',
  $filename = '',
  $filetype = '' 
)

Count files/attachments.

Parameters
$channel_id
$observer
$hash(optional)
$filename(optional)
$filetype(optional)
Returns
array $ret['success'] boolean $ret['results'] amount of found results, or false $ret['message'] string with error messages if any
attach_delete (   $channel_id,
  $resource 
)

Delete a file.

Parameters
$channel_id
$resource

Referenced by RedDirectory\createFile(), RedFile\delete(), filestorage_content(), and RedFile\put().

attach_list_files (   $channel_id,
  $observer,
  $hash = '',
  $filename = '',
  $filetype = '',
  $orderby = 'created desc',
  $start = 0,
  $entries = 0 
)

Returns a list of files/attachments.

Parameters
$channel_id
$observer
$hash(optional)
$filename(optional)
$filetype(optional)
$orderby
$start
$entries
Returns
array $ret['success'] boolean $ret['results'] array with results, or false $ret['message'] string with error messages if any
attach_mkdir (   $channel,
  $observer_hash,
  $arr = null 
)

Create directory.

attach_mkdir($channel,$observer_hash,$arr);

Parameters
$channelchannel array of owner
$observer_hashhash of current observer
$arrparameter array to fulfil request Required: $arr['filename'] $arr['folder'] // hash of parent directory, empty string for root directory Optional: $arr['hash'] // precumputed hash for this node $arr['allow_cid'] $arr['allow_gid'] $arr['deny_cid'] $arr['deny_gid']

Referenced by RedDirectory\createDirectory().

attach_store (   $channel,
  $observer_hash,
  $options = '',
  $arr = null 
)
Parameters
$channelchannel array of owner
$observer_hashhash of current observer
$options(optional)
$arr(optional)

Referenced by fix_attached_file_permissions(), importelm_post(), send_message(), and wall_attach_post().

find_filename_by_hash (   $channel_id,
  $attachHash 
)

Referenced by get_parent_cloudpath().

find_folder_hash_by_attach_hash (   $channel_id,
  $attachHash 
)

Referenced by get_parent_cloudpath().

get_cloudpath (   $arr)

Returns path to file in cloud/.

Parameters
$arr
Returns
string with the path the file to cloud/

Referenced by filestorage_content().

get_parent_cloudpath (   $channel_id,
  $channel_name,
  $attachHash 
)

Returns path to parent folder in cloud/.

Parameters
$arr
Returns
string with the folder path

Referenced by filestorage_content(), and filestorage_post().

pipe_streams (   $in,
  $out 
)
Parameters
$in
$out

Referenced by attach_init().

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.

Parameters
$filenamea string filename
Returns
string The mimetype according to a file ending.

Referenced by attach_store(), and RedDirectory\createFile().

z_readdir (   $channel_id,
  $observer_hash,
  $pathname,
  $parent_hash = '' 
)

Read a virtual directory and return contents, checking permissions of all parent components. z_readdir

Parameters
integer$channel_id
string$observer_hashhash of current observer
string$pathname
string$parent_hash(optional)
Returns
array $ret $ret['success'] = boolean true or false $ret['message'] = error message if success is false $ret['data'] = array of attach DB entries without data component