diff --git a/classes/OCRestClient/ApiEventsClient.php b/classes/OCRestClient/ApiEventsClient.php index c61169f469812c6b7833ab0501d0f318f2925f2e..b97c4f1fc5ca1f8584eef3d4c58e5276e94155ea 100644 --- a/classes/OCRestClient/ApiEventsClient.php +++ b/classes/OCRestClient/ApiEventsClient.php @@ -330,13 +330,13 @@ class ApiEventsClient extends OCRestClient return $result[1] == 204; } - public function getVisibilityForEpisode($episode, $course_id = null) + public function getVisibilityForEpisode(array $episode, $course_id = null) { if (is_null($course_id)) { $course_id = Context::getId(); } - $acls = $episode->acl; + $acls = $episode['acl'] ?? []; $vis_conf = !is_null(CourseConfig::get($course_id)->COURSE_HIDE_EPISODES) ? boolval(CourseConfig::get($course_id)->COURSE_HIDE_EPISODES) @@ -345,8 +345,8 @@ class ApiEventsClient extends OCRestClient ? 'invisible' : 'visible'; - if (empty($acls)) { - OCModel::setVisibilityForEpisode($course_id, $episode->id, $default); + if ($acls) { + OCModel::setVisibilityForEpisode($course_id, $episode['id'], $default); return $default; } @@ -384,7 +384,7 @@ class ApiEventsClient extends OCRestClient } // nothing found, return default visibility - OCModel::setVisibilityForEpisode($course_id, $episode->id, $default); + OCModel::setVisibilityForEpisode($course_id, $episode['id'], $default); return $default; } @@ -418,10 +418,11 @@ class ApiEventsClient extends OCRestClient $duration = 0; foreach ((array) $engage_publication->attachments as $attachment) { - if ($attachment->flavor === "presenter/search+preview" || $attachment->type === "presenter/search+preview") { + $type = $attachment->type ?? ''; + if ($attachment->flavor === "presenter/search+preview" || $type === "presenter/search+preview") { $preview = $attachment->url; } - if ($attachment->flavor === "presentation/player+preview" || $attachment->type === "presentation/player+preview") { + if ($attachment->flavor === "presentation/player+preview" || $type === "presentation/player+preview") { $presentation_preview = $attachment->url; } if ($attachment->flavor === "presenter/search+preview" && !$preview) { diff --git a/classes/OCRestClient/WorkflowClient.php b/classes/OCRestClient/WorkflowClient.php index c0cfc898f8d96c7c2558a15144d0dcc62364850d..6b5ffd1c2b0e575ae2a47a4d3d96ffb62cde7628 100644 --- a/classes/OCRestClient/WorkflowClient.php +++ b/classes/OCRestClient/WorkflowClient.php @@ -50,7 +50,7 @@ class WorkflowClient extends OCRestClient if (!empty($wf_defs->definitions->definition)) { foreach ($wf_defs->definitions->definition as $wdef) { - if (is_array($wdef->tags->tag)) { + if (!empty($wdef->tags) && is_array($wdef->tags->tag)) { $tagged_wfs[] = [ 'id' => $wdef->id, 'title' => $wdef->title, diff --git a/classes/lti/LtiHelper.php b/classes/lti/LtiHelper.php index a4e7eeb9a435f40d09a0ce3d9f08dd5d543d69cd..a533308a5b7228620ccc26276ae0d0b50abdcdad 100644 --- a/classes/lti/LtiHelper.php +++ b/classes/lti/LtiHelper.php @@ -33,10 +33,10 @@ class LtiHelper $url = parse_url($endpoint['service_url']); - $lti_url = $url['scheme'] . '://'. $url['host'] - . ($url['port'] ? ':' . $url['port'] : '') . '/lti'; + $port = isset($url['port']) ? ':' . $url['port'] : ''; + $lti_url = $url['scheme'] . '://'. $url['host'] . ($port) . '/lti'; - if (!$links[$lti_url]) { + if (empty($links[$lti_url])) { $links[$lti_url] = [ 'link' => new LtiLink( $lti_url, diff --git a/classes/lti/LtiLink.php b/classes/lti/LtiLink.php index 31d9c4f375c82eb075f45839cec7543d38c66c7c..b9a09fa9fc674d9606dffdff9b37a06095694b10 100644 --- a/classes/lti/LtiLink.php +++ b/classes/lti/LtiLink.php @@ -89,7 +89,7 @@ class LtiLink $this->addLaunchParameters([ 'resource_link_id' => $this->variables['ResourceLink.id'], 'resource_link_title' => $this->variables['ResourceLink.title'], - 'resource_link_description' => $this->variables['ResourceLink.description'], + 'resource_link_description' => $this->variables['ResourceLink.description'] ?? '', ]); } @@ -296,10 +296,14 @@ class LtiLink */ public function getLaunchSignature($launch_params) { - list($launch_url, $fragment) = explode('#', $this->launch_url); - list($launch_url, $query) = explode('?', $launch_url); - if (isset($query)) { + $split_by_fragment = explode('#', $this->launch_url); + $launch_url = $split_by_fragment[0]; + $split_by_q = explode('?', $launch_url); + $launch_url = $split_by_q[0]; + $query = $split_by_q[1] ?? null; + + if ($query) { parse_str($query, $query_params); $launch_params += $query_params; } diff --git a/classes/lti/OpencastLTI.php b/classes/lti/OpencastLTI.php index fdf69f3048af9e6eb7d9c6a43f6f1dc86013d7ce..b6384410bc6a0b1cb59fcecd96893aa8ed23d298 100644 --- a/classes/lti/OpencastLTI.php +++ b/classes/lti/OpencastLTI.php @@ -99,7 +99,7 @@ class OpencastLTI $entry = OCSeminarEpisodes::findOneBySQL( 'series_id = ? AND episode_id = ? AND seminar_id = ?', - [$series['series_id'], $episode->id, $course_id] + [$series['series_id'], $episode['id'], $course_id] ); if ($entry && $entry->visible != $vis) { @@ -380,8 +380,8 @@ class OpencastLTI $url = parse_url($search_config['service_url']); - return $url['scheme'] . '://' . $url['host'] - . ($url['port'] ? ':' . $url['port'] : '') . '/lti'; + $port = isset($url['port']) ? ':' . $url['port'] : ''; + return $url['scheme'] . '://'. $url['host'] . ($port) . '/lti'; } return ''; diff --git a/controllers/course.php b/controllers/course.php index fe1e07cf59e1265cba313a0369c35d42fdccbb52..be3a83cd72aef35bf5739cb5a39e196c36913b80 100644 --- a/controllers/course.php +++ b/controllers/course.php @@ -114,7 +114,8 @@ class CourseController extends OpencastController } // check, if studygroup upload is enabled and if the user is participant there - $studyGroupId = OCUploadStudygroup::findOneBySQL('course_id = ? AND active = TRUE', [$this->course_id])['studygroup_id']; + $studyGroup = OCUploadStudygroup::findOneBySQL('course_id = ? AND active = TRUE', [$this->course_id]); + $studyGroupId = !empty($studyGroup) ? $studyGroup['studygroup_id'] : null; if ($studyGroupId && !OCPerm::editAllowed($studyGroupId)) { PageLayout::postWarning($this->_( 'Sie können nicht auf die Studiengruppe für den Studierendenupload zugreifen, ' @@ -418,7 +419,7 @@ class CourseController extends OpencastController $events = $events_client->getBySeries($this->cseries[0]['series_id'], $this->course_id); foreach ($events as $event) { - $this->events[$event->identifier] = $event; + $this->events[$event['id']] = $event; } } diff --git a/models/OCConfig.php b/models/OCConfig.php index adbd352ede92a35b61004cbb865e11097ec70734..c4bc652da518214449cb6c5b4199ecad0ffad78d 100644 --- a/models/OCConfig.php +++ b/models/OCConfig.php @@ -32,7 +32,7 @@ class OCConfig extends \SimpleORMap { static $config; - if (!$config[$course_id]) { + if (empty($config[$course_id])) { $config_id = self::getConfigIdForCourse($course_id); if ($config_id) { $settings = Configuration::instance($config_id); diff --git a/models/Pager.php b/models/Pager.php index f7192fefc623391f62b74ebb51af00e03d418975..c4f2f1646262f25713eda955d67e1c03ea20d023 100644 --- a/models/Pager.php +++ b/models/Pager.php @@ -75,10 +75,10 @@ class Pager $sort_str = ''; $cid = \Context::getId(); - if ($_SESSION['opencast']['sort_order']) { + if (!empty($_SESSION['opencast']['sort_order'])) { $sort_str = $_SESSION['opencast']['sort_order']; } - else if (\CourseConfig::get($cid)->COURSE_SORT_ORDER) { + else if (!empty(\CourseConfig::get($cid)->COURSE_SORT_ORDER)) { $sort_str = \CourseConfig::get($cid)->COURSE_SORT_ORDER; } else { diff --git a/views/course/_schedule.php b/views/course/_schedule.php index fb61d358c34666b2c2396d8b875a8396782db620..1ba4bb92b9907ece287fe8b353c73d85209f6234 100644 --- a/views/course/_schedule.php +++ b/views/course/_schedule.php @@ -36,7 +36,8 @@ <tr> <? $date = new SingleDate($d['termin_id']); ?> <? $resource = $date->getResourceID(); ?> - <? $scheduled = reset(OCModel::checkScheduled($course_id, $resource, $date->termin_id)) ?> + <? $scheduled = OCModel::checkScheduled($course_id, $resource, $date->termin_id); ?> + <? $scheduled = reset($scheduled) ?> <td> <? if (isset($resource) && OCModel::checkResource($resource) && (date($d['date']) > time())) : ?> <input name="dates[<?= $date->termin_id ?>]" type="checkbox" value="<?= $resource ?>"> @@ -93,8 +94,8 @@ 'title' => $_('Aufzeichnung ist bereits geplant.') ] ) ?> - - <? if ($scheduled && $events[$scheduled['event_id']]->publication_status[0] == 'engage-live') : ?> + <? $publication_status = $scheduled && isset($events[$scheduled['event_id']]['publication_status'][0]) ? $events[$scheduled['event_id']]['publication_status'][0] : '' ?> + <? if ($publication_status == 'engage-live') : ?> <span style="font-weight: bold; color: red">LIVE</span> <? endif ?> <? else : ?> diff --git a/views/course/index.php b/views/course/index.php index a0f4ca1548c28030567a08be02dde7e253cb7c59..eba919694816e3f7e86a5d9931a155ec4f045f8e 100644 --- a/views/course/index.php +++ b/views/course/index.php @@ -40,7 +40,7 @@ use Opencast\Models\Pager; <script> jQuery(function() { STUDIP.hasperm = <?= var_export(OCPerm::editAllowed($course_id)) ?>; - OC.states = <?= json_encode($states) ?>; + OC.states = <?= json_encode($states ?? '') ?>; OC.initIndexpage(); }); </script>