Execution order of the configpageinit functions


I’m writing a module that adds a new type of extension to freepbx,
and I’d love to do it as an external module that use hooks to change
the normal Extensions page.

To it for actually work I need that the function
module_configpageinit() of my module to be executed after the core_devices_configpageinit.

Is there anyway to force the order of executions?


but what channel driver are you trying to write it for?

Thank you a lot for your help :slight_smile:
I really love the exensibility of freepbx :slight_smile:

I’m trying to write a module that uses a new channel driver for a customer.

looks like you are correct.

go ahead and file a feature request and we can make that change in 2.9 and see what the affect is, and then evaluate if it is something that should be back ported.

what device type are you trying to add?

p.s. I added a ticket for you: #4684, updated in r10703

thank you for your quick reply.

As I’m going on with the developement, I noticed that the only thing that is preventing me from writing a full module for a new tech is a single line in modules/core/functions.inc.php.

In the function core_devices_configpageinit($dispnum):


My module init function needs to add a new item in that array. But my module’s init function is executed first than the core_devices’s one. So when core_devices_configpageinit calls the
addgeneralarray(‘devtechs’) it:

  • display an error on the page
  • empty the devtechs array (so it remove the item I inserted first).

My quick fix is to just remove that line in core_devices_configpageinit().

It works withouth any problem, because the first time you call the
addgeneralarrayitem() function, it checks if the array exists, and it creates if needed.

I think it would be correct to remove that line in the freepbx code, making it possibile to write modules to add new extension type.

not for the configpageinit functions, they are executed in somewhat ‘random’ order, you can look at config.php to see where that is done.

For the process and pageload functions you can specify sorting order so you may need to have a look if that can some how help. you.

The alternative would be to extend how we do it and see if we can’t find a way to specify and order, though the earliest we could get any such change in would be 2.9 and we’d have to look at was was proposed and involved in doing that.