diff --git a/lib/classes/databox.php b/lib/classes/databox.php index 3a48021337..ffd0f467f8 100644 --- a/lib/classes/databox.php +++ b/lib/classes/databox.php @@ -992,7 +992,7 @@ class databox extends base ->set_separator(isset($field['separator']) ? (string) $field['separator'] : '') ->set_required((isset($field['required']) && (string) $field['required'] == 1)) ->set_business((isset($field['business']) && (string) $field['business'] == 1)) - ->set_aggregable((isset($field['aggregable']) && (string) $field['aggregable'] == 1)) + ->set_aggregable((isset($field['aggregable']) ? (string) $field['aggregable'] : 0)) ->set_type($type) ->set_tbranch(isset($field['tbranch']) ? (string) $field['tbranch'] : '') ->set_thumbtitle(isset($field['thumbtitle']) ? (string) $field['thumbtitle'] : (isset($field['thumbTitle']) ? $field['thumbTitle'] : '0')) diff --git a/lib/classes/databox/field.php b/lib/classes/databox/field.php index 2d25d2b4e3..7386db6d3b 100644 --- a/lib/classes/databox/field.php +++ b/lib/classes/databox/field.php @@ -122,8 +122,6 @@ class databox_field implements cache_cacheableInterface */ protected $Business; - protected $aggregable; - protected $renamed = false; /** @@ -146,6 +144,7 @@ class databox_field implements cache_cacheableInterface protected $VocabularyRestriction = false; protected $on_error = false; protected $original_src; + protected $aggregable; const TYPE_TEXT = "text"; const TYPE_DATE = "date"; @@ -221,7 +220,7 @@ class databox_field implements cache_cacheableInterface $this->multi = (Boolean) $row['multi']; $this->Business = (Boolean) $row['business']; $this->report = (Boolean) $row['report']; - $this->aggregable = (Boolean) $row['aggregable']; + $this->aggregable = (Int) $row['aggregable']; $this->position = (Int) $row['sorter']; $this->type = $row['type'] ? : self::TYPE_STRING; $this->tbranch = $row['tbranch']; @@ -271,7 +270,7 @@ class databox_field implements cache_cacheableInterface public function isAggregable() { - return $this->aggregable; + return $this->aggregable != 0; } /** @@ -408,7 +407,7 @@ class databox_field implements cache_cacheableInterface ':separator' => $this->separator, ':multi' => $this->multi ? '1' : '0', ':business' => $this->Business ? '1' : '0', - ':aggregable' => $this->aggregable ? '1' : '0', + ':aggregable' => $this->aggregable, ':report' => $this->report ? '1' : '0', ':type' => $this->type, ':tbranch' => $this->tbranch, @@ -460,7 +459,7 @@ class databox_field implements cache_cacheableInterface $meta->setAttribute('multi', $this->multi ? '1' : '0'); $meta->setAttribute('report', $this->report ? '1' : '0'); $meta->setAttribute('business', $this->Business ? '1' : '0'); - $meta->setAttribute('aggregable', $this->aggregable ? '1' : '0'); + $meta->setAttribute('aggregable', $this->aggregable); $meta->setAttribute('type', $this->type); $meta->setAttribute('tbranch', $this->tbranch); if ($this->multi) { @@ -721,9 +720,9 @@ class databox_field implements cache_cacheableInterface return $this; } - public function set_aggregable($boolean) + public function set_aggregable($int) { - $this->aggregable = ! ! $boolean; + $this->aggregable = $int; return $this; diff --git a/lib/classes/patch/390alpha22a.php b/lib/classes/patch/390alpha22a.php new file mode 100644 index 0000000000..d2a1f0c152 --- /dev/null +++ b/lib/classes/patch/390alpha22a.php @@ -0,0 +1,65 @@ +release; + } + + /** + * {@inheritdoc} + */ + public function getDoctrineMigrations() + { + return []; + } + + /** + * {@inheritdoc} + */ + public function require_all_upgrades() + { + return false; + } + + /** + * {@inheritdoc} + */ + public function concern() + { + return $this->concern; + } + + /** + * {@inheritdoc} + */ + public function apply(base $databox, Application $app) + { + $sql = "UPDATE metadatas_structure SET `aggregable`=20 WHERE `aggregable`=1"; + $stmt = $databox->get_connection()->prepare($sql); + $stmt->execute(); + + return true; + } +} diff --git a/lib/conf.d/bases_structure.xml b/lib/conf.d/bases_structure.xml index af4a143578..538320f3f0 100644 --- a/lib/conf.d/bases_structure.xml +++ b/lib/conf.d/bases_structure.xml @@ -2655,7 +2655,7 @@ aggregable - int(1) unsigned + int(5) 0 diff --git a/templates/web/admin/fields/templates.html.twig b/templates/web/admin/fields/templates.html.twig index 1e430b4e3a..ad6a890f88 100644 --- a/templates/web/admin/fields/templates.html.twig +++ b/templates/web/admin/fields/templates.html.twig @@ -177,11 +177,18 @@ - - + + + + + diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Admin/FieldsTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/FieldsTest.php index 935e5e8467..14c9fd965b 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/FieldsTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/FieldsTest.php @@ -221,7 +221,7 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase 'thumbtitle' => false, 'tag' => 'XMP:XMP', 'business' => false, - 'aggregable' => false, + 'aggregable' => 0, 'indexable' => true, 'required' => true, 'labels' => [