summaryrefslogtreecommitdiff
path: root/modules/forum
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-04-26 14:32:27 +0000
committerDries Buytaert <dries@buytaert.net>2010-04-26 14:32:27 +0000
commit9f70b717e56c8bc816dd5119e2830d668037d5cc (patch)
tree0cb7dc7ca632e90cc78d8ce65856ef6bbb74169f /modules/forum
parent96bfc650bc1f4430654575b8872e77c90bb8d50c (diff)
downloadbrdo-9f70b717e56c8bc816dd5119e2830d668037d5cc.tar.gz
brdo-9f70b717e56c8bc816dd5119e2830d668037d5cc.tar.bz2
- Patch #613272 by Kevin Hankens, Dave Reid, yoroy, rgristroph, pcarman: forums not usable out-of-the-box: disabled comments, no forums.
Diffstat (limited to 'modules/forum')
-rw-r--r--modules/forum/forum.install13
-rw-r--r--modules/forum/forum.module4
-rw-r--r--modules/forum/forum.test18
3 files changed, 34 insertions, 1 deletions
diff --git a/modules/forum/forum.install b/modules/forum/forum.install
index 7e6de833a..65841a4a1 100644
--- a/modules/forum/forum.install
+++ b/modules/forum/forum.install
@@ -20,6 +20,9 @@ function forum_install() {
variable_set('node_options_forum', array('status'));
}
+/**
+ * Implements hook_enable().
+ */
function forum_enable() {
// Create the forum vocabulary if it does not exist.
$vocabulary = taxonomy_vocabulary_load(variable_get('forum_nav_vocabulary', 0));
@@ -66,6 +69,16 @@ function forum_enable() {
field_create_instance($instance);
variable_set('forum_nav_vocabulary', $vocabulary->vid);
+
+ // Create a default forum so forum posts can be created.
+ $edit = array(
+ 'name' => t('General discussion'),
+ 'description' => '',
+ 'parent' => array(0),
+ 'vid' => $vocabulary->vid,
+ );
+ $term = (object) $edit;
+ taxonomy_term_save($term);
}
}
diff --git a/modules/forum/forum.module b/modules/forum/forum.module
index 10d55b1a3..413903434 100644
--- a/modules/forum/forum.module
+++ b/modules/forum/forum.module
@@ -307,6 +307,10 @@ function forum_node_validate($node, $form) {
continue;
}
$term = taxonomy_term_load($item['tid']);
+ if (!$term) {
+ form_set_error('taxonomy_forums', t('Select a forum.'));
+ continue;
+ }
$used = db_query_range('SELECT 1 FROM {taxonomy_term_data} WHERE tid = :tid AND vid = :vid',0 , 1, array(
':tid' => $term->tid,
':vid' => $term->vid,
diff --git a/modules/forum/forum.test b/modules/forum/forum.test
index c1076fe94..2cd4909d8 100644
--- a/modules/forum/forum.test
+++ b/modules/forum/forum.test
@@ -35,6 +35,11 @@ class ForumTestCase extends DrupalWebTestCase {
* Login users, create forum nodes, and test forum functionality through the admin and user interfaces.
*/
function testForum() {
+ //Check that the basic forum install creates a default forum topic
+ $this->drupalGet("/forum");
+ // Look for the "General discussion" default forum
+ $this->assertText(t("General discussion"), "Found the default forum at the /forum listing");
+
// Do the admin tests.
$this->doAdminTests($this->admin_user);
// Generate topics to populate the active forum block.
@@ -94,11 +99,22 @@ class ForumTestCase extends DrupalWebTestCase {
* Forum nodes should not be created without choosing forum from select list.
*/
function testAddOrphanTopic() {
+ // Must remove forum topics to test creating orphan topics.
+ $vid = variable_get('forum_nav_vocabulary');
+ $tree = taxonomy_get_tree($vid);
+ foreach($tree as $term) {
+ taxonomy_term_delete($term->tid);
+ }
+
+ // Create an orphan forum item.
$this->drupalLogin($this->admin_user);
$this->drupalPost('node/add/forum', array('title' => $this->randomName(10), 'body[' . LANGUAGE_NONE .'][0][value]' => $this->randomName(120)), t('Save'));
$nid_count = db_query('SELECT COUNT(nid) FROM {node}')->fetchField();
- $this->assertEqual(0, $nid_count, t('A forum node was not created.'));
+ $this->assertEqual(0, $nid_count, t('A forum node was not created when missing a forum vocabulary.'));
+
+ // Reset the defaults for future tests.
+ module_enable(array('forum'));
}
/**