Documentation

Attachments
in package
implements ActionInterface Uses 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  : object
$backcompat  : array<string|int, mixed>

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|array<string|int, mixed>
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.
browseFiles()  : void
Backward compatibility wrapper for the browse sub-action.
call()  : void
Convenience method to load() and execute() an instance of this class.
execute()  : void
Dispatcher to whichever sub-action method is necessary.
exportStatic()  : void
Provides a way to export a class's public static properties and methods to global namespace.
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()  : object
Static wrapper for constructor.
maintain()  : void
Show several file maintenance options.
maintainFiles()  : void
Backward compatibility wrapper for the maintenance sub-action.
manageAttachmentPaths()  : void
Backward compatibility wrapper for the attachpaths sub-action.
manageAttachmentSettings()  : void|array<string|int, mixed>
Backward compatibility wrapper for the attachments sub-action.
manageAvatarSettings()  : void|array<string|int, mixed>
Backward compatibility wrapper for the avatars sub-action.
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.
removeAllAttachments()  : void
Backward compatibility wrapper for the removeall sub-action.
removeAttachment()  : void
Backward compatibility wrapper for the remove sub-action.
removeAttachmentByAge()  : void
Backward compatibility wrapper for the byage sub-action.
removeAttachmentBySize()  : void
Backward compatibility wrapper for the bysize sub-action.
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.
repairAttachments()  : void
Backward compatibility wrapper for the repair sub-action.
transfer()  : void
Maintance function to move attachments from one directory to another
transferAttachments()  : void
Backward compatibility wrapper for the transfer sub-action.
__construct()  : mixed
Constructor. Protected to force instantiation via self::load().
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 object $obj

An instance of this class. This is used by the load() method to prevent mulitple instantiations.

$backcompat

private static array<string|int, mixed> $backcompat = ['func_names' => ['call' => 'ManageAttachments', 'list_getFiles' => 'list_getFiles', 'list_getNumFiles' => 'list_getNumFiles', 'list_getAttachDirs' => 'list_getAttachDirs', 'list_getBaseDirs' => 'list_getBaseDirs', 'attachDirStatus' => 'attachDirStatus', 'manageAttachmentSettings' => 'ManageAttachmentSettings', 'manageAvatarSettings' => 'ManageAvatarSettings', 'browseFiles' => 'BrowseFiles', 'maintainFiles' => 'MaintainFiles', 'removeAttachment' => 'RemoveAttachment', 'removeAttachmentByAge' => 'RemoveAttachmentByAge', 'removeAttachmentBySize' => 'RemoveAttachmentBySize', 'removeAllAttachments' => 'RemoveAllAttachments', 'repairAttachments' => 'RepairAttachments', 'manageAttachmentPaths' => 'ManageAttachmentPaths', 'transferAttachments' => 'TransferAttachments']]

BackwardCompatibility settings for this class.

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|array<string|int, mixed>

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.

Return values
void|array<string|int, mixed>

If $return_config is true, simply returns the config_vars array, otherwise returns nothing

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.

browseFiles()

Backward compatibility wrapper for the browse sub-action.

public static browseFiles() : void

call()

Convenience method to load() and execute() an instance of this class.

public static call() : void

execute()

Dispatcher to whichever sub-action method is necessary.

public execute() : void

exportStatic()

Provides a way to export a class's public static properties and methods to global namespace.

public static exportStatic() : void

To do so:

  1. Use this trait in the class.
  2. At the END of the class's file, call its exportStatic() method.

Although it might not seem that way at first glance, this approach conforms to section 2.3 of PSR 1, since executing this method is simply a dynamic means of declaring functions when the file is included; it has no other side effects.

Regarding the $backcompat items:

A class's static properties are not exported to global variables unless explicitly included in $backcompat['prop_names']. Likewise, a class's static methods are not exported as global functions unless explicitly included in $backcompat['func_names'].

$backcompat['prop_names'] is a simple array where the keys are the names of one or more of a class's static properties, and the values are the names of global variables. In each case, the global variable will be set to a reference to the static property. Static properties that are not named in this array will not be exported.

$backcompat['func_names'] is a simple array where the keys are the names of one or more of a class's static methods, and the values are the names that should be used for global functions that will encapsulate those methods. Methods that are not named in this array will not be exported.

Adding non-static properties or methods to the $backcompat arrays will produce runtime errors. It is the responsibility of the developer to make sure not to do this.

list_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() : object
Return values
object

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
uses
template_maintenance()

maintainFiles()

Backward compatibility wrapper for the maintenance sub-action.

public static maintainFiles() : void

manageAttachmentPaths()

Backward compatibility wrapper for the attachpaths sub-action.

public static manageAttachmentPaths() : void

manageAttachmentSettings()

Backward compatibility wrapper for the attachments sub-action.

public static manageAttachmentSettings([bool $return_config = false ]) : void|array<string|int, mixed>
Parameters
$return_config : bool = false

Whether to return the config_vars array.

Return values
void|array<string|int, mixed>

Returns nothing or returns the config_vars array.

manageAvatarSettings()

Backward compatibility wrapper for the avatars sub-action.

public static manageAvatarSettings([bool $return_config = false ]) : void|array<string|int, mixed>
Parameters
$return_config : bool = false

Whether to return the config_vars array.

Return values
void|array<string|int, mixed>

Returns nothing or returns the config_vars array.

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

removeAllAttachments()

Backward compatibility wrapper for the removeall sub-action.

public static removeAllAttachments() : void

removeAttachment()

Backward compatibility wrapper for the remove sub-action.

public static removeAttachment() : void

removeAttachmentByAge()

Backward compatibility wrapper for the byage sub-action.

public static removeAttachmentByAge() : void

removeAttachmentBySize()

Backward compatibility wrapper for the bysize sub-action.

public static removeAttachmentBySize() : 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

repairAttachments()

Backward compatibility wrapper for the repair sub-action.

public static repairAttachments() : void

transfer()

Maintance function to move attachments from one directory to another

public transfer() : void

transferAttachments()

Backward compatibility wrapper for the transfer sub-action.

public static transferAttachments() : void

__construct()

Constructor. Protected to force instantiation via self::load().

protected __construct() : 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.


        
On this page

Search results