|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00016 00025 require_once("../../config.php"); 00026 require_once("lib.php"); 00027 require_once('delete_completed_form.php'); 00028 00029 $id = required_param('id', PARAM_INT); 00030 $completedid = optional_param('completedid', 0, PARAM_INT); 00031 $return = optional_param('return', 'entries', PARAM_ALPHA); 00032 00033 if ($completedid == 0) { 00034 print_error('no_complete_to_delete', 00035 'feedback', 00036 'show_entries.php?id='.$id.'&do_show=showentries'); 00037 } 00038 00039 $PAGE->set_url('/mod/feedback/delete_completed.php', array('id'=>$id, 'completed'=>$completedid)); 00040 00041 if (! $cm = get_coursemodule_from_id('feedback', $id)) { 00042 print_error('invalidcoursemodule'); 00043 } 00044 00045 if (! $course = $DB->get_record("course", array("id"=>$cm->course))) { 00046 print_error('coursemisconf'); 00047 } 00048 00049 if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) { 00050 print_error('invalidcoursemodule'); 00051 } 00052 00053 if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) { 00054 print_error('badcontext'); 00055 } 00056 00057 require_login($course->id, true, $cm); 00058 00059 require_capability('mod/feedback:deletesubmissions', $context); 00060 00061 $mform = new mod_feedback_delete_completed_form(); 00062 $newformdata = array('id'=>$id, 00063 'completedid'=>$completedid, 00064 'confirmdelete'=>'1', 00065 'do_show'=>'edit', 00066 'return'=>$return); 00067 $mform->set_data($newformdata); 00068 $formdata = $mform->get_data(); 00069 00070 if ($mform->is_cancelled()) { 00071 if ($return == 'entriesanonym') { 00072 redirect('show_entries_anonym.php?id='.$id); 00073 } else { 00074 redirect('show_entries.php?id='.$id.'&do_show=showentries'); 00075 } 00076 } 00077 00078 if (isset($formdata->confirmdelete) AND $formdata->confirmdelete == 1) { 00079 if ($completed = $DB->get_record('feedback_completed', array('id'=>$completedid))) { 00080 feedback_delete_completed($completedid); 00081 add_to_log($course->id, 00082 'feedback', 00083 'delete', 00084 'view.php?id='.$cm->id, 00085 $feedback->id, 00086 $cm->id); 00087 00088 if ($return == 'entriesanonym') { 00089 redirect('show_entries_anonym.php?id='.$id); 00090 } else { 00091 redirect('show_entries.php?id='.$id.'&do_show=showentries'); 00092 } 00093 } 00094 } 00095 00097 $strfeedbacks = get_string("modulenameplural", "feedback"); 00098 $strfeedback = get_string("modulename", "feedback"); 00099 00100 $PAGE->navbar->add(get_string('delete_entry', 'feedback')); 00101 $PAGE->set_heading(format_string($course->fullname)); 00102 $PAGE->set_title(format_string($feedback->name)); 00103 echo $OUTPUT->header(); 00104 00109 echo $OUTPUT->heading(format_text($feedback->name)); 00110 echo $OUTPUT->box_start('generalbox errorboxcontent boxaligncenter boxwidthnormal'); 00111 echo $OUTPUT->heading(get_string('confirmdeleteentry', 'feedback')); 00112 $mform->display(); 00113 echo $OUTPUT->box_end(); 00114 00115 00116 echo $OUTPUT->footer();