This manual is deprecated. Please visit https://groupoffice.readthedocs.io for the latest documentation. |
Difference between revisions of "Event handling"
From Group-Office Groupware and CRM Documentation
(Replaced content with "TODO") |
|||
Line 1: | Line 1: | ||
− | + | Group-Office fires event on certain actions. You can attach your own functions to do specific actions on these events. To do this create a new module. | |
+ | |||
+ | eg. modules/myevent. | ||
+ | |||
+ | Inside this folder create the file MyeventModule.php: | ||
+ | |||
+ | <pre> | ||
+ | class GO_Filesearch_MyeventModule extends GO_Base_Module{ | ||
+ | |||
+ | public static function initListeners() { | ||
+ | GO_Files_Model_File::model()->addListener('save', 'GO_Myevent_MyeventModule', 'save'); | ||
+ | GO_Files_Model_File::model()->addListener('delete', 'GO_Myevent_MyeventModule', 'delete'); | ||
+ | |||
+ | //attaching to a controller works a bit different | ||
+ | $c = new GO_Core_Controller_Maintenance(); | ||
+ | $c->addListener('someAction', 'GO_Myevent_MyeventModule', 'doSomething'); | ||
+ | } | ||
+ | |||
+ | public static function save(&$file){ | ||
+ | //do something with the file module here | ||
+ | } | ||
+ | |||
+ | public static function delete(&$file){ | ||
+ | //do something with the file module here | ||
+ | } | ||
+ | |||
+ | public static function doSomething(){ | ||
+ | //do something with the file module here | ||
+ | } | ||
+ | } | ||
+ | </pre> |
Revision as of 08:46, 9 July 2012
Group-Office fires event on certain actions. You can attach your own functions to do specific actions on these events. To do this create a new module.
eg. modules/myevent.
Inside this folder create the file MyeventModule.php:
class GO_Filesearch_MyeventModule extends GO_Base_Module{ public static function initListeners() { GO_Files_Model_File::model()->addListener('save', 'GO_Myevent_MyeventModule', 'save'); GO_Files_Model_File::model()->addListener('delete', 'GO_Myevent_MyeventModule', 'delete'); //attaching to a controller works a bit different $c = new GO_Core_Controller_Maintenance(); $c->addListener('someAction', 'GO_Myevent_MyeventModule', 'doSomething'); } public static function save(&$file){ //do something with the file module here } public static function delete(&$file){ //do something with the file module here } public static function doSomething(){ //do something with the file module here } }