Override the default plone.app.registry controlpanel template; JS file for the controlpanel added. Disable all commenting options in the discussion control panel when comments are disabled globally.

svn path=/plone.app.discussion/trunk/; revision=46085
This commit is contained in:
Timo Stollenwerk 2010-12-02 18:15:47 +00:00
parent c311a4f88d
commit ffcc29a401
5 changed files with 112 additions and 2 deletions

View File

@ -4,6 +4,9 @@ Changelog
1.0RC1 (unreleased) 1.0RC1 (unreleased)
------------------- -------------------
- Disable all commenting options in the discussion control panel when comments
are disabled globally.
- Check for the 'review comments' permission instead of 'manage' to decide - Check for the 'review comments' permission instead of 'manage' to decide
if the user should see a 'this comment is pending' message. if the user should see a 'this comment is pending' message.
[timo] [timo]

View File

@ -0,0 +1,45 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
lang="en"
metal:use-macro="here/prefs_main_template/macros/master"
i18n:domain="plone">
<metal:block fill-slot="top_slot"
tal:define="dummy python:request.set('disable_border',1)" />
<metal:javascript_head_slot fill-slot="javascript_head_slot">
<script type="text/javascript"
tal:attributes="src string:${context/portal_url}/++resource++plone.app.discussion.javascripts/controlpanel.js">
</script>
</metal:javascript_head_slot>
<body>
<div id="content" metal:fill-slot="prefs_configlet_content">
<script type="text/javascript"
tal:attributes="src string:${context/portal_url}/++resource++plone.app.discussion.javascripts/controlpanel.js">
</script>
<div metal:use-macro="context/global_statusmessage/macros/portal_message">
Portal status message
</div>
<a href=""
id="setup-link"
tal:attributes="href string:$portal_url/plone_control_panel"
i18n:translate="">
Site Setup
</a> &rsaquo;
<h1 class="documentFirstHeading" tal:content="view/label">View Title</h1>
<div id="layout-contents">
<span tal:replace="structure view/contents" />
</div>
</div>
</body>
</html>

View File

@ -1,14 +1,18 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from Products.statusmessages.interfaces import IStatusMessage from Products.statusmessages.interfaces import IStatusMessage
from plone.app.registry.browser import controlpanel from plone.app.registry.browser import controlpanel
from plone.app.discussion.interfaces import IDiscussionSettings, _ from plone.registry.interfaces import IRegistry
from z3c.form import button from z3c.form import button
from z3c.form.browser.checkbox import SingleCheckBoxFieldWidget from z3c.form.browser.checkbox import SingleCheckBoxFieldWidget
from plone.app.discussion.interfaces import IDiscussionSettings, _
class DiscussionSettingsEditForm(controlpanel.RegistryEditForm): class DiscussionSettingsEditForm(controlpanel.RegistryEditForm):
@ -65,7 +69,12 @@ class DiscussionSettingsEditForm(controlpanel.RegistryEditForm):
"info") "info")
self.request.response.redirect("%s/%s" % (self.context.absolute_url(), self.request.response.redirect("%s/%s" % (self.context.absolute_url(),
self.control_panel_view)) self.control_panel_view))
def anonymous_discussion_allowed(self):
# Check if anonymous comments are allowed in the registry
registry = queryUtility(IRegistry)
settings = registry.forInterface(IDiscussionSettings, check=False)
return settings.anonymous_comments
class DiscussionSettingsControlPanel(controlpanel.ControlPanelFormWrapper): class DiscussionSettingsControlPanel(controlpanel.ControlPanelFormWrapper):
form = DiscussionSettingsEditForm form = DiscussionSettingsEditForm
index = ViewPageTemplateFile('controlpanel.pt')

View File

@ -0,0 +1,46 @@
/******************************************************************************
*
* jQuery functions for the plone.app.discussion comment viewlet and form.
*
******************************************************************************/
(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
//#JSCOVERAGE_IF 0
/**************************************************************************
* Window Load Function: Executes when complete page is fully loaded,
* including all frames,
**************************************************************************/
$(window).load(function () {
/**********************************************************************
* If the user hits the "clear" button of an open reply-to-comment form,
* remove the form and show the "reply" button again.
**********************************************************************/
$("input[name='form.widgets.globally_enabled:list']").bind("change", function (e) {
if ($(this).attr("checked")) {
// enable commenting globally
$('#formfield-form-widgets-anonymous_comments').removeClass('unclickable');
$('#formfield-form-widgets-text_transform').removeClass('unclickable');
$('#formfield-form-widgets-captcha').removeClass('unclickable');
$('#formfield-form-widgets-show_commenter_image').removeClass('unclickable');
$('#formfield-form-widgets-moderator_notification_enabled').removeClass('unclickable');
$('#formfield-form-widgets-user_notification_enabled').removeClass('unclickable');
} else {
$('#formfield-form-widgets-anonymous_comments').addClass('unclickable');
$('#formfield-form-widgets-text_transform').addClass('unclickable');
$('#formfield-form-widgets-captcha').addClass('unclickable');
$('#formfield-form-widgets-show_commenter_image').addClass('unclickable');
$('#formfield-form-widgets-moderator_notification_enabled').addClass('unclickable');
$('#formfield-form-widgets-user_notification_enabled').addClass('unclickable');
}
});
});
//#JSCOVERAGE_ENDIF
}(jQuery));

View File

@ -121,7 +121,14 @@
padding: 2em 1em; padding: 2em 1em;
} }
/* Discussion Control Panel
-------------------------------------------------------------------------- */
.template-discussion-settings .unclickable {
background: #f2f2f2;
opacity:0.6;
filter: alpha(opacity = 50);
}
/* Plone 4 Styles /* Plone 4 Styles
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */