How to add hooks to the calendar?

How to add hooks to the calendar?

por Vitaly Repin -
Número de respostas: 2

Hello!

I need to catch the calendar updates. E.g., new event has been added to the calendar, event has been removed from the calendar etc.

 I have found this thread which states:

Surprinsingly, Moodle's calendar does not use the events API (http://docs.moodle.org/dev/Events_API ) to notify that a calendar event has been addd, removed, modified ... but an hook mechanism with functions to call described in global $CFG .

Could you pint me to the documentation which describes the usage of hooks? How can I add the hook to the calendar from my (local) plugin?

Thanks in advance.

Em resposta a 'Vitaly Repin'

Re: How to add hooks to the calendar?

por Brian Jorgensen -

Hi, Vitaly:

 

http://docs.moodle.org/dev/Calendar_API#Event_hook

You will need your local plugin, plus another_folder under the top-level /calendar folder with a single lib.php file with your hook methods (another_folder_add_event(), etc), and a $CFG->calendar setting in config.php that tells the calendar to look for /calendar/another_folder/lib.php.

$CFG->calendar = 'another_folder';

You could put all your event handling code in the /calendar/another_folder/lib.php methods, or you could use them as stubs that call the methods from your local plugin.

 

Hope this helps,

Brian

Em resposta a 'Brian Jorgensen'

Re: How to add hooks to the calendar?

por Sudheera Palihakkara -

Hi Brian.

I'm interested in a software project which updating a calender that lies somewhere else according to the changes of the Moodle calender. I have created a top-level/calender/new_folder/lib.php and added the following line to config.php

$CFG->calendar = 'calender/calenderSync/lib.php';

Am I doing it right? Do you have any example code or documentation for me to get help. thank you for your time sorriso