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