Dashboard/Email Notifications

Dashboard/Email Notifications

 

Adding and Removing Dashboard and Nightly email Notifications that show up in the FreePBX Dashboard is extremely easy.

 

First Steps

Inside any module simply add:

$nt = notifications::create(); //OR $nt = FreePBX::Notifications();

The only things we need to know is the rawname of our module (in module.xml) and a unique string to identify this notification.

$rawname = 'dahdiconfig'; $uid = 'modprobeconf';

Adding Notifications

Before adding a new notification it is essential for you to check to make sure you aren't adding duplicate notifications.

if($nt->exists($rawname, $uid)) {     //Process add or delete

Notification Types

There are six different types of notifications that can be managed on the dashboard. They all use the same parameters as listed below:

* @param string $module Raw name of the module requesting * @param string $id ID of the notification * @param string $display_text The text that will be displayed as the subject/header of the message * @param string $extended_text The extended text of the notification when it is expanded * @param string $link The link that is set to the notification * @param bool $reset Reset notification on module update * @param bool $candelete If the notification can be deleted by the user on the notifications display page * @return int Returns the number of notifications per module & id
Critical
$nt->add_critical($module, $id, $display_text, $extended_text="", $link="", $reset=true, $candelete=false)
Security
$nt->add_security($module, $id, $display_text, $extended_text="", $link="", $reset=true, $candelete=false)
Update
$nt->add_update($module, $id, $display_text, $extended_text="", $link="", $reset=true, $candelete=false)
Error
$nt->add_error($module, $id, $display_text, $extended_text="", $link="", $reset=true, $candelete=false)
Warning
$nt->add_warning($module, $id, $display_text, $extended_text="", $link="", $reset=true, $candelete=false)
Notice
$nt->add_notice($module, $id, $display_text, $extended_text="", $link="", $reset=true, $candelete=false)

Removing Notifications

Delete

This will forcefully delete a notification, even if $candelete has been set to false

$nt->delete($rawname, $uid)
Safe Delete

This won't delete a notification if $candelete was set to false

$nt->safe_delete($rawname, $uid)