Skip to content
Snippets Groups Projects
system.install 111 KiB
Newer Older

  // Insert default user-defined node types into the database.
  $types = array(
    array(
      'type' => 'page',
      'name' => t('page'),
      'module' => 'node',
      'description' => t('If you want to add a static page, like a contact page or an about page, use a page.'),
      'custom' => TRUE,
      'modified' => TRUE,
      'locked' => FALSE,
    ),
    array(
      'type' => 'story',
      'name' => t('story'),
      'module' => 'node',
      'description' => t('Stories are articles in their simplest form: they have a title, a teaser and a body, but can be extendd by other modules. The teaser is part of the body too. Stories may be used as a personal blog or for news articles.'),
      'custom' => TRUE,
      'modified' => TRUE,
      'locked' => FALSE,
    )
  );

  foreach ($types as $type) {
    $type = (object) _node_type_set_defaults($type);
    node_type_save($type);
  }

  cache_clear_all();
  system_modules();
  menu_rebuild();
  node_types_rebuild();

  // Migrate old values for 'minimum_x_size' variables to the node_type table.
  $query = db_query('SELECT type FROM {node_type}');
  while ($result = db_fetch_object($query)) {
    $variable_name = 'minimum_'. $result->type .'_size';
    if ($value = db_fetch_object(db_query("SELECT value FROM {variable} WHERE name = '%s'", $variable_name))) {
      $value = (int) unserialize($value->value);
      db_query("UPDATE {node_type} SET min_word_count = %d, modified = %d WHERE type = '%s'", $value, 1, $result->type);
      variable_del($variable_name);
    }
  }

  node_types_rebuild();

  return $ret;
}
function system_update_1006() {
  // Add a customizable title to all blocks.
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
    $ret[] = update_sql("ALTER TABLE {blocks} ADD title VARCHAR(64) NOT NULL DEFAULT ''");
      break;
    case 'pgsql':
      db_add_column($ret, 'blocks', 'title', 'varchar(64)', array('default' => '', 'not null' => TRUE));
      break;
  }
  // Migrate custom block titles to new column.
  $boxes = db_query('SELECT bid, title from {boxes}');
  while ($box = db_fetch_object($boxes)) {
    db_query("UPDATE {blocks} SET title = '%s' WHERE delta = %d and module = 'block'", $box->title, $box->bid);
  }
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql('ALTER TABLE {boxes} DROP title');
      break;
    case 'pgsql':
      $ret[] = update_sql('ALTER TABLE {boxes} DROP COLUMN title');
      break;
  }
  return $ret;
}

function system_update_1007() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("ALTER TABLE {aggregator_item} ADD INDEX (fid)");
      break;
    case 'pgsql':
      $ret[] = update_sql("CREATE INDEX {aggregator_item}_fid_idx ON {aggregator_item} (fid)");
      break;
  }
  return $ret;
}

/**
 * Performance update for queries that are related to the locale.module
 */
function system_update_1008() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql('ALTER TABLE {locales_source} ADD KEY source (source(30))');
      break;
    case 'pgsql':
      $ret[] = update_sql("CREATE INDEX {locales_source}_source_idx on {locales_source} (source)");
  }

  return $ret;
}

/**
 * @} End of "defgroup updates-4.7-to-x.x"
 * The next series of updates should start at 2000.
 */