MDL-14493 First checkin of Feedback module into HEAD.
[moodle.git] / mod / feedback / delete_completed.php
1 <?php // $Id$
2 /**
3 * prints the form to confirm the deleting of a completed
4 *
5 * @version $Id$
6 * @author Andreas Grabs
7 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
8 * @package feedback
9 */
11     require_once("../../config.php");
12     require_once("lib.php");
13     require_once('delete_completed_form.php');
15     $id = required_param('id', PARAM_INT);
16     $completedid = optional_param('completedid', 0, PARAM_INT);
18     if($completedid == 0){
19         error(get_string('no_complete_to_delete', 'feedback'), 'show_entries.php?id='.$id.'&do_show=showentries');
20     }
22     if ($id) {
23         if (! $cm = get_coursemodule_from_id('feedback', $id)) {
24             error("Course Module ID was incorrect");
25         }
26      
27         if (! $course = get_record("course", "id", $cm->course)) {
28             error("Course is misconfigured");
29         }
30      
31         if (! $feedback = get_record("feedback", "id", $cm->instance)) {
32             error("Course module is incorrect");
33         }
34     }
35     $capabilities = feedback_load_capabilities($cm->id);
37     require_login($course->id);
38     
39     if(!$capabilities->deletesubmissions){
40         error(get_string('error'));
41     }
42     
43     $mform = new mod_feedback_delete_completed_form();
44     $newformdata = array('id'=>$id,
45                         'completedid'=>$completedid,
46                         'confirmdelete'=>'1',
47                         'do_show'=>'edit');
48     $mform->set_data($newformdata);
49     $formdata = $mform->get_data();
50     
51     if ($mform->is_cancelled()) {
52         redirect('show_entries.php?id='.$id.'&do_show=showentries');
53     }
54     
55     if(isset($formdata->confirmdelete) AND $formdata->confirmdelete == 1){
56         if($completed = get_record('feedback_completed', 'id', $completedid)) {
57             feedback_delete_completed($completedid);
58             add_to_log($course->id, "feedback", "delete", "view.php?id=$cm->id", "$feedback->name",$cm->id);
59             redirect('show_entries.php?id='.$id.'&do_show=showentries');
60         }
61     }
63     /// Print the page header
64     $strfeedbacks = get_string("modulenameplural", "feedback");
65     $strfeedback  = get_string("modulename", "feedback");
66     $buttontext = update_module_button($cm->id, $course->id, $strfeedback);
67     
68     $navlinks = array();
69     $navlinks[] = array('name' => $strfeedbacks, 'link' => "index.php?id=$course->id", 'type' => 'activity');
70     $navlinks[] = array('name' => format_string($feedback->name), 'link' => "", 'type' => 'activityinstance');
71     
72     $navigation = build_navigation($navlinks);
73     
74     print_header_simple(format_string($feedback->name), "",
75                  $navigation, "", "", true, $buttontext, navmenu($course, $cm));
77     /// Print the main part of the page
78     ///////////////////////////////////////////////////////////////////////////
79     ///////////////////////////////////////////////////////////////////////////
80     ///////////////////////////////////////////////////////////////////////////
81     print_heading(format_text($feedback->name));
82     // print_simple_box_start("center", "60%", "#FFAAAA", 20, "noticebox");
83     print_box_start('generalbox errorboxcontent boxaligncenter boxwidthnormal');
84     print_heading(get_string('confirmdeleteentry', 'feedback'));
85     $mform->display();
86     // print_simple_box_end();
87     print_box_end();
88         
90     print_footer($course);
92 ?>