Commit 02426bbc authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Fix make_private form to work with comment artefacts


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 710a1b48
......@@ -29,5 +29,12 @@ defined('INTERNAL') || die();
$string['pluginname'] = 'Comment';
$string['Comment'] = 'Comment';
$string['Comments'] = 'Comments';
$string['comment'] = 'comment';
$string['comments'] = 'comments';
$string['feedbackchangedtoprivate'] = 'Feedback changed to private';
$string['makeprivate'] = 'Change to Private';
$string['thisfeedbackispublic'] = 'This feedback is public';
$string['thisfeedbackisprivate'] = 'This feedback is private';
?>
......@@ -247,10 +247,10 @@ class ArtefactTypeComment extends ArtefactType {
}
}
if ($item->private) {
$item->pubmessage = get_string('thisfeedbackisprivate', 'view');
$item->pubmessage = get_string('thisfeedbackisprivate', 'artefact.comment');
}
else if (!$item->private && $data->canedit) {
$item->pubmessage = get_string('thisfeedbackispublic', 'view');
$item->pubmessage = get_string('thisfeedbackispublic', 'artefact.comment');
$item->makeprivateform = pieform(make_private_form($item->id));
}
......@@ -282,8 +282,8 @@ class ArtefactTypeComment extends ArtefactType {
'limit' => $data->limit,
'offset' => $data->offset,
'lastpage' => $data->lastpage,
'resultcounttextsingular' => get_string('comment', 'view'),
'resultcounttextplural' => get_string('comments', 'view'),
'resultcounttextsingular' => get_string('comment', 'artefact.comment'),
'resultcounttextplural' => get_string('comments', 'artefact.comment'),
'extradata' => $extradata,
));
$data->pagination = $pagination['html'];
......@@ -292,32 +292,33 @@ class ArtefactTypeComment extends ArtefactType {
}
function make_private_form($feedbackid) {
function make_private_form($id) {
return array(
'name' => 'make_private',
'renderer' => 'oneline',
'class' => 'makeprivate',
'elements' => array(
'feedback' => array('type' => 'hidden', 'value' => $feedbackid),
'comment' => array('type' => 'hidden', 'value' => $id),
'submit' => array(
'type' => 'submit',
'name' => 'make_private_submit',
'value' => get_string('makeprivate', 'view'),
'value' => get_string('makeprivate', 'artefact.comment'),
),
),
);
}
function make_private_submit(Pieform $form, $values) {
global $SESSION, $view, $artefact;
if (isset($artefact) && $artefact instanceof ArtefactType) {
update_record('artefact_feedback', (object) array('public' => 0, 'id' => (int) $values['feedback']));
$SESSION->add_ok_msg(get_string('feedbackchangedtoprivate', 'view'));
redirect(get_config('wwwroot') . 'view/artefact.php?view=' . $view->get('id') . '&artefact=' . $artefact->get('id'));
global $SESSION, $view;
$viewid = $view->get('id');
$comment = new ArtefactTypeComment((int) $values['comment']);
$comment->set('private', 1);
$comment->commit();
$SESSION->add_ok_msg(get_string('feedbackchangedtoprivate', 'artefact.comment'));
if ($artefact = $comment->get('onartefact')) {
redirect(get_config('wwwroot') . 'view/artefact.php?view=' . $viewid . '&artefact=' . $artefact);
}
update_record('view_feedback', (object) array('public' => 0, 'id' => (int) $values['feedback']));
$SESSION->add_ok_msg(get_string('feedbackchangedtoprivate', 'view'));
redirect(get_config('wwwroot') . 'view/view.php?id=' . $view->get('id'));
redirect(get_config('wwwroot') . 'view/view.php?id=' . $viewid);
}
?>
......@@ -122,9 +122,6 @@ $string['notifysiteadministrator'] = 'Notify site administrator';
$string['placefeedback'] = 'Place feedback';
$string['placefeedbacknotallowed'] = 'You are not allowed to place feedback on this View';
$string['print'] = 'Print';
$string['thisfeedbackispublic'] = 'This feedback is public';
$string['thisfeedbackisprivate'] = 'This feedback is private';
$string['makeprivate'] = 'Change to Private';
$string['reportobjectionablematerial'] = 'Report objectionable material';
$string['reportsent'] = 'Your report has been sent';
$string['updatewatchlistfailed'] = 'Update of watchlist failed';
......@@ -163,7 +160,6 @@ $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['canteditsubmitted'] = 'You can\'t edit this View because it has been submitted for assessment to "%s". You will have to wait until a tutor releases your view.';
$string['feedbackchangedtoprivate'] = 'Feedback changed to private';
$string['addtutors'] = 'Add Tutors';
$string['viewcreatedsuccessfully'] = 'View created successfully';
......@@ -300,8 +296,4 @@ $string['viewcopywouldexceedquota'] = 'Copying this View would exceed your file
$string['blockcopypermission'] = 'Block copy permission';
$string['blockcopypermissiondesc'] = 'If you allow other users to copy this View, you may choose how this block will be copied';
// Feedback list
$string['comment'] = 'comment';
$string['comments'] = 'comments';
?>
......@@ -34,6 +34,7 @@ define('SECTION_PAGE', 'view');
require(dirname(dirname(__FILE__)) . '/init.php');
require(get_config('libroot') . 'view.php');
require('group.php');
safe_require('artefact', 'comment');
// access key for roaming teachers
$mnettoken = $SESSION->get('mnetuser') ? param_alphanum('mt', null) : null;
......@@ -74,7 +75,7 @@ $view = new View($viewid);
// Create the "make feedback private form" now if it's been submitted
if (param_variable('make_private_submit', null)) {
pieform(make_private_form(param_integer('feedback')));
pieform(make_private_form(param_integer('comment')));
}
$owner = $view->get('owner');
......@@ -134,7 +135,6 @@ function releaseview_submit() {
$viewbeingwatched = (int)record_exists('usr_watchlist_view', 'usr', $USER->get('id'), 'view', $viewid);
safe_require('artefact', 'comment');
$comments = ArtefactTypeComment::get_comments($limit, $offset, false, $view);
$anonfeedback = !$USER->is_logged_in() && ($usertoken || $viewid == get_view_from_token(get_cookie('viewaccess:'.$viewid)));
......
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