Differences Between: [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 require_once('../config.php'); 18 require_once ('lib.php'); 19 require_once($CFG->dirroot . '/course/lib.php'); 20 21 $noteid = required_param('id', PARAM_INT); 22 23 $PAGE->set_url('/notes/delete.php', array('id' => $noteid)); 24 25 if (!$note = note_load($noteid)) { 26 print_error('invalidid'); 27 } 28 29 if (!$course = $DB->get_record('course', array('id' => $note->courseid))) { 30 print_error('invalidcourseid'); 31 } 32 33 require_login($course); 34 35 if (empty($CFG->enablenotes)) { 36 print_error('notesdisabled', 'notes'); 37 } 38 39 if (!$user = $DB->get_record('user', array('id' => $note->userid))) { 40 print_error('invaliduserid'); 41 } 42 43 $context = context_course::instance($course->id); 44 45 if (!has_capability('moodle/notes:manage', $context)) { 46 print_error('nopermissiontodelete', 'notes'); 47 } 48 49 if (data_submitted() && confirm_sesskey()) { 50 // If data was submitted and is valid, then delete note. 51 $returnurl = $CFG->wwwroot . '/notes/index.php?course=' . $course->id . '&user=' . $note->userid; 52 note_delete($note); 53 redirect($returnurl); 54 55 } else { 56 // If data was not submitted yet, then show note data with a delete confirmation form. 57 $strnotes = get_string('notes', 'notes'); 58 $optionsyes = array('id' => $noteid, 'sesskey' => sesskey()); 59 $optionsno = array('course' => $course->id, 'user' => $note->userid); 60 61 // Output HTML. 62 $link = null; 63 if (course_can_view_participants($context) || course_can_view_participants(context_system::instance())) { 64 $link = new moodle_url('/user/index.php', array('id' => $course->id)); 65 } 66 $PAGE->navbar->add(get_string('participants'), $link); 67 $PAGE->navbar->add(fullname($user), new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $course->id))); 68 $PAGE->navbar->add(get_string('notes', 'notes'), 69 new moodle_url('/notes/index.php', array('user' => $user->id, 'course' => $course->id))); 70 $PAGE->navbar->add(get_string('delete')); 71 $PAGE->set_title($course->shortname . ': ' . $strnotes); 72 $PAGE->set_heading($course->fullname); 73 echo $OUTPUT->header(); 74 echo $OUTPUT->confirm(get_string('deleteconfirm', 'notes'), 75 new moodle_url('delete.php', $optionsyes), 76 new moodle_url('index.php', $optionsno)); 77 echo '<br />'; 78 note_print($note, NOTES_SHOW_BODY | NOTES_SHOW_HEAD); 79 echo $OUTPUT->footer(); 80 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body