Show a link to manage templates
This commit is contained in:
parent
88b7a7839b
commit
e5f5e4297a
2 changed files with 23 additions and 12 deletions
|
@ -38,15 +38,29 @@ class load_template_form extends \moodleform {
|
|||
|
||||
$mform =& $this->_form;
|
||||
|
||||
// Get the context.
|
||||
$context = $this->_customdata['context'];
|
||||
|
||||
$mform->addElement('header', 'loadtemplateheader', get_string('loadtemplate', 'customcert'));
|
||||
|
||||
// Display a link to the manage templates page.
|
||||
if ($context->contextlevel != CONTEXT_SYSTEM && has_capability('mod/customcert:manage', \context_system::instance())) {
|
||||
$link = \html_writer::link(new \moodle_url('/mod/customcert/manage_templates.php'),
|
||||
get_string('managetemplates', 'customcert'));
|
||||
$mform->addElement('static', 'managetemplates', '', $link);
|
||||
}
|
||||
|
||||
$templates = $DB->get_records_menu('customcert_templates',
|
||||
array('contextid' => \context_system::instance()->id), 'name ASC', 'id, name');
|
||||
|
||||
$group = array();
|
||||
$group[] = $mform->createElement('select', 'ltid', '', $templates);
|
||||
$group[] = $mform->createElement('submit', 'loadtemplatesubmit', get_string('load', 'customcert'));
|
||||
$mform->addElement('group', 'loadtemplategroup', '', $group, '', false);
|
||||
$mform->setType('ltid', PARAM_INT);
|
||||
if ($templates) {
|
||||
$group = array();
|
||||
$group[] = $mform->createElement('select', 'ltid', '', $templates);
|
||||
$group[] = $mform->createElement('submit', 'loadtemplatesubmit', get_string('load', 'customcert'));
|
||||
$mform->addElement('group', 'loadtemplategroup', '', $group, '', false);
|
||||
$mform->setType('ltid', PARAM_INT);
|
||||
} else {
|
||||
$msg = \html_writer::tag('div', get_string('notemplates', 'customcert'), array('class' => 'alert'));
|
||||
$mform->addElement('static', 'notemplates', '', $msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
9
edit.php
9
edit.php
|
@ -66,11 +66,6 @@ if ($context->contextlevel == CONTEXT_SYSTEM) {
|
|||
$PAGE->navbar->add(get_string('editcustomcert', 'customcert'));
|
||||
}
|
||||
|
||||
// The form for loading a customcert templates.
|
||||
if ($tid && $DB->count_records('customcert_templates', array('contextid' => context_system::instance()->id)) > 0) {
|
||||
$loadtemplateurl = new moodle_url('/mod/customcert/load_template.php', array('tid' => $tid));
|
||||
$loadtemplateform = new \mod_customcert\load_template_form($loadtemplateurl);
|
||||
}
|
||||
|
||||
// Flag to determine if we are deleting anything.
|
||||
$deleting = false;
|
||||
|
@ -225,7 +220,9 @@ if ($data = $mform->get_data()) {
|
|||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('editcustomcert', 'customcert'));
|
||||
$mform->display();
|
||||
if (isset($loadtemplateform)) {
|
||||
if ($tid) {
|
||||
$loadtemplateurl = new moodle_url('/mod/customcert/load_template.php', array('tid' => $tid));
|
||||
$loadtemplateform = new \mod_customcert\load_template_form($loadtemplateurl, array('context' => $context));
|
||||
$loadtemplateform->display();
|
||||
}
|
||||
echo $OUTPUT->footer();
|
||||
|
|
Loading…
Reference in a new issue