Unverified Commit b4eca89c authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:sparkles: feat(config) Add option to deactivate a trigger

This allow to temporarily disable a trigger while keeping its definition
 in the configuration for later.
The syntax is backward compatible so that no migration is needed.

issue #6074
Showing with 13 additions and 2 deletions
+13 -2
...@@ -484,6 +484,10 @@ class config ...@@ -484,6 +484,10 @@ class config
$class = strtoupper($parts[0]); $class = strtoupper($parts[0]);
$mode = strtoupper($parts[1]); $mode = strtoupper($parts[1]);
$cmd = $parts[2]; $cmd = $parts[2];
if (!isset($cmd[0]) || ($cmd[0] == '#')) {
/* Ignore commented out and empty triggers */
continue;
}
if (!isset($this->data['HOOKS'][$class])) { if (!isset($this->data['HOOKS'][$class])) {
$this->data['HOOKS'][$class] = ['CLASS' => $parts[0]]; $this->data['HOOKS'][$class] = ['CLASS' => $parts[0]];
} }
......
...@@ -70,13 +70,19 @@ class hooksConfig extends simplePlugin ...@@ -70,13 +70,19 @@ class hooksConfig extends simplePlugin
'precreate', 'preremove', 'premodify', 'check', 'precreate', 'preremove', 'premodify', 'check',
'prelock', 'postlock', 'preunlock', 'postunlock'] 'prelock', 'postlock', 'preunlock', 'postunlock']
), ),
new BooleanAttribute(
_('Deactivated'), _('Use this to temporarily deactivate a trigger'),
'triggerDecativate', TRUE,
FALSE, '',
'#', ''
),
new TextAreaAttribute( new TextAreaAttribute(
_('Command'), _('The command that will be called'), _('Command'), _('The command that will be called'),
'triggerCmd', TRUE 'triggerCmd', TRUE
) )
], ],
'/^([^\\|]+)\\|([^\\|]+)\\|(.*)$/', '/^([^\\|]+)\\|([^\\|]+)\\|(#?)(.*)$/',
'%s|%s|%s', '%s|%s|%s%s',
'', // acl '', // acl
_('Triggers') _('Triggers')
), ),
...@@ -99,6 +105,7 @@ class hooksConfig extends simplePlugin ...@@ -99,6 +105,7 @@ class hooksConfig extends simplePlugin
$this->attributesAccess['fdTabHook']->setHeaders([ $this->attributesAccess['fdTabHook']->setHeaders([
_('Tab'), _('Tab'),
_('Mode'), _('Mode'),
_('Deactivated'),
_('Command'), _('Command'),
'', '',
]); ]);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment