title.install 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * @file
  4. * Installation functions for the Title module.
  5. */
  6. /**
  7. * Helper function.
  8. */
  9. function _title_install_set_weight($weight) {
  10. db_update('system')
  11. ->fields(array('weight' => $weight))
  12. ->condition('name', 'title')
  13. ->execute();
  14. }
  15. /**
  16. * Implements hook_install().
  17. */
  18. function title_install() {
  19. // Make (reasonably) sure that title_module_implements_alter() is invoked as
  20. // last so we can determine the priority of our hook implementations reliably.
  21. _title_install_set_weight(100);
  22. }
  23. /**
  24. * Implements hook_disable().
  25. */
  26. function title_disable() {
  27. foreach (field_read_fields() as $field) {
  28. if ($field['type'] !== 'taxonomy_term_reference') {
  29. continue;
  30. }
  31. if ($field['settings']['options_list_callback'] !== 'title_taxonomy_allowed_values') {
  32. continue;
  33. }
  34. $field['settings']['options_list_callback'] = '';
  35. field_update_field($field);
  36. }
  37. }
  38. /**
  39. * Implements hook_update_N().
  40. */
  41. /**
  42. * Make sure Title has a very high weight to be able to perform reverse
  43. * synchronization reliably.
  44. */
  45. function title_update_7001() {
  46. _title_install_set_weight(100);
  47. }
  48. /**
  49. * Update title_auto_attach variables to the new format.
  50. */
  51. function title_update_7002() {
  52. $variables = array();
  53. foreach (variable_get('title_auto_attach', array()) as $variable) {
  54. $pieces = explode(':', $variable);
  55. $variables['title_' . $pieces[0]]['auto_attach'][$pieces[1]] = $pieces[1];
  56. }
  57. foreach ($variables as $name => $value) {
  58. variable_set($name, $value);
  59. }
  60. variable_del('title_auto_attach');
  61. }