MDL-10984 more language strings
[moodle-pu.git] / notes / delete.php
blob574d7d270cbf6218062c3f73a454a8c0150e63f1
1 <?php // $Id$
3 require_once('../config.php');
4 require_once('lib.php');
6 // retrieve parameters
7 $noteid = required_param('note', PARAM_INT);
9 // locate note information
10 if (!$note = note_load($noteid)) {
11 error('Incorrect note id specified');
14 // locate course information
15 if (!$course = get_record('course', 'id', $note->courseid)) {
16 error('Incorrect course id found');
18 // require login to access notes
19 require_login($course->id);
21 // locate context information
22 $context = get_context_instance(CONTEXT_COURSE, $course->id);
24 // check capability
25 if (!has_capability('moodle/notes:manage', $context)) {
26 error('You may not delete this note');
29 if (data_submitted() && confirm_sesskey()) {
30 //if data was submitted and is valid, then delete note
31 $returnurl = $CFG->wwwroot . '/notes/index.php?course=' . $course->id . '&amp;user=' . $note->userid;
32 if (note_delete($noteid)) {
33 add_to_log($note->courseid, 'notes', 'delete', 'index.php?course='.$note->courseid.'&amp;user='.$note->userid . '#note-' . $note->id , 'delete note');
34 } else {
35 error('Error occured while deleting post', $returnurl);
37 redirect($returnurl);
38 } else {
39 // if data was not submitted yet, then show note data with a delete confirmation form
40 $strnotes = get_string('notes', 'notes');
41 $optionsyes = array('note'=>$noteid, 'sesskey'=>sesskey());
42 $optionsno = array('course'=>$course->id, 'user'=>$note->userid);
44 // output HTML
45 $crumbs = array(array('name' => $strnotes, 'link' => '', 'type' => 'activity'));
46 print_header($course->shortname . ': ' . $strnotes, $course->fullname, build_navigation($crumbs));
47 notice_yesno(get_string('deleteconfirm', 'notes'), 'delete.php', 'index.php', $optionsyes, $optionsno, 'post', 'get');
48 echo '<br />';
49 note_print($note, NOTES_SHOW_BODY | NOTES_SHOW_HEAD);
50 print_footer();