You are here

function name_update_6000 in Name Field 7

Same name and namespace in other branches
  1. 6 name.install \name_update_6000()

This adds the formats that would otherwise be inserted during installation.

File

./name.install, line 97
Standard installation functions for name.

Code

function name_update_6000() {
  $ret = array();

  // Create the table.
  $schema = array(
    'fields' => array(
      'ncfid' => array(
        'description' => t('The primary identifier for a custom format.'),
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'name' => array(
        'description' => t('The name to identify the custom format to a user.'),
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'machine_name' => array(
        'description' => t('The machine name to identify the custom format to the system.'),
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'format' => array(
        'description' => t('The format string to apply to names.'),
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'ncfid',
    ),
  );
  db_create_table('name_custom_format', $schema);

  // Install some default values.
  $t = get_t();
  name_install_default_formats();

  // Clear the caches.
  cache_clear_all('*', 'cache', TRUE);
  cache_clear_all('*', 'cache_content', TRUE);
  if (module_exists('views')) {

    // Needed because this can be called from .install files.
    module_load_include('module', 'views');
    views_invalidate_cache();
  }
  return t('Created name formats table {name_custom_format}.') . '<br/>' . $t('The default set of custom name format strings was generated and saved. These are listed !here.', array(
    '!here' => l($t('here', 'admin/config/content/name')),
  ));
}