An abstract class that defines Admin Alerts for CMSMS.
Admin alerts have a name, priority, title, message, a timestamp and can optionally refer to a module. Methods are used to test if a module is for a specific user, and to format the message.
Alerts are stored as preferences in the database. If the name is the name of the class or something else that is not data or time dependant the only one instance of that alert can be stored in the database. This class usses the ArrayAccess interface to behave like a PHP array.
since | 2.2 |
---|---|
package |
CMS |
license |
GPL |
author |
Robert Campbell (calguy1000@cmsmadesimple.org) |
prop |
string $name The alert name. This is set by default on construction, but can be overridden. It is used to control how the alert is saved. |
prop |
string $module An optional module name. If specified, the module will be loaded when the alert is read from the database. |
prop |
string $priority The alert priority |
prop-read |
int $created The timestamp that the alert was created. |
prop-read |
bool $loaded Whether or not this object was loaded from the database. Alerts cannot be modified if they were loaded from the database. |
__construct()
Initialize the name to a unique name, the priority to normal, and the creaed time.
__get(string $key) : \CMSMS\AdminAlerts\string;
Programmers can get the name, module, priority and title. If an unknown key is provided an exception thrown.
string
$key \CMSMS\AdminAlerts\string;
__set(string $key, string $val)
Progrramers can modify the name, module, priority, and title of the alert. Alerts can only be modified before the object is stored in the database. Not afterwards. If an unknown key, or invalid priority is provided then an exception is thrown.
string
$keystring
$valis_for(integer $admin_uid) : boolean
integer
$admin_uid boolean
get_title()
get_icon() : string
string
get_prefname(string $name = null) : string
string
$nameoptionaly provide a name for the alert. If not specified the current alert name will be used.
string
decode_object(string $serialized) : \CMSMS\AdminAlerts\Alert
string
$serializedA serialized array, containing an optional module name that must be loaded and the serialized alert object.
encode_object(\CMSMS\AdminAlerts\Alert $obj) : string
\CMSMS\AdminAlerts\Alert
$objThe object to be ecoded.
string
A serialized array, containing an optional module name that must be loaded, and the serrialized alert object.
load_by_name(string $name) : \CMSMS\AdminAlerts\Alert
load_all()
return Alert[]
load_my_alerts(integer|null $uid = null) : array<mixed,\CMSMS\AdminAlerts\Alert>
integer|null
$uidThe admin userid to test for. If no uid is specified, the currently logged in admin user id is used.
array<mixed,\CMSMS\AdminAlerts\Alert>
save()
delete()
PRIORITY_HIGH
PRIORITY_NORMAL
PRIORITY_LOW