mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 05:28:30 +01:00
Merge branch 'MDL-79334' of https://github.com/paulholden/moodle
This commit is contained in:
commit
5da0cee324
@ -163,9 +163,8 @@ class badges extends system_report {
|
||||
$this->add_action((new action(
|
||||
new moodle_url('/badges/action.php', [
|
||||
'id' => ':id',
|
||||
'sesskey' => sesskey(),
|
||||
'activate' => true,
|
||||
'return' => (new moodle_url(qualified_me()))->out_as_local_url(false),
|
||||
'return' => ':return',
|
||||
]),
|
||||
new pix_icon('t/show', '', 'core'),
|
||||
[],
|
||||
@ -173,8 +172,12 @@ class badges extends system_report {
|
||||
new lang_string('activate', 'badges')
|
||||
))->add_callback(static function(stdclass $row): bool {
|
||||
$badge = new \core_badges\badge($row->id);
|
||||
$context = self::get_badge_context((int)$row->type, (int)$row->courseid);
|
||||
return has_capability('moodle/badges:configuredetails', $context) &&
|
||||
|
||||
// Populate the return URL.
|
||||
$row->return = (new moodle_url('/badges/index.php',
|
||||
['type' => $badge->type, 'id' => (int) $badge->courseid]))->out_as_local_url(false);
|
||||
|
||||
return has_capability('moodle/badges:configuredetails', $badge->get_context()) &&
|
||||
$badge->has_criteria() &&
|
||||
($row->status == BADGE_STATUS_INACTIVE || $row->status == BADGE_STATUS_INACTIVE_LOCKED);
|
||||
|
||||
@ -194,8 +197,7 @@ class badges extends system_report {
|
||||
new lang_string('deactivate', 'badges')
|
||||
))->add_callback(static function(stdclass $row): bool {
|
||||
$badge = new \core_badges\badge($row->id);
|
||||
$context = self::get_badge_context((int)$row->type, (int)$row->courseid);
|
||||
return has_capability('moodle/badges:configuredetails', $context) &&
|
||||
return has_capability('moodle/badges:configuredetails', $badge->get_context()) &&
|
||||
$badge->has_criteria() &&
|
||||
$row->status != BADGE_STATUS_INACTIVE && $row->status != BADGE_STATUS_INACTIVE_LOCKED;
|
||||
}));
|
||||
@ -211,9 +213,8 @@ class badges extends system_report {
|
||||
new lang_string('award', 'badges')
|
||||
))->add_callback(static function(stdclass $row): bool {
|
||||
$badge = new \core_badges\badge($row->id);
|
||||
$context = self::get_badge_context((int)$row->type, (int)$row->courseid);
|
||||
return $badge->has_manual_award_criteria() &&
|
||||
has_capability('moodle/badges:awardbadge', $context) &&
|
||||
return has_capability('moodle/badges:awardbadge', $badge->get_context()) &&
|
||||
$badge->has_manual_award_criteria() &&
|
||||
$badge->is_active();
|
||||
}));
|
||||
|
||||
|
@ -48,7 +48,6 @@ if (empty($CFG->badges_allowcoursebadges) && ($type == BADGE_TYPE_COURSE)) {
|
||||
throw new \moodle_exception('coursebadgesdisabled', 'badges');
|
||||
}
|
||||
|
||||
$err = '';
|
||||
$urlparams = ['type' => $type];
|
||||
|
||||
if ($course = $DB->get_record('course', ['id' => $courseid])) {
|
||||
@ -150,25 +149,17 @@ if ($type == BADGE_TYPE_SITE) {
|
||||
|
||||
echo $OUTPUT->box('', 'notifyproblem hide', 'check_connection');
|
||||
|
||||
$totalcount = count(badges_get_badges($type, $courseid, '', '' , 0, 0));
|
||||
|
||||
if ($totalcount) {
|
||||
if ($course && $course->startdate > time()) {
|
||||
echo $OUTPUT->box(get_string('error:notifycoursedate', 'badges'), 'generalbox notifyproblem');
|
||||
}
|
||||
|
||||
if ($err !== '') {
|
||||
echo $OUTPUT->notification($err, 'notifyproblem');
|
||||
}
|
||||
|
||||
if ($msg !== '') {
|
||||
echo $OUTPUT->notification(get_string($msg, 'badges'), 'notifysuccess');
|
||||
}
|
||||
|
||||
$report = system_report_factory::create(badges::class, $PAGE->context);
|
||||
echo $report->output();
|
||||
} else {
|
||||
echo $output->notification(get_string('nobadges', 'badges'), 'info');
|
||||
if ($course && $course->startdate > time()) {
|
||||
echo $OUTPUT->box(get_string('error:notifycoursedate', 'badges'), 'generalbox notifyproblem');
|
||||
}
|
||||
|
||||
if ($msg !== '') {
|
||||
echo $OUTPUT->notification(get_string($msg, 'badges'), 'notifysuccess');
|
||||
}
|
||||
|
||||
$report = system_report_factory::create(badges::class, $PAGE->context);
|
||||
$report->set_default_no_results_notice(new lang_string('nobadges', 'badges'));
|
||||
|
||||
echo $report->output();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
Loading…
x
Reference in New Issue
Block a user