mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 02:46:40 +02:00
Merge branch 'MDL-72786' of https://github.com/paulholden/moodle
This commit is contained in:
commit
f8ba03ce1a
2 changed files with 13 additions and 133 deletions
7
.upgradenotes/MDL-72786-2024052421265765.yml
Normal file
7
.upgradenotes/MDL-72786-2024052421265765.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
issueNumber: MDL-72786
|
||||||
|
notes:
|
||||||
|
report_eventlist:
|
||||||
|
- message: >-
|
||||||
|
The report_eventlist_list_generator methods deprecated previously have
|
||||||
|
been removed
|
||||||
|
type: deprecated
|
|
@ -14,16 +14,6 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
|
||||||
* Event documentation
|
|
||||||
*
|
|
||||||
* @package report_eventlist
|
|
||||||
* @copyright 2014 Adrian Greeve <adrian@moodle.com>
|
|
||||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
||||||
*/
|
|
||||||
|
|
||||||
defined('MOODLE_INTERNAL') || die();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for returning system event information.
|
* Class for returning system event information.
|
||||||
*
|
*
|
||||||
|
@ -83,55 +73,11 @@ class report_eventlist_list_generator {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all of the core event files.
|
|
||||||
*
|
|
||||||
* @param bool $detail True will return details, but no abstract classes, False will return all events, but no details.
|
|
||||||
* @return array Core events.
|
|
||||||
*
|
|
||||||
* @deprecated since 4.0 use {@see get_all_events_list} instead
|
* @deprecated since 4.0 use {@see get_all_events_list} instead
|
||||||
*/
|
*/
|
||||||
public static function get_core_events_list($detail = true) {
|
#[\core\attribute\deprecated('::get_all_events_list', since: '4.0', mdl: 'MDL-72498', final: true)]
|
||||||
global $CFG;
|
public static function get_core_events_list() {
|
||||||
|
\core\deprecation::emit_deprecation_if_present([self::class, __FUNCTION__]);
|
||||||
debugging(__FUNCTION__ . '() is deprecated, please use report_eventlist_list_generator::get_all_events_list() instead',
|
|
||||||
DEBUG_DEVELOPER);
|
|
||||||
|
|
||||||
// Disable developer debugging as deprecated events will fire warnings.
|
|
||||||
// Setup backup variables to restore the following settings back to what they were when we are finished.
|
|
||||||
$debuglevel = $CFG->debug;
|
|
||||||
$debugdisplay = $CFG->debugdisplay;
|
|
||||||
$debugdeveloper = $CFG->debugdeveloper;
|
|
||||||
$CFG->debug = 0;
|
|
||||||
$CFG->debugdisplay = false;
|
|
||||||
$CFG->debugdeveloper = false;
|
|
||||||
|
|
||||||
$eventinformation = array();
|
|
||||||
$directory = $CFG->libdir . '/classes/event';
|
|
||||||
$files = self::get_file_list($directory);
|
|
||||||
|
|
||||||
// Remove exceptional events that will cause problems being displayed.
|
|
||||||
if (isset($files['unknown_logged'])) {
|
|
||||||
unset($files['unknown_logged']);
|
|
||||||
}
|
|
||||||
foreach ($files as $file => $location) {
|
|
||||||
$functionname = '\\core\\event\\' . $file;
|
|
||||||
// Check to see if this is actually a valid event.
|
|
||||||
if (method_exists($functionname, 'get_static_info')) {
|
|
||||||
if ($detail) {
|
|
||||||
$ref = new \ReflectionClass($functionname);
|
|
||||||
if (!$ref->isAbstract() && $file != 'manager') {
|
|
||||||
$eventinformation = self::format_data($eventinformation, $functionname);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$eventinformation[$functionname] = $file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Now enable developer debugging as event information has been retrieved.
|
|
||||||
$CFG->debug = $debuglevel;
|
|
||||||
$CFG->debugdisplay = $debugdisplay;
|
|
||||||
$CFG->debugdeveloper = $debugdeveloper;
|
|
||||||
return $eventinformation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -185,84 +131,11 @@ class report_eventlist_list_generator {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of files (events) with a full directory path for events in a specified directory.
|
|
||||||
*
|
|
||||||
* @param string $directory location of files.
|
|
||||||
* @return array full location of files from the specified directory.
|
|
||||||
*/
|
|
||||||
private static function get_file_list($directory) {
|
|
||||||
global $CFG;
|
|
||||||
$directoryroot = $CFG->dirroot;
|
|
||||||
$finaleventfiles = array();
|
|
||||||
if (is_dir($directory)) {
|
|
||||||
if ($handle = opendir($directory)) {
|
|
||||||
$eventfiles = scandir($directory);
|
|
||||||
foreach ($eventfiles as $file) {
|
|
||||||
if ($file != '.' && $file != '..') {
|
|
||||||
// Ignore the file if it is external to the system.
|
|
||||||
if (strrpos($directory, $directoryroot) !== false) {
|
|
||||||
$location = substr($directory, strlen($directoryroot));
|
|
||||||
$eventname = substr($file, 0, -4);
|
|
||||||
$finaleventfiles[$eventname] = $location . '/' . $file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $finaleventfiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This function returns an array of all events for the plugins of the system.
|
|
||||||
*
|
|
||||||
* @param bool $detail True will return details, but no abstract classes, False will return all events, but no details.
|
|
||||||
* @return array A list of events from all plug-ins.
|
|
||||||
*
|
|
||||||
* @deprecated since 4.0 use {@see get_all_events_list} instead
|
* @deprecated since 4.0 use {@see get_all_events_list} instead
|
||||||
*/
|
*/
|
||||||
public static function get_non_core_event_list($detail = true) {
|
#[\core\attribute\deprecated('::get_all_events_list', since: '4.0', mdl: 'MDL-72498', final: true)]
|
||||||
global $CFG;
|
public static function get_non_core_event_list() {
|
||||||
|
\core\deprecation::emit_deprecation_if_present([self::class, __FUNCTION__]);
|
||||||
debugging(__FUNCTION__ . '() is deprecated, please use report_eventlist_list_generator::get_all_events_list() instead',
|
|
||||||
DEBUG_DEVELOPER);
|
|
||||||
|
|
||||||
// Disable developer debugging as deprecated events will fire warnings.
|
|
||||||
// Setup backup variables to restore the following settings back to what they were when we are finished.
|
|
||||||
$debuglevel = $CFG->debug;
|
|
||||||
$debugdisplay = $CFG->debugdisplay;
|
|
||||||
$debugdeveloper = $CFG->debugdeveloper;
|
|
||||||
$CFG->debug = 0;
|
|
||||||
$CFG->debugdisplay = false;
|
|
||||||
$CFG->debugdeveloper = false;
|
|
||||||
|
|
||||||
$noncorepluginlist = array();
|
|
||||||
$plugintypes = \core_component::get_plugin_types();
|
|
||||||
foreach ($plugintypes as $plugintype => $notused) {
|
|
||||||
$pluginlist = \core_component::get_plugin_list($plugintype);
|
|
||||||
foreach ($pluginlist as $plugin => $directory) {
|
|
||||||
$plugindirectory = $directory . '/classes/event';
|
|
||||||
foreach (self::get_file_list($plugindirectory) as $eventname => $notused) {
|
|
||||||
$plugineventname = '\\' . $plugintype . '_' . $plugin . '\\event\\' . $eventname;
|
|
||||||
// Check that this is actually an event.
|
|
||||||
if (method_exists($plugineventname, 'get_static_info')) {
|
|
||||||
if ($detail) {
|
|
||||||
$ref = new \ReflectionClass($plugineventname);
|
|
||||||
if (!$ref->isAbstract()) {
|
|
||||||
$noncorepluginlist = self::format_data($noncorepluginlist, $plugineventname);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$noncorepluginlist[$plugineventname] = $eventname;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Now enable developer debugging as event information has been retrieved.
|
|
||||||
$CFG->debug = $debuglevel;
|
|
||||||
$CFG->debugdisplay = $debugdisplay;
|
|
||||||
$CFG->debugdeveloper = $debugdeveloper;
|
|
||||||
|
|
||||||
return $noncorepluginlist;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue