Commit 428d48b6 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Merge branch '5897-support-for-askme-in-booleanattribute-is-broken' into '1.3-dev'

Resolve "Support for %askme% in BooleanAttribute is broken" in 1.3-dev

See merge request fusiondirectory/fd!495
Showing with 19 additions and 7 deletions
+19 -7
......@@ -44,18 +44,32 @@ class BooleanAttribute extends Attribute
$this->falseValue = $falseValue;
}
function setTemplatable($bool)
{
$this->templatable = $bool;
}
protected function isTemplatable()
{
/* Allow to set to %askme% if we are not (de)activating other fields */
return (!$this->submitForm && empty($this->managedAttributes) && $this->templatable);
}
function inputValue ($value)
{
if ($this->isTemplate() && $this->isTemplatable() && ($value === '%askme%')) {
return $value;
}
return ($value == $this->trueValue);
}
function loadPostValue ()
{
if ($this->isVisible()) {
if ($this->isTemplate() && !$this->submitForm && empty($this->managedAttributes)) {
if ($this->isTemplate() && $this->isTemplatable()) {
if (!isset($_POST[$this->getHtmlId()])) {
$this->setPostValue(FALSE);
} elseif ($_POST[$this->getHtmlId()] == '%askme%') {
} elseif ($_POST[$this->getHtmlId()] === '%askme%') {
$this->setPostValue('%askme%');
} else {
$this->setPostValue($_POST[$this->getHtmlId()] == 'TRUE');
......@@ -68,7 +82,7 @@ class BooleanAttribute extends Attribute
function computeLdapValue ()
{
if ($this->isTemplate() && ($this->value == '%askme%')) {
if ($this->isTemplate() && $this->isTemplatable() && ($this->value === '%askme%')) {
return $this->value;
} else {
return ($this->value ? $this->trueValue : $this->falseValue);
......@@ -92,11 +106,9 @@ class BooleanAttribute extends Attribute
function renderTemplateInput ()
{
if (!$this->submitForm && empty($this->managedAttributes)) {
/* Allow to set to %askme% if we are not (de)activating other fields */
if ($this->isTemplatable()) {
$id = $this->getHtmlId();
if ($this->getValue() == '%askme%') {
if ($this->getValue() === '%askme%') {
$selected = '%askme%';
} elseif ($this->getValue()) {
$selected = 'TRUE';
......
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