+ /* Removes duplicated entries for the fields that do not allow them. */
+ private function clean($value)
+ {
+ $single_types = XDB::fetchAllAssoc('id',
+ 'SELECT id, 0
+ FROM profile_name_enum
+ WHERE NOT FIND_IN_SET(\'allow_duplicates\', flags)');
+
+ foreach ($value as $key => $item) {
+ if (isset($single_types[$item['typeid']])) {
+ if ($single_types[$item['typeid']] === true) {
+ unset($value[$key]);
+ } else {
+ $single_types[$item['typeid']] = true;
+ }
+ }
+ }
+
+ return $value;
+ }
+