You are here

function globallink_settings_beans_process in GlobalLink Connect for Drupal 7.7

1 string reference to 'globallink_settings_beans_process'
prepare_beans_button_submit in ./globallink_settings.inc
Beans batch sets .

File

./globallink_settings.inc, line 1361

Code

function globallink_settings_beans_process($progress, $limit, $resultbeans, &$context) {
  $source = language_default()->language;
  foreach ($resultbeans as $key => $value) {
    $bean_fields = field_info_instances('bean', $value->name);
    foreach ($bean_fields as $bean_key => $bean_field) {
      db_update('field_config')
        ->fields(array(
        'translatable' => '1',
      ))
        ->condition('field_name', $bean_field['field_name'], '=')
        ->execute();
      $fc_fields = db_select('globallink_field_config', 'gfc')
        ->fields('gfc', array(
        'field_name',
      ))
        ->condition('bundle', 'bean:' . $value->name, '=')
        ->condition('entity_type', 'bean', '=')
        ->execute();
      foreach ($fc_fields as $k => $val) {
        db_update('field_config')
          ->fields(array(
          'translatable' => '1',
        ))
          ->condition('field_name', $val->field_name, '=')
          ->execute();
      }
      $bean_field_table = db_select('field_data_' . $bean_field['field_name'], 'gb')
        ->fields('gb', array(
        'entity_id',
      ))
        ->condition('entity_type', 'bean', '=')
        ->condition('bundle', $value->name, '=')
        ->condition('language', 'und', '=')
        ->execute();
      foreach ($bean_field_table as $bn_field => $bn_value) {
        db_update('field_data_' . $bean_field['field_name'])
          ->fields(array(
          'language' => $source,
        ))
          ->condition('entity_id', $bn_value->entity_id, '=')
          ->condition('entity_type', 'bean', '=')
          ->condition('bundle', $value->name, '=')
          ->execute();
      }
    }
  }
  $progress = $progress + $limit;
  $context['message'] = 'Now processing ' . $progress . ' - ' . $context['results'][0] . ' Updated';
}