Notification from plugins
e107 Wiki: English | Русский | Deutsch | Français | Magyar | Português | Български | Česky | Nederlands | Ελληνικά | Italiano | Norske | Polska | Slovenščina | Español | Svenska | Translate: Wiki | Page
e107 includes a 'notify' facility, whereby a specified user or user class can be notified when certain events take place.
An event has a 'trigger', and it is straightforward to add one or more triggers to a plugin.
The existing chatbox code is being used as an example.
There are two parts to causing notifications:
The e_notify.php file
This simple file contains the information needed to link the triggers into the notification system, and to pre-process the details of the notification if necessary.
The following is a simple (single-trigger) e_notify.php file:
There are three key parts to this file:
If defining multiple triggers, simply clone the above process - an additional entry in the $config_events array, and a separate function to handle the notify.
config_events are registered during a plugin install/upgrade, which you will need to do when adding or changing event names.
Triggering an event
To trigger a 'notify' event, simply insert a call to the event handler in your code:
The first parameter is the internal name of the trigger ( as defined earlier )
The second is data ( typically small ) which the function can make use of, such as part of the notification, to avoid additional sql queries. The data is passed by reference, so must be a variable, trying to set anything within the function brackets will cause an error.