Documentation

Rule
in package
implements ArrayAccess Uses BackwardCompatibility, ArrayAccessHelper

Represents a sorting rule that can be applied to incoming personal messages.

Table of Contents

Interfaces

ArrayAccess

Constants

LIMITS  = ['criteria' => 10, 'actions' => 10]
Maximum number of criteria and actions allowed per rule.
RULE_AND  = false
Whether a rule's criteria are combined using AND or OR logic.
RULE_OR  = true

Properties

$actions  : array<string|int, mixed>
$criteria  : array<string|int, mixed>
$delete  : bool
$id  : int
$loaded  : array<string|int, mixed>
$logic  : bool
$member  : int
$name  : string
$prop_aliases  : array<string|int, mixed>
$backcompat  : array<string|int, mixed>

Methods

__construct()  : mixed
Constructor.
apply()  : void
This will apply rules to all unread messages.
delete()  : void
Deletes the given rules from the database.
exportStatic()  : void
Provides a way to export a class's public static properties and methods to global namespace.
load()  : array<string|int, mixed>
Loads all the rules for the current user.
manage()  : void
List all rules, and allow adding, editing, etc.
offsetExists()  : bool
Checks whether a property has been set when object is accessed as an array.
offsetGet()  : mixed
Gets properties when object is accessed as an array.
offsetSet()  : void
Sets properties when object is accessed as an array.
offsetUnset()  : void
Unsets properties when object is accessed as an array.
save()  : void
Save this rule to the database.

Constants

LIMITS

Maximum number of criteria and actions allowed per rule.

public mixed LIMITS = ['criteria' => 10, 'actions' => 10]

RULE_AND

Whether a rule's criteria are combined using AND or OR logic.

public mixed RULE_AND = false

RULE_OR

public mixed RULE_OR = true

Properties

$actions

public array<string|int, mixed> $actions = []

Actions that this rule performs.

$criteria

public array<string|int, mixed> $criteria = []

This rule's criteria.

$delete

public bool $delete = false

Whether this rule deletes PMs.

$id

public int $id

This rule's ID number.

$loaded

public static array<string|int, mixed> $loaded = []

All loaded instances of this class.

$logic

public bool $logic = self::RULE_AND

Whether to combine this rule with others using OR logic or AND logic. Either self::RULE_AND or self::RULE_OR.

$member

public int $member

ID number of the member that this rule belongs to.

$name

public string $name = ''

This rule's name.

$prop_aliases

protected array<string|int, mixed> $prop_aliases = ['id_rule' => 'id', 'id_member' => 'member', 'rule_name' => 'name', 'delete_pm' => 'delete', 'is_or' => 'logic']

Alternate names for some object properties.

$backcompat

private static array<string|int, mixed> $backcompat = ['func_names' => ['load' => 'loadRules', 'apply' => 'applyRules', 'delete' => 'delete', 'manage' => 'manage']]

BackwardCompatibility settings for this class.

Methods

__construct()

Constructor.

public __construct([array<string|int, mixed> $props = [] ]) : mixed
Parameters
$props : array<string|int, mixed> = []

Properties to set for this rule.

apply()

This will apply rules to all unread messages.

public static apply([bool $all_messages = false ]) : void

If $all_messages is set will, obviously, do it to all!

Parameters
$all_messages : bool = false

Whether to apply this to all messages or just unread ones.

delete()

Deletes the given rules from the database.

public static delete(array<string|int, mixed> $ids) : void
Parameters
$ids : array<string|int, mixed>

IDs of the rules to delete.

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.

load()

Loads all the rules for the current user.

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

If true, force a reload.

Return values
array<string|int, mixed>

manage()

List all rules, and allow adding, editing, etc.

public static manage() : void

..

offsetExists()

Checks whether a property has been set when object is accessed as an array.

public offsetExists(mixed $prop) : bool
Parameters
$prop : mixed

The property name.

Return values
bool

offsetGet()

Gets properties when object is accessed as an array.

public offsetGet(mixed $prop) : mixed
Parameters
$prop : mixed

The property name.

offsetSet()

Sets properties when object is accessed as an array.

public offsetSet(mixed $prop, mixed $value) : void
Parameters
$prop : mixed

The property name.

$value : mixed

The value to set.

offsetUnset()

Unsets properties when object is accessed as an array.

public offsetUnset(mixed $prop) : void
Parameters
$prop : mixed

The property name.

save()

Save this rule to the database.

public save() : void

        
On this page

Search results