Forums | Mahara Community

Developers /
Creating Artefact Plugin - on group creation


anonymous profile picture
Account deleted
Posts: 4

10 July 2013, 1:53

I'm starting to make an artefact plugin for which I need to create a json file for each new group that is created (in dataroot/artefact/myplugin/group_id/).  Is there any way to keep the code for creating this file within my plugin or do I have to insert it directly into the group_create code (in lib/group.php)? 

Im new to the mahara architecture so any tips are much appreciated!  

 

Aaron Wells's profile picture
Posts: 896

15 July 2013, 13:57

Hi Nathaniel,

Sorry for the slow response!

create_group() implements the Event Handler API, so you should be able to add an event handler to your artefact. See at the bottom of create_group() where it calls "handle_event('creategroup', $data)".

Unfortunately there is basically no documentation of the Event Handler API at present. Embarassed

So, you'll have to work it out by example. See artefact/blog and its subscription to the "createuser" event as an example. In outline:

1. You add a "public static function get_event_subscriptions()" function to your PluginArtefactWhatever class. This function will be called when the artefact is installed, and will load the event subscription into the relevant database tables.

2. The array returned by get_event_subscriptions() should identify a public static function of your PluginArtefactWhatever, which will be called when the event occurs.

3. That function will then get called with two arguments when the event is triggered. The first will be the name of the event "creategroup", and the second will be the $data that the create_group() function passed to handle_event().

Cheers,
Aaron

Aaron Wells's profile picture
Posts: 896

15 July 2013, 16:18

Actually, here, I wrote up some documentation of the Events API while I was thinking about it: https://wiki.mahara.org/index.php/User:Aaronw/Events_API

anonymous profile picture
Account deleted
Posts: 4

15 July 2013, 20:07

Thanks for the reply and for adding the documentation, exactly what Im looking for.  

anonymous profile picture
Account deleted
Posts: 2

26 July 2013, 18:16

Anne Klein watches are moderately priced, designer timepieces that typically use a battery-powered quartz movement. Some watches feature an automatic mechanical movement.replica rolex The movement is a spring or electronic mechanism that regulates the time. Owners with no experience in watch repair should not attempt to repair the movement if it is broken because of its complex construction.replica watches uk However, replacing a dead battery, which is the most common reason for an inoperative watch, and removing scratches from the crystal are jobs that require little time or skill to perform.

A post by Account deleted was deleted

6 results