\MatthiasWeb\RealMediaLibrary\apiIFolderActions

This interface provides elementary action methods for folder objects. All folder types (Folder, Collection, Gallery, .

..) have implemented this interface. Also the root ("Unorganized") is a folder and implements this interface.

Summary

Methods
Constants
read()
relocate()
orderSubfolders()
resetSubfolderOrder()
reindexChildrens()
insert()
updateThisAndChildrensAbsolutePath()
setVisible()
setRestrictions()
setParent()
setName()
No constants found
No protected methods found
N/A
No private methods found
N/A

Methods

read()

read(string  $order = null,string  $orderby = null): array<mixed,integer>

Fetch all attachment ids currently in this folder. It uses the default WP_Query to fetch the ids. You can also use the WP_Query like: ```php $query = new \WP_Query([ 'post_status' => 'inherit', 'post_type' => 'attachment', 'rml_folder' => 4, 'rml_include_children' => false // (optional) Include files of subfolder, you have to use wp_rml_all_children_sql_supported(false, 'function') for checking support ]); ```

Parameters

string $order

The order "ASC" or "DESC"

string $orderby

Use "rml" to get ids ordered by custom order

Returns

array<mixed,integer> —

Post ids

relocate()

relocate(integer  $parentId,integer  $nextFolderId = false): boolean|array<mixed,string>

Relocate a folder to a given place in the folder structure.

Parameters

integer $parentId

The parent id

integer $nextFolderId

The next folder id it should be prepend or false for the end

Throws

\MatthiasWeb\RealMediaLibrary\api\Exception

Returns

boolean|array<mixed,string> —

true or array with errors

orderSubfolders()

orderSubfolders(string  $orderby,boolean  $writeMetadata = true): boolean

(Pro only) Start to order the given folder subfolders by a given order type.

Parameters

string $orderby

The order type key

boolean $writeMetadata

Throws

\MatthiasWeb\RealMediaLibrary\exception\OnlyInProVersionException

Returns

boolean

resetSubfolderOrder()

resetSubfolderOrder(): boolean

(Pro only) Reset the subfolders order'.

Throws

\MatthiasWeb\RealMediaLibrary\exception\OnlyInProVersionException

Returns

boolean

reindexChildrens()

reindexChildrens(boolean  $resetData = false): boolean

(Pro only) Reindex the children folders so the "ord" number is set right.

Parameters

boolean $resetData

If true, the structure is reset

Returns

boolean

insert()

insert(array<mixed,integer>  $ids,boolean  $supress_validation = false,boolean  $isShortcut = false): true

Insert an amount of post ID's (attachments) to this folder.

Parameters

array<mixed,integer> $ids

Array of post ids

boolean $supress_validation

Suppress the permission validation

boolean $isShortcut

Determines, if the post's should be "copied" to the folder (no physical copy)

Throws

\Exception

Returns

true

updateThisAndChildrensAbsolutePath()

updateThisAndChildrensAbsolutePath()

Iterate all children of this folder recursively and update the absolute path. Use this function with caution because it can be time intensive.

setVisible()

setVisible(boolean  $visible)

Sets the folders visibility to the user.

Parameters

boolean $visible

setRestrictions()

setRestrictions(array<mixed,string>  $restrictions = array()): boolean

Set restrictions for this folder. Allowed restrictions for folders:

  • par Restrict to change the parent id
  • rea Restrict to rearrange the hierarchical levels of all subfolders (it is downwards all subfolders!) and cannot be inherited
  • cre Restrict to create new subfolders
  • ins Restrict to insert/upload new attachments, automatically moved to root if upload
  • ren Restrict to rename the folder
  • del Restrict to delete the folder
  • mov Restrict to move files outside the folder

You can append a ">" after each permission so it is inherited in each created subfolder: "cre>", "ins>", ...

Parameters

array<mixed,string> $restrictions

Array with restrictions

Returns

boolean

setParent()

setParent(integer  $id,integer  $ord = -1,boolean  $force = false): boolean

Changes the parent folder of this folder.

Parameters

integer $id

The new parent (use -1 for root)

integer $ord

The order number

boolean $force

If true no permission checks are executed

Throws

\Exception

Returns

boolean

setName()

setName(string  $name,boolean  $supress_validation = false): boolean

Renames a folder and then checks, if there is no duplicate folder in the parent folder.

Parameters

string $name

String New name of the folder

boolean $supress_validation

Suppress the permission validation

Throws

\Exception

Returns

boolean