Custom trigger

A custom trigger is a function whose first parameter is a reference to the executing Transaction. This allows any trigger to have access to the Transaction context (SQL fields, primary key etc.).
If an error is raised inside the trigger it must be returned as an instance of the tNG_error object.
Here is a sample of a custom trigger that checks if a user is authenticated or not:

function TriggerBEFORE_checkSession(&$tNG) {
if (!isset($_SESSION['authorised'])) {
$errObj = new tNG_error('User is not authenticated.', array(), array());
return $errObj;
} else {
return null;
}
}

 

This code uses the following: