/** * Evaluates 'group' or 'select' type values. * * @param array The result array. The processed value (if any!) is set in the 'value' key. * @param string The value to set. * @param array Field configuration from TCA * @param array Additional parameters in a numeric array: $table,$id,$curValue,$status,$realPid,$recFID * @param [type] $uploadedFiles: ... * @param string Field name * @return array Modified $res array */ function checkValue_group_select($res, $value, $tcaFieldConf, $PP, $uploadedFiles, $field) { list($table, $id, $curValue, $status, $realPid, $recFID) = $PP; // Detecting if value sent is an array and if so, implode it around a comma: if (is_array($value)) { $value = implode(',', $value); } // This converts all occurencies of '{' to the byte 123 in the string - this is needed in very rare cases where filenames with special characters (like ???, umlaud etc) gets sent to the server as HTML entities instead of bytes. The error is done only by MSIE, not Mozilla and Opera. // Anyways, this should NOT disturb anything else: $value = $this->convNumEntityToByteValue($value); // When values are sent as group or select they come as comma-separated values which are exploded by this function: $valueArray = $this->checkValue_group_select_explodeSelectGroupValue($value); // If not multiple is set, then remove duplicates: if (!$tcaFieldConf['multiple']) { $valueArray = array_unique($valueArray); } // If an exclusive key is found, discard all others: if ($tcaFieldConf['type'] == 'select' && $tcaFieldConf['exclusiveKeys']) { $exclusiveKeys = t3lib_div::trimExplode(',', $tcaFieldConf['exclusiveKeys']); foreach ($valueArray as $kk => $vv) { if (in_array($vv, $exclusiveKeys)) { // $vv is the item key! $valueArray = array($kk => $vv); break; } } } // This could be a good spot for parsing the array through a validation-function which checks if the values are alright (except that database references are not in their final form - but that is the point, isn't it?) // NOTE!!! Must check max-items of files before the later check because that check would just leave out filenames if there are too many!! // Checking for select / authMode, removing elements from $valueArray if any of them is not allowed! if ($tcaFieldConf['type'] == 'select' && $tcaFieldConf['authMode']) { $preCount = count($valueArray); foreach ($valueArray as $kk => $vv) { if (!$this->BE_USER->checkAuthMode($table, $field, $vv, $tcaFieldConf['authMode'])) { unset($valueArray[$kk]); } } // During the check it turns out that the value / all values were removed - we respond by simply returning an empty array so nothing is written to DB for this field. if ($preCount && !count($valueArray)) { return array(); } } // For group types: if ($tcaFieldConf['type'] == 'group') { switch ($tcaFieldConf['internal_type']) { case 'file_reference': case 'file': $valueArray = $this->checkValue_group_select_file($valueArray, $tcaFieldConf, $curValue, $uploadedFiles, $status, $table, $id, $recFID); break; case 'db': $valueArray = $this->checkValue_group_select_processDBdata($valueArray, $tcaFieldConf, $id, $status, 'group', $table, $field); break; } } // For select types which has a foreign table attached: if ($tcaFieldConf['type'] == 'select' && $tcaFieldConf['foreign_table']) { // check, if there is a NEW... id in the value, that should be substituded later if (strpos($value, 'NEW') !== FALSE) { $this->remapStackRecords[$table][$id] = array('remapStackIndex' => count($this->remapStack)); $this->addNewValuesToRemapStackChildIds($valueArray); $this->remapStack[] = array('func' => 'checkValue_group_select_processDBdata', 'args' => array($valueArray, $tcaFieldConf, $id, $status, 'select', $table, $field), 'pos' => array('valueArray' => 0, 'tcaFieldConf' => 1, 'id' => 2, 'table' => 5), 'field' => $field); $unsetResult = TRUE; } else { $valueArray = $this->checkValue_group_select_processDBdata($valueArray, $tcaFieldConf, $id, $status, 'select', $table, $field); } } if (!$unsetResult) { $newVal = $this->checkValue_checkMax($tcaFieldConf, $valueArray); $res['value'] = implode(',', $newVal); } else { unset($res['value']); } return $res; }