Commit b9b75e4a authored by Martyn Smith's avatar Martyn Smith Committed by Martyn Smith
Browse files

Added ability for a view owner to turn public feedback => private

parent 1e1e5262
......@@ -370,6 +370,7 @@ $string['alreadyinwatchlist'] = 'This %s is already in your watchlist';
$string['complaint'] = 'Complaint';
$string['date'] = 'Date';
$string['feedback'] = 'Feedback';
$string['feedbackmadeprivate'] = 'Feedback changed to private';
$string['feedbacksubmitted'] = 'Feedback submitted';
$string['makepublic'] = 'Make public';
$string['nopublicfeedback'] = 'No public feedback';
......@@ -377,6 +378,7 @@ $string['notifysiteadministrator'] = 'Notify site administrator';
$string['placefeedback'] = 'Place feedback';
$string['print'] = 'Print';
$string['private'] = 'Private';
$string['makeprivate'] = 'Change to Private';
$string['reportobjectionablematerial'] = 'Report objectionable material';
$string['reportsent'] = 'Your report has been sent';
$string['updatewatchlistfailed'] = 'Update of watchlist failed';
......
......@@ -61,6 +61,8 @@ $string['empty_block'] = 'Select an artefact from the tree on the left to place
$string['viewinformationsaved'] = 'View information saved successfully';
$string['canteditdontown'] = 'You can\'t edit this view because you don\'t own it';
$string['canteditdontownfeedback'] = 'You can\'t edit this feedback because you don\'t own it';
$string['feedbackchangedtoprivate'] = 'Feedback changed to private';
$string['chooseformat'] = 'Select how you would like to display this artefact in this block ...';
......
<?php
/**
* This program is part of Mahara
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @package mahara
* @subpackage core
* @author Martyn Smith <martyn@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
define('JSON', 1);
require(dirname(dirname(__FILE__)) . '/init.php');
$feedback_id = param_integer('id');
$feedback_table = param_variable('table');
if ($feedback_table != 'view_feedback' && $feedback_table != 'artefact_feedback') {
json_reply('local', 'Invalid table type');
}
$view_id = get_field($feedback_table, 'view', 'id', $feedback_id);
$owner = get_field('view', 'owner', 'id', $view_id);
if ($owner != $USER->get('id')) {
json_reply('local', get_string('canteditdontownfeedback', 'view'));
}
update_record($feedback_table, (object)array('public' => 0, 'id' => $feedback_id));
json_headers();
json_reply(false,get_string('feedbackchangedtoprivate', 'view'));
?>
......@@ -60,7 +60,7 @@ else {
$publicclause = ' AND public = 1';
}
$feedback = get_records_sql_array('SELECT author, ctime, message, public
$feedback = get_records_sql_array('SELECT id, author, ctime, message, public
FROM ' . $prefix . $table . '
WHERE view = ' . $view . $whereartefactclause . $publicclause . '
ORDER BY id DESC', '', $offset, $limit);
......@@ -68,10 +68,15 @@ $feedback = get_records_sql_array('SELECT author, ctime, message, public
$data = array();
if ($feedback) {
foreach ($feedback as $record) {
$data[] = array('name' => display_name($record->author),
'date' => format_date(strtotime($record->ctime), 'strftimedate'),
'message' => $record->message,
'public' => $record->public);
$data[] = array(
'id' => $record->id,
'ownedbythisuser' => ( get_field('view', 'owner', 'id', $view) == $USER->get('id') ? true : false ),
'table' => $table,
'name' => display_name($record->author),
'date' => format_date(strtotime($record->ctime), 'strftimedate'),
'message' => $record->message,
'public' => $record->public
);
}
}
......
......@@ -177,15 +177,33 @@ addLoadEvent(view_menu);
var feedbacklist = new TableRenderer(
'feedbacktable',
'getfeedback.json.php',
['message',
'name',
'date',
function (r) {
if (r.public == 1) {
return;
}
return TD(null, '(' + get_string('private') + ')');
},
[
'message',
'name',
'date',
function (r) {
if (r.public == 1) {
var makePrivate = null;
if (r.ownedbythisuser) {
makePrivate = A({'href': ''}, get_string('makeprivate'));
connect(makePrivate, 'onclick', function (e) {
sendjsonrequest(
'changefeedback.json.php',
r,
function (data) {
if (!data.error) {
replaceChildNodes(makePrivate.parentNode, '(' + get_string('private') + ')');
}
}
);
e.stop();
});
}
return TD(null, '(' + get_string('public') + ') ', makePrivate);
}
return TD(null, '(' + get_string('private') + ')');
},
]
);
......@@ -199,7 +217,17 @@ feedbacklist.updateOnLoad();
EOF;
$smarty = smarty(array('tablerenderer'));
$smarty = smarty(
array('tablerenderer'),
array(),
array(
'mahara' => array(
'public',
'private',
'makeprivate',
),
)
);
$smarty->assign('INLINEJAVASCRIPT', $javascript);
$smarty->assign('VIEWNAV', $navlist);
if (isset($content)) {
......
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