Skip to content

Commit

Permalink
get subplugins events only when available
Browse files Browse the repository at this point in the history
  • Loading branch information
TamaroWalter committed May 23, 2024
1 parent 667d400 commit 58c5cc4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions classes/townsquareevents.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
global $CFG;
require_once($CFG->dirroot . '/calendar/lib.php');
require_once($CFG->dirroot . '/blocks/townsquare/locallib.php');
require_once($CFG->dirroot . '/local/townsquaresupport/lib.php');

/**
* Class to get events and posts that will be shown in the townsquare block..
Expand Down Expand Up @@ -72,10 +71,17 @@ public function __construct() {
* @return array
*/
public function get_all_events_sorted(): array {
global $CFG;
$coreevents = $this->get_coreevents();
$postevents = $this->get_postevents();
$subpluginevents = townsquaresupport_get_subplugin_events();

// Check if the townsquaresupport plugin is installed.
$localplugins = \core_plugin_manager::instance()->get_plugins_of_type('local');
$subpluginevents = [];
if (array_key_exists('townsquaresupport', $localplugins)) {
require_once($CFG->dirroot . '/local/townsquaresupport/lib.php');
$subpluginevents = townsquaresupport_get_subplugin_events();
}
// Merge the events in a sorted order.
$events = $coreevents + $postevents + $subpluginevents;
return townsquare_mergesort($events);
Expand Down

0 comments on commit 58c5cc4

Please sign in to comment.