| Línea 30... |
Línea 30... |
| 30 |
require_once(__DIR__ . '/../config.php');
|
30 |
require_once(__DIR__ . '/../config.php');
|
| 31 |
require_once($CFG->libdir . '/badgeslib.php');
|
31 |
require_once($CFG->libdir . '/badgeslib.php');
|
| Línea 32... |
Línea 32... |
| 32 |
|
32 |
|
| 33 |
$type = required_param('type', PARAM_INT);
|
33 |
$type = required_param('type', PARAM_INT);
|
| 34 |
$courseid = optional_param('id', 0, PARAM_INT);
|
- |
|
| 35 |
$deactivate = optional_param('lock', 0, PARAM_INT);
|
34 |
$courseid = optional_param('id', 0, PARAM_INT);
|
| 36 |
$confirm = optional_param('confirm', false, PARAM_BOOL);
|
35 |
$confirm = optional_param('confirm', false, PARAM_BOOL);
|
| 37 |
$delete = optional_param('delete', 0, PARAM_INT);
|
36 |
$delete = optional_param('delete', 0, PARAM_INT);
|
| 38 |
$archive = optional_param('archive', 0, PARAM_INT);
|
37 |
$archive = optional_param('archive', 0, PARAM_INT);
|
| Línea 46... |
Línea 45... |
| 46 |
|
45 |
|
| 47 |
if (empty($CFG->badges_allowcoursebadges) && ($type == BADGE_TYPE_COURSE)) {
|
46 |
if (empty($CFG->badges_allowcoursebadges) && ($type == BADGE_TYPE_COURSE)) {
|
| 48 |
throw new \moodle_exception('coursebadgesdisabled', 'badges');
|
47 |
throw new \moodle_exception('coursebadgesdisabled', 'badges');
|
| Línea -... |
Línea 48... |
| - |
|
48 |
}
|
| - |
|
49 |
|
| - |
|
50 |
if ($type == BADGE_TYPE_COURSE && !$courseid) {
|
| - |
|
51 |
throw new \moodle_exception('courseidnotfound');
|
| 49 |
}
|
52 |
}
|
| Línea 50... |
Línea 53... |
| 50 |
|
53 |
|
| 51 |
$urlparams = ['type' => $type];
|
54 |
$urlparams = ['type' => $type];
|
| 52 |
|
55 |
|
| Línea 53... |
Línea -... |
| 53 |
if ($course = $DB->get_record('course', ['id' => $courseid])) {
|
- |
|
| 54 |
$urlparams['id'] = $course->id;
|
56 |
if ($course = $DB->get_record('course', ['id' => $courseid])) {
|
| 55 |
}
|
57 |
$urlparams['id'] = $course->id;
|
| 56 |
|
58 |
}
|
| Línea 57... |
Línea 59... |
| 57 |
$hdr = get_string('managebadges', 'badges');
|
59 |
|
| 58 |
$returnurl = new moodle_url('/badges/index.php', $urlparams);
|
60 |
$returnurl = new moodle_url('/badges/index.php', $urlparams);
|
| 59 |
$PAGE->set_url($returnurl);
|
61 |
$PAGE->set_url($returnurl);
|
| 60 |
$PAGE->add_body_class('limitedwidth');
|
62 |
$PAGE->add_body_class('limitedwidth');
|
| 61 |
|
63 |
|
| 62 |
if ($type == BADGE_TYPE_SITE) {
|
64 |
if ($type == BADGE_TYPE_SITE) {
|
| - |
|
65 |
$title = get_string('sitebadges', 'badges');
|
| 63 |
$title = get_string('sitebadges', 'badges');
|
66 |
$PAGE->set_context(context_system::instance());
|
| 64 |
$PAGE->set_context(context_system::instance());
|
67 |
$PAGE->set_pagelayout('admin');
|
| 65 |
$PAGE->set_pagelayout('admin');
|
68 |
$PAGE->set_heading(get_string('administrationsite'));
|
| 66 |
$PAGE->set_heading(get_string('administrationsite'));
|
69 |
navigation_node::override_active_url(new moodle_url('/badges/index.php', ['type' => BADGE_TYPE_SITE]), true);
|
| 67 |
navigation_node::override_active_url(new moodle_url('/badges/index.php', array('type' => BADGE_TYPE_SITE)), true);
|
70 |
$eventotherparams = ['badgetype' => BADGE_TYPE_SITE];
|
| 68 |
} else {
|
71 |
} else {
|
| 69 |
require_login($course);
|
72 |
require_login($course);
|
| 70 |
$coursecontext = context_course::instance($course->id);
|
73 |
$coursecontext = context_course::instance($course->id);
|
| 71 |
$title = get_string('coursebadges', 'badges');
|
74 |
$title = get_string('coursebadges', 'badges');
|
| 72 |
$PAGE->set_context($coursecontext);
|
75 |
$PAGE->set_context($coursecontext);
|
| - |
|
76 |
$PAGE->set_pagelayout('incourse');
|
| 73 |
$PAGE->set_pagelayout('incourse');
|
77 |
$PAGE->set_heading(format_string($course->fullname, true, ['context' => $coursecontext]));
|
| Línea 74... |
Línea 78... |
| 74 |
$PAGE->set_heading(format_string($course->fullname, true, array('context' => $coursecontext)));
|
78 |
navigation_node::override_active_url(
|
| - |
|
79 |
new moodle_url('/badges/index.php', ['type' => BADGE_TYPE_COURSE, 'id' => $course->id])
|
| 75 |
navigation_node::override_active_url(
|
80 |
);
|
| 76 |
new moodle_url('/badges/index.php', array('type' => BADGE_TYPE_COURSE, 'id' => $course->id))
|
81 |
$eventotherparams = ['badgetype' => BADGE_TYPE_COURSE, 'courseid' => $course->id];
|
| 77 |
);
|
82 |
}
|
| 78 |
}
|
83 |
|
| 79 |
|
84 |
if (!has_any_capability([
|
| 80 |
if (!has_any_capability(array(
|
85 |
'moodle/badges:viewbadges',
|
| 81 |
'moodle/badges:viewawarded',
|
86 |
'moodle/badges:viewawarded',
|
| 82 |
'moodle/badges:createbadge',
|
87 |
'moodle/badges:createbadge',
|
| 83 |
'moodle/badges:awardbadge',
|
88 |
'moodle/badges:awardbadge',
|
| Línea 84... |
Línea 89... |
| 84 |
'moodle/badges:configurecriteria',
|
89 |
'moodle/badges:configurecriteria',
|
| - |
|
90 |
'moodle/badges:configuremessages',
|
| - |
|
91 |
'moodle/badges:configuredetails',
|
| 85 |
'moodle/badges:configuremessages',
|
92 |
'moodle/badges:deletebadge'], $PAGE->context)) {
|
| Línea 86... |
Línea 93... |
| 86 |
'moodle/badges:configuredetails',
|
93 |
redirect($CFG->wwwroot);
|
| 87 |
'moodle/badges:deletebadge'), $PAGE->context)) {
|
94 |
}
|
| 88 |
redirect($CFG->wwwroot);
|
95 |
|
| Línea 98... |
Línea 105... |
| 98 |
if (!$confirm) {
|
105 |
if (!$confirm) {
|
| 99 |
echo $output->header();
|
106 |
echo $output->header();
|
| 100 |
// Archive this badge?
|
107 |
// Archive this badge?
|
| 101 |
echo $output->heading(get_string('archivebadge', 'badges', $badge->name));
|
108 |
echo $output->heading(get_string('archivebadge', 'badges', $badge->name));
|
| 102 |
$archivebutton = $output->single_button(
|
109 |
$archivebutton = $output->single_button(
|
| 103 |
new moodle_url($PAGE->url, array('archive' => $badge->id, 'confirm' => 1)),
|
110 |
new moodle_url($PAGE->url, ['archive' => $badge->id, 'confirm' => 1]),
|
| 104 |
get_string('archiveconfirm', 'badges'));
|
111 |
get_string('archiveconfirm', 'badges'));
|
| 105 |
echo $output->box(get_string('archivehelp', 'badges') . $archivebutton, 'generalbox');
|
112 |
echo $output->box(get_string('archivehelp', 'badges') . $archivebutton, 'generalbox');
|
| Línea 106... |
Línea 113... |
| 106 |
|
113 |
|
| 107 |
// Delete this badge?
|
114 |
// Delete this badge?
|
| 108 |
echo $output->heading(get_string('delbadge', 'badges', $badge->name));
|
115 |
echo $output->heading(get_string('delbadge', 'badges', $badge->name));
|
| 109 |
$deletebutton = $output->single_button(
|
116 |
$deletebutton = $output->single_button(
|
| 110 |
new moodle_url($PAGE->url, array('delete' => $badge->id, 'confirm' => 1)),
|
117 |
new moodle_url($PAGE->url, ['delete' => $badge->id, 'confirm' => 1]),
|
| 111 |
get_string('delconfirm', 'badges'));
|
118 |
get_string('delconfirm', 'badges'));
|
| Línea 112... |
Línea 119... |
| 112 |
echo $output->box(get_string('deletehelp', 'badges') . $deletebutton, 'generalbox');
|
119 |
echo $output->box(get_string('deletehelp', 'badges') . $deletebutton, 'generalbox');
|
| 113 |
|
120 |
|
| Línea 122... |
Línea 129... |
| 122 |
$badge->delete($archiveonly);
|
129 |
$badge->delete($archiveonly);
|
| 123 |
redirect($returnurl);
|
130 |
redirect($returnurl);
|
| 124 |
}
|
131 |
}
|
| 125 |
}
|
132 |
}
|
| Línea 126... |
Línea -... |
| 126 |
|
- |
|
| 127 |
if ($deactivate && has_capability('moodle/badges:configuredetails', $PAGE->context)) {
|
- |
|
| 128 |
require_sesskey();
|
- |
|
| 129 |
$badge = new badge($deactivate);
|
- |
|
| 130 |
if ($badge->is_locked()) {
|
- |
|
| 131 |
$badge->set_status(BADGE_STATUS_INACTIVE_LOCKED);
|
- |
|
| 132 |
} else {
|
- |
|
| 133 |
$badge->set_status(BADGE_STATUS_INACTIVE);
|
- |
|
| 134 |
}
|
- |
|
| 135 |
$msg = 'deactivatesuccess';
|
- |
|
| 136 |
$returnurl->param('msg', $msg);
|
- |
|
| 137 |
redirect($returnurl);
|
- |
|
| 138 |
}
|
- |
|
| 139 |
|
133 |
|
| 140 |
echo $OUTPUT->header();
|
- |
|
| 141 |
$backurl = $type == BADGE_TYPE_SITE ? null : new moodle_url('/badges/view.php', ['type' => $type, 'id' => $courseid]);
|
- |
|
| 142 |
$actionbar = new \core_badges\output\standard_action_bar($PAGE, $type, false, true, $backurl);
|
- |
|
| Línea -... |
Línea 134... |
| - |
|
134 |
echo $OUTPUT->header();
|
| 143 |
echo $output->render_tertiary_navigation($actionbar);
|
135 |
|
| 144 |
|
136 |
echo $OUTPUT->container_start('badges-heading');
|
| 145 |
if ($type == BADGE_TYPE_SITE) {
|
137 |
if ($type == BADGE_TYPE_SITE) {
|
| 146 |
echo $OUTPUT->heading_with_help($hdr, 'sitebadges', 'badges');
|
138 |
echo $OUTPUT->heading_with_help($title, 'sitebadges', 'badges');
|
| 147 |
} else {
|
139 |
} else {
|
| - |
|
140 |
echo $OUTPUT->heading($title);
|
| - |
|
141 |
}
|
| - |
|
142 |
$actionbar = new \core_badges\output\standard_action_bar(
|
| - |
|
143 |
page: $PAGE,
|
| - |
|
144 |
type: $type,
|
| - |
|
145 |
showaddbadge: true,
|
| - |
|
146 |
);
|
| Línea 148... |
Línea 147... |
| 148 |
echo $OUTPUT->heading($hdr);
|
147 |
echo $output->render_tertiary_navigation($actionbar);
|
| Línea 149... |
Línea 148... |
| 149 |
}
|
148 |
echo $OUTPUT->container_end();
|
| - |
|
149 |
|
| 150 |
|
150 |
echo $OUTPUT->box('', 'notifyproblem hide', 'check_connection');
|
| - |
|
151 |
|
| - |
|
152 |
if ($course && $course->startdate > time()) {
|
| 151 |
echo $OUTPUT->box('', 'notifyproblem hide', 'check_connection');
|
153 |
echo $OUTPUT->notification(
|
| Línea 152... |
Línea 154... |
| 152 |
|
154 |
get_string('error:notifycoursedate', 'badges', userdate($course->startdate)),
|
| 153 |
if ($course && $course->startdate > time()) {
|
155 |
'warning'
|
| 154 |
echo $OUTPUT->box(get_string('error:notifycoursedate', 'badges'), 'generalbox notifyproblem');
|
156 |
);
|
| Línea 155... |
Línea 157... |
| 155 |
}
|
157 |
}
|
| 156 |
|
- |
|
| Línea 157... |
Línea 158... |
| 157 |
if ($msg !== '') {
|
158 |
|
| - |
|
159 |
if ($msg !== '') {
|
| - |
|
160 |
echo $OUTPUT->notification(get_string($msg, 'badges'), 'notifysuccess');
|
| - |
|
161 |
}
|
| - |
|
162 |
|
| - |
|
163 |
$report = system_report_factory::create(badges::class, $PAGE->context);
|
| - |
|
164 |
|
| Línea 158... |
Línea 165... |
| 158 |
echo $OUTPUT->notification(get_string($msg, 'badges'), 'notifysuccess');
|
165 |
echo $report->output();
|