From 25171d1703eaa793af8bd2f5deb14f156d8e1573 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Fri, 13 Mar 2015 21:09:56 -0700 Subject: [PATCH] Fixed issue deleting customcerts --- lib.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib.php b/lib.php index 36984c8..c23bdd5 100644 --- a/lib.php +++ b/lib.php @@ -71,7 +71,7 @@ function customcert_update_instance($data, $mform) { * @return bool true if successful */ function customcert_delete_instance($id) { - global $DB; + global $CFG, $DB; // Ensure the customcert exists. if (!$DB->get_record('customcert', array('id' => $id))) { @@ -95,10 +95,14 @@ function customcert_delete_instance($id) { ON e.pageid = p.id WHERE p.customcertid = :customcertid"; if ($elements = $DB->get_records_sql($sql, array('customcertid' => $id))) { + require_once($CFG->dirroot . '/mod/customcert/locallib.php'); foreach ($elements as $element) { // Get an instance of the element class. if ($e = customcert_get_element_instance($element)) { - return $e->delete_element(); + $e->delete_element(); + } else { + // The plugin files are missing, so just remove the entry from the DB. + $DB->delete_records('customcert_elements', array('id' => $element->id)); } } }