phorum_api_file_check_delete_access (line 848)
Check if the active user has permission to delete a file.
boolean
phorum_api_file_check_delete_access
(mixed $file_id, integer $file_id
)
-
integer
$file_id
: The file_id of the file for which to check the delete access.
phorum_api_file_check_read_access (line 580)
Check if a file exists and if the active user has permission to read it.
The function will return either an array containing descriptive data for the file or FALSE, in case access was not granted.
Note that the file_data field is not available in the return array. That data can be retrieved by the phorum_api_file_retrieve() function.
mixed
phorum_api_file_check_read_access
(mixed $file_id, [mixed $flags = 0], integer $file_id
, integer $flags
)
-
integer
$file_id
: The file_id of the file for which to check read access.
-
integer
$flags
: If the PHORUM_FLAG_IGNORE_PERMS flag is used, then permission checks are fully bypassed. In this case, the function will only check if the file exists or not.
phorum_api_file_check_write_access (line 166)
Check if the active user has permissions to store a personal file or a message attachment.
Note that the checks for message attachments aren't all checks that are done by Phorum. The attachment posting script does run some additional checks on the message level (e.g. to see if the maximum cumulative attachment size is not exceeded).
array
phorum_api_file_check_write_access
(mixed $file, array $file
)
-
array
$file
: This is an array, containing information about the file that will be uploaded. The array should contain at least the "link" field. That field will be used to handle checking for personal uploaded files in the control center (PHORUM_LINK_USER) or message attachments (PHORUM_LINK_MESSAGE). Next to that, interesting file fields to pass to this function are "filesize" (to check maximum size) and "filename" (to check allowed file type extensions). A "user_id" field can either be provided or the user_id of the active Phorum user will be used.
phorum_api_file_delete (line 945)
Delete a Phorum file.
void
phorum_api_file_delete
(mixed $file, mixed $file
)
-
mixed
$file
: This is either an array containing at least the field "file_id" or a numerical file_id value.
phorum_api_file_exists (line 1096)
Check if a Phorum file exists.
(this is a simple wrapper function around the phorum_api_file_check_read_access() function)
bool
phorum_api_file_exists
(mixed $file_id, integer $file_id
)
-
integer
$file_id
: The file_id of the Phorum file to check.
phorum_api_file_get (line 1149)
Retrieve and return a Phorum file.
(this is a simple wrapper function around the phorum_api_file_retrieve() function)
mixed
phorum_api_file_get
(mixed $file, [mixed $flags = 0], mixed $file
, integer $flags
)
-
mixed
$file
: This is either an array containing at least the fields "file_id" and "filename" or a numerical file_id value. Note that you can use the return value of the function phorum_api_file_check_read_access() as input for this function.
-
integer
$flags
: If the PHORUM_FLAG_IGNORE_PERMS flag is used, then permission checks are fully bypassed.
phorum_api_file_get_mimetype (line 119)
Lookup the MIME type for a given filename.
This will use an internal lookup list of known file extensions to find the correct content type for a filename. If no content type is known, then "application/octet-stream" will be used as the MIME type (causing the browser to download the file, instead of opening it).
string
phorum_api_file_get_mimetype
(mixed $filename, string $filename
)
-
string
$filename
: The filename for which to lookup the MIME type.
phorum_api_file_list (line 997)
Retrieve a list of files.
array
phorum_api_file_list
([mixed $link_type = NULL], [mixed $user_id = NULL], [mixed $message_id = NULL], string $link_type
, integer $user_id
, integer $message_id
)
-
string
$link_type
: The type of link to retrieve from the database. Normally this is one of the Phorum built-in link types, but it can also be a custom link type (e.g. if a module uses the file storage on its own). This parameter can be NULL to retrieve any link type.
-
integer
$user_id
: The user_id to retrieve files for or NULL to retrieve files for any user_id.
-
integer
$message_id
: The message_id to retrieve files for or NULL to retrieve files for any message_id.
phorum_api_file_purge_stale (line 1023)
This function is used for purging stale files from the Phorum system.
array
phorum_api_file_purge_stale
(mixed $do_purge, boolean $do_purge
)
-
boolean
$do_purge
: If this parameter is set to a false value (the default), then no actual purging will take place. The function will only return an array of stale files. If the parameter is set to a true value, then the stale files will be purged for real.
phorum_api_file_retrieve (line 729)
Retrieve a Phorum file.
This function can handle Phorum file retrieval in multiple ways: either return the file to the caller or send it directly to the user's browser (based on the $flags parameter). Sending it directly to the browser allows for the implementation of modules that don't have to buffer the full file data before sending it (a.k.a. streaming, which provides the advantage of using less memory for sending files).
mixed
phorum_api_file_retrieve
(mixed $file, [mixed $flags = PHORUM_FLAG_GET], mixed $file
, integer $flags
)
phorum_api_file_send (line 1123)
Send a file to the browser.
(this is a simple wrapper function around the phorum_api_file_retrieve() function)
void
phorum_api_file_send
(mixed $file, [integer $flags = 0])
-
mixed
$file: This is either an array containing at least the fields "file_id" and "filename" or a numerical file_id value. Note that you can use the return value of the function phorum_api_file_check_read_access() as input for this function.
-
integer
$flags: If the PHORUM_FLAG_IGNORE_PERMS flag is used, then permission checks are fully bypassed. If PHORUM_FLAG_FORCE_DOWNLOAD is used, then a download by the browser is forced (instead of opening the file in an appliction that the browser finds appropriate for the file type).
phorum_api_file_store (line 354)
Store or update a file.
mixed
phorum_api_file_store
(mixed $file, array $file
)
-
array
$file
:
An array, containing information for the file. This array has to contain the following fields:
- filename: The name of the file.
- file_data: The file data.
- filesize: The size of the file data in bytes.
- link: A value describing to what type of entity the file is
linked. The following values are available:
- PHORUM_LINK_USER
- PHORUM_LINK_MESSAGE
- PHORUM_LINK_EDITOR
- PHORUM_LINK_TEMPFILE
- user_id: The user to link a file to. If none is provided, then
- message_id: The message to link a file to or 0 if it's no
message attachment.
Additionally, the "file_id" field can be set. If it is set, then the existing file will be updated. If it is not set, a new file will be created.