#203 Consistency among headings/titles on all pages

This commit is contained in:
Mark Nelson 2018-06-26 18:50:21 +08:00
parent ab4f8e1fb3
commit d3b22a23b5
8 changed files with 86 additions and 47 deletions

View file

@ -51,19 +51,31 @@ $context = context::instance_by_id($contextid);
if ($context->contextlevel == CONTEXT_MODULE) { if ($context->contextlevel == CONTEXT_MODULE) {
$cm = get_coursemodule_from_id('customcert', $context->instanceid, 0, false, MUST_EXIST); $cm = get_coursemodule_from_id('customcert', $context->instanceid, 0, false, MUST_EXIST);
require_login($cm->course, false, $cm); require_login($cm->course, false, $cm);
$customcert = $DB->get_record('customcert', ['id' => $cm->instance], '*', MUST_EXIST);
$title = $customcert->name;
$heading = format_string($title);
} else { } else {
require_login(); require_login();
$title = $SITE->fullname;
$heading = $title;
} }
require_capability('mod/customcert:manage', $context); require_capability('mod/customcert:manage', $context);
// Set up the page. // Set up the page.
\mod_customcert\page_helper::page_setup($pageurl, $context, get_string('editcustomcert', 'customcert')); \mod_customcert\page_helper::page_setup($pageurl, $context, $title);
if ($context->contextlevel == CONTEXT_SYSTEM) { if ($context->contextlevel == CONTEXT_SYSTEM) {
// We are managing a template - add some navigation. // We are managing a template - add some navigation.
$PAGE->navbar->add(get_string('managetemplates', 'customcert'), $PAGE->navbar->add(get_string('managetemplates', 'customcert'),
new moodle_url('/mod/customcert/manage_templates.php')); new moodle_url('/mod/customcert/manage_templates.php'));
$PAGE->navbar->add(get_string('editcustomcert', 'customcert')); if (!$tid) {
$PAGE->navbar->add(get_string('editcustomcert', 'customcert'));
} else {
$PAGE->navbar->add(get_string('editcustomcert', 'customcert'),
new moodle_url('/mod/customcert/edit.php', ['tid' => $tid]));
}
} }
// Flag to determine if we are deleting anything. // Flag to determine if we are deleting anything.
@ -140,11 +152,9 @@ if ($tid) {
// Check if we are deleting either a page or an element. // Check if we are deleting either a page or an element.
if ($deleting) { if ($deleting) {
// Show a confirmation page. // Show a confirmation page.
$strheading = get_string('deleteconfirm', 'customcert'); $PAGE->navbar->add(get_string('deleteconfirm', 'customcert'));
$PAGE->navbar->add($strheading);
$PAGE->set_title($strheading);
echo $OUTPUT->header(); echo $OUTPUT->header();
echo $OUTPUT->heading($strheading); echo $OUTPUT->heading($heading);
echo $OUTPUT->confirm($message, $yesurl, $nourl); echo $OUTPUT->confirm($message, $yesurl, $nourl);
echo $OUTPUT->footer(); echo $OUTPUT->footer();
exit(); exit();
@ -230,7 +240,7 @@ if ($data = $mform->get_data()) {
} }
echo $OUTPUT->header(); echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('editcustomcert', 'customcert')); echo $OUTPUT->heading($heading);
$mform->display(); $mform->display();
if ($tid && $context->contextlevel == CONTEXT_MODULE) { if ($tid && $context->contextlevel == CONTEXT_MODULE) {
$loadtemplateurl = new moodle_url('/mod/customcert/load_template.php', array('tid' => $tid)); $loadtemplateurl = new moodle_url('/mod/customcert/load_template.php', array('tid' => $tid));

View file

@ -41,6 +41,15 @@ if ($cm = $template->get_cm()) {
// Make sure the user has the required capabilities. // Make sure the user has the required capabilities.
$template->require_manage(); $template->require_manage();
if ($template->get_context()->contextlevel == CONTEXT_MODULE) {
$customcert = $DB->get_record('customcert', ['id' => $cm->instance], '*', MUST_EXIST);
$title = $customcert->name;
$heading = format_string($title);
} else {
$title = $SITE->fullname;
$heading = $title;
}
if ($action == 'edit') { if ($action == 'edit') {
// The id of the element must be supplied if we are currently editing one. // The id of the element must be supplied if we are currently editing one.
$id = required_param('id', PARAM_INT); $id = required_param('id', PARAM_INT);
@ -56,7 +65,6 @@ if ($action == 'edit') {
} }
// Set up the page. // Set up the page.
$title = get_string('editelement', 'customcert');
\mod_customcert\page_helper::page_setup($pageurl, $template->get_context(), $title); \mod_customcert\page_helper::page_setup($pageurl, $template->get_context(), $title);
// Additional page setup. // Additional page setup.
@ -66,7 +74,7 @@ if ($template->get_context()->contextlevel == CONTEXT_SYSTEM) {
} }
$PAGE->navbar->add(get_string('editcustomcert', 'customcert'), new moodle_url('/mod/customcert/edit.php', $PAGE->navbar->add(get_string('editcustomcert', 'customcert'), new moodle_url('/mod/customcert/edit.php',
array('tid' => $tid))); array('tid' => $tid)));
$PAGE->navbar->add($title); $PAGE->navbar->add(get_string('editelement', 'customcert'));
$mform = new \mod_customcert\edit_element_form($pageurl, array('element' => $element)); $mform = new \mod_customcert\edit_element_form($pageurl, array('element' => $element));
@ -95,6 +103,6 @@ if ($data = $mform->get_data()) {
} }
echo $OUTPUT->header(); echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('editelement', 'customcert')); echo $OUTPUT->heading($heading);
$mform->display(); $mform->display();
echo $OUTPUT->footer(); echo $OUTPUT->footer();

View file

@ -170,6 +170,7 @@ $string['verifyallcertificates_desc'] = 'When this setting is enabled any person
Note - this only applies to certificates where \'Allow anyone to verify a certificate\' has been set to \'Yes\' in the certificate settings.'; Note - this only applies to certificates where \'Allow anyone to verify a certificate\' has been set to \'Yes\' in the certificate settings.';
$string['verifycertificate'] = 'Verify certificate'; $string['verifycertificate'] = 'Verify certificate';
$string['verifycertificatedesc'] = 'This link will take you to a new screen where you will be able to verify certificates on the site';
$string['verifycertificateanyone'] = 'Allow anyone to verify a certificate'; $string['verifycertificateanyone'] = 'Allow anyone to verify a certificate';
$string['verifycertificateanyone_help'] = 'This setting enables anyone with the certificate verification link (including users not logged in) to verify a certificate.'; $string['verifycertificateanyone_help'] = 'This setting enables anyone with the certificate verification link (including users not logged in) to verify a certificate.';
$string['viewcustomcertissues'] = 'View {$a} issued certificates'; $string['viewcustomcertissues'] = 'View {$a} issued certificates';

View file

@ -46,12 +46,20 @@ $context = context::instance_by_id($contextid);
require_login(); require_login();
require_capability('mod/customcert:manage', $context); require_capability('mod/customcert:manage', $context);
$title = $SITE->fullname;
$heading = $title;
// Set up the page. // Set up the page.
$pageurl = new moodle_url('/mod/customcert/manage_templates.php'); $pageurl = new moodle_url('/mod/customcert/manage_templates.php');
\mod_customcert\page_helper::page_setup($pageurl, $context, get_string('managetemplates', 'customcert')); \mod_customcert\page_helper::page_setup($pageurl, $context, $title);
// Additional page setup. // Additional page setup.
$PAGE->navbar->add(get_string('managetemplates', 'customcert')); if ($tid && $action && confirm_sesskey()) {
$PAGE->navbar->add(get_string('managetemplates', 'customcert'),
new moodle_url('/mod/customcert/manage_templates.php'));
} else {
$PAGE->navbar->add(get_string('managetemplates', 'customcert'));
}
if ($tid) { if ($tid) {
if ($action && confirm_sesskey()) { if ($action && confirm_sesskey()) {
@ -69,12 +77,10 @@ if ($tid) {
if ($action == 'delete') { if ($action == 'delete') {
if (!$confirm) { if (!$confirm) {
// Show a confirmation page. // Show a confirmation page.
$strheading = get_string('deleteconfirm', 'customcert'); $PAGE->navbar->add(get_string('deleteconfirm', 'customcert'));
$PAGE->navbar->add($strheading);
$PAGE->set_title($strheading);
$message = get_string('deletetemplateconfirm', 'customcert'); $message = get_string('deletetemplateconfirm', 'customcert');
echo $OUTPUT->header(); echo $OUTPUT->header();
echo $OUTPUT->heading($strheading); echo $OUTPUT->heading($heading);
echo $OUTPUT->confirm($message, $yesurl, $nourl); echo $OUTPUT->confirm($message, $yesurl, $nourl);
echo $OUTPUT->footer(); echo $OUTPUT->footer();
exit(); exit();
@ -88,12 +94,10 @@ if ($tid) {
} else if ($action == 'duplicate') { } else if ($action == 'duplicate') {
if (!$confirm) { if (!$confirm) {
// Show a confirmation page. // Show a confirmation page.
$strheading = get_string('duplicateconfirm', 'customcert'); $PAGE->navbar->add(get_string('duplicateconfirm', 'customcert'));
$PAGE->navbar->add($strheading);
$PAGE->set_title($strheading);
$message = get_string('duplicatetemplateconfirm', 'customcert'); $message = get_string('duplicatetemplateconfirm', 'customcert');
echo $OUTPUT->header(); echo $OUTPUT->header();
echo $OUTPUT->heading($strheading); echo $OUTPUT->heading($heading);
echo $OUTPUT->confirm($message, $yesurl, $nourl); echo $OUTPUT->confirm($message, $yesurl, $nourl);
echo $OUTPUT->footer(); echo $OUTPUT->footer();
exit(); exit();
@ -120,6 +124,7 @@ $table = new \mod_customcert\manage_templates_table($context);
$table->define_baseurl($pageurl); $table->define_baseurl($pageurl);
echo $OUTPUT->header(); echo $OUTPUT->header();
echo $OUTPUT->heading($heading);
$table->out($perpage, false); $table->out($perpage, false);
$url = new moodle_url('/mod/customcert/edit.php?contextid=' . $contextid); $url = new moodle_url('/mod/customcert/edit.php?contextid=' . $contextid);
echo $OUTPUT->single_button($url, get_string('createtemplate', 'customcert'), 'get'); echo $OUTPUT->single_button($url, get_string('createtemplate', 'customcert'), 'get');

View file

@ -48,6 +48,19 @@ require_login($course, false, $cm);
$context = context_module::instance($cm->id); $context = context_module::instance($cm->id);
require_capability('mod/customcert:viewreport', $context); require_capability('mod/customcert:viewreport', $context);
// Set up the page.
$title = $customcert->name;
$heading = format_string($title);
\mod_customcert\page_helper::page_setup($pageurl, $context, $title);
// Additional page setup.
if ($deleteissue && confirm_sesskey()) {
$PAGE->navbar->add(get_string('listofissues', 'customcert'),
new moodle_url('/mod/customcert/report.php', ['id' => $id]));
} else {
$PAGE->navbar->add(get_string('listofissues', 'customcert'));
}
if ($deleteissue && confirm_sesskey()) { if ($deleteissue && confirm_sesskey()) {
require_capability('mod/customcert:manage', $context); require_capability('mod/customcert:manage', $context);
@ -63,13 +76,10 @@ if ($deleteissue && confirm_sesskey()) {
); );
// Show a confirmation page. // Show a confirmation page.
$strheading = get_string('deleteconfirm', 'customcert'); $PAGE->navbar->add(get_string('deleteconfirm', 'customcert'));
$PAGE->navbar->add($strheading);
$PAGE->set_title($strheading);
$PAGE->set_url($url);
$message = get_string('deleteissueconfirm', 'customcert'); $message = get_string('deleteissueconfirm', 'customcert');
echo $OUTPUT->header(); echo $OUTPUT->header();
echo $OUTPUT->heading($strheading); echo $OUTPUT->heading($heading);
echo $OUTPUT->confirm($message, $yesurl, $nourl); echo $OUTPUT->confirm($message, $yesurl, $nourl);
echo $OUTPUT->footer(); echo $OUTPUT->footer();
exit(); exit();
@ -103,11 +113,7 @@ if ($table->is_downloading()) {
exit(); exit();
} }
// Set up the page.
\mod_customcert\page_helper::page_setup($pageurl, $context, $customcert->name);
// Additional page setup.
$PAGE->navbar->add(get_string('listofissues', 'customcert'));
echo $OUTPUT->header(); echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($customcert->name), 2); echo $OUTPUT->heading(format_string($customcert->name), 2);

View file

@ -35,6 +35,10 @@ $settings->add(new admin_setting_configcheckbox('customcert/showposxy',
get_string('showposxy_desc', 'customcert'), get_string('showposxy_desc', 'customcert'),
0)); 0));
$settings->add(new \mod_customcert\admin_setting_link('customcert/verifycertificate',
get_string('verifycertificate', 'customcert'), get_string('verifycertificatedesc', 'customcert'),
get_string('verifycertificate', 'customcert'), new moodle_url('/mod/customcert/verify_certificate.php'), ''));
$settings->add(new \mod_customcert\admin_setting_link('customcert/managetemplates', $settings->add(new \mod_customcert\admin_setting_link('customcert/managetemplates',
get_string('managetemplates', 'customcert'), get_string('managetemplatesdesc', 'customcert'), get_string('managetemplates', 'customcert'), get_string('managetemplatesdesc', 'customcert'),
get_string('managetemplates', 'customcert'), new moodle_url('/mod/customcert/manage_templates.php'), '')); get_string('managetemplates', 'customcert'), new moodle_url('/mod/customcert/manage_templates.php'), ''));

View file

@ -33,7 +33,7 @@ $struploadimage = get_string('uploadimage', 'customcert');
// Set the page variables. // Set the page variables.
$pageurl = new moodle_url('/mod/customcert/upload_image.php'); $pageurl = new moodle_url('/mod/customcert/upload_image.php');
\mod_customcert\page_helper::page_setup($pageurl, $context, $struploadimage, $SITE->fullname); \mod_customcert\page_helper::page_setup($pageurl, $context, $SITE->fullname);
// Additional page setup. // Additional page setup.
$PAGE->navbar->add($struploadimage); $PAGE->navbar->add($struploadimage);
@ -50,5 +50,6 @@ if ($uploadform->is_cancelled()) {
} }
echo $OUTPUT->header(); echo $OUTPUT->header();
echo $OUTPUT->heading($SITE->fullname);
$uploadform->display(); $uploadform->display();
echo $OUTPUT->footer(); echo $OUTPUT->footer();

View file

@ -33,6 +33,10 @@ $context = context::instance_by_id($contextid);
// Set up the page. // Set up the page.
$pageurl = new moodle_url('/mod/customcert/verify_certificate.php', array('contextid' => $contextid)); $pageurl = new moodle_url('/mod/customcert/verify_certificate.php', array('contextid' => $contextid));
if ($code) {
$pageurl->param('code', $code);
}
// Ok, a certificate was specified. // Ok, a certificate was specified.
if ($context->contextlevel != CONTEXT_SYSTEM) { if ($context->contextlevel != CONTEXT_SYSTEM) {
$cm = get_coursemodule_from_id('customcert', $context->instanceid, 0, false, MUST_EXIST); $cm = get_coursemodule_from_id('customcert', $context->instanceid, 0, false, MUST_EXIST);
@ -49,36 +53,36 @@ if ($context->contextlevel != CONTEXT_SYSTEM) {
$PAGE->set_cm($cm, $course); $PAGE->set_cm($cm, $course);
} }
$title = $customcert->name;
$heading = format_string($title);
$checkallofsite = false; $checkallofsite = false;
} else { } else {
$title = $SITE->fullname;
$heading = $title;
$checkallofsite = true;
}
\mod_customcert\page_helper::page_setup($pageurl, $context, $title);
// Additional page setup.
if ($context->contextlevel == CONTEXT_SYSTEM) {
$PAGE->navbar->add(get_string('verifycertificate', 'customcert'));
}
if ($checkallofsite) {
// If the 'verifyallcertificates' is not set and the user does not have the capability 'mod/customcert:verifyallcertificates' // If the 'verifyallcertificates' is not set and the user does not have the capability 'mod/customcert:verifyallcertificates'
// then show them a message letting them know they can not proceed. // then show them a message letting them know they can not proceed.
$verifyallcertificates = get_config('customcert', 'verifyallcertificates'); $verifyallcertificates = get_config('customcert', 'verifyallcertificates');
$canverifyallcertificates = has_capability('mod/customcert:verifyallcertificates', $context); $canverifyallcertificates = has_capability('mod/customcert:verifyallcertificates', $context);
if (!$verifyallcertificates && !$canverifyallcertificates) { if (!$verifyallcertificates && !$canverifyallcertificates) {
$strheading = get_string('verifycertificate', 'customcert');
$PAGE->navbar->add($strheading);
$PAGE->set_context(context_system::instance());
$PAGE->set_title($strheading);
$PAGE->set_url($pageurl);
echo $OUTPUT->header(); echo $OUTPUT->header();
echo $OUTPUT->heading($strheading); echo $OUTPUT->heading($heading);
echo $OUTPUT->notification(get_string('cannotverifyallcertificates', 'customcert')); echo $OUTPUT->notification(get_string('cannotverifyallcertificates', 'customcert'));
echo $OUTPUT->footer(); echo $OUTPUT->footer();
exit(); exit();
} }
$checkallofsite = true;
} }
if ($code) {
$pageurl->param('code', $code);
}
$PAGE->set_url($pageurl);
$PAGE->set_context($context);
$PAGE->set_title(get_string('verifycertificate', 'customcert'));
// The form we are using to verify these codes. // The form we are using to verify these codes.
$form = new \mod_customcert\verify_certificate_form($pageurl); $form = new \mod_customcert\verify_certificate_form($pageurl);
@ -124,7 +128,7 @@ if ($form->get_data()) {
} }
echo $OUTPUT->header(); echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('verifycertificate', 'customcert')); echo $OUTPUT->heading($heading);
echo $form->display(); echo $form->display();
if (isset($result)) { if (isset($result)) {
$renderer = $PAGE->get_renderer('mod_customcert'); $renderer = $PAGE->get_renderer('mod_customcert');