function discussthis_admin in Discuss This! 5
Admin settings callback (from menu hook) The admin/settings/discussthis page provides three sets of configuration options: 1. The author of newly-created forum discussions 2. The set of node types for which Discuss This! links should appear 3. For each selected node type, a default forum in which to create discussion topics
1 string reference to 'discussthis_admin'
- discussthis_menu in ./
discussthis.module - hook_menu implementation
File
- ./
discussthis.module, line 375
Code
function discussthis_admin() {
drupal_add_js(drupal_get_path('module', 'discussthis') . '/discussthis.js');
drupal_add_css(drupal_get_path('module', 'discussthis') . '/discussthis.css');
$node_types = node_get_types('names');
$discussthis_nodetypes = variable_get('discussthis_nodetypes', $node_types);
$form['discussthis_newsubject'] = array(
'#type' => 'textfield',
'#title' => t('Title for newly created Forum discussions'),
'#size' => 30,
'#maxlength' => 60,
'#default_value' => variable_get('discussthis_newsubject', 'Discuss This: [node-title]'),
'#weight' => -3,
);
$default_body = 'Following is a discussion on the [node-type-name] item titled: [node-link]' . '.<br /> Below is the discussion so far. Feel free to add your own comments!<br />';
$form['discussthis_newtemplate'] = array(
'#type' => 'textarea',
'#title' => t('Template for auto-created Forum discussions'),
'#description' => theme('token_help', 'discussthis'),
'#default_value' => variable_get('discussthis_newtemplate', $default_body),
'#weight' => -2,
);
$form['discussthis_comments'] = array(
'#type' => 'select',
'#title' => t('How many recent comments should be displayed with non-teaser node view?'),
'#options' => array(
0 => 'none',
1 => '1',
2 => '2',
3 => '3',
4 => '4',
5 => '5',
10 => '10',
),
'#default_value' => variable_get('discussthis_comments', 10),
);
$form['discussthis_nodetypes'] = array(
'#type' => 'checkboxes',
'#title' => t('Which node types should use the Discuss This feature'),
'#description' => t('Select all node types which should allow Discuss This links and a corresponding Default forum in which to create the topic. Also choose whether links should be displayed on Full node views, Teaser views, or both.'),
'#default_value' => $discussthis_nodetypes,
'#options' => $node_types,
);
$forums = forum_get_forums();
$discussthis_forums = array(
'0' => '-- select --',
);
foreach ($forums as $tid => $forum) {
if (!$forum->container) {
$discussthis_forums[$tid] = $forum->name;
}
}
// This should probably be within the node type config page, or else use some AJAXy thing to update
// these form fields based on the discussthis_nodetypes selection above..
foreach ($discussthis_nodetypes as $type => $name) {
$form['defaults']['discussthis_node_' . $type] = array(
'#prefix' => '<span class="conditional">',
'#suffix' => '</span>',
'#type' => 'select',
'#default_value' => variable_get('discussthis_node_' . $type, 0),
'#options' => $discussthis_forums,
);
$form['defaults']['discussthis_teaser_' . $type] = array(
'#prefix' => '<span class="conditional">',
'#suffix' => '</span>',
'#type' => 'select',
'#default_value' => variable_get('discussthis_teaser_' . $type, 0),
'#options' => array(
'0' => t('Full view only'),
'1' => t('Teaser view only'),
'2' => t('Both'),
),
);
}
$form['#validate'] = array(
'discussthis_admin_validate' => array(),
);
$form['#theme'] = 'discussthis_admin';
return system_settings_form($form);
}