Línea 14... |
Línea 14... |
14 |
// You should have received a copy of the GNU General Public License
|
14 |
// You should have received a copy of the GNU General Public License
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
Línea 16... |
Línea 16... |
16 |
|
16 |
|
Línea 17... |
Línea 17... |
17 |
namespace core_contentbank\output;
|
17 |
namespace core_contentbank\output;
|
18 |
|
18 |
|
19 |
use context_course;
|
19 |
use core\context\{course, coursecat};
|
20 |
use context_coursecat;
|
20 |
use core\context_helper;
|
21 |
use core_contentbank\content;
|
21 |
use core_contentbank\content;
|
22 |
use core_contentbank\contentbank;
|
22 |
use core_contentbank\contentbank;
|
23 |
use renderable;
|
23 |
use renderable;
|
Línea 131... |
Línea 131... |
131 |
if (has_capability('moodle/contentbank:access', $systemcontext)) {
|
131 |
if (has_capability('moodle/contentbank:access', $systemcontext)) {
|
132 |
$allowedcontexts[$systemcontext->id] = get_string('coresystem');
|
132 |
$allowedcontexts[$systemcontext->id] = get_string('coresystem');
|
133 |
}
|
133 |
}
|
134 |
$options = [];
|
134 |
$options = [];
|
135 |
foreach ($this->allowedcategories as $allowedcategory) {
|
135 |
foreach ($this->allowedcategories as $allowedcategory) {
|
- |
|
136 |
context_helper::preload_from_record(clone $allowedcategory);
|
136 |
$options[$allowedcategory->ctxid] = format_string($allowedcategory->name, true, [
|
137 |
$options[$allowedcategory->ctxid] = format_string($allowedcategory->name, true, [
|
137 |
'context' => context_coursecat::instance($allowedcategory->ctxinstance),
|
138 |
'context' => coursecat::instance($allowedcategory->ctxinstance),
|
138 |
]);
|
139 |
]);
|
139 |
}
|
140 |
}
|
140 |
if (!empty($options)) {
|
141 |
if (!empty($options)) {
|
141 |
$allowedcontexts['categories'] = [get_string('coursecategories') => $options];
|
142 |
$allowedcontexts['categories'] = [get_string('coursecategories') => $options];
|
142 |
}
|
143 |
}
|
143 |
$options = [];
|
144 |
$options = [];
|
144 |
foreach ($this->allowedcourses as $allowedcourse) {
|
145 |
foreach ($this->allowedcourses as $allowedcourse) {
|
145 |
// Don't add the frontpage course to the list.
|
146 |
// Don't add the frontpage course to the list.
|
146 |
if ($allowedcourse->id != $SITE->id) {
|
147 |
if ($allowedcourse->id != $SITE->id) {
|
- |
|
148 |
context_helper::preload_from_record(clone $allowedcourse);
|
147 |
$options[$allowedcourse->ctxid] = format_string($allowedcourse->fullname, true, [
|
149 |
$options[$allowedcourse->ctxid] = format_string($allowedcourse->fullname, true, [
|
148 |
'context' => context_course::instance($allowedcourse->ctxinstance),
|
150 |
'context' => course::instance($allowedcourse->ctxinstance),
|
149 |
]);
|
151 |
]);
|
150 |
}
|
152 |
}
|
151 |
}
|
153 |
}
|
152 |
if (!empty($options)) {
|
154 |
if (!empty($options)) {
|
153 |
$allowedcontexts['courses'] = [get_string('courses') => $options];
|
155 |
$allowedcontexts['courses'] = [get_string('courses') => $options];
|