Skip to content

Commit

Permalink
Fixed issue #13924: Attribute without description are not seen in man…
Browse files Browse the repository at this point in the history
…agement

Dev: get attributes from description AND db
Dev: Have same issue using API activate_tokens : no update of descriptions
  • Loading branch information
Shnoulle committed Aug 1, 2018
1 parent ff46124 commit c98f800
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions application/models/Survey.php
Expand Up @@ -640,14 +640,22 @@ public function getTokenAttributes()
$ls->save();
$attdescriptiondata = $fields;
}
// Without token table : all extra attribute are only saved on $this->attributedescriptions
$allKnowAttributes = $attdescriptiondata;
// Without token table : all attribute $this->attributedescriptions AND real attribute. @see issue #13924
if($this->getHasTokensTable()){
$allKnowAttributes = array_intersect_key(array_merge($attdescriptiondata,Token::model($this->sid)->getAttributes()),Token::model($this->sid)->getAttributes());
// We remove deleted attribute even if deleted manually in DB
}
$aCompleteData = array();
foreach ($attdescriptiondata as $sKey=>$aValues) {
if (!is_array($aValues)) {
$aValues = array();
}
if (preg_match("/^attribute_[0-9]{1,}$/", $sKey)) {
foreach ($allKnowAttributes as $sKey=>$aValues) {
if (preg_match("/^attribute_[0-9]{1,}$/", $sKey)) { // Select only extra attributes here
if (!is_array($aValues)) {
$aValues = array();
}
// merge default with attributedescriptions
$aCompleteData[$sKey] = array_merge(array(
'description' => '',
'description' => $sKey,
'mandatory' => 'N',
'show_register' => 'N',
'cpdbmap' =>''
Expand Down

0 comments on commit c98f800

Please sign in to comment.