Commit 4ee3e259 authored by greggles's avatar greggles

feature #280502 followup by greggles: let the admin choose which modes are...

feature #280502 followup by greggles: let the admin choose which modes are enabled in case, for example, they don't use threaded comments
parent a711591e
......@@ -105,6 +105,20 @@ function comment_notify_form_alter(&$form, &$form_state, $form_id) {
}
}
$total_options = array(
COMMENT_NOTIFY_DISABLED => t('No notifications'),
COMMENT_NOTIFY_NODE => t('For all comments on this post'),
COMMENT_NOTIFY_COMMENT => t('Just for replies to my comment')
);
// Always allow disabled
$options[] = COMMENT_NOTIFY_DISABLED;
$options = array_merge($options, variable_get('comment_notify_available_alerts', array(COMMENT_NOTIFY_NODE, COMMENT_NOTIFY_COMMENT)));
foreach($options as $available) {
$available_options[$available] = $total_options[$available];
}
// Add the checkbox for anonymous users and set the default based on admin settings.
if ($user->uid == 0) {
// If anonymous user's can't enter their e-mail don't tempt them with the checkbox
......@@ -112,19 +126,21 @@ function comment_notify_form_alter(&$form, &$form_state, $form_id) {
return;
}
$form['notify'] = array(
'#type' => 'checkbox',
'#type' => 'select',
'#title' => t('Notify me of follow-up comments posted here.'),
'#default_value' => ($user->uid != 0) ? $user->comment_notify_mailalert : variable_get('comment_notify_default_anon_mailalert', TRUE),
'#default_value' => variable_get('comment_notify_default_anon_mailalert', FALSE),
'#options' => $available_options,
);
}
// For registered users and the admin wants them to see the checkbox.
elseif (variable_get('comment_notify_regged_checkbox', TRUE)) {
$user_setting = empty($user->comment_notify_mailalert) ? FALSE : $user->comment_notify_mailalert;
$form['notify'] = array(
'#type' => 'checkbox',
'#type' => 'select',
'#title' => t('Notify me of follow-up comments posted here.'),
'#default_value' => ($user->uid != 0) ? $user_setting : variable_get('comment_notify_default_anon_mailalert', TRUE),
'#default_value' => !empty($user->comment_notify_mailalert) ? $user->comment_notify_mailalert : variable_get('comment_notify_default_anon_maila\
lert', FALSE),
'#description' => t('You can change the default for this field in "Comment follow-up notification settings" on <a href="!uri">your account edit page</a>', array('!uri' => url('user/'. $user->uid .'/edit'))),
'#options' => $available_options,
);
}
// For the registered users where the admin wants the checkbox hidden.
......@@ -514,12 +530,29 @@ function comment_notify_settings() {
'#description' => t('letting registered users select/unselect if they want to be notified. If this is disabled, this setting is propagated from their user profile, hence reducing and clutter and confusion')
);
$form['comment_notify_settings']['comment_notify_available_alerts'] = array(
'#type' => 'checkboxes',
'#title' => t('Available subscription modes.'),
'#return_value' => 1,
'#default_value' => variable_get('comment_notify_available_alerts', TRUE),
'#description' => t('Choose which notification subscription styles are available for users.'),
'#options' => array(
COMMENT_NOTIFY_NODE => t('For all comments on a post'),
COMMENT_NOTIFY_COMMENT => t('Just for replies to a comment')
)
);
$form['comment_notify_settings']['comment_notify_default_anon_mailalert'] = array(
'#type' => 'select',
'#title' => t('Default state for the notification selection box for anonymous users.'),
'#return_value' => 1,
'#default_value' => variable_get('comment_notify_default_anon_mailalert', TRUE),
'#description' => t('This flag presets the flag for the follow-up notification on the form that anon users will see when posting a comment')
'#default_value' => variable_get('comment_notify_default_anon_mailalert', array(COMMENT_NOTIFY_NODE, COMMENT_NOTIFY_COMMENT)),
'#description' => t('This flag presets the flag for the follow-up notification on the form that anon users will see when posting a comment'),
'#options' => array(
COMMENT_NOTIFY_DISABLED => t('No notifications'),
COMMENT_NOTIFY_NODE => t('For all comments on this post'),
COMMENT_NOTIFY_COMMENT => t('Just for replies to my comment')
)
);
$form['comment_notify_settings']['comment_notify_default_mailtext'] = array(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment