Feature Wiki

Information about planned and released features

Tabs

Plugins as Event Listeners

1 Initial Problem

ILIAS has an event handling system where components can listen to events raised by other components. The listening is declared in xml files within the module or service directory and registered with the database update (reload control structure) in the ILIAS setup.  See the development guide for details.

Plugins of a specific type (EventHook) are additionally able to listen to events and don’t need to register their listening. Any active EventHook plugin is called for any event.

Other plugin types are not able to listen to events. This is however needed at some places and the development of an extra event hook plugin is cumbersome. Two examples:

  • The Flashcards plugin stores the status of the cards for a user in a database table. These entries should be cleaned up if a user is deleted.
  • The ExtendedTestStatistics plugin would benefit from a cache of calculated values. But the cache has to be set as outdated if test results are changed.
To support this I propose a support of event listening for any plugin type.

2 Conceptual Summary

Similar to the module.xml a plugin will have a plugin.xml where the events are declared to which the plugin listens:

1
2
3
4
5
6
<?php xml version = "1.0" encoding = "UTF-8"?>
<plugin id="xflc">
<events>
<event type="listen" id="Services/User" />
</events>
</plugin>

This file is read for any plugin:

  • When the control structure is read in the ilias setup
  • When the plugin is updated / activated
The information is stored in the il_event_handling table like for modules and services, e.g:

INSERT INTO il_event_handling(component, type, id) VALUES('Plugins/Flashcards', 'listen', 'Services/User');

Additionally the plugin class or a specific EventHandler class in the plugin must provide a method handleEvent().

The class ilAppEventHandler will check the active status of the plugin and call its handleEvent() function when an event is raised by a component to which  the plugin listens.

3 User Interface Modifications

No user interface modifications are required by the basic feature request.

3.1 List of Affected Views

It may be of purpose to simply show the listened components on the information page of the plugin.

3.2 User Interface Details

The listened components can just be an additional propery/value entry on the information page.

3.3 New User Interface Concepts

None.

4 Technical Information

This feature needs modifications of the following components:

  • Services/EventHandling
  • Services/Component
  • Setup

5 Contact

6 Funding

A pull request for this feature as well as test cases may be provided by Neumann, Fred [fneumann] to reduce the integration effort.

7 Discussion

Killing, Alexander [alex], 27 Apr 2017: I support this idea. The general issue is of course that one plugin can only implement one slot. But I think having a plugin.xml would also be helpful for other issues.

JourFixe, ILIAS [jourfixe], May 22, 2017: We highly appreciate this suggestion and schedule it for 5.3. We keep the idea in mind to substitute the plugin.php by a plugin.xml.

8 Implementation

Neumann, Fred [fneumann] August 22, 2017:

  • Pull Request created: https://github.com/ILIAS-eLearning/ILIAS/pull/616
  • Test Plugin available: https://github.com/fneumann/TestPageComponent
Implementation Notes:
  • The ILIAS setup does not need to read  the plugin.xml files. Instead ilObjDefReader keeps existing entries of plugins in table il_event_handling when it reads the definitions of modules and services.
  • An existing plugin.xml is only read when the plugin is updated and the entries in il_event_handling are delete when the plugin is uninstalled. Activation/deactivation of the plugin does not change this. Instead the activation status is checked in ilAppEventHandler (like for EventHook plugins).
August 23, 2017: Integrated in Trunk by Schmid, Fabian [fschmid]

Test Cases

Test cases completed at August 22, 2017 by Neumann, Fred [fneumann]

C18702     Test-Plugin installieren             
C18703     Login-Event auf ILIAS-Seite anzeigen

Approval

Approved at August 22, 2017 by Neumann, Fred [fneumann] (own funding, no separate customer).

Last edited: 23. Aug 2017, 09:27, Neumann, Fred [fneumann]