You are here

site_map.install in Site map 7

Same filename and directory in other branches
  1. 5 site_map.install
  2. 6.2 site_map.install
  3. 6 site_map.install

The install and update code for the site_map module.

File

site_map.install
View source
<?php

/**
 * @file
 * The install and update code for the site_map module.
 *
 * @ingroup site_map
 */

/**
 * Implements hook_uninstall().
 */
function site_map_uninstall() {
  db_delete('variable')
    ->condition('name', db_like('site_map_') . '%', 'LIKE')
    ->execute();
}

/**
 * Delete no longer used variables.
 */
function site_map_update_6000() {
  db_delete('variable')
    ->condition('name', db_like('site_map_message_') . '%', 'LIKE')
    ->execute();
  db_delete('variable')
    ->condition('name', db_like('site_map_show_menus_') . '%', 'LIKE')
    ->execute();
}

/**
 * Upgrade site map message format setting.
 */
function site_map_update_7000() {
  variable_set('site_map_message', array(
    'value' => variable_get('site_map_message', ''),
    'format' => variable_get('site_map_message_format', filter_default_format()),
  ));
  variable_del('site_map_message_format');
  return t('Successfully upgraded site map message format setting.');
}

/**
 * Change block caching mode.
 */
function site_map_update_7001() {
  db_update('block')
    ->fields(array(
    'cache' => DRUPAL_NO_CACHE,
  ))
    ->condition('module', 'site_map')
    ->execute();
}

/**
 * Use vocabulary machine names instead of IDs for taxonomy settings.
 */
function site_map_update_7002() {
  $vids = array_filter(variable_get('site_map_show_vocabularies', array()));
  if (module_exists('taxonomy') && !empty($vids)) {
    $vocab_options = array();
    foreach ($vids as $vid) {
      if (is_numeric($vid)) {
        $vocabulary = taxonomy_vocabulary_load($vid);
        $vocab_options[$vocabulary->machine_name] = $vocabulary->machine_name;
      }
    }
    if (!empty($vocab_options)) {
      variable_set('site_map_show_vocabularies', $vocab_options);
    }
  }
}

/**
 * Implements hook_update_N().
 *
 * Set the configuration page permission for user roles who have
 * "administer site configuration" permission.
 */
function site_map_update_7003() {
  $roles = user_roles(FALSE, 'administer site configuration');
  if (count($roles) > 0 && isset($roles)) {
    foreach ($roles as $rid => $role) {
      user_role_grant_permissions($rid, array(
        'administer site map',
      ));
    }
  }
}

Functions

Namesort descending Description
site_map_uninstall Implements hook_uninstall().
site_map_update_6000 Delete no longer used variables.
site_map_update_7000 Upgrade site map message format setting.
site_map_update_7001 Change block caching mode.
site_map_update_7002 Use vocabulary machine names instead of IDs for taxonomy settings.
site_map_update_7003 Implements hook_update_N().