diff options
Diffstat (limited to 'modules/forum.module')
-rw-r--r-- | modules/forum.module | 71 |
1 files changed, 42 insertions, 29 deletions
diff --git a/modules/forum.module b/modules/forum.module index 972b0ce3f..4c520aa95 100644 --- a/modules/forum.module +++ b/modules/forum.module @@ -13,10 +13,10 @@ function forum_help($section) { <p>When you are happy with your vocabulary, go to <a href=\"%forums\">administer » configutation » modules » forum</a> and set <strong>Forum vocabulary</strong> to the one you have just created. There will now be fora active on the site. For users to access them they must have the \"access content\" <a href=\"%permission\">permission</a> and to create a topic they must have the \"create forum topics\" <a href=\"%permission\">permission</a>. These permissions can be set in the <a href=\"%permission\">permission</a> pages.</p> <h4>Icons</h4> <p>To disable icons, set the icon path as blank in <a href=\"%forums\">administer » configutation » modules » forum</a>.</p> - <p>All files in the icon directory are assumed to be images. You may use images of whatever size you wish, but it is recommended to use 15x15 or 16x16.</p>", array("%taxonomy" => url('admin/taxonomy/add/vocabulary'), '%taxo-terms' => url('admin/taxonomy'), '%forums' => url('admin/system/modules/forum'), '%permission' => url('admin/user/permission'))); - case 'admin/system/modules#description': + <p>All files in the icon directory are assumed to be images. You may use images of whatever size you wish, but it is recommended to use 15x15 or 16x16.</p>", array("%taxonomy" => url('admin/taxonomy/add/vocabulary'), '%taxo-terms' => url('admin/taxonomy'), '%forums' => url('admin/settings/forum'), '%permission' => url('admin/user/permission'))); + case 'admin/modules#description': return t('Enable threaded discussions about general topics.'); - case 'admin/system/modules/forum': + case 'admin/settings/forum': return t("Forums are threaded discussions based on the taxonomy system. For the forums to work, the taxonomy module has to be installed and enabled. When activated, a taxonomy vocabulary (eg. \"forums\") needs to be <a href=\"%created\">created</a> and bound to the node type \"forum topic\".", array('%created' => url('admin/taxonomy/add/vocabulary'))); case 'node/add/forum': return variable_get('forum_help', ''); @@ -78,7 +78,7 @@ function forum_settings() { $group .= form_radios(t('Default order'), 'forum_order', variable_get('forum_order', '1'), $forder, t('The default display order for topics.')); $output .= form_group(t('Forum viewing options'), $group); - $group = form_textfield(t('Number of topics in block'), 'forum_block_num', variable_get('forum_block_num', '5'), 5, 5, t('The number of topics to show in the "Forum topics" block. To enable the block, go to the <a href="%block-administration">block administration</a> page.', array('%block-administration' => url('admin/system/block')))); + $group = form_textfield(t('Number of topics in block'), 'forum_block_num', variable_get('forum_block_num', '5'), 5, 5, t('The number of topics to show in the "Forum topics" block. To enable the block, go to the <a href="%block-administration">block administration</a> page.', array('%block-administration' => url('admin/block')))); $output .= form_group(t('"Forum topic" block settings'), $group); } } @@ -149,11 +149,6 @@ function forum_link($type, $node = 0, $main = 0) { $links[] = l(t('forums'), 'forum'); } - if ($type == 'system') { - menu('node/add/forum', t('forum topic'), user_access('create forum topics') ? MENU_FALLTHROUGH : MENU_DENIED); - menu('forum', t('forums'), user_access('access content') ? 'forum_page' : MENU_DENIED, 0, MENU_HIDE); - } - if (!$main && $type == 'node' && $node->type == 'forum') { // get previous and next topic @@ -175,11 +170,11 @@ function forum_link($type, $node = 0, $main = 0) { } if ($prev) { - $links[] = l(t('previous forum topic'), "node/view/$prev->nid", array('title' => $prev->title)); + $links[] = l(t('previous forum topic'), "node/$prev->nid", array('title' => $prev->title)); } if ($next) { - $links[] = l(t('next forum topic'), "node/view/$next->nid", array('title' => $next->title)); + $links[] = l(t('next forum topic'), "node/$next->nid", array('title' => $next->title)); } } @@ -187,31 +182,49 @@ function forum_link($type, $node = 0, $main = 0) { } /** + * Implementation of hook_menu(). + */ +function forum_menu() { + $items = array(); + + $items[] = array('path' => 'node/add/forum', 'title' => t('forum topic'), + 'access' => user_access('create forum topics')); + $items[] = array('path' => 'forum', 'title' => t('forums'), + 'callback' => 'forum_page', + 'access' => user_access('access content'), + 'type' => MENU_CALLBACK); + + return $items; +} + +/** * Implementation of hook_content(). */ -function forum_content($node, $main = 0) { - return node_prepare($node, $main); +function forum_content($node, $teaser = FALSE) { + return node_prepare($node, $teaser); } /** * Implementation of hook_view(). */ -function forum_view($node, $main = 0, $page = 0) { +function forum_view($node, $teaser = FALSE, $page = FALSE) { if ($page) { $vocabulary = taxonomy_get_vocabulary(variable_get('forum_nav_vocabulary', '')); // Breadcrumb navigation - $breadcrumb = array(l(t('Home'), NULL), l($vocabulary->name, 'forum')); + $breadcrumb = array(); + $breadcrumb[] = array('path' => 'forum', 'title' => $vocabulary->name); if ($parents = taxonomy_get_parents_all($node->tid)) { $parents = array_reverse($parents); foreach ($parents as $p) { - $breadcrumb[] = l($p->name, "forum/$p->tid"); + $breadcrumb[] = array('path' => 'forum/'. $p->tid, 'title' => $p->name); } } - drupal_set_breadcrumb($breadcrumb); + $breadcrumb[] = array('path' => 'node/'. $node->nid); + menu_set_location($breadcrumb); } - return theme('node', forum_content($node, $main), $main, $page); + return theme('node', forum_content($node, $teaser), $teaser, $page); } /** @@ -453,7 +466,7 @@ function forum_page($tid = 0, $display = 'all') { if (module_exist('taxonomy')) { if ($display == 'new') { if ($nid = _forum_new($tid)) { - drupal_goto("node/view/$nid"); + drupal_goto("node/$nid"); } } else { @@ -477,7 +490,7 @@ function forum_page($tid = 0, $display = 'all') { } } else { - print theme('page', forum_help('admin/system/modules/forum'), t('Warning')); + print theme('page', forum_help('admin/settings/forum'), t('Warning')); } } @@ -506,12 +519,10 @@ function theme_forum_display($forums, $topics, $parents, $tid, $sortby, $forum_p $vocabulary = taxonomy_get_vocabulary(variable_get('forum_nav_vocabulary', '')); $title = $vocabulary->name; - /* - ** Breadcrumb navigation: - */ - $breadcrumb[] = l(t('Home'), ''); + // Breadcrumb navigation: + $breadcrumb = array(); if ($tid) { - $breadcrumb[] = l($title, 'forum'); + $breadcrumb[] = array('path' => 'forum', 'title' => $title); } if ($parents) { @@ -521,10 +532,12 @@ function theme_forum_display($forums, $topics, $parents, $tid, $sortby, $forum_p $title = $p->name; } else { - $breadcrumb[] = l($p->name, "forum/$p->tid"); + $breadcrumb[] = array('path' => 'forum/'. $p->tid, 'title' => $p->name); } } } + $breadcrumb[] = array('path' => $_GET['q']); + menu_set_location($breadcrumb); if (count($forums) || count($parents)) { $output = '<div id="forum">'; @@ -561,7 +574,7 @@ function theme_forum_display($forums, $topics, $parents, $tid, $sortby, $forum_p $output = ''; } - print theme('page', $output, $title, $breadcrumb); + print theme('page', $output, $title); } /** @@ -654,8 +667,8 @@ function theme_forum_topic_list($tid, $topics, $sortby, $forum_per_page, $offset else { $rows[] = array( array('data' => _forum_icon($topic->new, $topic->num_comments, $topic->comment_mode), 'class' => 'icon'), - array('data' => l($topic->title, "node/view/$topic->nid"), 'class' => 'topic'), - array('data' => $topic->num_comments . ($topic->new_replies ? '<br />'. l(t('%a new', array('%a' => $topic->new_replies)), "node/view/$topic->nid", NULL, NULL, 'new') : ''), 'class' => 'replies'), + array('data' => l($topic->title, "node/$topic->nid"), 'class' => 'topic'), + array('data' => $topic->num_comments . ($topic->new_replies ? '<br />'. l(t('%a new', array('%a' => $topic->new_replies)), "node/$topic->nid", NULL, NULL, 'new') : ''), 'class' => 'replies'), array('data' => _forum_format($topic), 'class' => 'created'), array('data' => _forum_format($topic->last_reply), 'class' => 'last-reply') ); |