You are here

function tca_modules_enabled in Token Content Access 7

Implements hook_modules_enabled().

File

./tca.module, line 54
The Token Content Access module file.

Code

function tca_modules_enabled($modules) {
  foreach ($modules as $module) {

    // If this module implements hook_tca(), we should add the Token Content
    // Access fields to the base table of the entity type that this module is
    // altering.
    $function = $module . '_tca';
    if (function_exists($function)) {

      // Gather info about the module, entity and get the Token Content Access
      // fields.
      $tca_info = $function();
      $entity_info = entity_get_info($tca_info[$module]['entity type']);
      $fields = tca_schema_fields();

      // Add each field to the base table for the entity.
      foreach ($fields as $name => $spec) {
        if (!db_field_exists($entity_info['base table'], $name)) {
          db_add_field($entity_info['base table'], $name, $spec);
        }
      }
    }
  }
}