From 851ce4e77a03794c1d42bd5117360d0262582b52 Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Wed, 24 Nov 2021 09:39:29 +0100 Subject: [PATCH] Remove references to removed elements feature --- lib.php | 57 ----------------------------------------------- load_template.php | 18 --------------- 2 files changed, 75 deletions(-) diff --git a/lib.php b/lib.php index 3494438..858e37a 100644 --- a/lib.php +++ b/lib.php @@ -297,24 +297,6 @@ function htmlcert_cron() { return true; } -/** - * Serve the edit element as a fragment. - * - * @param array $args List of named arguments for the fragment loader. - * @return string - */ -function mod_htmlcert_output_fragment_editelement($args) { - global $DB; - - // Get the element. - $element = $DB->get_record('htmlcert_elements', array('id' => $args['elementid']), '*', MUST_EXIST); - - $pageurl = new moodle_url('/mod/htmlcert/rearrange.php', array('pid' => $element->pageid)); - $form = new \mod_htmlcert\edit_element_form($pageurl, array('element' => $element)); - - return $form->render(); -} - /** * This function extends the settings navigation block for the site. * @@ -373,45 +355,6 @@ function mod_htmlcert_myprofile_navigation(core_user\output\myprofile\tree $tree $tree->add_node($node); } -/** - * Handles editing the 'name' of the element in a list. - * - * @param string $itemtype - * @param int $itemid - * @param string $newvalue - * @return \core\output\inplace_editable - */ -function mod_htmlcert_inplace_editable($itemtype, $itemid, $newvalue) { - global $DB, $PAGE; - - if ($itemtype === 'elementname') { - $element = $DB->get_record('htmlcert_elements', array('id' => $itemid), '*', MUST_EXIST); - $page = $DB->get_record('htmlcert_pages', array('id' => $element->pageid), '*', MUST_EXIST); - $template = $DB->get_record('htmlcert_templates', array('id' => $page->templateid), '*', MUST_EXIST); - - // Set the template object. - $template = new \mod_htmlcert\template($template); - // Perform checks. - if ($cm = $template->get_cm()) { - require_login($cm->course, false, $cm); - } else { - $PAGE->set_context(context_system::instance()); - require_login(); - } - // Make sure the user has the required capabilities. - $template->require_manage(); - - // Clean input and update the record. - $updateelement = new stdClass(); - $updateelement->id = $element->id; - $updateelement->name = clean_param($newvalue, PARAM_TEXT); - $DB->update_record('htmlcert_elements', $updateelement); - - return new \core\output\inplace_editable('mod_htmlcert', 'elementname', $element->id, true, - $updateelement->name, $updateelement->name); - } -} - /** * Get icon mapping for font-awesome. */ diff --git a/load_template.php b/load_template.php index 2c28b92..4973b4a 100644 --- a/load_template.php +++ b/load_template.php @@ -52,24 +52,6 @@ if ($template->get_context()->contextlevel == CONTEXT_MODULE) { // Check that they have confirmed they wish to load the template. if ($confirm && confirm_sesskey()) { - // First, remove all the existing elements and pages. - $sql = "SELECT e.* - FROM {htmlcert_elements} e - INNER JOIN {htmlcert_pages} p - ON e.pageid = p.id - WHERE p.templateid = :templateid"; - if ($elements = $DB->get_records_sql($sql, array('templateid' => $template->get_id()))) { - foreach ($elements as $element) { - // Get an instance of the element class. - if ($e = \mod_htmlcert\element_factory::get_element_instance($element)) { - $e->delete(); - } - } - } - - // Delete the pages. - $DB->delete_records('htmlcert_pages', array('templateid' => $template->get_id())); - // Copy the items across. $loadtemplate->copy_to_template($template->get_id());