Commit 11c4796f authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Private feedback visible to view owner

parent b4fe382a
......@@ -13,7 +13,7 @@ class="cnr-bl"><span class="cnr-br">
<table id="feedbacktable">
<thead>
<tr><th colspan=3>{str tag=feedback}</th></tr>
<tr><th colspan=4>{str tag=feedback}</th></tr>
</thead>
</table>
......
......@@ -35,21 +35,30 @@ $offset = param_integer('offset', 0);
$prefix = get_config('dbprefix');
if ($artefact) {
$table = 'artefact_feedback';
$table = 'artefact';
$artefactfield = 'artefact';
$whereartefact = ' AND artefact = ' . $artefact;
$whereartefactclause = ' AND artefact = ' . $artefact;
}
else {
$table = 'view_feedback';
$table = 'view';
$artefactfield = null;
$whereartefact = '';
$whereartefactclause = '';
}
$count = count_records($table, 'public', 1, 'view', $view, $artefactfield, $artefact);
$owner = get_field($table, 'owner', 'id', $artefact ? $artefact : $view);
$table .= '_feedback';
if ($owner == $USER->get('id')) {
$count = count_records($table, 'view', $view, $artefactfield, $artefact);
$publicclause = '';
}
else {
$count = count_records($table, 'public', 1, 'view', $view, $artefactfield, $artefact);
$publicclause = ' AND public = 1';
}
$feedback = get_records_sql_array('SELECT author, ctime, message
$feedback = get_records_sql_array('SELECT author, ctime, message, public
FROM ' . $prefix . $table . '
WHERE public = 1 AND view = ' . $view . $whereartefact . '
WHERE view = ' . $view . $whereartefactclause . $publicclause . '
ORDER BY id DESC', '', $offset, $limit);
$data = array();
......@@ -57,10 +66,13 @@ if ($feedback) {
foreach ($feedback as $record) {
$data[] = array('name' => display_name($record->author),
'date' => strftime(get_string('strftimedate'),strtotime($record->ctime)),
'message' => $record->message);
'message' => $record->message,
'public' => $record->public);
}
}
log_debug($data);
$result = array(
'count' => $count,
'limit' => $limit,
......
......@@ -91,9 +91,7 @@ function feedbackform() {
}
sendjsonrequest('addfeedback.json.php', data, function () {
removeElement('menuform');
if (form.public.checked) {
feedbacklist.doupdate();
}
feedbacklist.doupdate();
});
return false;
}
......@@ -165,7 +163,16 @@ addLoadEvent(view_menu);
var feedbacklist = new TableRenderer(
'feedbacktable',
'getfeedback.json.php',
['message', 'name', 'date']
['message',
'name',
'date',
function (r) {
if (r.public == 1) {
return;
}
return TD(null, '(' + get_string('private') + ')');
},
]
);
feedbacklist.limit = 10;
......
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