From bf97d2a2fa5239a7d9a4819c8afed73d5aa9e233 Mon Sep 17 00:00:00 2001 From: Daniel Berthereau Date: Wed, 27 Nov 2013 02:47:02 +0100 Subject: [PATCH] Added an option to display a checkbox for terms of use. --- CommentForm.php | 19 +++++++++++++++++++ CommentingPlugin.php | 16 ++++++++++++++++ config_form.php | 34 +++++++++++++++++++++++++++++++++- 3 files changed, 68 insertions(+), 1 deletion(-) diff --git a/CommentForm.php b/CommentForm.php index c9b7469..b2fd53c 100644 --- a/CommentForm.php +++ b/CommentForm.php @@ -61,6 +61,25 @@ public function init() ) ); + // The legal agreement is checked by default for logged users. + if (get_option('commenting_legal_text')) { + $this->addElement('checkbox', 'tagging_legal_text', array( + 'label' => get_option('commenting_legal_text'), + 'value' => (boolean) $user, + 'required' => true, + 'uncheckedValue'=> '', + 'checkedValue' => 'checked', + 'validators' => array( + array('notEmpty', true, array( + 'messages' => array( + 'isEmpty'=> __('You must agree to the terms and conditions.'), + ), + )), + ), + 'decorators' => array('ViewHelper', 'Errors', array('label', array('escape' => false))), + )); + } + $request = Zend_Controller_Front::getInstance()->getRequest(); $params = $request->getParams(); diff --git a/CommentingPlugin.php b/CommentingPlugin.php index 059cb62..5f1f893 100644 --- a/CommentingPlugin.php +++ b/CommentingPlugin.php @@ -27,6 +27,13 @@ class CommentingPlugin extends Omeka_Plugin_AbstractPlugin 'api_extend_collections' ); + /** + * @var array Options and their default values. + */ + protected $_options = array( + 'commenting_legal_text' => '', + ); + /** * Add the translations. */ @@ -78,6 +85,15 @@ public function hookInstall() set_option('commenting_reqapp_comment_roles', serialize(array())); set_option('commenting_view_roles', serialize(array())); + $html = '

'; + $html .= __('I agree with %s terms of use %s and I accept to free my contribution under the licence %s CC BY-SA %s.', + '', '', + '', '' + ); + $html .= '

'; + $this->_options['commenting_legal_text'] = $html; + + $this->_installOptions(); } public function hookUpgrade($args) diff --git a/config_form.php b/config_form.php index 31c74b2..a047c0b 100644 --- a/config_form.php +++ b/config_form.php @@ -1,3 +1,12 @@ + + @@ -30,7 +39,30 @@ - + +
+
+ +
+
+
+ formTextarea( + 'commenting_legal_text', + get_option('commenting_legal_text'), + array( + 'rows' => 5, + 'cols' => 60, + 'class' => array('textinput', 'html-editor') + ) + ); ?> +

+ +

+
+
+
+