CMS Made Simple API

TranslatableAlert extends Alert
in package

The TranslatableAlert object is an alert that supports translatable language keys.

This class will use the module that is associated with the alert to translate the key. If the module name is empty, or the special value 'core' then the global 'lang' function will be used to read translations from the admin lang file.

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 $titlekey The language key (relative to the module) for the alert title.

prop

string $msgkey The language key (relative to the module) for the alert message.

prop

mixed $msgargs Either an array of arguments to pass to the language function or a single string or value.

see
CmsSecurityCheckTask

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 URL for an iconf or this alert.
get_message()  : string
Given the message key and the message args (if any) translate the key and arguments into a displayable striing.
get_prefname()  : string
Get the name of the preference that this alert will be stored as.
get_title()  : string
Givent he title key, translate the key into a displayable string.
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([mixed $perms = null ]) : mixed
Parameters
$perms : mixed = null

A single permission name, or an 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 URL for an iconf or this alert.

public abstract get_icon() : string
Tags
abstract
Return values
string

get_message()

Given the message key and the message args (if any) translate the key and arguments into a displayable striing.

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

Givent he title key, translate the key into a displayable string.

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