Merge branch 'MDL-74643-master' of https://github.com/mickhawkins/moodle

This commit is contained in:
Ilya Tregubov 2022-10-31 14:52:47 +03:00
commit 9a723c0e15
13 changed files with 221 additions and 8 deletions

View file

@ -2992,5 +2992,18 @@ privatefiles,moodle|/user/files.php';
upgrade_main_savepoint(true, 2022101400.05);
}
if ($oldversion < 2022102800.01) {
// For sites with "contact site support" already available (4.0.x), maintain existing functionality.
if ($oldversion >= 2022041900.00) {
set_config('supportavailability', CONTACT_SUPPORT_ANYONE);
} else {
// Sites which did not previously have the "contact site support" feature default to it requiring authentication.
set_config('supportavailability', CONTACT_SUPPORT_AUTHENTICATED);
}
// Main savepoint reached.
upgrade_main_savepoint(true, 2022102800.01);
}
return true;
}

View file

@ -563,6 +563,21 @@ define('EMAIL_VIA_ALWAYS', 1);
*/
define('EMAIL_VIA_NO_REPLY_ONLY', 2);
/**
* Contact site support form/link disabled.
*/
define('CONTACT_SUPPORT_DISABLED', 0);
/**
* Contact site support form/link only available to authenticated users.
*/
define('CONTACT_SUPPORT_AUTHENTICATED', 1);
/**
* Contact site support form/link available to anyone visiting the site.
*/
define('CONTACT_SUPPORT_ANYONE', 2);
// PARAMETER HANDLING.
/**

View file

@ -4195,6 +4195,14 @@ EOD;
public function supportemail(array $customattribs = []): string {
global $CFG;
// Do not provide a link to contact site support if it is unavailable to this user. This would be where the site has
// disabled support, or limited it to authenticated users and the current user is a guest or not logged in.
if (!isset($CFG->supportavailability) ||
$CFG->supportavailability == CONTACT_SUPPORT_DISABLED ||
($CFG->supportavailability == CONTACT_SUPPORT_AUTHENTICATED && (!isloggedin() || isguestuser()))) {
return '';
}
$label = get_string('contactsitesupport', 'admin');
$icon = $this->pix_icon('t/email', '');
$content = $icon . $label;