You are here

function globallink_settings_field_collections_process in GlobalLink Connect for Drupal 7.7

Field collections process start.

1 string reference to 'globallink_settings_field_collections_process'
prepare_field_collections_button_submit in ./globallink_settings.inc
Field collections batch set.

File

./globallink_settings.inc, line 1122

Code

function globallink_settings_field_collections_process($progress, $limit, $resultAlltabledata, &$context) {
  $source = language_default()->language;
  foreach ($resultAlltabledata as $key => $value) {
    if (strpos($key, 'field_data_') !== FALSE) {
      $table = explode('field_data_', $key);
      $table_name = $table[1];
      db_update('field_config')
        ->fields(array(
        'translatable' => '1',
      ))
        ->condition('field_name', $table_name, '=')
        ->execute();

      /*$fc_fields = db_select('globallink_field_config', 'gfc')
        ->fields('gfc', array('field_name'))
        ->condition('bundle', $table_name, '=')
        ->condition('entity_type', 'field_collection_item', '=')
        ->execute();*/
      $fc_fields = field_info_instances('field_collection_item', $table_name);
      foreach ($fc_fields as $k => $val) {
        db_update('field_config')
          ->fields(array(
          'translatable' => '1',
        ))
          ->condition('field_name', $val['field_name'], '=')
          ->execute();
        $update = db_update('field_data_' . $val['field_name'])
          ->fields(array(
          'language' => $source,
        ))
          ->condition('language', 'und', '=')
          ->condition('bundle', $table_name, '=')
          ->condition('entity_type', 'field_collection_item', '=')
          ->execute();
      }
    }
  }
  $progress = $progress + $limit;
  $context['message'] = 'Now processing ' . $progress . ' - ' . $context['results'][0] . ' Updated';
}