Class AlertManager

Description

Methods to access properties of an alert

This class is used to manage alerts. The following functions are supplied

  • add a new alert
  • edit properties of an exising alert
  • delete an alert
  • view list of currently existing alerts
  • add a rule to an alert
  • edit a rule
  • delete a rule from an alert
The default action is to show a list of existing alerts.

Located in /program/lib/alertmanager.class.php (line 55)


	
			
Variable Summary
 array $intervals
 object|null $output
Method Summary
 AlertManager AlertManager (object &$output)
 void alerts_overview ()
 void alert_delete (int $alert_id)
 void alert_edit ([ $alert_id = 0])
 void alert_rule_delete (int $alert_id, int $rule_id)
 void alert_rule_edit (int $alert_id, [int $rule_id = 0])
 void alert_rule_save (int $alert_id, int $rule_id)
 void alert_save (int $alert_id)
 array a_param (string $chore, [int|null $alert_id = NULL], [int|null $rule_id = NULL])
 bool dialog_validate_alert (array &$dialogdef)
 bool dialog_validate_rule (array &$dialogdef, int $alert_id, in $rule_id)
 array get_dialogdef_alert ([int $alert_id = 0])
 array get_dialogdef_rule ([int $alert_id = 0], [int $rule_id = 0])
 void run ()
 void show_alert ( &$dialogdef, [in $alert_id = 0])
 void show_rule (array &$dialogdef, int $alert_id, [int $rule_id = 0])
 void tree_walk (array &$tree, array &$options, int &$area_id, string &$area_title, int $node_id)
Variables
array $intervals = array() (line 63)
  • var: $intervals quick translation between cron interval and human readable values
object|null $output = NULL (line 57)
  • var: $output collects the html output
bool $show_parent_menu = FALSE (line 60)
  • var: $show_parent_menu if TRUE caller is allowed to use menu area (show config mgr menu)
Methods
Constructor AlertManager (line 73)

construct an AlertManager object

This initialises the AlertManager.

  • uses: $CFG
AlertManager AlertManager (object &$output)
  • object &$output: collects the html output
alerts_overview (line 179)

show link to 'add an alert' followed by a list of existing alerts

this constructs an overview dialogue with options add, edit and delete alerts. Records are ordered by 'is_active' and 'full name'.

  • return: output via $this->output
void alerts_overview ()
alert_delete (line 392)

handle confirmation and actual delete of an alert

this single routine handles

  • the display of a confirmation message,
  • handling of the actual delete, and
  • handling of the bail out/cancelbutton

  • return: output written via $output
void alert_delete (int $alert_id)
  • int $alert_id
alert_edit (line 239)

display dialogue for an alert (new or existing)

if $alert_id is 0 show_alert() presents the add alert dialogue, otherwise the edit dialogue.

  • return: dialogue written via $output
void alert_edit ([ $alert_id = 0])
  • $alert_id
alert_rule_delete (line 610)

handle confirmation and actual delete of a rule

this single routine handles

  • the display of a confirmation message,
  • handling of the actual delete, and
  • handling of the bail out/cancelbutton

  • return: output written via $output
void alert_rule_delete (int $alert_id, int $rule_id)
  • int $alert_id
  • int $rule_id
alert_rule_edit (line 568)

display dialogue for a rule (new or existing)

if $rule_id is 0 show_rule() presents the add rule dialogue, otherwise the edit rule dialogue.

  • return: dialogue written via $output
void alert_rule_edit (int $alert_id, [int $rule_id = 0])
  • int $alert_id
  • int $rule_id
alert_rule_save (line 705)

store a new or modified alert rule in the database

  • return: data saved and dialogue displayed via $output
void alert_rule_save (int $alert_id, int $rule_id)
  • int $alert_id
  • int $rule_id
alert_save (line 479)

store a new or modified alert in the database

if the user pressed cancel (or somehow no button was pressed) she is returned to the alerts overview. after that the data is validated. On error the user is returned to the same dialogue to correct errors. after adding or updating the alert the user is taken to either

  • the alerts overview (after pressing [Done]
  • the add rule dialogue (in case of a new alert), or
  • the alert edit dialogue
This attempts to seduce the user to actually add at least one rule to the alert.

  • return: data saved and dialogue displayed via $output
void alert_save (int $alert_id)
  • int $alert_id
a_param (line 763)

shorthand for the anchor parameters that lead to the alert manager

  • return: ready-to-use array with parameters for constructing a-tag
array a_param (string $chore, [int|null $alert_id = NULL], [int|null $rule_id = NULL])
  • string $chore: the next chore that could be done
  • int|null $alert_id: the alert of interest or NULL if none
  • int|null $rule_id: the alert rule of interest or NULL if none
dialog_validate_alert (line 936)

validate add/edit alert dialog

the usual validation and an additional check on the email address

  • return: TRUE if all submitted values are considered valid, FALSE otherwise
bool dialog_validate_alert (array &$dialogdef)
  • array &$dialogdef
dialog_validate_rule (line 959)

validate add/edit rule dialog

the usual validation and an additional check on existing rule

  • return: TRUE if all submitted values are considered valid, FALSE otherwise
bool dialog_validate_rule (array &$dialogdef, int $alert_id, in $rule_id)
  • array &$dialogdef
  • int $alert_id
  • in $rule_id
get_dialogdef_alert (line 780)

construct a dialogue defintion for adding/editing selected alert properties

  • return: with dialogue definition
array get_dialogdef_alert ([int $alert_id = 0])
  • int $alert_id
get_dialogdef_rule (line 849)

construct a dialogdef for adding/editing a rule for alert $alert_id

  • return: with dialog definition
array get_dialogdef_rule ([int $alert_id = 0], [int $rule_id = 0])
  • int $alert_id
  • int $rule_id
run (line 94)

entry point

  • return: output written to browser via $output
void run ()
show_alert (line 266)

show a dialog to add a new or edit an existing alert

if $alert_id is 0 we show the add new alert dialogue, with just three fields: Name, E-mail and Frequency (is_active is set to TRUE upon saving data). There are only two buttons: [Save] or [Cancel]. The former takes the user to the edit dialogue after adding the initial alert, the latter takes the user back to the overview.

If $alert_id is non-0, we show the same dialogue but this time including is_active flag. This time there is also a [Done] button: this saves the changes and returns to the overview. [Save] stores the data but restarts the edit.

Also, if we are not adding but editing the current list of alert rules is displayed in a table, beneath the Save/Done/Cancel buttons. There is also an Add rule link.

  • return: output via $output
void show_alert ( &$dialogdef, [in $alert_id = 0])
  • in $alert_id: indicates which alert to show, 0 means add new dialogue
  • &$dialogdef
show_parent_menu (line 162)

allow the caller to use the menu area (or not)

this routine tells the caller if it is OK to use the menu area (TRUE returned) or not (FALSE returned).

  • return: TRUE if menu area is available, FALSE otherwise
bool show_parent_menu ()
show_rule (line 585)

show a dialogue where a rule can be edited

we expect the caller to fill dialogdef with the correct values etc. This allows for reusing this routine to easily display errors,

  • return: dialogue sent to user via $output
void show_rule (array &$dialogdef, int $alert_id, [int $rule_id = 0])
  • array &$dialogdef
  • int $alert_id
  • int $rule_id
tree_walk (line 899)

walk the tree and add all nodes to an options array

void tree_walk (array &$tree, array &$options, int &$area_id, string &$area_title, int $node_id)
  • array &$tree: contains all nodes in $area_id
  • array &$options: receives nodes in tree order
  • int &$area_id
  • string &$area_title
  • int $node_id: start of the (sub)tree

Documentation generated on Tue, 28 Jun 2016 19:08:06 +0200 by phpDocumentor 1.4.0