Commit 81c918ec authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Add checkbox for overall view setting to moderate comments and hide it when comments are disabled


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 5bf27f6d
...@@ -65,6 +65,8 @@ $string['makepublicrequestbyauthormessage'] = '%s has requested that you make th ...@@ -65,6 +65,8 @@ $string['makepublicrequestbyauthormessage'] = '%s has requested that you make th
$string['makepublicrequestbyownermessage'] = '%s has requested that you make your comment public.'; $string['makepublicrequestbyownermessage'] = '%s has requested that you make your comment public.';
$string['makepublicrequestsent'] = 'A message has been sent to %s to request that the comment be made public.'; $string['makepublicrequestsent'] = 'A message has been sent to %s to request that the comment be made public.';
$string['Moderate'] = 'Moderate'; $string['Moderate'] = 'Moderate';
$string['moderatecomments'] = 'Moderate comments';
$string['moderatecommentsdescription'] = 'Comments will remain private until they are approved by you.';
$string['newfeedbacknotificationsubject'] = 'New feedback on %s'; $string['newfeedbacknotificationsubject'] = 'New feedback on %s';
$string['placefeedback'] = 'Place feedback'; $string['placefeedback'] = 'Place feedback';
$string['reallydeletethiscomment'] = 'Are you sure you want to delete this comment?'; $string['reallydeletethiscomment'] = 'Are you sure you want to delete this comment?';
......
...@@ -86,6 +86,12 @@ $form = array( ...@@ -86,6 +86,12 @@ $form = array(
'description' => get_string('allowcommentsonview','view'), 'description' => get_string('allowcommentsonview','view'),
'defaultvalue' => $view->get('allowcomments'), 'defaultvalue' => $view->get('allowcomments'),
), ),
'approvecomments' => array(
'type' => 'checkbox',
'title' => get_string('moderatecomments', 'artefact.comment'),
'description' => get_string('moderatecommentsdescription', 'artefact.comment'),
'defaultvalue' => $view->get('approvecomments'),
),
'template' => array( 'template' => array(
'type' => 'checkbox', 'type' => 'checkbox',
'title' => get_string('allowcopying', 'view'), 'title' => get_string('allowcopying', 'view'),
...@@ -178,18 +184,24 @@ EOF; ...@@ -178,18 +184,24 @@ EOF;
$js .= "function update_loggedin_access() {}\n"; $js .= "function update_loggedin_access() {}\n";
} }
$allowcomments = json_encode((int)$view->get('allowcomments')); if (!$allowcomments = $view->get('allowcomments')) {
$form['elements']['approvecomments']['class'] = 'hidden';
}
$allowcomments = json_encode((int) $allowcomments);
$js .= <<<EOF $js .= <<<EOF
var allowcomments = {$allowcomments}; var allowcomments = {$allowcomments};
function update_comment_options() { function update_comment_options() {
allowcomments = $('editaccess_allowcomments').checked; allowcomments = $('editaccess_allowcomments').checked;
if (allowcomments) { if (allowcomments) {
removeElementClass($('editaccess_approvecomments'), 'hidden');
removeElementClass($('editaccess_approvecomments_container'), 'hidden');
forEach(getElementsByTagAndClassName('tr', 'comments', 'accesslistitems'), function (elem) { forEach(getElementsByTagAndClassName('tr', 'comments', 'accesslistitems'), function (elem) {
addElementClass(elem, 'hidden'); addElementClass(elem, 'hidden');
}); });
} }
else { else {
addElementClass($('editaccess_approvecomments_container'), 'hidden');
forEach(getElementsByTagAndClassName('tr', 'comments', 'accesslistitems'), function (elem) { forEach(getElementsByTagAndClassName('tr', 'comments', 'accesslistitems'), function (elem) {
removeElementClass(elem, 'hidden'); removeElementClass(elem, 'hidden');
}); });
...@@ -408,6 +420,9 @@ function editaccess_submit(Pieform $form, $values) { ...@@ -408,6 +420,9 @@ function editaccess_submit(Pieform $form, $values) {
} }
$view->set('allowcomments', (int) $values['allowcomments']); $view->set('allowcomments', (int) $values['allowcomments']);
if ($values['allowcomments']) {
$view->set('approvecomments', (int) $values['approvecomments']);
}
$view->commit(); $view->commit();
if ($values['new']) { if ($values['new']) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment