Attachments
in package
implements
ActionInterface
uses
ActionTrait, BackwardCompatibility
Maintains and manages attachments and avatars.
Table of Contents
Interfaces
- ActionInterface
- Interface for all action classes.
Properties
- $subaction : string
- $subactions : array<string|int, mixed>
- $obj : static
Methods
- attachConfigVars() : array<string|int, mixed>
- Gets the configuration variables for the attachments sub-action.
- attachDirStatus() : array<string|int, mixed>
- Checks the status of an attachment directory and returns an array of the status key, if that status key signifies an error, and the file count.
- attachmentSettings() : void
- Allows to show/change attachment settings.
- avatarConfigVars() : array<string|int, mixed>
- Gets the configuration variables for the avatars sub-action.
- avatarSettings() : void
- This allows to show/change avatar settings.
- browse() : void
- Show a list of attachment or avatar files.
- call() : void
- Convenience method to load() and execute() an instance of this class.
- canBeLogged() : bool
- Determines whether this action can be logged in the online log.
- canShowDebuggingInfo() : bool
- Determines whether debugging info should be shown.
- canShowInMaintenanceMode() : bool
- Determines whether this action allows access in maintenance mode.
- execute() : void
- Dispatcher to whichever sub-action method is necessary.
- getOutputType() : OutputTypeInterface
- Gets the output type for this action.
- isAgreementAction() : bool
- Determines whether this action can be accessed without accepting the registration agreement and privacy policy.
- isRestrictedGuestAccessAllowed() : bool
- Determines whether this action allows access if guest access is restricted.
- isSimpleAction() : bool
- Determines whether this is a simple action.
- list_getAttachDirs() : array<string|int, mixed>
- Prepare the actual attachment directories to be displayed in the list.
- list_getBaseDirs() : array<string|int, mixed>
- Prepare the base directories to be displayed in a list.
- list_getFiles() : array<string|int, mixed>
- Returns the list of attachments files (avatars or not), recorded in the database, per the parameters received.
- list_getNumFiles() : int
- Return the number of files of the specified type recorded in the database.
- load() : static
- Static wrapper for constructor.
- maintain() : void
- Show several file maintenance options.
- paths() : void
- This function lists and allows updating of multiple attachments paths.
- remove() : void
- Remove a selection of attachments or avatars.
- removeAll() : void
- Removes all attachments in a single click Called from the maintenance screen by ?action=admin;area=manageattachments;sa=removeall.
- removeByAge() : void
- Remove attachments older than a given age.
- removeBySize() : void
- Remove attachments larger than a given size.
- repair() : void
- This function should find attachments in the database that no longer exist and clear them, and fix filesize issues.
- subActionProvider() : null|array<string|int, mixed>
- Called by Subs-Compat.php BackwardCompatibility wrapper functions to provide subaction execution for existing mods
- transfer() : void
- Maintenance function to move attachments from one directory to another
- __construct() : mixed
- Constructor. Protected to force instantiation via self::load().
- init() : mixed
- Does some initial setup.
- pauseAttachmentMaintenance() : void
- Function called in-between each round of attachments and avatar repairs.
Properties
$subaction
public
string
$subaction
= 'browse'
The requested sub-action. This should be set by the constructor.
$subactions
public
static array<string|int, mixed>
$subactions
= ['attachments' => 'attachmentSettings', 'avatars' => 'avatarSettings', 'browse' => 'browse', 'maintenance' => 'maintain', 'remove' => 'remove', 'byage' => 'removeByAge', 'bysize' => 'removeBySize', 'removeall' => 'removeAll', 'repair' => 'repair', 'attachpaths' => 'paths', 'transfer' => 'transfer']
Available sub-actions.
$obj
protected
static static
$obj
An instance of this class. This is used by the load() method to prevent multiple instantiations.
Methods
attachConfigVars()
Gets the configuration variables for the attachments sub-action.
public
static attachConfigVars() : array<string|int, mixed>
Return values
array<string|int, mixed> —$config_vars for the attachments sub-action.
attachDirStatus()
Checks the status of an attachment directory and returns an array of the status key, if that status key signifies an error, and the file count.
public
static attachDirStatus(string $dir, int $expected_files) : array<string|int, mixed>
Parameters
- $dir : string
-
The directory to check
- $expected_files : int
-
How many files should be in that directory
Return values
array<string|int, mixed> —An array containing the status of the directory, whether the number of files was what we expected and how many were in the directory
attachmentSettings()
Allows to show/change attachment settings.
public
attachmentSettings() : void
This is the default sub-action of the 'Attachments and Avatars' center. Called by index.php?action=admin;area=manageattachments;sa=attachments. Uses 'attachments' sub template.
avatarConfigVars()
Gets the configuration variables for the avatars sub-action.
public
static avatarConfigVars() : array<string|int, mixed>
Return values
array<string|int, mixed> —$config_vars for the avatars sub-action.
avatarSettings()
This allows to show/change avatar settings.
public
avatarSettings() : void
Called by index.php?action=admin;area=manageattachments;sa=avatars. Show/set permissions for permissions: 'profile_server_avatar', 'profile_upload_avatar' and 'profile_remote_avatar'.
browse()
Show a list of attachment or avatar files.
public
browse() : void
Called by ?action=admin;area=manageattachments;sa=browse for attachments and ?action=admin;area=manageattachments;sa=browse;avatars for avatars. Allows sorting by name, date, size and member. Paginates results.
call()
Convenience method to load() and execute() an instance of this class.
public
static call() : void
canBeLogged()
Determines whether this action can be logged in the online log.
public
canBeLogged() : bool
Return values
boolcanShowDebuggingInfo()
Determines whether debugging info should be shown.
public
canShowDebuggingInfo() : bool
Return values
boolcanShowInMaintenanceMode()
Determines whether this action allows access in maintenance mode.
public
canShowInMaintenanceMode() : bool
Return values
bool —True if access is allowed, false otherwise.
execute()
Dispatcher to whichever sub-action method is necessary.
public
execute() : void
getOutputType()
Gets the output type for this action.
public
getOutputType() : OutputTypeInterface
Return values
OutputTypeInterfaceisAgreementAction()
Determines whether this action can be accessed without accepting the registration agreement and privacy policy.
public
isAgreementAction() : bool
Return values
boolisRestrictedGuestAccessAllowed()
Determines whether this action allows access if guest access is restricted.
public
isRestrictedGuestAccessAllowed() : bool
Return values
bool —True if access is allowed, false otherwise.
isSimpleAction()
Determines whether this is a simple action.
public
isSimpleAction() : bool
Return values
boollist_getAttachDirs()
Prepare the actual attachment directories to be displayed in the list.
public
static list_getAttachDirs() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array of information about the attachment directories
list_getBaseDirs()
Prepare the base directories to be displayed in a list.
public
static list_getBaseDirs() : array<string|int, mixed>
Return values
array<string|int, mixed> —Returns an array of info about the directories.
list_getFiles()
Returns the list of attachments files (avatars or not), recorded in the database, per the parameters received.
public
static list_getFiles(int $start, int $items_per_page, string $sort, string $browse_type) : array<string|int, mixed>
Parameters
- $start : int
-
The item to start with
- $items_per_page : int
-
How many items to show per page
- $sort : string
-
A string indicating how to sort results
- $browse_type : string
-
can be one of 'avatars' or ... not. :P
Return values
array<string|int, mixed> —An array of file info
list_getNumFiles()
Return the number of files of the specified type recorded in the database.
public
static list_getNumFiles(string $browse_type) : int
(the specified type being attachments or avatars).
Parameters
- $browse_type : string
-
can be one of 'avatars' or not. (in which case they're attachments)
Return values
int —The number of files
load()
Static wrapper for constructor.
public
static load() : static
Return values
static —An instance of this class.
maintain()
Show several file maintenance options.
public
maintain() : void
Called by ?action=admin;area=manageattachments;sa=maintain. Calculates file statistics (total file size, number of attachments, number of avatars, attachment space available).
Tags
paths()
This function lists and allows updating of multiple attachments paths.
public
paths() : void
remove()
Remove a selection of attachments or avatars.
public
remove() : void
Called from the browse screen as submitted form by ?action=admin;area=manageattachments;sa=remove
removeAll()
Removes all attachments in a single click Called from the maintenance screen by ?action=admin;area=manageattachments;sa=removeall.
public
removeAll() : void
removeByAge()
Remove attachments older than a given age.
public
removeByAge() : void
Called from the maintenance screen by ?action=admin;area=manageattachments;sa=byage. It optionally adds a certain text to the messages the attachments were removed from.
removeBySize()
Remove attachments larger than a given size.
public
removeBySize() : void
Called from the maintenance screen by ?action=admin;area=manageattachments;sa=bysize. Optionally adds a certain text to the messages the attachments were removed from.
repair()
This function should find attachments in the database that no longer exist and clear them, and fix filesize issues.
public
repair() : void
subActionProvider()
Called by Subs-Compat.php BackwardCompatibility wrapper functions to provide subaction execution for existing mods
public
static subActionProvider([null|string $sa = null ][, bool $return_config = false ][, string|null $activity = null ]) : null|array<string|int, mixed>
Parameters
- $sa : null|string = null
- $return_config : bool = false
- $activity : string|null = null
Return values
null|array<string|int, mixed>transfer()
Maintenance function to move attachments from one directory to another
public
transfer() : void
__construct()
Constructor. Protected to force instantiation via self::load().
protected
__construct() : mixed
init()
Does some initial setup.
protected
init() : mixed
pauseAttachmentMaintenance()
Function called in-between each round of attachments and avatar repairs.
protected
pauseAttachmentMaintenance(array<string|int, mixed> $to_fix[, int $max_substep = 0 ]) : void
Called by self::repair().
If more steps are ever added to self::repair(), this method will need to be updated!
Parameters
- $to_fix : array<string|int, mixed>
-
IDs of attachments to fix.
- $max_substep : int = 0
-
The maximum substep to reach before pausing.