Skip to content

Commit

Permalink
MDL-48621 admin: Warning about events 1 API deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
David Monllao committed Jan 19, 2016
1 parent 20ff2fb commit 356e235
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
4 changes: 3 additions & 1 deletion admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -843,11 +843,13 @@
$registered = $DB->count_records('registration_hubs', array('huburl' => HUB_MOODLEORGHUBURL, 'confirmed' => 1));
// Check if there are any cache warnings.
$cachewarnings = cache_helper::warnings();
// Check if there are events 1 API handlers.
$eventshandlers = $DB->get_records_sql('SELECT DISTINCT component FROM {events_handlers}');

admin_externalpage_setup('adminnotifications');

$output = $PAGE->get_renderer('core', 'admin');

echo $output->admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed, $cronoverdue, $dbproblems,
$maintenancemode, $availableupdates, $availableupdatesfetch, $buggyiconvnomb,
$registered, $cachewarnings);
$registered, $cachewarnings, $eventshandlers);
21 changes: 20 additions & 1 deletion admin/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,13 @@ public function upgrade_confirm_abort_install_page(array $abortable, moodle_url
* @param array|null $availableupdates array of \core\update\info objects or null
* @param int|null $availableupdatesfetch timestamp of the most recent updates fetch or null (unknown)
* @param string[] $cachewarnings An array containing warnings from the Cache API.
* @param array $eventshandlers Events 1 API handlers.
*
* @return string HTML to output.
*/
public function admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed,
$cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch,
$buggyiconvnomb, $registered, array $cachewarnings = array()) {
$buggyiconvnomb, $registered, array $cachewarnings = array(), $eventshandlers = 0) {
global $CFG;
$output = '';

Expand All @@ -294,6 +295,7 @@ public function admin_notifications_page($maturity, $insecuredataroot, $errorsdi
$output .= $this->db_problems($dbproblems);
$output .= $this->maintenance_mode_warning($maintenancemode);
$output .= $this->cache_warnings($cachewarnings);
$output .= $this->events_handlers($eventshandlers);
$output .= $this->registration_warning($registered);

//////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -594,6 +596,23 @@ public function cache_warnings(array $cachewarnings) {
return join("\n", array_map(array($this, 'warning'), $cachewarnings));
}

/**
* Renders events 1 API handlers warning.
*
* @param array $eventshandlers
* @return string
*/
public function events_handlers($eventshandlers) {
if ($eventshandlers) {
$components = '';
foreach ($eventshandlers as $eventhandler) {
$components .= $eventhandler->component . ', ';
}
$components = rtrim($components, ', ');
return $this->warning(get_string('eventshandlersinuse', 'admin', $components));
}
}

/**
* Render an appropriate message if the site in in maintenance mode.
* @param bool $maintenancemode
Expand Down
1 change: 1 addition & 0 deletions lang/en/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@
$string['errordeletingconfig'] = 'An error occurred while deleting the configuration records for plugin \'{$a}\'.';
$string['errorsetting'] = 'Could not save setting:';
$string['errorwithsettings'] = 'Some settings were not changed due to an error.';
$string['eventshandlersinuse'] = 'The following plugins in your system are using Events 1 API deprecated handlers: \'{$a}\'. Please, update them to use Events 2 API. See https://docs.moodle.org/dev/Event_2#Event_dispatching_and_observers.';
$string['everyonewhocan'] = 'Everyone who can \'{$a}\'';
$string['exceptions'] = 'exceptions';
$string['execpathnotallowed'] = 'Setting executable and local paths disabled in config.php';
Expand Down

0 comments on commit 356e235

Please sign in to comment.