Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403]
1 <?php 2 3 require_once("../../config.php"); 4 require_once ("lib.php"); 5 6 $id = required_param('id', PARAM_INT); // course module ID 7 $confirm = optional_param('confirm', 0, PARAM_INT); // commit the operation? 8 $entry = optional_param('entry', 0, PARAM_INT); // entry id 9 $prevmode = required_param('prevmode', PARAM_ALPHA); 10 $hook = optional_param('hook', '', PARAM_CLEAN); 11 12 $url = new moodle_url('/mod/glossary/deleteentry.php', array('id'=>$id,'prevmode'=>$prevmode)); 13 if ($confirm !== 0) { 14 $url->param('confirm', $confirm); 15 } 16 if ($entry !== 0) { 17 $url->param('entry', $entry); 18 } 19 if ($hook !== '') { 20 $url->param('hook', $hook); 21 } 22 $PAGE->set_url($url); 23 24 $strglossary = get_string("modulename", "glossary"); 25 $strglossaries = get_string("modulenameplural", "glossary"); 26 $stredit = get_string("edit"); 27 $entrydeleted = get_string("entrydeleted","glossary"); 28 29 30 if (! $cm = get_coursemodule_from_id('glossary', $id)) { 31 throw new \moodle_exception("invalidcoursemodule"); 32 } 33 34 if (! $course = $DB->get_record("course", array("id"=>$cm->course))) { 35 throw new \moodle_exception('coursemisconf'); 36 } 37 38 if (! $entry = $DB->get_record("glossary_entries", array("id"=>$entry))) { 39 throw new \moodle_exception('invalidentry'); 40 } 41 42 // Permission checks are based on the course module instance so make sure it is correct. 43 if ($cm->instance != $entry->glossaryid) { 44 throw new \moodle_exception('invalidentry'); 45 } 46 47 require_login($course, false, $cm); 48 $context = context_module::instance($cm->id); 49 50 if (! $glossary = $DB->get_record("glossary", array("id"=>$cm->instance))) { 51 throw new \moodle_exception('invalidid', 'glossary'); 52 } 53 54 // Throws an exception if the user cannot delete the entry. 55 mod_glossary_can_delete_entry($entry, $glossary, $context, false); 56 57 /// If data submitted, then process and store. 58 59 if ($confirm and confirm_sesskey()) { // the operation was confirmed. 60 61 mod_glossary_delete_entry($entry, $glossary, $cm, $context, $course, $hook, $prevmode); 62 redirect("view.php?id=$cm->id&mode=$prevmode&hook=$hook"); 63 64 } else { // the operation has not been confirmed yet so ask the user to do so 65 $strareyousuredelete = get_string("areyousuredelete", "glossary"); 66 $PAGE->navbar->add(get_string('delete')); 67 $PAGE->set_title($glossary->name); 68 $PAGE->set_heading($course->fullname); 69 $PAGE->activityheader->disable(); 70 echo $OUTPUT->header(); 71 $areyousure = "<b>".format_string($entry->concept)."</b><p>$strareyousuredelete</p>"; 72 $linkyes = 'deleteentry.php'; 73 $linkno = 'view.php'; 74 $optionsyes = array('id'=>$cm->id, 'entry'=>$entry->id, 'confirm'=>1, 'sesskey'=>sesskey(), 'prevmode'=>$prevmode, 'hook'=>$hook); 75 $optionsno = array('id'=>$cm->id, 'mode'=>$prevmode, 'hook'=>$hook); 76 77 echo $OUTPUT->confirm($areyousure, new moodle_url($linkyes, $optionsyes), new moodle_url($linkno, $optionsno)); 78 79 echo $OUTPUT->footer(); 80 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body