You are here

function _emfield_audit in Embedded Media Field 6.2

This will audit all nodes to ensure all emfield providers are present.

The function will pass through all emfield fields to see if there is any content in the system without a provider.

Return value

array An array of all missing providers. Ideally the array will be empty.

1 call to _emfield_audit()
emfield_audit in ./emfield.module
This will audit all nodes to ensure all emfield providers are present.

File

includes/emfield.audit.inc, line 18
emfield/includes/emfield.audit.inc

Code

function _emfield_audit() {
  $audit = array();

  // Build a list of fields that need data updating.
  $fields = array();
  foreach (content_fields() as $field) {
    if (in_array($field['module'], array(
      'emvideo',
      'emimage',
      'emaudio',
    ))) {

      // We only process a given field once.
      $fields[$field['field_name']] = $field;
    }
  }

  // Update database storage.
  foreach ($fields as $field) {
    $db_info = content_database_info($field);
    $table = $db_info['table'];
    $provider_column = $db_info['columns']['provider']['column'];
    $module = $field['module'];
    $sql = "SELECT {$provider_column} FROM {{$table}} WHERE {$provider_column} IS NOT NULL GROUP BY {$provider_column}";
    $results = db_query($sql);
    while ($result = db_fetch_object($results)) {
      $provider = emfield_system_list($module, $result->{$provider_column});
      if (empty($provider)) {
        $audit[$result->{$provider_column}] = $result->{$provider_column};
      }
    }
  }
  return $audit;
}