Commit 5dde4bd9 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Allow view comments to be switched off by the owner


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 5d96cc8e
......@@ -42,6 +42,8 @@ $string['stopdate'] = 'Access End Date/Time';
$string['stopdatecannotbeinpast'] = 'The stop date cannot be in the past';
$string['startdatemustbebeforestopdate'] = 'The start date must be before the stop date';
$string['unrecogniseddateformat'] = 'Unrecognised date format';
$string['enablecomments'] = 'Enable comments';
$string['enablecommentsdescription'] = 'If checked, users who can see your View will be allowed to leave comments.';
$string['ownerformat'] = 'Name display format';
$string['ownerformatdescription'] = 'How do you want people who look at your View to see your name?';
$string['profileviewtitle'] = 'Profile view';
......
......@@ -63,6 +63,7 @@ class View {
private $copynewuser = 0;
private $copynewgroups;
private $type;
private $allowcomments;
/**
* Valid view layouts. These are read at install time and inserted into
......
......@@ -29,7 +29,7 @@
</table>
{$feedback->pagination}
<div id="viewmenu">
{include file="view/viewmenu.tpl"}
{include file="view/viewmenu.tpl" enablecomments=$enablecomments}
</div>
{if $addfeedbackform}<div>{$addfeedbackform}</div>{/if}
{if $objectionform}<div>{$objectionform}</div>{/if}
......
{if $LOGGEDIN || $anonfeedback}
{if $enablecomments}
<a id="add_feedback_link" href="">{str tag=placefeedback section=artefact.comment}</a> |
{/if}
{if $LOGGEDIN}
......
......@@ -134,6 +134,13 @@ if (!($group || $institution)) {
);
}
$editview['elements']['allowcomments'] = array(
'type' => 'checkbox',
'title' => get_string('enablecomments','view'),
'description' => get_string('enablecommentsdescription','view'),
'defaultvalue' => $view->get('allowcomments'),
);
if ($new) {
$editview['elements']['submit'] = array(
'type' => 'cancelbackcreate',
......@@ -175,6 +182,7 @@ function editview_submit(Pieform $form, $values) {
$view->set('title', $values['title']);
$view->set('description', $values['description']);
$view->set('tags', $values['tags']);
$view->set('allowcomments', (int) $values['allowcomments']);
if (isset($values['ownerformat']) && $view->get('owner')) {
$view->set('ownerformat', $values['ownerformat']);
}
......
......@@ -139,7 +139,9 @@ $viewbeingwatched = (int)record_exists('usr_watchlist_view', 'usr', $USER->get('
$feedback = ArtefactTypeComment::get_comments($limit, $offset, false, $view);
$anonfeedback = !$USER->is_logged_in() && ($usertoken || $viewid == get_view_from_token(get_cookie('viewaccess:'.$viewid)));
if ($USER->is_logged_in() || $anonfeedback) {
// If the view has comments turned off, tutors can still leave
// comments if the view is submitted to their group.
if (($USER->is_logged_in() || $anonfeedback) && ($view->get('allowcomments') || !empty($releaseform))) {
$addfeedbackform = pieform(ArtefactTypeComment::add_comment_form());
}
if ($USER->is_logged_in()) {
......@@ -268,6 +270,7 @@ $smarty->assign('viewcontent', $view->build_columns());
$smarty->assign('releaseform', $releaseform);
$smarty->assign('anonfeedback', $anonfeedback);
if (isset($addfeedbackform)) {
$smarty->assign('enablecomments', 1);
$smarty->assign('addfeedbackform', $addfeedbackform);
}
if (isset($objectionform)) {
......
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