synonyms.install 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * @file
  4. * Install, update, and uninstall functions for the Synonyms module.
  5. */
  6. /**
  7. * Implements hook_uninstall().
  8. */
  9. function synonyms_uninstall() {
  10. // We rely on a constant defined in the main module's file, so we include it.
  11. drupal_load('module', 'synonyms');
  12. field_delete_field(SYNONYMS_DEFAULT_FIELD_NAME);
  13. // Cleaning all configure variables.
  14. $results = db_select('variable', 'var')
  15. ->fields('var', array('name'))
  16. ->condition('var.name', db_like('synonyms_') . '%', 'LIKE')
  17. ->execute();
  18. foreach ($results as $var) {
  19. variable_del($var->name);
  20. }
  21. }
  22. /**
  23. * Implements hook_update_N().
  24. *
  25. * Update to version 7.x-1.1 of Synonyms module.
  26. */
  27. function synonyms_update_7101() {
  28. $result = db_select('variable', 'var')
  29. ->fields('var', array('name'))
  30. ->condition('var.name', db_like('synonyms_settings_') . '%', 'LIKE')
  31. ->execute();
  32. foreach ($result as $var) {
  33. $settings = variable_get($var->name);
  34. // Term merging has been deprecated in favor of Term Merge module.
  35. unset($settings['term_merge']);
  36. // Enabled synonyms now stored as field names, since the field independency
  37. // has been introduced. See issue http://drupal.org/node/1850748.
  38. drupal_load('module', 'synonyms');
  39. $settings['synonyms'] = $settings['synonyms'] ? array(SYNONYMS_DEFAULT_FIELD_NAME) : array();
  40. variable_set($var->name, $settings);
  41. }
  42. return t('Updated settings of synonyms.');
  43. }