You are here

function services_client_update_7003 in Services Client 7.2

Same name and namespace in other branches
  1. 7 services_client.install \services_client_update_7003()

Add ctools support and move data around

File

./services_client.install, line 210
Installation file for services_client module.

Code

function services_client_update_7003() {
  $schema = services_client_schema();

  // Services client verion 2 is installed, we can skip this step.
  if (!empty($schema['services_client_connection_event'])) {
    return;
  }
  ctools_include('export');
  if (db_table_exists('services_client_connection_hook') && !db_field_exists('services_client_connection_hook', 'config')) {

    // Use what's already defined in uuid schema in order to be consistent.
    $schema = services_client_schema();
    $spec = $schema['services_client_connection_hook']['fields']['config'];
    db_add_field('services_client_connection_hook', 'config', $spec);
  }
  $hooks = ctools_export_crud_load_all('services_client_connection_hook');
  foreach ($hooks as $hook) {

    // Copy over the settings from hook_mappings
    if (isset($hook->hook_mappings)) {
      $hook->config['mapping']['config'] = $hook->hook_mappings;
    }

    // Copy over the settings from hook_conditions
    if (isset($hook->hook_conditions)) {
      $hook->config['condition']['config'] = $hook->hook_conditions;
    }
    ctools_export_crud_save('services_client_connection_hook', $hook);
  }
  if (db_table_exists('services_client_connection_hook')) {

    // Use what's already defined in uuid schema in order to be consistent.
    db_drop_field('services_client_connection_hook', 'hook_mappings');
    db_drop_field('services_client_connection_hook', 'hook_conditions');
  }
}