Skip to content

Commit

Permalink
Review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
abias committed Dec 28, 2024
1 parent 1ea708b commit d910fa7
Show file tree
Hide file tree
Showing 38 changed files with 1,272 additions and 759 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ moodle-theme_boost_union
Changes
-------

### Unreleased

* 2024-12-15 - Feature: Add declaration of accessibility page and accessibility support page, resolves #567.

### v4.3-r20

* 2024-11-20 - Improvement: Implement accessibility statement and feedback mechanism, resolves #567.
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,11 @@ In this tab there are the following settings:

#### Declaration of accessibility

With these settings, you can add rich text content which will be shown on the declaration of accessibility page.
With these settings, you can add rich text content which will be shown on a declaration of accessibility page.

#### Accessibility support
#### Accessibility support page

With these settings, you can add rich text content and configure the form which will be shown on the accessibility support page.
With these settings, you can enable the accessibility support page which provides a contact form for accessibility issues.

#### Tab "Information banners"

Expand Down Expand Up @@ -830,6 +830,6 @@ Moodle an Hochschulen e.V. would like to thank these main contributors (in alpha
* University of Bayreuth, Nikolai Jahreis: Code
* University of Graz, André Menrath: Code
* University of Lübeck, Christian Wolters: Code, Peer Review, Ideating
* Zurich University of Applied Sciences (ZHAW): Funding, Ideating, Code
* Zurich University of Applied Sciences (ZHAW): Code, Funding, Ideating

Additionally, we thank all other contributors who contributed ideas, feedback and code snippets within the Github issues and pull requests as well as all contributors who contributed additional translations in AMOS, the Moodle translation tool.
24 changes: 11 additions & 13 deletions pages/accessibility.php → accessibility/declaration.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,16 @@
*/

// Include config.php.
// @codingStandardsIgnoreStart
// Let codechecker ignore the next line because otherwise it would complain about a missing login check
// after requiring config.php which is really not needed.
require(__DIR__ . '/../../../config.php');
// @codingStandardsIgnoreEnd
require(__DIR__ . '/../../../config.php'); // phpcs:disable moodle.Files.RequireLogin.Missing

// Require the necessary libraries.
require_once($CFG->dirroot.'/theme/boost_union/lib.php');
require_once($CFG->dirroot.'/theme/boost_union/locallib.php');

// Set page URL.
$PAGE->set_url('/theme/boost_union/pages/accessibility.php');
$PAGE->set_url('/theme/boost_union/accessibility/declaration.php');

// Set page layout.
$PAGE->set_pagelayout('standard');
Expand All @@ -44,33 +42,33 @@
$PAGE->set_context(context_system::instance());

// Add page name as body class.
$PAGE->add_body_class('theme_boost_union-accessibility');
$PAGE->add_body_class('theme_boost_union-accessibilitydeclaration');

// Get theme config.
$config = get_config('theme_boost_union');

// If the Declaration of accessibility page is disabled, we just show a short friendly warning page and are done.
if ($config->enableaccessibility != THEME_BOOST_UNION_SETTING_SELECT_YES) {
// If the declaration of accessibility page is disabled, we just show a short friendly warning page and are done.
if ($config->enableaccessibilitydeclaration != THEME_BOOST_UNION_SETTING_SELECT_YES) {
echo $OUTPUT->header();
$notification = new \core\output\notification(get_string('accessibilitydisabled', 'theme_boost_union'),
\core\output\notification::NOTIFY_INFO);
$notification = new \core\output\notification(get_string('accessibilitydeclarationdisabled', 'theme_boost_union'),
\core\output\notification::NOTIFY_INFO);
$notification->set_show_closebutton(false);
echo $OUTPUT->render($notification);
echo $OUTPUT->footer();
die;
}

// Set page title.
$PAGE->set_title(theme_boost_union_get_staticpage_pagetitle('accessibility'));
$PAGE->set_title(theme_boost_union_get_accessibility_pagetitle('declaration'));

// Start page output.
echo $OUTPUT->header();

// Show page heading.
echo $OUTPUT->heading(theme_boost_union_get_staticpage_pagetitle('accessibility'));
echo $OUTPUT->heading(theme_boost_union_get_accessibility_pagetitle('declaration'));

// Output Declaration of accessibility page content.
echo format_text($config->accessibilitycontent, FORMAT_MOODLE, ['trusted' => true, 'noclean' => true]);
// Output declaration of accessibility page content.
echo format_text($config->accessibilitydeclarationcontent, FORMAT_MOODLE, ['trusted' => true, 'noclean' => true]);

// Finish page.
echo $OUTPUT->footer();
98 changes: 66 additions & 32 deletions pages/accessibilitysupport.php → accessibility/support.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,16 @@
*/

// Include config.php.
// @codingStandardsIgnoreStart
// Let codechecker ignore the next line because otherwise it would complain about a missing login check
// after requiring config.php which is really not needed.
require(__DIR__ . '/../../../config.php');
// @codingStandardsIgnoreEnd
require(__DIR__ . '/../../../config.php'); // phpcs:disable moodle.Files.RequireLogin.Missing

// Require the necessary libraries.
require_once($CFG->dirroot.'/theme/boost_union/lib.php');
require_once($CFG->dirroot.'/theme/boost_union/locallib.php');

// Set page URL.
$PAGE->set_url('/theme/boost_union/pages/accessibilitysupport.php');
$PAGE->set_url('/theme/boost_union/accessibility/support.php');

// Set page layout.
$PAGE->set_pagelayout('standard');
Expand All @@ -49,27 +47,29 @@
// Get theme config.
$config = get_config('theme_boost_union');

// If the Accessibility supportpage is disabled, we just show a short friendly warning page and are done.
// If the accessibility support page is disabled, we just show a short friendly warning page and are done.
if ($config->enableaccessibilitysupport != THEME_BOOST_UNION_SETTING_SELECT_YES) {
echo $OUTPUT->header();
$notification = new \core\output\notification(get_string('accessibilitysupportdisabled', 'theme_boost_union'),
\core\output\notification::NOTIFY_INFO);
\core\output\notification::NOTIFY_INFO);
$notification->set_show_closebutton(false);
echo $OUTPUT->render($notification);
echo $OUTPUT->footer();
die;
}

// If user login is required, we redirect to the login page.
if ($config->enableaccessibilitysupportwithoutlogin != THEME_BOOST_UNION_SETTING_SELECT_YES) {
if (isset($config->allowaccessibilitysupportwithoutlogin) &&
$config->allowaccessibilitysupportwithoutlogin != THEME_BOOST_UNION_SETTING_SELECT_YES) {
if (!isloggedin() || isguestuser()) {
redirect(get_login_url());
}
}

// Set page title.
$PAGE->set_title(theme_boost_union_get_staticpage_pagetitle('accessibilitysupport'));
$PAGE->set_title(theme_boost_union_get_accessibility_pagetitle('support'));

// Initialize the accessibility support form.
$form = new \theme_boost_union\form\accessibilitysupport_form();

// Get the page where we came from.
Expand All @@ -78,17 +78,22 @@
$referrerpage = $CFG->wwwroot;
}

// If the form was cancelled.
if ($form->is_cancelled()) {
// Redirect to the previous page when the form was canceled.
// Redirect to the previous page when the form was cancelled.
redirect($referrerpage);

// Otherwise, if the form was submitted and validated.
} else if ($form->is_submitted() && $form->is_validated() && confirm_sesskey()) {
// Get the form data.
$data = $form->get_data();

// Remove the automatic system information field when the sendtechinfo field was unchecked by the user.
if (!$data->sendtechinfo) {
unset($data->techinfo);
}

// If we have a valid user.
$validuser = isloggedin() && !isguestuser();
if ($validuser) {
// Use the current user as sender when logged in.
Expand All @@ -107,46 +112,75 @@
$data->email = get_string('accessibilitysupportanonymousemail', 'theme_boost_union');
}

$subject = get_string('accessibilitysupportemailsubject', 'theme_boost_union', format_string($SITE->fullname));
// Compose the mail content from form data.
$subjectprefix = get_string('accessibilitysupportusermailsubject', 'theme_boost_union');
$subject = '['.$subjectprefix.'] '.$data->subject;
$renderer = $PAGE->get_renderer('core');
// Render email body with form data.
$message = $renderer->render_from_template('theme_boost_union/accessibility_support_email_body', $data);

$accessibilityemail = get_config('theme_boost_union', 'accessibilitysupportemail');
$accessibilityname = get_config('theme_boost_union', 'accessibilitysupportname');
$message = $renderer->render_from_template('theme_boost_union/accessibility-support-email-body', $data);

// Configure the noreply user as receiver when an accessibility support email was configured.
$accessibilityemail = get_config('theme_boost_union', 'accessibilitysupportusermail');
// If an accessibility support email was configured, we use it as receiver.
if ($accessibilityemail) {
// We need to create a dummy user record to send the mail.
// The user record is only used to send the mail.
$supportuser = core_user::get_noreply_user();
$supportuser = \core_user::get_noreply_user();
$supportuser->email = $accessibilityemail;
if ($accessibilityname) {
$supportuser->firstname = $accessibilityname;
}
$supportuser->firstname = get_string('accessibilitysupportuserfirstname', 'theme_boost_union');
$supportuser->lastname = get_string('accessibilitysupportuserlastname', 'theme_boost_union');

// Otherwise.
} else {
// Use the default support user as receiver when no accessibility support email was configured.
$supportuser = core_user::get_support_user();
// Use the default support user as receiver.
$supportuser = \core_user::get_support_user();
}

// Send the email.
$sendresult = email_to_user($supportuser, $from, $subject, $message);

// Show fallback page with contact information when the email could not be sent.
if (!email_to_user($supportuser, $from, $subject, $message)) {
$supportemail = $CFG->supportemail;
if (!$sendresult) {
// If we have a valid user (who should be allowed to see email addresses).
if ($validuser) {
// Get the notification support email address to be shown as fallback for valid users.
$supportemail = $supportuser->email;

// Prepare the notification text.
$notificationtext = get_string('accessibilitysupportmessagenotsent', 'theme_boost_union');
$notificationtext .= '<br />';
$notificationtext .= get_string('accessibilitysupportmessagetryalternative', 'theme_boost_union', $supportemail);

// Otherwise.
} else {
// Prepare the notification text.
$notificationtext = get_string('accessibilitysupportmessagenotsent', 'theme_boost_union');
$notificationtext .= '<br />';
$notificationtext .= get_string('accessibilitysupportmessagetryagain', 'theme_boost_union');
}

$notification = new \core\output\notification($notificationtext, \core\output\notification::NOTIFY_ERROR);
$notification->set_show_closebutton(false);
$formoutput = $OUTPUT->render($notification);

// Set the form data with the subitted data.
$form->set_data($data);
$templatectx = [
'supportemail' => $validuser ? html_writer::link("mailto:{$supportemail}", $supportemail) : false,
'supportform' => $form->render(),
];

// Render the support fallback page.
$formoutput = $renderer->render_from_template('theme_boost_union/accessibility_support_not_available', $templatectx);
// Render the form.
$formoutput .= $form->render();

// Otherwise, if the message was sent.
} else {
// Unset the referrer page session variable (to avoid harming future form submissions).
unset($SESSION->boost_union_accessibility_pagereferrer);

// Redirect to the previous page and show message when the email was successfully sent.
$level = \core\output\notification::NOTIFY_SUCCESS;
redirect($referrerpage, get_string('accessibilitysupportmessagesent', 'theme_boost_union'), 3, $level);
}

// Otherwise, when the form was not submitted yet.
} else {
// Render the form when it was not submitted yet.
// Render the form.
$formoutput = $form->render();
}

Expand All @@ -161,9 +195,9 @@
echo $OUTPUT->header();

// Show page heading.
echo $OUTPUT->heading(theme_boost_union_get_staticpage_pagetitle('accessibilitysupport'));
echo $OUTPUT->heading(theme_boost_union_get_accessibility_pagetitle('support'));

// Output Accessibility support page content.
// Output accessibility support page content.
echo format_text($config->accessibilitysupportcontent, FORMAT_MOODLE, ['trusted' => true, 'noclean' => true]);

// Output the form.
Expand Down
2 changes: 1 addition & 1 deletion amd/build/accessibilitysupportform.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d910fa7

Please sign in to comment.