mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2026-05-28 04:35:53 -04:00
PropertyModifierBitmask: new bitmask modifier
This commit is contained in:
parent
dee5c422f2
commit
e3852fecce
2 changed files with 36 additions and 0 deletions
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\PropertyModifier;
|
||||
|
||||
use Icinga\Exception\InvalidPropertyException;
|
||||
use Icinga\Module\Director\Hook\PropertyModifierHook;
|
||||
use Icinga\Module\Director\Web\Form\QuickForm;
|
||||
|
||||
class PropertyModifierBitmask extends PropertyModifierHook
|
||||
{
|
||||
public static function addSettingsFormFields(QuickForm $form)
|
||||
{
|
||||
$form->addElement('text', 'bitmask', array(
|
||||
'label' => 'Bitmask',
|
||||
'description' => $form->translate(
|
||||
'The numeric bitmask you want to apply. In case you have a hexadecimal'
|
||||
. ' or binary mask please transform it to a deximal number first. The'
|
||||
. ' result of this modifier is a boolean value, telling whether the'
|
||||
. ' given mask applies to the numeric value in your source column'
|
||||
),
|
||||
'required' => true,
|
||||
));
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'Bitmask match (numeric)';
|
||||
}
|
||||
|
||||
public function transform($value)
|
||||
{
|
||||
$mask = (int) $this->getSetting('bitmask');
|
||||
return (((int) $value) & $mask) === $mask;
|
||||
}
|
||||
}
|
||||
1
run.php
1
run.php
|
|
@ -31,6 +31,7 @@ $this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\Pro
|
|||
$this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierExtractFromDN');
|
||||
$this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierFromAdSid');
|
||||
$this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierFromLatin1');
|
||||
$this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierBitmask');
|
||||
|
||||
$this->provideHook('director/Job', $prefix . 'Job\\HousekeepingJob');
|
||||
$this->provideHook('director/Job', $prefix . 'Job\\ConfigJob');
|
||||
|
|
|
|||
Loading…
Reference in a new issue