Skip to content
Snippets Groups Projects
Commit 789cba51 authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

#186546 by bjaspan: fix missing forum vocabulary when people turned on forum...

#186546 by bjaspan: fix missing forum vocabulary when people turned on forum module, but never visited any pages in Drupal 5 and they upgrade to Drupal 6 which does this much better
parent bca91310
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -91,3 +91,33 @@ function forum_schema() {
return $schema;
}
/**
* 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.
*/
function forum_update_6000() {
$ret = array();
$vid = variable_get('forum_nav_vocabulary', 0);
$vocabularies = taxonomy_get_vocabularies();
if (!isset($vocabularies[$vid])) {
$vocabulary = array(
'name' => t('Forums'),
'multiple' => 0,
'required' => 0,
'hierarchy' => 1,
'relations' => 0,
'module' => 'forum',
'weight' => -10,
'nodes' => array('forum' => 1),
);
taxonomy_save_vocabulary($vocabulary);
variable_set('forum_nav_vocabulary', $vocabulary['vid']);
}
return $ret;
}
\ No newline at end of file
......@@ -161,8 +161,15 @@ function forum_init() {
* Implementation of hook_nodeapi().
*/
function forum_nodeapi(&$node, $op, $teaser, $page) {
// We are going to return if $node->type is not one of the node
// types assigned to the forum vocabulary. If forum_nav_vocabulary
// is undefined or the vocabulary does not exist, it clearly cannot
// be assigned to $node->type, so return to avoid E_ALL warnings.
$vid = variable_get('forum_nav_vocabulary', '');
$vocabulary = taxonomy_vocabulary_load($vid);
if (empty($vocabulary)) {
return;
}
// Operate only on node types assigned for the forum vocabulary.
if (!in_array($node->type, $vocabulary->nodes)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment