Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added an option to display a checkbox for terms of use. #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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