CMS Made Simple API

SimpleAlert extends Alert
in package

The SimpleAlert class is a type of alert that allows the developer to create alerts with pre-defined titles, messages, icons, and permissions.

Tags
since
2.2
license

GPL

author

Robert Campbell (calguy1000@cmsmadesimple.org)

prop

string[] $perms An array of permission names. The logged in user must have at least one of these permissions to see the alert.

prop

string $icon The complete URL to an icon to associate with this alert

prop

string $msg The message to display. Note: Since alerts are stored in the database, and can be created asynchronously you cannot rely on language strings for the message or title when using this class.

Table of Contents

Constants

PRIORITY_HIGH  = '_high'
High priority
PRIORITY_LOW  = '_low'
Low/Simple priority
PRIORITY_NORMAL  = '_normal'
Normal priority

Methods

__construct()  : mixed
Constructor
__get()  : mixed
The magic __get method.
__set()  : mixed
The magic __set method.
delete()  : mixed
Delete this alert from the database.
get_icon()  : string
Return the alert icon URL (if any)
get_message()  : string
Return the alert message
get_prefname()  : string
Get the name of the preference that this alert will be stored as.
get_title()  : string
Return the alert title.
load_all()  : mixed
Load all known alerts from the database.
load_by_name()  : Alert
Given an alert preference name, load it from the database.
load_my_alerts()  : array<string|int, Alert>
Load all alerts that are suitable for the specified user id.
save()  : mixed
Save an alert object to the database.
decode_object()  : Alert
Decode a serialized object read from the database.
encode_object()  : string
Encode an alert into a format suitable for storing
get_fixed_prefname()  : mixed
is_for()  : bool
Givent he admin_uid, check if the specified uid has at least one of the permissions specified in the perms array.

Constants

PRIORITY_HIGH

High priority

public mixed PRIORITY_HIGH = '_high'

PRIORITY_LOW

Low/Simple priority

public mixed PRIORITY_LOW = '_low'

PRIORITY_NORMAL

Normal priority

public mixed PRIORITY_NORMAL = '_normal'

Methods

__construct()

Constructor

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

An array of permission names. Or null.

__get()

The magic __get method.

public __get(string $key) : mixed

Get a property from this object, or from the base class.

Parameters
$key : string
Tags
throws
InvalidArgumentException

__set()

The magic __set method.

public __set(string $key, mixed $val) : mixed

Set a property for this object, or for the base Alert class.

Parameters
$key : string
$val : mixed

delete()

Delete this alert from the database.

public delete() : mixed

get_icon()

Return the alert icon URL (if any)

public get_icon() : string
Return values
string

get_message()

Return the alert message

public get_message() : string
Return values
string

get_prefname()

Get the name of the preference that this alert will be stored as.

public get_prefname([string $name = null ]) : string
Parameters
$name : string = null

optionaly provide a name for the alert. If not specified the current alert name will be used.

Return values
string

get_title()

Return the alert title.

public get_title() : string
Return values
string

load_all()

Load all known alerts from the database.

public static load_all() : mixed

return Alert[]

load_by_name()

Given an alert preference name, load it from the database.

public static load_by_name(string $name[, mixed $throw = true ]) : Alert
Parameters
$name : string

The preference name

$throw : mixed = true
Tags
throws
InvalidArgumentException
throws
LogicException
Return values
Alert

load_my_alerts()

Load all alerts that are suitable for the specified user id.

public static load_my_alerts([int|null $uid = null ]) : array<string|int, Alert>
Parameters
$uid : int|null = null

The admin userid to test for. If no uid is specified, the currently logged in admin user id is used.

Return values
array<string|int, Alert>

save()

Save an alert object to the database.

public save() : mixed
Tags
throws
LogicException

decode_object()

Decode a serialized object read from the database.

protected static decode_object(string $serialized) : Alert
Parameters
$serialized : string

A serialized array, containing an optional module name that must be loaded and the serialized alert object.

Return values
Alert

encode_object()

Encode an alert into a format suitable for storing

protected static encode_object(Alert $obj) : string
Parameters
$obj : Alert

The object to be ecoded.

Return values
string

A serialized array, containing an optional module name that must be loaded, and the serrialized alert object.

get_fixed_prefname()

protected static get_fixed_prefname(mixed $name) : mixed
Parameters
$name : mixed

is_for()

Givent he admin_uid, check if the specified uid has at least one of the permissions specified in the perms array.

protected is_for(int $admin_uid) : bool
Parameters
$admin_uid : int
Tags
@return

bool;

Return values
bool

        
On this page

Search results