Proposed Intercom Solution

I have come up with the following to expand on Per Holmes concept…

place this in the /var/www/html/custom dir that per holmes said to create -

intercom.php -

<?php $link = mysql_connect('localhost', 'asteriskuser', 'amp109'); if (!$link) { die('Not Connected : ' . mysql_error()); } $db = mysql_select_db('asterisk', $link); if (!$db) { die ('Can\'t use foo : ' . mysql_error()); } $dest = $_GET['dst']; $src = $_GET['src']; $output="DENY"; $query="SELECT * from `devices` where (id='$src')"; $result=mysql_query($query,$link) or Die('Query Failed : ' . mysql_error()); while ($row=mysql_fetch_array($result)) { $q2="SELECT * from `devices` where (id='$dst')"; $res2=mysql_query($q2,$link) or Die('Query Failed : ' . mysql_error()); $nr=mysql_num_rows($res2); if ($nr>0) { $output="ALLOW"; } } echo $output; ?>

also place this in the same dir

intercomcode.php -

<?php $link = mysql_connect('localhost', 'asteriskuser', 'amp109'); if (!$link) { die('Not Connected : ' . mysql_error()); } $db = mysql_select_db('asterisk', $link); if (!$db) { die ('Can\'t use foo : ' . mysql_error()); } $query="SELECT * from `featurecodes` where (featurename='intercom-prefix')"; $result=mysql_query($query,$link) or Die('Query Failed : ' . mysql_error()); while ($row=mysql_fetch_array($result)) { $output=$row['customcode']; if (empty($output)) { $output=$row['defaultcode']; } } echo $output; ?>

and lastly, make the following changes to your dialplan in extensions.conf, under macro-dial (this just happens to be from a TrixBox 2.6 machine ) -

Original TB 2.6 code -

[macro-dial]
exten => s,1,GotoIf($["${MOHCLASS}" = “”]?dial)
exten => s,n,SetMusicOnHold(${MOHCLASS})
exten => s,n(dial),AGI(dialparties.agi)
exten => s,n,NoOp(Returned from dialparties with no extensions to call and DIALSTATUS: ${DIALSTATUS})

MY modified version -

[macro-dial]
exten => s,1,GotoIf($["${MOHCLASS}" = “”]?dial)
exten => s,n,SetMusicOnHold(${MOHCLASS})
exten => s,n(dial),Set(DOINTERCOM=${CURL(http://localhost/custom/intercom.php?dst=${ARG3}&src=${CALLERID(num)} )})
exten => s,n,GotoIf($[ “${DOINTERCOM}” = “ALLOW” ] ?ext-intercom-users,${CURL(http://localhost/custom/intercomcode.php}${ARG3},1)
exten => s,n,AGI(dialparties.agi)
exten => s,n,NoOp(Returned from dialparties with no extensions to call and DIALSTATUS: ${DIALSTATUS})

I’m sure this would work on others, such as PBX in a Flash, Elastix, etc, what this does is allow you to use your onetouch keys aka BLF keys to one-touch intercom to people within your system by reading the source and destination straight from the freepbx devices mysql db, if both exist in the db then the device is local, jump to the intercom context and use the rules set forth by freepbx, if not, continue to dial as normal :slight_smile:

the intercomcode.php simply tells the dialplan what the intercom code is, be it custom, or default.

-Andy

Andrew Miffleton
Telecommunications Technician
DFW Business Telephones, Inc.
(972)424-4242 x455
1260 Shiloh Rd.
Plano, TX 75074