You are here

function computing_validate_fields in Drupal Computing 7

Parameters

$fields:

Return value

array of valid fields.

4 calls to computing_validate_fields()
computing_create_record in ./computing.module
Creates a command record and save to {computing_record} queue. Duplicate command would not get saved twice. To force saving a duplicate command, set the 'updated' field or any input field with different value in $options.
computing_update_record in ./computing.module
Update the record with id; only updates the fields in $fields. Callers are responsible to make sure 'input' and 'output' are bytes.
computing_update_record_field in ./computing.module
_computing_query_records in ./computing.module
This is an internal function to query records. It returns the query result object. Calling function is responsible to fetch array/object from it.

File

./computing.module, line 274

Code

function computing_validate_fields($fields, $insert_default = FALSE) {
  $valid_fields = array();
  $schema = drupal_get_schema_unprocessed('computing', 'computing_record');
  if (is_array($fields)) {
    $valid_fields = array_intersect_key($fields, $schema['fields']);
  }
  if ($insert_default) {
    foreach ($schema['fields'] as $field_name => $field_value) {
      if ($field_name != 'id' && !array_key_exists($field_name, $valid_fields)) {
        $valid_fields[$field_name] = isset($field_value['default']) ? $field_value['default'] : NULL;
      }
    }
  }
  return $valid_fields;
}