FOP2 Modifications for FreePBX with BRIA module

  1. 3 years ago

    admin

    17 Mar 2015 Administrator

    There is a commercial module for FreePBX to be used with BRIA softphones that does strange things to the FreePBX configuration tables/databases, and then breaks the FOP2 manager auto configuration as it generates TWO devices for a user, without being in user^device mode.

    There is a way to make the FOP2 Manager and FOP2 autoconfiguration scripts works, but requires some tweaks:

    1. Create a mysql trigger
    2. Use a customized autoconfig-buttons.sh script

    For the MySQL trigger, create a file named trigger.sql with this content:

    DROP TRIGGER IF EXISTS AddNines;
    DELIMITER $$
    CREATE TRIGGER AddNines
    BEFORE INSERT ON fop2buttons
    FOR EACH ROW
    BEGIN
    IF(new.Device like '%/%' AND new.Device not like '%/999%' AND new.type='extension')
        then 
                set new.`Channel` = REPLACE( new.Device, '/', '/999');
    END IF;
    END;
    $$
    DELIMITER ;

    You have to create it in MySQL with this command (you must know the MySQL root password):

    mysql -u root -p asterisk < trigger.sql

    The trigger will populate the channel field in the fop2buttons table with the extra device that Bria uses.

    Then you must alter autoconfig-buttons.sh, look for this query:

    mysql -EB -u $DBUSER $DBPASS -h $DBHOST $DBNAME -e \
        "SET NAMES utf8; SELECT device AS channel,type,if(type<>'trunk',exten,'') AS extension,\
        label, mailbox, context, privacy,\`group\`,IF(type='trunk',IF(email<>'',concat('splitme-',email),''),email) as email, \
        channel as extrachannel, $FINAL_FIELDS FROM fop2buttons \
        WHERE exclude=0 \
        ORDER BY $ORDER" | sed '/\*\*/d' | sed 's/: /=/g' | sed '/.*=$/d' | while read LINEA

    and replace it with this one instead:

    mysql -EB -u $DBUSER $DBPASS -h $DBHOST $DBNAME -e \
        "SET NAMES utf8; SELECT IF(type='extension' AND channel<>'',channel,device) AS channel,type,if(type<>'trunk',exten,'') AS extension,\
        label, mailbox, context, privacy,\`group\`,IF(type='trunk',IF(email<>'',concat('splitme-',email),''),email) as email, \
        IF(type='extension' AND channel<>'',device,channel) as extrachannel, $FINAL_FIELDS FROM fop2buttons \
        WHERE exclude=0 \
        ORDER BY $ORDER" | sed '/\*\*/d' | sed 's/: /=/g' | sed '/.*=$/d' | while read LINEA

    Finally log into the FOP2 Manager and select the Buttons tab, and then restart the FOP2 service.

or Sign Up to reply!