40 lines
1.4 KiB
PHP
40 lines
1.4 KiB
PHP
<?php
|
|
// This file is part of the htmlcert module for Moodle - http://moodle.org/
|
|
//
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
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());
|