Added support for using Transport name in templates (#9411)

This commit is contained in:
Neil Lathwood
2018-11-05 07:56:16 +00:00
committed by GitHub
parent 356357ad8d
commit 38e3250528
3 changed files with 5 additions and 3 deletions

View File

@ -25,7 +25,7 @@ class AlertUtil
*/
public static function getAlertTransports($alert_id)
{
$query = "SELECT b.transport_id, b.transport_type FROM alert_transport_map AS a LEFT JOIN alert_transports AS b ON b.transport_id=a.transport_or_group_id WHERE a.target_type='single' AND a.rule_id=? UNION DISTINCT SELECT d.transport_id, d.transport_type FROM alert_transport_map AS a LEFT JOIN alert_transport_groups AS b ON a.transport_or_group_id=b.transport_group_id LEFT JOIN transport_group_transport AS c ON b.transport_group_id=c.transport_group_id LEFT JOIN alert_transports AS d ON c.transport_id=d.transport_id WHERE a.target_type='group' AND a.rule_id=?";
$query = "SELECT b.transport_id, b.transport_type, b.transport_name FROM alert_transport_map AS a LEFT JOIN alert_transports AS b ON b.transport_id=a.transport_or_group_id WHERE a.target_type='single' AND a.rule_id=? UNION DISTINCT SELECT d.transport_id, d.transport_type FROM alert_transport_map AS a LEFT JOIN alert_transport_groups AS b ON a.transport_or_group_id=b.transport_group_id LEFT JOIN transport_group_transport AS c ON b.transport_group_id=c.transport_group_id LEFT JOIN alert_transports AS d ON c.transport_id=d.transport_id WHERE a.target_type='group' AND a.rule_id=?";
$rule_id = self::getRuleId($alert_id);
return dbFetchRows($query, [$rule_id, $rule_id]);
}
@ -38,7 +38,7 @@ class AlertUtil
*/
public static function getDefaultAlertTransports()
{
$query = "SELECT transport_id, transport_type FROM alert_transports WHERE is_default=true";
$query = "SELECT transport_id, transport_type, transport_name FROM alert_transports WHERE is_default=true";
return dbFetchRows($query);
}
}

View File

@ -61,7 +61,8 @@ Placeholders are special variables that if used within the template will be repl
- Rule: `$alert->rule`
- Rule-Name: `$alert->name`
- Timestamp: `$alert->timestamp`
- Transport name: `$alert->transport`
- Transport type: `$alert->transport`
- Transport name: `$alert->transport_name`
- Contacts, must be iterated in a foreach, `$key` holds email and `$value` holds name: `$alert->contacts`
Placeholders can be used within the subjects for templates as well although $faults is most likely going to be worthless.

View File

@ -864,6 +864,7 @@ function ExtTransports($obj)
if (class_exists($class)) {
$transport_title = ($item['legacy'] === true) ? "{$item['transport_type']} (legacy)" : $item['transport_type'];
$obj['transport'] = $item['transport_type'];
$obj['transport_name'] = $item['transport_name'];
$obj['alert'] = new AlertData($obj);
$obj['title'] = $type->getTitle($obj);
$obj['alert']['title'] = $obj['title'];