| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?php // $Id: deleteentry.php,v 1.37.2.1 2007/10/12 16:09:44 tjhunt Exp $ 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 10 $prevmode = required_param('prevmode'); 11 $hook = optional_param('hook', '', PARAM_CLEAN); 12 13 $strglossary = get_string("modulename", "glossary"); 14 $strglossaries = get_string("modulenameplural", "glossary"); 15 $stredit = get_string("edit"); 16 $entrydeleted = get_string("entrydeleted","glossary"); 17 18 19 if (! $cm = get_coursemodule_from_id('glossary', $id)) { 20 error("Course Module ID was incorrect"); 21 } 22 23 if (! $course = get_record("course", "id", $cm->course)) { 24 error("Course is misconfigured"); 25 } 26 27 if (! $entry = get_record("glossary_entries","id", $entry)) { 28 error("Entry ID was incorrect"); 29 } 30 31 require_login($course->id, false, $cm); 32 $context = get_context_instance(CONTEXT_MODULE, $cm->id); 33 $manageentries = has_capability('mod/glossary:manageentries', $context); 34 35 if (! $glossary = get_record("glossary", "id", $cm->instance)) { 36 error("Glossary is incorrect"); 37 } 38 39 40 $strareyousuredelete = get_string("areyousuredelete","glossary"); 41 42 $navigation = build_navigation('', $cm); 43 print_header_simple(format_string($glossary->name), "", $navigation, 44 "", "", true, update_module_button($cm->id, $course->id, $strglossary), 45 navmenu($course, $cm)); 46 47 if (($entry->userid != $USER->id) and !$manageentries) { // guest id is never matched, no need for special check here 48 error("You can't delete other people's entries!"); 49 } 50 $ineditperiod = ((time() - $entry->timecreated < $CFG->maxeditingtime) || $glossary->editalways); 51 if (!$ineditperiod and !$manageentries) { 52 error("You can't delete this. Time expired!"); 53 } 54 55 /// If data submitted, then process and store. 56 57 if ($confirm) { // the operation was confirmed. 58 // if it is an imported entry, just delete the relation 59 60 if ( $entry->sourceglossaryid ) { 61 $dbentry = new stdClass; 62 $dbentry->id = $entry->id; 63 $dbentry->glossaryid = $entry->sourceglossaryid; 64 $dbentry->sourceglossaryid = 0; 65 if (! update_record('glossary_entries', $dbentry)) { 66 error("Could not update your glossary"); 67 } 68 69 } else { 70 if ( $entry->attachment ) { 71 glossary_delete_old_attachments($entry); 72 } 73 delete_records("glossary_comments", "entryid",$entry->id); 74 delete_records("glossary_alias", "entryid", $entry->id); 75 delete_records("glossary_ratings", "entryid", $entry->id); 76 delete_records("glossary_entries","id", $entry->id); 77 } 78 79 add_to_log($course->id, "glossary", "delete entry", "view.php?id=$cm->id&mode=$prevmode&hook=$hook", $entry->id,$cm->id); 80 redirect("view.php?id=$cm->id&mode=$prevmode&hook=$hook", $entrydeleted); 81 82 } else { // the operation has not been confirmed yet so ask the user to do so 83 84 notice_yesno("<b>".format_string($entry->concept)."</b><p>$strareyousuredelete</p>", 85 "deleteentry.php?id=$cm->id&mode=delete&confirm=1&entry=".s($entry->id)."&prevmode=$prevmode&hook=$hook", 86 "view.php?id=$cm->id&mode=$prevmode&hook=$hook"); 87 88 } 89 90 print_footer($course); 91 92 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |