You are here

function access_update_7103 in Access Control Kit 7

Convert list-based schemes to new realm settings and handlers.

File

./access.install, line 248
Install, update and uninstall functions for the access control kit module.

Code

function access_update_7103() {

  // Get a list of all access realm fields.
  $field_names = db_query('SELECT field_name FROM {field_config} WHERE type IN (:types)', array(
    ':types' => array(
      'access_boolean',
      'access_integer',
      'access_float',
      'access_text',
    ),
  ))
    ->fetchCol();

  // Convert the 'field' setting on the realm fields to 'field_name'.
  foreach ($field_names as $field_name) {
    $field = field_info_field($field_name);
    if (isset($field['settings']['arguments']['field'])) {
      $field['settings']['arguments']['field_name'] = $field['settings']['arguments']['field'];
      unset($field['settings']['arguments']['field']);
      field_update_field($field);
    }
  }

  // Convert ACKEntityList handlers to ACKEntityField.
  db_update('access_handler')
    ->fields(array(
    'handler' => 'ACKEntityField',
  ))
    ->condition('handler', 'ACKEntityList')
    ->execute();
}