function node_limit_settings_form in Node Limit 7
Form of settings node limit module.
1 string reference to 'node_limit_settings_form'
- node_limit_menu in ./
node_limit.module - Implements hook_menu().
File
- ./
node_limit.module, line 730
Code
function node_limit_settings_form($form, &$form_state) {
$types = array();
// Get all content types on the site.
$content_types = node_type_get_types();
foreach ($content_types as $type) {
$types[$type->type] = $type->name;
}
$form['node_limit_global_msg'] = array(
'#type' => 'textarea',
'#title' => t('Global message'),
'#required' => TRUE,
'#description' => t('Available variables are: [node_limit:type_name], [node_limit:type_title]'),
'#rows' => 2,
'#default_value' => variable_get('node_limit_global_msg', t("You can't create more content of type [node_limit:type_title]")),
);
$form['node_limit_global_redirect'] = array(
'#type' => 'textfield',
'#title' => t('Global redirect path'),
'#default_value' => variable_get('node_limit_global_redirect', NULL),
'#description' => t("Available variables are: [node_limit:type_name], [node_limit:type_title] (Leave empty if you don't need redirect)"),
);
if (!empty($types)) {
$form['node_limit_custom_msg'] = array(
'#type' => 'checkbox',
'#title' => t('Enable custom error message'),
'#default_value' => variable_get('node_limit_custom_msg', NULL),
);
}
foreach ((array) $types as $machine_name => $title) {
$settings = variable_get('node_limit_settings_' . $machine_name);
$form['custom_msg']['node_limit_settings_' . $machine_name] = array(
'#type' => 'fieldset',
'#title' => $title,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#tree' => TRUE,
'#states' => array(
'visible' => array(
':input[name="node_limit_custom_msg"]' => array(
'checked' => TRUE,
),
),
),
);
$form['custom_msg']['node_limit_settings_' . $machine_name]['message_' . $machine_name] = array(
'#type' => 'textarea',
'#title' => t('Message'),
'#rows' => 2,
'#default_value' => $settings['message_' . $machine_name],
);
$form['custom_msg']['node_limit_settings_' . $machine_name]['redirect_' . $machine_name] = array(
'#type' => 'textfield',
'#title' => t('Redirect path'),
'#default_value' => $settings['redirect_' . $machine_name],
);
}
return system_settings_form($form);
}