Remove references to removed elements feature
This commit is contained in:
parent
85d3a2644e
commit
851ce4e77a
2 changed files with 0 additions and 75 deletions
57
lib.php
57
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.
|
||||
*/
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
Loading…
Reference in a new issue