123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- /**
- * @file
- * Install, update and uninstall functions for the Hierarchical Select module.
- */
- /**
- * Implements hook_uninstall().
- */
- function hierarchical_select_uninstall() {
- db_delete('variable')
- ->condition('name', 'hs_config_%', 'LIKE')
- ->execute();
- db_delete('variable')
- ->condition('name', 'hierarchical_select_%', 'LIKE')
- ->execute();
- }
- //----------------------------------------------------------------------------
- // Updates.
- /**
- * Update Hierarchical Select to Drupal 7. Basically remove a lot of cruft.
- */
- function hierarchical_select_update_7001() {
- // Drop Hierarchical Select's cache table, which is now obsolete.
- db_drop_table('cache_hierarchical_select');
- // Undo Hierarchical Select module weight changes, because they're no longer
- // necessary.
- db_update('system')
- ->fields(array(
- 'weight' => 0,
- ))
- ->condition('name', 'hierarchical_select')
- ->execute();
- }
- /**
- * Update Hierarchical Select config to support improved "entity count".
- */
- function hierarchical_select_update_7002() {
- module_load_include('inc', 'hierarchical_select', 'includes/common');
- // Retrieve all information items.
- $info_items = array();
- foreach (module_implements('hierarchical_select_config_info') as $module) {
- $info_items = array_merge_recursive($info_items, module_invoke($module, 'hierarchical_select_config_info'));
- }
- foreach ($info_items as $info_item) {
- // Load config.
- $config = hierarchical_select_common_config_get($info_item['config_id']);
- // Move old settings to new location.
- $config['entity_count'] = array(
- 'enabled' => $config['entity_count'],
- 'require_entity' => $config['require_entity'],
- );
- // Remove old setting.
- unset($config['require_entity']);
- // Add entity types settings.
- $entity_info = entity_get_info();
- foreach ($entity_info as $entity => $entity_info) {
- if (!empty($entity_info['bundles']) && $entity_info['fieldable'] === TRUE) {
- foreach ($entity_info['bundles'] as $bundle => $bundle_info) {
- if ($entity == 'node') {
- $config['entity_count']['settings']['entity_types'][$entity]['count_' . $entity][$bundle] = $bundle;
- }
- else {
- $config['entity_count']['settings']['entity_types'][$entity]['count_' . $entity][$bundle] = 0;
- }
- }
- }
- }
- // Save new config.
- hierarchical_select_common_config_set($info_item['config_id'], $config);
- }
- }
|