Skip to content

Commit

Permalink
Added an option to display a checkbox for terms of use.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel-KM committed Sep 25, 2014
1 parent de23675 commit b09a0cb
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 2 deletions.
21 changes: 20 additions & 1 deletion CommentForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', 'commenting_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();

Expand Down Expand Up @@ -135,4 +154,4 @@ private function _getRecordType($params)
return $model;
}

}
}
16 changes: 16 additions & 0 deletions CommentingPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -78,6 +85,15 @@ public function hookInstall()
set_option('commenting_reqapp_comment_roles', serialize(array()));
set_option('commenting_view_roles', serialize(array()));

$html = '<p>';
$html .= __('I agree with %s terms of use %s and I accept to free my contribution under the licence %s CC BY-SA %s.',
'<a href="#" target="_blank">', '</a>',
'<a href="https://creativecommons.org/licenses/by-sa/3.0/" target="_blank">', '</a>'
);
$html .= '</p>';
$this->_options['commenting_legal_text'] = $html;

$this->_installOptions();
}

public function hookUpgrade($args)
Expand Down
34 changes: 33 additions & 1 deletion config_form.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
<?php echo js_tag('vendor/tiny_mce/tiny_mce'); ?>
<script type="text/javascript">
jQuery(window).load(function () {
Omeka.wysiwyg({
mode: 'specific_textareas',
editor_selector: 'html-editor'
});
});
</script>
<script type='text/javascript'>
<?php include('config_form.js'); ?>
</script>
Expand Down Expand Up @@ -30,7 +39,30 @@
</div>
</div>
</div>


<div class='field'>
<div class="two columns alpha">
<label><?php echo __('Legal agreement'); ?></label>
</div>
<div class='inputs five columns omega'>
<div class='input-block'>
<?php echo $view->formTextarea(
'commenting_legal_text',
get_option('commenting_legal_text'),
array(
'rows' => 5,
'cols' => 60,
'class' => array('textinput', 'html-editor')
)
); ?>
<p class="explanation">
<?php echo __('This text will be shown beside the legal checkbox.'
. " Let empty if you don't want to use a legal agreement."); ?>
</p>
</div>
</div>
</div>

<div class="field">
<div class="three columns alpha">
<label><?php echo __("Allow public commenting?"); ?></label>
Expand Down

0 comments on commit b09a0cb

Please sign in to comment.