Example #1
0
    throw new AccessDeniedException(get_string('canteditnotauthor', 'artefact.annotation'));
}
$annotationid = $annotationfeedback->get('onannotation');
$annotation = new ArtefactTypeAnnotation($annotationid);
$onview = $annotation->get('view');
if ($onview && $onview != $viewid) {
    throw new NotFoundException(get_string('annotationfeedbacknotinview', 'artefact.annotation', $annotationfeedbackid, $viewid));
}
$maxage = (int) get_config_plugin('artefact', 'annotation', 'commenteditabletime');
$editableafter = time() - 60 * $maxage;
$goto = $annotation->get_view_url($viewid, false);
if ($annotationfeedback->get('ctime') < $editableafter) {
    $SESSION->add_error_msg(get_string('cantedittooold', 'artefact.annotation', $maxage));
    redirect($goto);
}
$lastcomment = ArtefactTypeAnnotationfeedback::last_public_annotation_feedback($annotationid, $viewid, $annotation->get('artefact'));
if (!$annotationfeedback->get('private') && $annotationfeedbackid != $lastcomment->id) {
    $SESSION->add_error_msg(get_string('cantedithasreplies', 'artefact.annotation'));
    redirect($goto);
}
$elements = array();
$elements['message'] = array('type' => 'wysiwyg', 'title' => get_string('Annotationfeedback', 'artefact.annotation'), 'rows' => 5, 'cols' => 80, 'defaultvalue' => $annotationfeedback->get('description'), 'rules' => array('maxlength' => 8192));
$elements['ispublic'] = array('type' => 'checkbox', 'title' => get_string('makepublic', 'artefact.annotation'), 'defaultvalue' => !$annotationfeedback->get('private'));
// What is this annotation feedback linked to? Store it in hidden fields.
$elements['viewid'] = array('type' => 'hidden', 'value' => $viewid);
$elements['artefactid'] = array('type' => 'hidden', 'value' => $annotation->get('artefact'));
// Save the artefactid of the annotation.
$elements['annotationid'] = array('type' => 'hidden', 'value' => $annotationid);
$elements['submit'] = array('type' => 'submitcancel', 'value' => array(get_string('save'), get_string('cancel')), 'goto' => $goto);
$form = pieform(array('name' => 'edit_annotation_feedback', 'method' => 'post', 'plugintype' => 'artefact', 'pluginname' => 'annotation', 'elements' => $elements));
function edit_annotation_feedback_validate(Pieform $form, $values)