forum.install

Archivo

drupal-6.x/modules/forum/forum.install
View source
  1. <?php
  2. /**
  3. * Implementation of hook_install().
  4. */
  5. function forum_install() {
  6. // Create tables.
  7. drupal_install_schema('forum');
  8. // Set the weight of the forum.module to 1 so it is loaded after the taxonomy.module.
  9. db_query("UPDATE {system} SET weight = 1 WHERE name = 'forum'");
  10. }
  11. function forum_enable() {
  12. if ($vocabulary = taxonomy_vocabulary_load(variable_get('forum_nav_vocabulary', 0))) {
  13. // Existing install. Add back forum node type, if the forums
  14. // vocabulary still exists. Keep all other node types intact there.
  15. $vocabulary = (array) $vocabulary;
  16. $vocabulary['nodes']['forum'] = 1;
  17. taxonomy_save_vocabulary($vocabulary);
  18. }
  19. else {
  20. // Create the forum vocabulary if it does not exist. Assign the vocabulary
  21. // a low weight so it will appear first in forum topic create and edit
  22. // forms.
  23. $vocabulary = array(
  24. 'name' => t('Forums'),
  25. 'multiple' => 0,
  26. 'required' => 0,
  27. 'hierarchy' => 1,
  28. 'relations' => 0,
  29. 'module' => 'forum',
  30. 'weight' => -10,
  31. 'nodes' => array('forum' => 1),
  32. );
  33. taxonomy_save_vocabulary($vocabulary);
  34. variable_set('forum_nav_vocabulary', $vocabulary['vid']);
  35. }
  36. }
  37. /**
  38. * Implementation of hook_uninstall().
  39. */
  40. function forum_uninstall() {
  41. // Load the dependent Taxonomy module, in case it has been disabled.
  42. drupal_load('module', 'taxonomy');
  43. // Delete the vocabulary.
  44. $vid = variable_get('forum_nav_vocabulary', '');
  45. taxonomy_del_vocabulary($vid);
  46. db_query('DROP TABLE {forum}');
  47. variable_del('forum_containers');
  48. variable_del('forum_nav_vocabulary');
  49. variable_del('forum_hot_topic');
  50. variable_del('forum_per_page');
  51. variable_del('forum_order');
  52. variable_del('forum_block_num_0');
  53. variable_del('forum_block_num_1');
  54. }
  55. /**
  56. * Implementation of hook_schema().
  57. */
  58. function forum_schema() {
  59. $schema['forum'] = array(
  60. 'description' => 'Stores the relationship of nodes to forum terms.',
  61. 'fields' => array(
  62. 'nid' => array(
  63. 'type' => 'int',
  64. 'unsigned' => TRUE,
  65. 'not null' => TRUE,
  66. 'default' => 0,
  67. 'description' => 'The {node}.nid of the node.',
  68. ),
  69. 'vid' => array(
  70. 'type' => 'int',
  71. 'unsigned' => TRUE,
  72. 'not null' => TRUE,
  73. 'default' => 0,
  74. 'description' => 'Primary Key: The {node}.vid of the node.',
  75. ),
  76. 'tid' => array(
  77. 'type' => 'int',
  78. 'unsigned' => TRUE,
  79. 'not null' => TRUE,
  80. 'default' => 0,
  81. 'description' => 'The {term_data}.tid of the forum term assigned to the node.',
  82. ),
  83. ),
  84. 'indexes' => array(
  85. 'nid' => array('nid'),
  86. 'tid' => array('tid')
  87. ),
  88. 'primary key' => array('vid'),
  89. );
  90. return $schema;
  91. }
  92. /**
  93. * Create the forum vocabulary if does not exist. Assign the
  94. * vocabulary a low weight so it will appear first in forum topic
  95. * create and edit forms. Do not just call forum_enable() because in
  96. * future versions it might do something different.
  97. */
  98. function forum_update_6000() {
  99. $ret = array();
  100. $vid = variable_get('forum_nav_vocabulary', 0);
  101. $vocabularies = taxonomy_get_vocabularies();
  102. if (!isset($vocabularies[$vid])) {
  103. $vocabulary = array(
  104. 'name' => t('Forums'),
  105. 'multiple' => 0,
  106. 'required' => 0,
  107. 'hierarchy' => 1,
  108. 'relations' => 0,
  109. 'module' => 'forum',
  110. 'weight' => -10,
  111. 'nodes' => array('forum' => 1),
  112. );
  113. taxonomy_save_vocabulary($vocabulary);
  114. variable_set('forum_nav_vocabulary', $vocabulary['vid']);
  115. }
  116. return $ret;
  117. }

Functions

Nombreorden descendente Descripción
forum_enable
forum_install Implementation of hook_install().
forum_schema Implementation of hook_schema().
forum_uninstall Implementation of hook_uninstall().
forum_update_6000 Create the forum vocabulary if does not exist. Assign the vocabulary a low weight so it will appear first in forum topic create and edit forms. Do not just call forum_enable() because in future versions it might do something different.