. define('CLI_SCRIPT', true); require_once('../../config.php'); $tid = $argv[1]; $ltid = $argv[2]; $template = $DB->get_record('htmlcert_templates', array('id' => $tid), '*', MUST_EXIST); $template = new \mod_htmlcert\template($template); $loadtemplate = $DB->get_record('htmlcert_templates', array('id' => $ltid), '*', MUST_EXIST); $loadtemplate = new \mod_htmlcert\template($loadtemplate); $cm = $template->get_cm(); if ($template->get_context()->contextlevel == CONTEXT_MODULE) { $htmlcert = $DB->get_record('htmlcert', ['id' => $cm->instance], '*', MUST_EXIST); $title = $htmlcert->name; $heading = format_string($title); } else { $title = $SITE->fullname; $heading = $title; } $loadtemplate->copy_to_template($template->get_id());