diff --git a/plone/app/discussion/browser/controlpanel.py b/plone/app/discussion/browser/controlpanel.py
index f8f9dfb..ad30781 100644
--- a/plone/app/discussion/browser/controlpanel.py
+++ b/plone/app/discussion/browser/controlpanel.py
@@ -40,6 +40,8 @@ class DiscussionSettingsEditForm(controlpanel.RegistryEditForm):
super(DiscussionSettingsEditForm, self).updateFields()
self.fields['globally_enabled'].widgetFactory = \
SingleCheckBoxFieldWidget
+ self.fields['moderation_enabled'].widgetFactory = \
+ SingleCheckBoxFieldWidget
self.fields['anonymous_comments'].widgetFactory = \
SingleCheckBoxFieldWidget
self.fields['show_commenter_image'].widgetFactory = \
@@ -97,6 +99,8 @@ class DiscussionSettingsControlPanel(controlpanel.ControlPanelFormWrapper):
if settings.globally_enabled:
output.append("globally_enabled")
+ # Comment moderation
+
# Anonymous comments
if settings.anonymous_comments:
output.append("anonymous_comments")
@@ -127,4 +131,31 @@ class DiscussionSettingsControlPanel(controlpanel.ControlPanelFormWrapper):
email = getattr(aq_inner(self.context), 'email_from_address', None)
if mailhost and email:
return False
- return True
\ No newline at end of file
+ return True
+
+def notify_configuration_changed(event):
+ """Event subscriber that is called every time the configuration changed.
+ """
+ from zope.app.component.hooks import getSite
+ portal = getSite()
+ wftool = getToolByName(portal, 'portal_workflow', None)
+ from plone.registry.interfaces import IRecordModifiedEvent
+ if IRecordModifiedEvent.providedBy(event):
+ # Discussion control panel setting changed
+ if event.record.fieldName == 'moderation_enabled':
+ # Moderation enabled has changed
+ if event.record.value == True:
+ # Enable moderation workflow
+ wftool.setChainForPortalTypes(('Discussion Item',),
+ 'comment_review_workflow')
+ else:
+ # Disable moderation workflow
+ wftool.setChainForPortalTypes(('Discussion Item',),
+ 'one_state_workflow')
+
+ from plone.app.controlpanel.interfaces import IConfigurationChangedEvent
+ if IConfigurationChangedEvent.providedBy(event):
+ # Types control panel setting changed
+ # XXX: Todo!!!
+ pass
+
diff --git a/plone/app/discussion/interfaces.py b/plone/app/discussion/interfaces.py
index e309b59..7083e15 100644
--- a/plone/app/discussion/interfaces.py
+++ b/plone/app/discussion/interfaces.py
@@ -31,7 +31,7 @@ class IDiscussionSettings(Interface):
required=False,
default=True,
)
-
+
anonymous_comments = schema.Bool(
title=_(u"label_anonymous_comments",
default="Enable anonymous comments"),
@@ -43,6 +43,22 @@ class IDiscussionSettings(Interface):
required=False,
default=False,
)
+
+ moderation_enabled = schema.Bool(
+ title=_(u"label_moderation_enabled",
+ default="Enable comment moderation"),
+ description=_(u"help_moderation_enabled",
+ default=u"If selected, comments will enter a 'Pending' state "
+ "in which they are invisible to the public. A user "
+ "with the 'Review comments' permission ('Reviewer' or "
+ "'Manager') can approve comments to make them visible "
+ "to the public. If you want to enable a custom "
+ "comment workflow, you have to go to the types "
+ "control panel."),
+ required=False,
+ default=False,
+ )
+
text_transform = schema.Choice(
title=_(u"label_text_transform",
diff --git a/plone/app/discussion/subscribers.zcml b/plone/app/discussion/subscribers.zcml
index 89918b1..ebb57dd 100644
--- a/plone/app/discussion/subscribers.zcml
+++ b/plone/app/discussion/subscribers.zcml
@@ -85,7 +85,17 @@
zope.app.container.interfaces.IObjectRemovedEvent"
handler=".comment.notify_content_object_deleted"
/>
-
+
+
+
+
+
diff --git a/plone/app/discussion/tests/test_controlpanel.py b/plone/app/discussion/tests/test_controlpanel.py
index 20ee71e..6d41025 100644
--- a/plone/app/discussion/tests/test_controlpanel.py
+++ b/plone/app/discussion/tests/test_controlpanel.py
@@ -90,5 +90,21 @@ class RegistryTest(PloneTestCase):
# self.assertEquals(self.registry['plone.app.discussion.interfaces.' +
# 'IDiscussionSettings.user_notification_enabled'], False)
+
+class ConfigurationChangedSubscriberTest(PloneTestCase):
+
+ layer = DiscussionLayer
+
+ def afterSetUp(self):
+ self.loginAsPortalOwner()
+ # Set up the registry
+ self.registry = Registry()
+ self.registry.registerInterface(IDiscussionSettings)
+
+ def todo(self):
+ # XXX: Todo!!!
+ pass
+
+
def test_suite():
return unittest.defaultTestLoader.loadTestsFromName(__name__)