Trigger Entry

Creating a trigger is performed by clicking upon the 'NEW' icon button in the Trigger list display. This would then display the figure below, which has a few fields which need to be completed. These are the table upon which the trigger is to be placed, the type of trigger required (BEFORE or AFTER), the operation to be monitored (INSERT, UPDATE or DELETE), and whether the trigger should be applied immediately after being created.

The trigger created at the end of this stage would be based upon 'ALL' of the columns that are in the selected table.

Figure 4.6. Trigger entry (creation)

Trigger entry (creation)

If the 'Save' icon button is pressed then the display is changed and a few additional fields are now available. The first of these is the 'Columns' field which has to be completed. It is this field where one selects the specific columns within the table that are to be monitored. The fields are selected from the drop down list and there is also the 'All' option if one wishes to retain the previously generated trigger upon all of the table columns. If the 'ALL' option is selected then any other selected fields are ignored.

If the 'Save and Close' button is pressed the Trigger list display is shown and the 'columns' entry indicates '(array) All'. If the entry is edited then it is necessary to explicitly select the 'All from the columns drop down list as described above otherwise an error message indicating that the column must be specified is displayed..

[Note]Note

By design it is not currently possible to edit the generated trigger text. This design criteria may be relaxed later if demand is sufficient.

After supplying the required columns when the save button is pressed the trigger text is regenerated with the new selection.

Figure 4.7. Trigger entry (after save)

Trigger entry (after save)

Note the entries in the 'columns' field when populated with desired values as shown in the figure below.

Figure 4.8. Trigger entry (edit columns)

Trigger entry (edit columns)

When saved the selected columns field would be shown in the Triggers List as indicated in the figure below.

Figure 4.9. Columns field in the Triggers list display

Columns field in the Triggers list display.

The above is an example for a small selection of fields, which are stored in the table in JSON format.

[Important]Important

Release 1.0.0 does not have any ability to incorporate the contents of any existing trigger upon a database table that may exists within the database. This restriction should not provide a problem for most systems. The reason is that most (all?) currently known components, including core components do NOT make use of database features such as database triggers, preferring instead to contain the logic within the application layer. If your system does make use of triggers the problem would seen when an attempt is made to apply the generated trigger in the database, since MySQL does not permit more than one trigger of any given type on a database table.

[Note]Note

The Macrotone Issue Tracker component does make use of database triggers, however it uses 'BEFORE' triggers which do not conflict with the use of the AFTER triggers created by the Macrotone Joomla Audit component.