Provides an application programming interface (API) for managing files within the Tripal data directory structure.
◆ tripal_create_files_dir()
tripal_create_files_dir |
( |
|
$module_name, |
|
|
|
$path = FALSE |
|
) |
| |
Creates a directory for a module in the Drupal's public files directory.
Previously it was recommended that this function be called during installation of the module in the .install file. However this causes permission problems if the module is installed via drush with a user account that is not the same as the web user. Therefore, this function should not be called in a location accessible via a drush command. The tripal_get_files_dir() and tripal_get_files_stream() will automatically create the directory if it doesn't exist so there is little need to call this function directly.
- Parameters
-
$module_name | the name of the module being installed |
$path | Optional sub-path to create |
◆ tripal_format_bytes()
tripal_format_bytes |
( |
|
$bytes, |
|
|
|
$precision = 2 |
|
) |
| |
Formats a size (in bytes) in human readable format.
Function taken from php.net
- Parameters
-
$bytes | The size of the file in bytes |
$precision | The number of decimal places to use in the final number if needed |
- Returns
- string A formatted string indicating the size of the file
◆ tripal_get_files_dir()
tripal_get_files_dir |
( |
|
$module_name = FALSE | ) |
|
Retrieves the Drupal relative directory for a Tripal module.
Each Tripal module has a unique data directory which was created using the tripal_create_files_dir function during installation. This function retrieves the directory path.
- Parameters
-
$module_name | (Optional) The name of the module. |
- Returns
- The path within the Drupal installation where the data directory resides
◆ tripal_get_files_stream()
tripal_get_files_stream |
( |
|
$module_name = FALSE | ) |
|
Retrieves the Drupal stream (e.g. public://...) for a Tripal module.
Each Tripal module has a unique data directory which was created using the tripal_create_files_dir function during installation. This function retrieves the directory path.
- Parameters
-
$module_name | (Optional) The name of the module. |
- Returns
- The path within the Drupal installation where the data directory resides
◆ tripal_get_user_files_dir()
tripal_get_user_files_dir |
( |
|
$uid | ) |
|
Retrieves the URI for the dedicated directory for a user's files.
This directory is used by the file uploader and by data collections.
- Parameters
-
- Returns
- The URI of the directory.
◆ tripal_get_user_uploads()
tripal_get_user_uploads |
( |
|
$uid, |
|
|
|
$allowed_types = [] , |
|
|
|
$module = 'tripal' |
|
) |
| |
Retrieves the list of files uploaded by a user.
- Parameters
-
$uid | The ID of the user whose files should be retrieved. |
$allowed_types | A list of valid extensions to restrict the files to. |
$module | The name of the module that is managing the file. |
- Returns
- A list of file objects.
◆ tripal_is_user_files_dir_writeable()
tripal_is_user_files_dir_writeable |
( |
|
$uid | ) |
|
Checks if the user's dedicated directory is accessible and writeable.
- Parameters
-
- Returns
- TRUE if the user's directory is writeable. FALSE otherwise.