|
|
|
Well, the easiest way to see how the module system works is to get 0.6 up and running (latest code) and look at one of the existing modules. Basically there are places throughout the code that the function call_hooks('hookname', &$argument) is called. Usually the argument is an array which is passed by reference. This array is modified by the functions associated with that hook and then manipulated when it returns. These hooks exist throughout the back-end and front-end. If there are any places you need hook calls simply edit the code to have a call_hooks function call. Within your module, you will call the function register_hook('hookname', 'your_function_name', $hookpriority). These register_hook calls register your function names to be called when call_hooks('hookname', &$argument) is called. $hookpriority is an integer which indicates with what priority registered hooks should be called. Lower numbers are called first and the priority defaults to 0. Let's say, for instance, that you write a module which needs to do something (for example, set a user quota) after the unix_users module does something (creates the user account). Since the unix-user module functions default to 0 priority, you may set your function to a priority of 1. Now, you can be assured that the function you registered for hook server:user:create will be called after the function that the unix-users module registered for server:user:create. That's all there is to it. See AvailableHooks for more info on what hooks are currently available. Reading through some of the existing modules can help you get a better idea of how modules work. Please note that when writing modules you MUST ensure that if your module has dependencies that they are written in the format: "modulename" where modulename has the same name as the module's filename. For example if i want to require the Unix Users module as a dependancy then I would use the dependancy name "unix_users" because the filename for the Unix Users module is unix_users.mod.phps |