2,
'path' => drupal_get_path('module', 'drubb'),
);
}
/**
* @file
* A phpBB-like forum for Drupal.
*/
function drubb_init() {
drupal_add_css(drupal_get_path('module', 'drubb') .'/drubb.css');
}
/**
* Implementation of hook_menu_alter().
*/
function drubb_menu_alter(&$items) {
// Set the 'forum' path to a normal item so that it appears in navigation.
$items['forum']['type'] = MENU_NORMAL_ITEM;
}
/**
* Implementation of hook_form_alter().
*/
function drubb_form_alter(&$form, $form_state, $form_id) {
// Hide the forum selection from node forms.
if ($form['#id'] == 'node-form') {
$forum_vid = variable_get('forum_nav_vocabulary', '');
$forum_vocabulary = taxonomy_vocabulary_load($forum_vid);
$types = array_values($forum_vocabulary->nodes);
if (!in_array($form['type']['#value'], $types)) {
return;
}
// Add identifier that can be used in css to target forum posts.
$form['#prefix'] = '
';
$form['#suffix'] = '
';
if (!$form['vid']['#value']) {
// Node add form. Hide this value rather than using #type 'value'
// so the Draft module javascript can still manipulate it.
// Hide the forum value for drafts. We won't have a value
// for arg(3) when using drafts. The value will get added
// by the Draft module js.
if ($_GET['draft_id']) {
$form['taxonomy'][$forum_vid] = array(
'#type' => 'hidden',
);
}
// Always hide the forum selection when adding a new topic
// that has a target forum specified.
else {
$forum_tid = arg(3);
if ($forum = forum_term_load($forum_tid) && isset($form['taxonomy'][$forum_vid])) {
$form['taxonomy'][$forum_vid] = array(
'#type' => 'hidden',
'#value' => $forum_tid,
);
}
}
}
else {
// Node edit form. Only show forum selection to administrative users.
if (!user_access('administer nodes')) {
$forum_tid = $form['taxonomy'][$forum_vid]['#default_value'][0];
$form['taxonomy'][$forum_vid] = array(
'#type' => 'hidden',
'#value' => $forum_tid,
);
$form['shadow']['#type'] = 'value';
}
}
// Remove ugly fieldset around smileys block.
$form['body_field']['smileys']['#collapsible'] = FALSE;
}
elseif ($form_id == 'comment_form') {
// Add a method to identify forum comments.
$forum_vid = variable_get('forum_nav_vocabulary', '');
$forum_vocabulary = taxonomy_vocabulary_load($forum_vid);
$types = array_values($forum_vocabulary->nodes);
$node = node_load($form['nid']['#value']);
if (!in_array($node->type, $types)) {
return;
}
// Add identifier that can be used in css to target forum posts.
$form['#prefix'] = '';
$form['#suffix'] = '
';
// Remove ugly fieldset around smileys block.
$form['comment_filter']['smileys']['#collapsible'] = FALSE;
}
}
/**
* Theme a quote with its content and author, rework the default
* to use blockquote instead of div for the quote itself, to take
* advantage of themes that provide quote mark gifs.
*
* @param $quote_content
* The quote's string content.
* @param $quote_author
* The quote author's name.
*
* @return $output_quote
* Themed quote.
*/
function drubb_quote($quote_content, $quote_author) {
$quote_output = '';
if ($quote_author != '') {
$quote_output .= '
'. t('%name wrote:', array('%name' => $quote_author)) .'
';
}
else {
$quote_output .= '
XXX'. t('Quote:') .'
';
}
$quote_output .= '
'. $quote_content .'
';
$quote_output .= '
';
return $quote_output;
}