MDL-74570 badges: Correct coding style violation

This commit is contained in:
Andrew Nicols 2023-06-24 22:24:45 +08:00
parent bd3a28eb2b
commit 8e436dcce7
No known key found for this signature in database
GPG Key ID: 6D1E3157C8CFBF14

View File

@ -418,9 +418,11 @@ function badges_get_badge_by_hash(string $hash): object|bool {
*/
function badges_prepare_badge_for_external(stdClass $badge, stdClass $user): object {
global $PAGE, $USER;
$context = ($badge->type == BADGE_TYPE_SITE) ?
context_system::instance() :
context_course::instance($badge->courseid);
if ($badge->type == BADGE_TYPE_SITE) {
$context = context_system::instance();
} else {
$context = context_course::instance($badge->courseid);
}
$canconfiguredetails = has_capability('moodle/badges:configuredetails', $context);
// If the user is viewing another user's badge and doesn't have the right capability return only part of the data.
if ($USER->id != $user->id && !$canconfiguredetails) {