Commit e5aa1639 authored by Côme Chilliet's avatar Côme Chilliet

Merge branch '6025-handling-of-booleans-in-csv-import' into '1.4-dev'

Resolve "Handling of booleans in CSV import"

See merge request fusiondirectory/fd!674
parents 712aad73 f2a5b845
......@@ -158,6 +158,44 @@ class BooleanAttribute extends Attribute
}
return $js;
}
/*! \brief Apply value from RPC requests
*
* \param mixed $value the value
*/
function deserializeValue ($value)
{
if ($this->disabled) {
return sprintf(_('Attribute %s is disabled, its value could not be set'), $this->getLdapName());
}
if ($value === $this->trueValue) {
$this->setValue(TRUE);
} elseif ($value === $this->falseValue) {
$this->setValue(FALSE);
} elseif (is_bool($value)) {
$this->setValue($value);
} elseif ($value === 1) {
$this->setValue(TRUE);
} elseif ($value === 0) {
$this->setValue(FALSE);
} else {
return sprintf(_('"%s" is not a valid value for attribute "%s" should be "%s" or "%s"'), $value, $this->getLdapName(), $this->trueValue, $this->falseValue);
}
/* No error */
return '';
}
function serializeAttribute (array &$attributes, bool $form = TRUE)
{
if (!$form || $this->visible) {
parent::serializeAttribute($attributes, $form);
$attributes[$this->getLdapName()]['choices'] = [
$this->trueValue => 'True',
$this->falseValue => 'False',
];
}
}
}
/*! \brief This class allow to handle easily a Boolean LDAP attribute that triggers a set of objectclasses
......
Markdown is supported
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