1

I see a lot of modules in freepbx and try to understand how they work without success.

the point I can't understand how they hook a call and when call is made so they called and do they work

for example lets say I write module that print "CALL IS MADE" when call is made and I have install.php and uninstall.php and module.xml and function.inc.php and all the files that need to and I have the next code in Function.inc.php

function callmade(){agi->Verbose("Call is Made");}

now I know i can create dialplan manualy in extension_freepbx.conf (not in extension.conf) that call my php but how to make freepbx auto do it (like all modules)

I sorry for my english thks for helpers

eli chen
  • 653
  • 6
  • 17

2 Answers2

2

References to install.php or functions.inc.php are outdated, this is not how modern FreePBX modules are built any longer. All work is done in a class in the FreePBX\modules namespace. So within your module directory you'll have this class file:

Mymodule.class.php

<?php
namespace FreePBX\modules;

class Mymodule extends \FreePBX\FreePBX_Helpers implements \FreePBX\BMO
{
    public function install()
    {
        // here is the install stuff
    }

    public function uninstall()
    {
        // here is the uninstall stuff
    }

    public function myDialplanHooks()
    {
        // signal our intent to hook into the dialplan
        return true;        
    }

    public function doDialplanHook(&$ext, $engine, $pri)
    {
        // this is run when the PBX is reloaded
        $context = "from-internal";
        $extension = "s";
        $ext->splice($context, $exten, "n", new \ext_log(1, "Call is made"));    
    }
}

Now, I have no idea if this will work. I'm very familiar with FreePBX modules, but don't usually hook into the dialplan. But it will give you an idea where to start. Take a look at the modules provided by FreePBX, and dig around in the code. Keep in mind a lot of the modules are still using the legacy files mentioned above, but they are deprecated and will be removed in a future version.

miken32
  • 42,008
  • 16
  • 111
  • 154
0

Unfortanly no way write app for freepbx without knowledge of asterisk AND freepbx internals.

There is manual on freepbx wiki site.

You should understand, that freepbx do nothing except CREATE config for asterisk.

Regarding configuration for asterisk, in most modules it is in functions.inc.php in function like modulename_config.

Most of freepbx NOT use agi at all. Actualy agi used only by people who have low experience with asterisk and included into freepbx becuase of historical reasons. Most of that agi's can be rewrited by dialplan even in less code.

arheops
  • 15,544
  • 1
  • 21
  • 27