Make sure the email settings in the control panel are disabled when commenting is disabled globally;

Enable/disable moderator_email setting dynamically as mail settings or discussion settings change.

svn path=/plone.app.discussion/trunk/; revision=49035
This commit is contained in:
Timo Stollenwerk
2011-04-22 15:41:45 +00:00
parent ff3cc181b8
commit c66e243a86
2 changed files with 35 additions and 12 deletions
@@ -4,9 +4,9 @@
*
******************************************************************************/
(function ($) {
// This unnamed function allows us to use $ inside of a block of code
// without permanently overwriting $.
// http://docs.jquery.com/Using_jQuery_with_Other_Libraries
// This unnamed function allows us to use $ inside of a block of code
// without permanently overwriting $.
// http://docs.jquery.com/Using_jQuery_with_Other_Libraries
/* Disable a control panel setting */
$.disableSettings = function (settings) {
@@ -43,7 +43,8 @@
$('#formfield-form-widgets-text_transform'),
$('#formfield-form-widgets-captcha'),
$('#formfield-form-widgets-show_commenter_image'),
$('#formfield-form-widgets-moderator_notification_enabled'),
$('#formfield-form-widgets-moderator_notification_enabled'),
$('#formfield-form-widgets-moderator_email'),
$('#formfield-form-widgets-user_notification_enabled')
]);
}
@@ -55,35 +56,49 @@
$('#formfield-form-widgets-captcha'),
$('#formfield-form-widgets-show_commenter_image'),
$('#formfield-form-widgets-moderator_notification_enabled'),
$('#formfield-form-widgets-moderator_email'),
$('#formfield-form-widgets-user_notification_enabled')
]);
}
/* If the mail setup is invalid, disable the mail settings. */
if (invalid_mail_setup === true) {
$.disableSettings([$('#formfield-form-widgets-moderator_notification_enabled'), $('#formfield-form-widgets-user_notification_enabled')]);
$.disableSettings([
$('#formfield-form-widgets-moderator_notification_enabled'),
$('#formfield-form-widgets-moderator_email'),
$('#formfield-form-widgets-user_notification_enabled')
]);
}
else {
$.enableSettings([$('#formfield-form-widgets-moderator_notification_enabled'), $('#formfield-form-widgets-user_notification_enabled')]);
/* Enable mail setup only if discussion is enabled. */
if (globally_enabled === true) {
$.enableSettings([
$('#formfield-form-widgets-moderator_notification_enabled'),
$('#formfield-form-widgets-moderator_email'),
$('#formfield-form-widgets-user_notification_enabled')
]);
}
}
/* If a custom workflow for comments is enabled, disable the moderation
switch. */
if (moderation_custom === true) {
$.disableSettings([$('#formfield-form-widgets-moderation_enabled')]);
$.disableSettings([
$('#formfield-form-widgets-moderation_enabled')
]);
}
};
//#JSCOVERAGE_IF 0
/**************************************************************************
* Window Load Function: Executes when complete page is fully loaded,
* including all frames,
**************************************************************************/
$(window).load(function () {
// Update settings on page load
$.updateSettings();
// Set #content class and update settings afterwards
$("input,select").live("change", function (e) {
var id = $(this).attr("id");
@@ -109,8 +124,8 @@
$(form).find("input,select").removeAttr('disabled');
$(form).submit();
});
});
});
//#JSCOVERAGE_ENDIF