Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 13... Línea 13...
13
//
13
//
14
// You should have received a copy of the GNU General Public License
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
Línea 16... Línea 16...
16
 
16
 
17
/**
-
 
18
 * Event documentation
-
 
19
 *
-
 
20
 * @package   report_eventlist
-
 
21
 * @copyright 2014 Adrian Greeve <adrian@moodle.com>
-
 
22
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
-
 
23
 */
-
 
24
 
-
 
25
defined('MOODLE_INTERNAL') || die();
-
 
26
 
-
 
27
/**
17
/**
28
 * Class for returning system event information.
18
 * Class for returning system event information.
29
 *
19
 *
30
 * @package   report_eventlist
20
 * @package   report_eventlist
31
 * @copyright 2014 Adrian Greeve <adrian@moodle.com>
21
 * @copyright 2014 Adrian Greeve <adrian@moodle.com>
Línea 81... Línea 71...
81
 
71
 
82
        return $eventinformation;
72
        return $eventinformation;
Línea 83... Línea 73...
83
    }
73
    }
84
 
-
 
85
    /**
-
 
86
     * Return all of the core event files.
-
 
87
     *
-
 
88
     * @param bool $detail True will return details, but no abstract classes, False will return all events, but no details.
-
 
89
     * @return array Core events.
74
 
90
     *
75
    /**
91
     * @deprecated since 4.0 use {@see get_all_events_list} instead
-
 
92
     */
-
 
93
    public static function get_core_events_list($detail = true) {
-
 
94
        global $CFG;
-
 
95
 
-
 
96
        debugging(__FUNCTION__ . '() is deprecated, please use report_eventlist_list_generator::get_all_events_list() instead',
-
 
97
            DEBUG_DEVELOPER);
-
 
98
 
76
     * @deprecated since 4.0 use {@see get_all_events_list} instead
99
        // Disable developer debugging as deprecated events will fire warnings.
-
 
100
        // Setup backup variables to restore the following settings back to what they were when we are finished.
-
 
101
        $debuglevel          = $CFG->debug;
-
 
102
        $debugdisplay        = $CFG->debugdisplay;
-
 
103
        $debugdeveloper      = $CFG->debugdeveloper;
-
 
104
        $CFG->debug          = 0;
-
 
105
        $CFG->debugdisplay   = false;
-
 
106
        $CFG->debugdeveloper = false;
-
 
107
 
-
 
108
        $eventinformation = array();
-
 
109
        $directory = $CFG->libdir . '/classes/event';
-
 
110
        $files = self::get_file_list($directory);
-
 
111
 
-
 
112
        // Remove exceptional events that will cause problems being displayed.
-
 
113
        if (isset($files['unknown_logged'])) {
-
 
114
            unset($files['unknown_logged']);
-
 
115
        }
77
     */
116
        foreach ($files as $file => $location) {
-
 
117
            $functionname = '\\core\\event\\' . $file;
78
    #[\core\attribute\deprecated('::get_all_events_list', since: '4.0', mdl: 'MDL-72498', final: true)]
118
            // Check to see if this is actually a valid event.
-
 
119
            if (method_exists($functionname, 'get_static_info')) {
-
 
120
                if ($detail) {
-
 
121
                    $ref = new \ReflectionClass($functionname);
-
 
122
                    if (!$ref->isAbstract() && $file != 'manager') {
-
 
123
                        $eventinformation = self::format_data($eventinformation, $functionname);
-
 
124
                    }
-
 
125
                } else {
-
 
126
                    $eventinformation[$functionname] = $file;
-
 
127
                }
-
 
128
            }
-
 
129
        }
-
 
130
        // Now enable developer debugging as event information has been retrieved.
-
 
131
        $CFG->debug          = $debuglevel;
-
 
132
        $CFG->debugdisplay   = $debugdisplay;
-
 
133
        $CFG->debugdeveloper = $debugdeveloper;
79
    public static function get_core_events_list() {
Línea 134... Línea 80...
134
        return $eventinformation;
80
        \core\deprecation::emit_deprecation([self::class, __FUNCTION__]);
135
    }
81
    }
136
 
82
 
Línea 183... Línea 129...
183
                break;
129
                break;
184
        }
130
        }
185
    }
131
    }
Línea 186... Línea 132...
186
 
132
 
187
    /**
-
 
188
     * Returns a list of files (events) with a full directory path for events in a specified directory.
-
 
189
     *
-
 
190
     * @param string $directory location of files.
-
 
191
     * @return array full location of files from the specified directory.
-
 
192
     */
-
 
193
    private static function get_file_list($directory) {
-
 
194
        global $CFG;
-
 
195
        $directoryroot = $CFG->dirroot;
-
 
196
        $finaleventfiles = array();
-
 
197
        if (is_dir($directory)) {
-
 
198
            if ($handle = opendir($directory)) {
-
 
199
                $eventfiles = scandir($directory);
-
 
200
                foreach ($eventfiles as $file) {
-
 
201
                    if ($file != '.' && $file != '..') {
-
 
202
                        // Ignore the file if it is external to the system.
-
 
203
                        if (strrpos($directory, $directoryroot) !== false) {
-
 
204
                            $location = substr($directory, strlen($directoryroot));
-
 
205
                            $eventname = substr($file, 0, -4);
-
 
206
                            $finaleventfiles[$eventname] = $location  . '/' . $file;
-
 
207
                        }
-
 
208
                    }
-
 
209
                }
-
 
210
            }
-
 
211
        }
-
 
212
        return $finaleventfiles;
-
 
213
    }
-
 
214
 
-
 
215
    /**
-
 
216
     * This function returns an array of all events for the plugins of the system.
-
 
217
     *
-
 
218
     * @param bool $detail True will return details, but no abstract classes, False will return all events, but no details.
-
 
219
     * @return array A list of events from all plug-ins.
-
 
220
     *
133
    /**
221
     * @deprecated since 4.0 use {@see get_all_events_list} instead
134
     * @deprecated since 4.0 use {@see get_all_events_list} instead
222
     */
-
 
223
    public static function get_non_core_event_list($detail = true) {
-
 
224
        global $CFG;
-
 
225
 
-
 
226
        debugging(__FUNCTION__ . '() is deprecated, please use report_eventlist_list_generator::get_all_events_list() instead',
-
 
227
            DEBUG_DEVELOPER);
-
 
228
 
-
 
229
        // Disable developer debugging as deprecated events will fire warnings.
135
     */
230
        // Setup backup variables to restore the following settings back to what they were when we are finished.
-
 
231
        $debuglevel          = $CFG->debug;
-
 
232
        $debugdisplay        = $CFG->debugdisplay;
-
 
233
        $debugdeveloper      = $CFG->debugdeveloper;
-
 
234
        $CFG->debug          = 0;
-
 
235
        $CFG->debugdisplay   = false;
-
 
236
        $CFG->debugdeveloper = false;
-
 
237
 
-
 
238
        $noncorepluginlist = array();
136
    #[\core\attribute\deprecated('::get_all_events_list', since: '4.0', mdl: 'MDL-72498', final: true)]
239
        $plugintypes = \core_component::get_plugin_types();
-
 
240
        foreach ($plugintypes as $plugintype => $notused) {
-
 
241
            $pluginlist = \core_component::get_plugin_list($plugintype);
-
 
242
            foreach ($pluginlist as $plugin => $directory) {
137
    public static function get_non_core_event_list() {
243
                $plugindirectory = $directory . '/classes/event';
-
 
244
                foreach (self::get_file_list($plugindirectory) as $eventname => $notused) {
-
 
245
                    $plugineventname = '\\' . $plugintype . '_' . $plugin . '\\event\\' . $eventname;
-
 
246
                    // Check that this is actually an event.
-
 
247
                    if (method_exists($plugineventname, 'get_static_info')) {
-
 
248
                        if ($detail) {
-
 
249
                            $ref = new \ReflectionClass($plugineventname);
-
 
250
                            if (!$ref->isAbstract()) {
-
 
251
                                $noncorepluginlist = self::format_data($noncorepluginlist, $plugineventname);
-
 
252
                            }
-
 
253
                        } else {
-
 
254
                            $noncorepluginlist[$plugineventname] = $eventname;
-
 
255
                        }
-
 
256
                    }
-
 
257
                }
-
 
258
            }
-
 
259
        }
-
 
260
        // Now enable developer debugging as event information has been retrieved.
-
 
261
        $CFG->debug          = $debuglevel;
-
 
262
        $CFG->debugdisplay   = $debugdisplay;
-
 
263
        $CFG->debugdeveloper = $debugdeveloper;
-
 
264
 
-
 
265
        return $noncorepluginlist;
138
        \core\deprecation::emit_deprecation([self::class, __FUNCTION__]);
Línea 266... Línea 139...
266
    }
139
    }
267
 
140
 
268
    /**
141
    /**