function signature_forum_admin_settings in Signatures for Forums 6
Same name and namespace in other branches
- 5.2 signature_forum.module \signature_forum_admin_settings()
- 5 signature_forum.module \signature_forum_admin_settings()
Admin settings form.
TODO: Move admin form to existing signature form under admin/user/settings.
1 string reference to 'signature_forum_admin_settings'
- signature_forum_menu in ./
signature_forum.module - Implementation of hook_menu().
File
- ./
signature_forum.module, line 76 - Tweaks signatures in ways inspired by other traditional forum software:
Code
function signature_forum_admin_settings() {
$settings = variable_get('signature_forum_settings', signature_forum_defaults());
// Check to ensure the admin has enabled signatures in admin/user/settings.
if (!variable_get('user_signatures', FALSE)) {
drupal_set_message(t('Note: signatures are switched off, enable them under <a href="@settings-page">Administer -> User management -> User settings</a>', array(
'@settings-page' => url('admin/user/settings'),
)));
}
$form['signature'] = array(
'#type' => 'fieldset',
'#title' => t('Show signatures with nodes and comments for'),
);
foreach (node_get_types('names') as $type => $name) {
$form['signature']['signature_forum_show_for_' . $type] = array(
'#type' => 'checkbox',
'#title' => $name,
'#return_value' => 1,
'#default_value' => isset($settings['signature_forum_show_for_' . $type]) ? $settings['signature_forum_show_for_' . $type] : FALSE,
);
}
$form['template'] = array(
'#type' => 'textarea',
'#title' => t('Template for signatures'),
'#default_value' => $settings['signature_forum_template'],
'#description' => t("%s will be replaced with the user's signature."),
);
$form['format'] = filter_form($settings['signature_forum_format']);
$form['content_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Minimum content length'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['content_settings']['min_content_length'] = array(
'#type' => 'textfield',
'#title' => t('Minimum content length'),
'#size' => 3,
'#maxlength' => 10,
'#default_value' => $settings['signature_forum_min_content_length'],
'#description' => t('The minimum number of characters in the content a signature is being attached to. 0 means no limit.'),
);
$form['content_settings']['min_content_length_action'] = array(
'#type' => 'radios',
'#title' => t('Minimum content action'),
'#default_value' => $settings['signature_forum_min_content_length_action'],
'#options' => array(
MIN_CONTENT_ACTION_DO_NOT_DISPLAY => t('Do not display signature'),
MIN_CONTENT_ACTION_ADDITIONAL_FILTER => t('Run through an additional filter'),
),
'#description' => t('What to do if the content is under the minimum length. Set the filter below.'),
);
$form['content_settings']['min_content_length_filter'] = filter_form($settings['signature_forum_min_content_length_filter'], NULL, array(
'min_content_length_filter',
));
$form['content_settings']['min_content_length_filter']['#title'] = t('Minimum content additional filter format (if enabled)');
// If admin has opted to run signature through additional filter when content too short,
// expand the additional filter selection fieldset.
if ($settings['signature_forum_min_content_length_action'] == MIN_CONTENT_ACTION_ADDITIONAL_FILTER) {
$form['content_settings']['min_content_length_filter']['#collapsed'] = FALSE;
}
$roles = user_roles(TRUE);
$form['content_settings']['roles'] = array(
'#type' => 'checkboxes',
'#title' => t('Exempt roles'),
'#default_value' => isset($settings['signature_forum_roles']) ? $settings['signature_forum_roles'] : array(),
'#options' => $roles,
'#description' => t('Members of these roles will be exempt from content length settings.'),
);
$form['show_once'] = array(
'#type' => 'fieldset',
'#title' => t('Per-conversation signatures'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['show_once']['show_once_options'] = array(
'#type' => 'radios',
'#title' => t("Show a user's signature"),
'#default_value' => $settings['signature_forum_show_once_options'],
'#options' => array(
SHOW_ONCE_OPTIONS_ALWAYS => t('Always'),
SHOW_ONCE_OPTIONS_ONCE => t('Once per conversation'),
),
);
$form['show_once']['show_once_roles'] = array(
'#type' => 'checkboxes',
'#title' => t('Exempt roles'),
'#default_value' => isset($settings['signature_forum_show_once_roles']) ? $settings['signature_forum_show_once_roles'] : array(),
'#options' => $roles,
'#description' => t('Members of these roles will have their signatures shown in every post.'),
);
$form['signature_defaults'] = array(
'#type' => 'fieldset',
'#title' => t('Per-post settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' => t('Users will see a checkbox below the comment form allowing them to choose whether or not to use their signature. If signatures are not enabled for a content type, this setting will have no effect.'),
);
if (module_exists('comment')) {
$form['signature_defaults']['signature_forum_default_comments'] = array(
'#type' => 'checkbox',
'#title' => t('Core Comments'),
'#return_value' => 1,
'#default_value' => isset($settings['signature_forum_default_comments']) ? $settings['signature_forum_default_comments'] : FALSE,
);
}
foreach (node_get_types('names') as $type => $name) {
$form['signature_defaults']['signature_forum_default_for_' . $type] = array(
'#type' => 'checkbox',
'#title' => $name,
'#return_value' => 1,
'#default_value' => isset($settings['signature_forum_default_for_' . $type]) ? $settings['signature_forum_default_for_' . $type] : FALSE,
);
}
$form['signature_defaults']['signature_forum_allow_user_default'] = array(
'#type' => 'radios',
'#title' => t('Allow users to choose their own global default'),
'#default_value' => isset($settings['signature_forum_allow_user_default']) ? $settings['signature_forum_allow_user_default'] : 0,
'#options' => array(
t('No'),
t('Yes'),
),
'#description' => t("This will add an option in a user's profile settings where they can choose whether their signature should be used by default."),
);
$form['signature_other'] = array(
'#type' => 'fieldset',
'#title' => t('Other options'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['signature_other']['line_limit'] = array(
'#type' => 'textfield',
'#title' => t('Line limit'),
'#size' => 3,
'#maxlength' => 10,
'#default_value' => $settings['signature_forum_line_limit'],
'#description' => t('The maximum number of lines allowed in a signature. 0 means no limit. Note: existing signatures that are too long will not be changed.'),
);
$form['signature_other']['char_limit'] = array(
'#type' => 'textfield',
'#title' => t('Character limit'),
'#size' => 5,
'#maxlength' => 10,
'#default_value' => $settings['signature_forum_char_limit'],
'#description' => t('The maximum number of characters allowed in a signature. 0 means no limit. Note: existing signatures that are too long will not be changed.'),
);
$form['signature_other']['delete_signatures'] = array(
'#type' => 'checkbox',
'#title' => t('Delete embedded signatures'),
'#description' => t('Deletes signatures that are embedded in existing comments (warning: cannot be undone!).'),
'#default_value' => FALSE,
);
$form['signature_other']['auto_insert'] = array(
'#type' => 'checkbox',
'#title' => t('Automatically add signatures to content'),
'#description' => t('If this is switched on signatures will automatically be added to content. Themers may wish to switch this off, so the signature may be positioned in the templates manually.'),
'#default_value' => $settings['signature_forum_auto_insert'],
);
$form = system_settings_form($form);
unset($form['#submit']);
$form['#submit'][] = 'signature_forum_admin_settings_submit';
return $form;
}