Commit 4157a521 authored by Gábor Hojtsy's avatar Gábor Hojtsy

#199373 report by avskip, patch by myself, testing by keith.smith: forum node...

#199373 report by avskip, patch by myself, testing by keith.smith: forum node type was not re-added to the forum vocabulary when the module is re-enabled (after being disabled)
parent 6bb7647f
...@@ -12,12 +12,17 @@ function forum_install() { ...@@ -12,12 +12,17 @@ function forum_install() {
} }
function forum_enable() { function forum_enable() {
// Create the forum vocabulary if it does not exist. Assign the vocabulary if ($vocabulary = taxonomy_vocabulary_load(variable_get('forum_nav_vocabulary', 0))) {
// a low weight so it will appear first in forum topic create and edit // Existing install. Add back forum node type, if the forums
// forms. // vocabulary still exists. Keep all other node types intact there.
$vid = variable_get('forum_nav_vocabulary', 0); $vocabulary = (array) $vocabulary;
$vocabularies = taxonomy_get_vocabularies(); $vocabulary['nodes']['forum'] = 1;
if (!isset($vocabularies[$vid])) { taxonomy_save_vocabulary($vocabulary);
}
else {
// Create the forum vocabulary if it does not exist. Assign the vocabulary
// a low weight so it will appear first in forum topic create and edit
// forms.
$vocabulary = array( $vocabulary = array(
'name' => t('Forums'), 'name' => t('Forums'),
'multiple' => 0, 'multiple' => 0,
...@@ -123,4 +128,4 @@ function forum_update_6000() { ...@@ -123,4 +128,4 @@ function forum_update_6000() {
} }
return $ret; return $ret;
} }
\ No newline at end of file
...@@ -967,14 +967,18 @@ function taxonomy_get_term_by_name($name) { ...@@ -967,14 +967,18 @@ function taxonomy_get_term_by_name($name) {
* @param $vid * @param $vid
* The vocabulary's ID * The vocabulary's ID
* *
* @return Object * @return
* The vocabulary object with all of its metadata. * The vocabulary object with all of its metadata, if exists, NULL otherwise.
* Results are statically cached. * Results are statically cached.
*/ */
function taxonomy_vocabulary_load($vid) { function taxonomy_vocabulary_load($vid) {
static $vocabularies = array(); static $vocabularies = array();
if (!array_key_exists($vid, $vocabularies)) { if (!isset($vocabularies[$vid])) {
// Initialize so if this vocabulary does not exist, we have
// that cached, and we will not try to load this later.
$vocabularies[$vid] = FALSE;
// Try to load the data and fill up the object.
$result = db_query('SELECT v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE v.vid = %d', $vid); $result = db_query('SELECT v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE v.vid = %d', $vid);
$node_types = array(); $node_types = array();
while ($voc = db_fetch_object($result)) { while ($voc = db_fetch_object($result)) {
...@@ -986,8 +990,9 @@ function taxonomy_vocabulary_load($vid) { ...@@ -986,8 +990,9 @@ function taxonomy_vocabulary_load($vid) {
$vocabularies[$vid] = $voc; $vocabularies[$vid] = $voc;
} }
} }
return $vocabularies[$vid]; // Return NULL if this vocabulary does not exist.
return !empty($vocabularies[$vid]) ? $vocabularies[$vid] : NULL;
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment