MDL-76555 mod_resource: Fix PHP8.0 type error (legacy resources)

This commit is contained in:
Paola Maneggia 2022-12-03 00:08:40 +01:00
parent e4d1369475
commit 44d2db0de1
2 changed files with 12 additions and 8 deletions

View File

@ -29,7 +29,10 @@ class activitybadge extends \core_courseformat\output\activitybadge {
* This method will be called before exporting the template.
*/
protected function update_content(): void {
$options = (object) ['displayoptions' => $this->cminfo->customdata['displayoptions']];
$this->content = resource_get_optional_filetype($options, $this->cminfo);
$customdata = $this->cminfo->customdata;
if (is_array($customdata) && isset($customdata['displayoptions'])) {
$options = (object) ['displayoptions' => $customdata['displayoptions']];
$this->content = resource_get_optional_filetype($options, $this->cminfo);
}
}
}

View File

@ -271,12 +271,13 @@ function resource_get_coursemodule_info($coursemodule) {
function resource_cm_info_view(cm_info $cm) {
global $CFG;
require_once($CFG->dirroot . '/mod/resource/locallib.php');
$resource = (object) ['displayoptions' => $cm->customdata['displayoptions']];
$details = resource_get_optional_details($resource, $cm, false);
if ($details) {
$cm->set_after_link(' ' . html_writer::tag('span', $details,
array('class' => 'resourcelinkdetails')));
$customdata = $cm->customdata;
if (is_array($customdata) && isset($customdata['displayoptions'])) {
$resource = (object) ['displayoptions' => $customdata['displayoptions']];
$details = resource_get_optional_details($resource, $cm, false);
if ($details) {
$cm->set_after_link(' ' . html_writer::tag('span', $details, ['class' => 'resourcelinkdetails']));
}
}
}