diff options
author | mcrane <mctch@yahoo.com> | 2009-07-22 05:32:38 -0600 |
---|---|---|
committer | mcrane <mctch@yahoo.com> | 2009-07-22 05:32:38 -0600 |
commit | 21c87ae73aa3cd317e3eeeab22342a0c25c386f5 (patch) | |
tree | da770672dcfe6e46712da9ef1a462a6308053f71 /config/freeswitch_dev/freeswitch.inc | |
parent | 122c1cb7e5efb2e4c0ed1f12617c0cf39ab5dc06 (diff) | |
download | pfsense-packages-21c87ae73aa3cd317e3eeeab22342a0c25c386f5.tar.gz pfsense-packages-21c87ae73aa3cd317e3eeeab22342a0c25c386f5.tar.bz2 pfsense-packages-21c87ae73aa3cd317e3eeeab22342a0c25c386f5.zip |
FreeSWITCH package add optional pin number and caller announce to the huntgroup, dialplan default.xml add *97 for general voicemail box access, optional 5 digit extensions, add work around for broken path when clicking on the pfsense logo.
Diffstat (limited to 'config/freeswitch_dev/freeswitch.inc')
-rw-r--r-- | config/freeswitch_dev/freeswitch.inc | 568 |
1 files changed, 425 insertions, 143 deletions
diff --git a/config/freeswitch_dev/freeswitch.inc b/config/freeswitch_dev/freeswitch.inc index 77847d8e..7d25a8e8 100644 --- a/config/freeswitch_dev/freeswitch.inc +++ b/config/freeswitch_dev/freeswitch.inc @@ -32,6 +32,8 @@ POSSIBILITY OF SUCH DAMAGE. */ +//ob_start("ob_gzhandler"); + function build_menu() { //$script_name_array = split ("/", $_SERVER["SCRIPT_NAME"]); @@ -1062,14 +1064,15 @@ function sync_package_freeswitch_hunt_group() //$rowhelper['huntgrouptimeout'] //$rowhelper['huntgroupcontext'] //$rowhelper['huntgroupringback'] - //$rowhelper['huntgroupcidnameprefix'] + //$rowhelper['huntgroupcidnameprefix'] + //$rowhelper['huntgrouppin'] + //$rowhelper['huntgroupcallerannounce'] //$rowhelper['huntgroupdescr'] //add each Hunt Group to the dialplan $a_dialplan_includes = &$config['installedpackages']['freeswitchdialplanincludes']['config']; $a_dialplan_include_details = &$config['installedpackages']['freeswitchdialplanincludedetails']['config']; - if (strlen($rowhelper['huntgroupid']) > 0) { $action = 'add'; //set default action to add $i = 0; @@ -1083,7 +1086,6 @@ function sync_package_freeswitch_hunt_group() //$row['enabled']; if ($row['opt1name'] == "huntgroupid" && $row['opt1value'] == $rowhelper['huntgroupid']) { - //update $action = 'update'; $dialplanincludeid = $row['dialplanincludeid']; $extensionname = $row['extensionname']; @@ -1094,8 +1096,6 @@ function sync_package_freeswitch_hunt_group() $opt1name = $row['opt1name']; $opt1value = $row['opt1value']; $id = $i; - //echo "update".$i."<br />\n"; - } $i++; } @@ -1105,99 +1105,268 @@ function sync_package_freeswitch_hunt_group() $ent = array(); if ($action == 'add') { + //create huntgroup extension in the dialplan + $ent = array(); + $dialplanincludeid = guid(); + $ent['dialplanincludeid'] = $dialplanincludeid; + $ent['extensionname'] = $rowhelper['huntgroupname']; + $ent['order'] = '9001'; //if update use the existing order number and extension name and desc + $ent['context'] = $rowhelper['huntgroupcontext']; + $ent['enabled'] = 'true'; + $ent['descr'] = 'huntgroup'; + $ent['opt1name'] = 'huntgroupid'; + $ent['opt1value'] = $rowhelper['huntgroupid']; + + $a_dialplan_includes[] = $ent; //add to the config + unset($ent); + + $ent = array(); + $ent['dialplanincludeid'] = $dialplanincludeid; + $ent['tag'] = 'condition'; //condition, action, antiaction + $ent['fieldtype'] = 'destination_number'; + $ent['fielddata'] = '^'.$rowhelper['huntgroupextension'].'$'; + $a_dialplan_include_details[] = $ent; + unset($ent); + $huntgroupid = str_replace(array("{", "}"), "", $rowhelper['huntgroupid']); + + $ent = array(); + $ent['dialplanincludeid'] = $dialplanincludeid; + $ent['tag'] = 'action'; //condition, action, antiaction + $ent['fieldtype'] = 'javascript'; + $ent['fielddata'] = 'huntgroup_'.$huntgroupid.'.js'; + $a_dialplan_include_details[] = $ent; + unset($ent); + + unset($huntgroupid); + + } + if ($action == 'update') { + //update the huntgroup + $ent = array(); + $ent['dialplanincludeid'] = $dialplanincludeid; + $ent['extensionname'] = $rowhelper['huntgroupname']; + $ent['order'] = $order; + $ent['context'] = $context; + $ent['enabled'] = $enabled; + $ent['descr'] = $descr; + $ent['opt1name'] = $opt1name; + $ent['opt1value'] = $opt1value; + + //update the config + $a_dialplan_includes[$id] = $ent; + + unset($ent); + unset($extensionname); + unset($order); + unset($context); + unset($enabled); + unset($descr); + unset($opt1name); + unset($opt1value); + unset($id); + } + unset($action); + unset($dialplanincludeid); + + //check whether the fifo queue exists already + $action = 'add'; //set default action to add + $i = 0; + if (count($a_dialplan_includes) > 0) { + + foreach($a_dialplan_includes as $row) { + + //$row['dialplanincludeid']; + //$row['extensionname']; + //$row['context']; + //$row['enabled']; + + if ($row['opt1name'] == "huntgroupfifoid" && $row['opt1value'] == $rowhelper['huntgroupid']) { + $action = 'update'; + $dialplanincludeid = $row['dialplanincludeid']; + $extensionname = $row['extensionname']; + $order = $row['order']; + $context = $row['context']; + $enabled = $row['enabled']; + $descr = $row['descr']; + $opt1name = $row['opt1name']; + $opt1value = $row['opt1value']; + $id = $i; + } + $i++; + } + unset($i); + } + + if ($action == 'add') { + + //create a fifo queue for each huntgroup + $ent = array(); $dialplanincludeid = guid(); $ent['dialplanincludeid'] = $dialplanincludeid; - $ent['extensionname'] = $rowhelper['huntgroupname']; - $ent['order'] = '9001'; //if update use the existing order number and extension name and desc + $ent['extensionname'] = $rowhelper['huntgroupname'].'.park'; + $ent['order'] = '9999'; //if update use the existing order number and extension name and desc $ent['context'] = $rowhelper['huntgroupcontext']; $ent['enabled'] = 'true'; - $ent['descr'] = 'huntgroup'; - $ent['opt1name'] = 'huntgroupid'; + $ent['descr'] = 'fifo '.$rowhelper['huntgroupextension']; + $ent['opt1name'] = 'huntgroupfifoid'; $ent['opt1value'] = $rowhelper['huntgroupid']; + $a_dialplan_includes[] = $ent; //add to the config + unset($ent); - //add to the config - $a_dialplan_includes[] = $ent; - unset($ent); - $ent = array(); $ent['dialplanincludeid'] = $dialplanincludeid; $ent['tag'] = 'condition'; //condition, action, antiaction $ent['fieldtype'] = 'destination_number'; - $ent['fielddata'] = '^'.$rowhelper['huntgroupextension'].'$'; - $a_dialplan_include_details[] = $ent; + $ent['fielddata'] = '^\*'.$rowhelper['huntgroupextension'].'$'; + $ent['fieldorder'] = '000'; + $a_dialplan_include_details[] = $ent; //add to the config + unset($ent); + + $ent = array(); + $ent['dialplanincludeid'] = $dialplanincludeid; + $ent['tag'] = 'action'; //condition, action, antiaction + $ent['fieldtype'] = 'set'; + $ent['fielddata'] = 'fifo_music=$${hold_music}'; + $ent['fieldorder'] = '001'; + $a_dialplan_include_details[] = $ent; //add to the config unset($ent); - $huntgroupid = str_replace(array("{", "}"), "", $rowhelper['huntgroupid']); + $huntgrouptimeouttype = $rowhelper['huntgrouptimeouttype']; + $huntgrouptimeoutdestination = $rowhelper['huntgrouptimeoutdestination']; + if ($huntgrouptimeouttype == "voicemail") { $huntgrouptimeoutdestination = '***'.$huntgrouptimeoutdestination; } $ent = array(); $ent['dialplanincludeid'] = $dialplanincludeid; $ent['tag'] = 'action'; //condition, action, antiaction - $ent['fieldtype'] = 'javascript'; - $ent['fielddata'] = 'huntgroup_'.$huntgroupid.'.js'; + $ent['fieldtype'] = 'set'; + $ent['fielddata'] = 'fifo_orbit_exten='.$huntgrouptimeoutdestination.':'.$rowhelper['huntgrouptimeout']; + $ent['fieldorder'] = '002'; $a_dialplan_include_details[] = $ent; - unset($ent); + unset($ent); //add to the config - unset($huntgroupid); - + $ent = array(); + $ent['dialplanincludeid'] = $dialplanincludeid; + $ent['tag'] = 'action'; //condition, action, antiaction + $ent['fieldtype'] = 'fifo'; + $ent['fielddata'] = $rowhelper['huntgroupextension'].'@${domain_name} in'; + $ent['fieldorder'] = '003'; + $a_dialplan_include_details[] = $ent; //add to the config + unset($ent); } if ($action == 'update') { + //update the huntgroup + $ent = array(); + $ent['dialplanincludeid'] = $dialplanincludeid; + $ent['extensionname'] = $rowhelper['huntgroupname'].'.park'; + $ent['order'] = $order; + $ent['context'] = $rowhelper['huntgroupcontext']; + $ent['enabled'] = $enabled; + $ent['descr'] = 'fifo '.$rowhelper['huntgroupextension']; + $ent['opt1name'] = $opt1name; + $ent['opt1value'] = $opt1value; + + //update the config + $a_dialplan_includes[$id] = $ent; - $ent['dialplanincludeid'] = $dialplanincludeid; - $ent['extensionname'] = $rowhelper['huntgroupname']; - $ent['order'] = $order; - $ent['context'] = $context; - $ent['enabled'] = $enabled; - $ent['descr'] = $descr; - $ent['opt1name'] = $opt1name; - $ent['opt1value'] = $opt1value; + unset($ent); + unset($extensionname); + unset($order); + unset($context); + unset($enabled); + unset($descr); + unset($opt1name); + unset($opt1value); + unset($id); + + //delete dialplan include details + if (count($a_dialplan_include_details) > 0) { + foreach($a_dialplan_include_details as $row) { + if ($row['dialplanincludeid'] == $dialplanincludeid) { + $id = $i; + unset($a_dialplan_include_details[$id]); + } + $i++; + } + unset($i); + } - //update the config - $a_dialplan_includes[$id] = $ent; + $ent = array(); + $ent['dialplanincludeid'] = $dialplanincludeid; + $ent['tag'] = 'condition'; //condition, action, antiaction + $ent['fieldtype'] = 'destination_number'; + $ent['fielddata'] = '^\*'.$rowhelper['huntgroupextension'].'$'; + $ent['fieldorder'] = '000'; + $a_dialplan_include_details[] = $ent; //add to the config + unset($ent); - unset($ent); - unset($extensionname); - unset($order); - unset($context); - unset($enabled); - unset($descr); - unset($opt1name); - unset($opt1value); - unset($id); + $ent = array(); + $ent['dialplanincludeid'] = $dialplanincludeid; + $ent['tag'] = 'action'; //condition, action, antiaction + $ent['fieldtype'] = 'set'; + $ent['fielddata'] = 'fifo_music=$${hold_music}'; + $ent['fieldorder'] = '001'; + $a_dialplan_include_details[] = $ent; //add to the config + unset($ent); + + $huntgrouptimeouttype = $rowhelper['huntgrouptimeouttype']; + $huntgrouptimeoutdestination = $rowhelper['huntgrouptimeoutdestination']; + if ($huntgrouptimeouttype == "voicemail") { $huntgrouptimeoutdestination = '***'.$huntgrouptimeoutdestination; } + + $ent = array(); + $ent['dialplanincludeid'] = $dialplanincludeid; + $ent['tag'] = 'action'; //condition, action, antiaction + $ent['fieldtype'] = 'set'; + $ent['fielddata'] = 'fifo_orbit_exten='.$huntgrouptimeoutdestination.':'.$rowhelper['huntgrouptimeout']; + $ent['fieldorder'] = '002'; + $a_dialplan_include_details[] = $ent; + unset($ent); //add to the config + + $ent = array(); + $ent['dialplanincludeid'] = $dialplanincludeid; + $ent['tag'] = 'action'; //condition, action, antiaction + $ent['fieldtype'] = 'fifo'; + $ent['fielddata'] = $rowhelper['huntgroupextension'].'@${domain_name} in'; + $ent['fieldorder'] = '003'; + $a_dialplan_include_details[] = $ent; //add to the config + unset($ent); } + write_config(); - - sync_package_freeswitch_dialplan_includes(); + sync_package_freeswitch_dialplan_includes(); unset($dialplanincludeid); } //end if strlen huntgroupid; add the Hunt Group to the dialplan - //--- begin: pin number ------------------------------------ - if (strlen($rowhelper['huntgrouppin']) > 0) { - $tmp .= "var pin = '".$rowhelper['huntgrouppin']."';\n"; - $tmp .= "if (pin.length > 0) {\n"; - $tmp .= " var dtmf = new Object();\n"; - $tmp .= " dtmf.digits = \"\";\n"; - $tmp .= " digitmaxlength = 6;\n"; - $tmp .= " session.execute(\"set\", \"playback_terminators=#\");\n"; - $tmp .= " session.streamFile( \"/usr/local/freeswitch/sounds/custom/8000/please_enter_the_pin_number.wav\", mycb, \"dtmf\");\n"; - $tmp .= " session.collectInput( mycb, dtmf, timeoutpin );\n"; - $tmp .= "\n"; - $tmp .= " if (dtmf.digits == pin || pin.length == 0) {\n"; - $tmp .= " //continue\n"; - $tmp .= " }\n"; - $tmp .= " else {\n"; - $tmp .= " console_log( \"info\", \"Pin: \" + dtmf.digits + \" is incorrect\\n\" );\n"; - $tmp .= " session.streamFile( \"/usr/local/freeswitch/sounds/custom/8000/your_pin_number_is_incorect_goodbye.wav\", mycb, \"dtmf\");\n"; - $tmp .= " session.hangup();\n"; - $tmp .= " }\n"; - $tmp .= "}"; - } - //--- end: pin number ------------------------------------ - + + //Get the list of destinations then build the Hunt Group javascript $tmp = ""; $tmp .= "\n"; + $tmp .= "session.answer();\n"; + $tmp .= "var domain_name = session.getVariable(\"domain_name\");\n"; + $tmp .= "var extension = '".$rowhelper['huntgroupextension']."';\n"; + $tmp .= "var result;\n"; + $tmp .= "var timeoutpin = 7500;\n"; + $tmp .= "\n"; + $tmp .= "var objdate = new Date();\n"; + $tmp .= "var adjusthours = 0; //Adjust Server time that is set to GMT 7 hours\n"; + $tmp .= "var adjustoperator = \"-\"; //+ or -\n"; + $tmp .= "if (adjustoperator == \"-\") {\n"; + $tmp .= "var objdate2 = new Date(objdate.getFullYear(),objdate.getMonth(),objdate.getDate(),(objdate.getHours() - adjusthours),objdate.getMinutes(),objdate.getSeconds());\n"; + $tmp .= "}\n"; + $tmp .= "if (adjustoperator == \"+\") {\n"; + $tmp .= "var objdate2 = new Date(objdate.getFullYear(),objdate.getMonth(),objdate.getDate(),(objdate.getHours() + adjusthours),objdate.getMinutes(),objdate.getSeconds());\n"; + $tmp .= "}\n"; + $tmp .= "var Hours = objdate2.getHours();\n"; + $tmp .= "var Mins = objdate2.getMinutes();\n"; + $tmp .= "var Seconds = objdate2.getSeconds();\n"; + $tmp .= "var Month = objdate2.getMonth() + 1;\n"; + $tmp .= "var Date = objdate2.getDate();\n"; + $tmp .= "var Year = objdate2.getYear()\n"; + $tmp .= "var Day = objdate2.getDay()+1;\n"; + $tmp .= "var exit = false;\n"; + $tmp .= "\n"; $tmp .= " function get_sofia_contact(extension,domain_name, profile){\n"; $tmp .= " if (profile == \"auto\") {\n"; @@ -1229,57 +1398,131 @@ function sync_package_freeswitch_hunt_group() $tmp .= " return sofia_contact;\n"; $tmp .= " }\n"; $tmp .= "\n"; + + $tmp .= "\n"; + $tmp .= " function mycb( session, type, obj, arg ) {\n"; + $tmp .= " try {\n"; + $tmp .= " if ( type == \"dtmf\" ) {\n"; + $tmp .= " console_log( \"info\", \"digit: \"+obj.digit+\"\\n\" );\n"; + $tmp .= " if ( obj.digit == \"#\" ) {\n"; + $tmp .= " //console_log( \"info\", \"detected pound sign.\\n\" );\n"; + $tmp .= " exit = true;\n"; + $tmp .= " return( false );\n"; + $tmp .= " }\n"; + $tmp .= "\n"; + $tmp .= " dtmf.digits += obj.digit;\n"; + $tmp .= "\n"; + $tmp .= " if ( dtmf.digits.length >= digitmaxlength ) {\n"; + $tmp .= " exit = true;\n"; + $tmp .= " return( false );\n"; + $tmp .= " }\n"; + $tmp .= " }\n"; + $tmp .= " } catch (e) {\n"; + $tmp .= " console_log( \"err\", e+\"\\n\" );\n"; + $tmp .= " }\n"; + $tmp .= " return( true );\n"; + $tmp .= " } //end function mycb\n"; + $tmp .= "\n"; + $tmp .= "\n"; - $tmp .= " dialed_extension = session.getVariable(\"dialed_extension\");\n"; - $tmp .= " domain_name = session.getVariable(\"domain_name\");\n"; - $tmp .= " domain = session.getVariable(\"domain\");\n"; - $tmp .= " us_ring = session.getVariable(\"us-ring\");\n"; - $tmp .= " caller_id_name = session.getVariable(\"caller_id_name\");\n"; - $tmp .= " caller_id_number = session.getVariable(\"caller_id_number\");\n"; - $tmp .= " effective_caller_id_name = session.getVariable(\"effective_caller_id_name\");\n"; - $tmp .= " effective_caller_id_number = session.getVariable(\"effective_caller_id_number\");\n"; - $tmp .= " outbound_caller_id_name = session.getVariable(\"outbound_caller_id_name\");\n"; - $tmp .= " outbound_caller_id_number = session.getVariable(\"outbound_caller_id_number\");\n"; + $tmp .= "dialed_extension = session.getVariable(\"dialed_extension\");\n"; + $tmp .= "domain_name = session.getVariable(\"domain_name\");\n"; + $tmp .= "domain = session.getVariable(\"domain\");\n"; + $tmp .= "us_ring = session.getVariable(\"us-ring\");\n"; + $tmp .= "caller_id_name = session.getVariable(\"caller_id_name\");\n"; + $tmp .= "caller_id_number = session.getVariable(\"caller_id_number\");\n"; + $tmp .= "effective_caller_id_name = session.getVariable(\"effective_caller_id_name\");\n"; + $tmp .= "effective_caller_id_number = session.getVariable(\"effective_caller_id_number\");\n"; + $tmp .= "outbound_caller_id_name = session.getVariable(\"outbound_caller_id_name\");\n"; + $tmp .= "outbound_caller_id_number = session.getVariable(\"outbound_caller_id_number\");\n"; $tmp .= "\n"; + + //pin number requested from caller if provided + if (strlen($rowhelper['huntgrouppin']) > 0) { + $tmp .= "var pin = '".$rowhelper['huntgrouppin']."';\n"; + $tmp .= "if (pin.length > 0) {\n"; + $tmp .= " var dtmf = new Object();\n"; + $tmp .= " dtmf.digits = \"\";\n"; + $tmp .= " digitmaxlength = 6;\n"; + $tmp .= " session.execute(\"set\", \"playback_terminators=#\");\n"; + $tmp .= " session.streamFile( \"/usr/local/freeswitch/sounds/custom/8000/please_enter_the_pin_number.wav\", mycb, \"dtmf\");\n"; + $tmp .= " session.collectInput( mycb, dtmf, timeoutpin );\n"; + $tmp .= "\n"; + $tmp .= " if (dtmf.digits == pin || pin.length == 0) {\n"; + $tmp .= " //continue\n"; + $tmp .= " }\n"; + $tmp .= " else {\n"; + $tmp .= " console_log( \"info\", \"Pin: \" + dtmf.digits + \" is incorrect\\n\" );\n"; + $tmp .= " session.streamFile( \"/usr/local/freeswitch/sounds/custom/8000/your_pin_number_is_incorect_goodbye.wav\", mycb, \"dtmf\");\n"; + $tmp .= " session.hangup();\n"; + $tmp .= " }\n"; + $tmp .= "}\n"; + $tmp .= "\n"; + } + + //caller announce requested from caller if provided + if ($rowhelper['huntgroupcallerannounce'] == "true") { + $tmp .= "function originate(session, sipuri, extension, caller_announce, caller_id_name, caller_id_number) {\n"; + $tmp .= " caller_id_name = caller_id_name.replace(\" \", \"+\");\n"; + $tmp .= " apiExecute(\"jsrun\", \"originate.js \"+session.uuid+\" \"+sipuri+\" \"+extension+\" \"+caller_announce+\" \"+caller_id_name+\" \"+caller_id_number);\n"; + $tmp .= "}"; + $tmp .= "\n"; + $tmp .= "var caller_announce = extension+\"_\"+Year+Month+Day+Hours+Mins+Seconds+\".wav\";\n"; + $tmp .= "session.streamFile( \"/usr/local/freeswitch/sounds/custom/8000/please_say_your_name_and_reason_for_calling.wav\");\n"; + $tmp .= "session.execute(\"gentones\", \"%(1000, 0, 640)\");\n"; + $tmp .= "session.execute(\"set\", \"playback_terminators=#\");\n"; + $tmp .= "session.execute(\"record\", \"/tmp/\"+caller_announce+\" 180 200\");\n"; + $tmp .= "\n"; + $tmp .= "result = session.setAutoHangup(false);\n"; + $tmp .= "session.execute(\"transfer\", \"*\"+extension+\" XML default\");\n"; + $tmp .= "\n"; + } + //set caller id prefix - if (strlen($rowhelper['huntgroupcidnameprefix'])> 0) { - $tmp .= "session.execute(\"set\", \"caller_id_name=".$rowhelper['huntgroupcidnameprefix']."\"+caller_id_name);\n"; - $tmp .= "session.execute(\"set\", \"effective_caller_id_name=".$rowhelper['huntgroupcidnameprefix']."\"+effective_caller_id_name);\n"; - $tmp .= "session.execute(\"set\", \"outbound_caller_id_name=".$rowhelper['huntgroupcidnameprefix']."\"+outbound_caller_id_name);\n"; - } + if (strlen($rowhelper['huntgroupcidnameprefix'])> 0) { + $tmp .= "session.execute(\"set\", \"caller_id_name=".$rowhelper['huntgroupcidnameprefix']."\"+caller_id_name);\n"; + $tmp .= "session.execute(\"set\", \"effective_caller_id_name=".$rowhelper['huntgroupcidnameprefix']."\"+effective_caller_id_name);\n"; + $tmp .= "session.execute(\"set\", \"outbound_caller_id_name=".$rowhelper['huntgroupcidnameprefix']."\"+outbound_caller_id_name);\n"; + } - if (isset($rowhelper['huntgroupringback'])){ - if ($rowhelper['huntgroupringback'] == "ring"){ - $tmp .= " session.execute(\"set\", \"ringback=\"+us_ring); //set to ringtone\n"; - $tmp .= " session.execute(\"set\", \"transfer_ringback=\"+us_ring); //set to ringtone\n"; + //set ring back + if (isset($rowhelper['huntgroupringback'])){ + if ($rowhelper['huntgroupringback'] == "ring"){ + $tmp .= "session.execute(\"set\", \"ringback=\"+us_ring); //set to ringtone\n"; + $tmp .= "session.execute(\"set\", \"transfer_ringback=\"+us_ring); //set to ringtone\n"; + } + if ($rowhelper['huntgroupringback'] == "music"){ + $tmp .= "session.execute(\"set\", \"ringback=\${hold_music}\"); //set to ringtone\n"; + $tmp .= "session.execute(\"set\", \"transfer_ringback=\${hold_music}\"); //set to ringtone\n"; + } } - if ($rowhelper['huntgroupringback'] == "music"){ - $tmp .= " session.execute(\"set\", \"ringback=\${hold_music}\"); //set to ringtone\n"; - $tmp .= " session.execute(\"set\", \"transfer_ringback=\${hold_music}\"); //set to ringtone\n"; + else { + $tmp .= "session.execute(\"set\", \"ringback=\${hold_music}\"); //set to ringtone\n"; + $tmp .= "session.execute(\"set\", \"transfer_ringback=\${hold_music}\"); //set to ringtone\n"; } - } - else { - $tmp .= " session.execute(\"set\", \"ringback=\${hold_music}\"); //set to ringtone\n"; - $tmp .= " session.execute(\"set\", \"transfer_ringback=\${hold_music}\"); //set to ringtone\n"; - } if ($rowhelper['huntgrouptimeout'] > 0) { - $tmp .= " session.execute(\"set\", \"call_timeout=".$rowhelper['huntgrouptimeout']."\");\n"; - $tmp .= " session.execute(\"set\", \"continue_on_fail=true\");\n"; + $tmp .= "session.execute(\"set\", \"call_timeout=".$rowhelper['huntgrouptimeout']."\");\n"; + $tmp .= "session.execute(\"set\", \"continue_on_fail=true\");\n"; } - $tmp .= " session.execute(\"set\", \"hangup_after_bridge=true\");\n"; + $tmp .= "session.execute(\"set\", \"hangup_after_bridge=true\");\n"; $tmp .= "\n"; - $tmp .= " //console_log( \"info\", \"dialed extension:\"+dialed_extension+\".\\n\" );\n"; - $tmp .= " //console_log( \"info\", \"domain: \"+domain+\".\\n\" );\n"; - $tmp .= " //console_log( \"info\", \"us_ring: \"+us_ring+\".\\n\" );\n"; - $tmp .= " //console_log( \"info\", \"domain: \"+domain+\".\\n\" );\n"; - $tmp .= " //console_log( \"info\", \"domain_name: \"+domain_name+\".\\n\" );\n"; + $tmp .= "//console_log( \"info\", \"dialed extension:\"+dialed_extension+\".\\n\" );\n"; + $tmp .= "//console_log( \"info\", \"domain: \"+domain+\".\\n\" );\n"; + $tmp .= "//console_log( \"info\", \"us_ring: \"+us_ring+\".\\n\" );\n"; + $tmp .= "//console_log( \"info\", \"domain: \"+domain+\".\\n\" );\n"; + $tmp .= "//console_log( \"info\", \"domain_name: \"+domain_name+\".\\n\" );\n"; $tmp .= "\n"; - $tmp .= " //console_log( \"info\", \"action call now don't wait for dtmf\\n\" );\n"; - $tmp .= " if ( session.ready() ) {\n"; - $tmp .= " session.answer();\n"; + $tmp .= "//console_log( \"info\", \"action call now don't wait for dtmf\\n\" );\n"; + if ($rowhelper['huntgroupcallerannounce'] == "true") { + //do nothing + } + else { + $tmp .= "if ( session.ready() ) {\n"; + $tmp .= " session.answer();\n"; + } $tmp .= "\n"; $a_hunt_group = &$config['installedpackages']['freeswitchhuntgroup']['config']; @@ -1323,20 +1566,21 @@ function sync_package_freeswitch_hunt_group() if (strlen($row['destinationnumber']) == 0) { $row['destinationnumber'] = "internal"; } if ($row['destinationtype'] == "extension") { - $tmp .= " sofia_contact_".$row['destinationnumber']." = get_sofia_contact(\"".$row['destinationnumber']."\",domain_name, \"".$row['destinationprofile']."\");\n"; + $tmp .= "sofia_contact_".$row['destinationnumber']." = get_sofia_contact(\"".$row['destinationnumber']."\",domain_name, \"".$row['destinationprofile']."\");\n"; $tmp_sub_array["application"] = "bridge"; $tmp_sub_array["data"] = "sofia_contact_".$row['destinationnumber']; $tmp_array[$i] = $tmp_sub_array; - unset($tmp_sub_array); + unset($tmp_sub_array); } - if ($row['destinationtype'] == "voicemail") { - $tmp .= " session.execute(\"voicemail\", \"default \${domain} ".$row['destinationnumber']."\");\n"; + if ($row['destinationtype'] == "voicemail") { + $tmp_sub_array["application"] = "voicemail"; + $tmp .= "session.execute(\"voicemail\", \"default \${domain} ".$row['destinationnumber']."\");\n"; //$tmp_sub_array["application"] = "voicemail"; //$tmp_sub_array["data"] = "default \${domain} ".$row['destinationnumber']; //$tmp_array[$i] = $tmp_sub_array; unset($tmp_sub_array); } - if ($row['destinationtype'] == "sip uri") { + if ($row['destinationtype'] == "sip uri") { $tmp_sub_array["application"] = "bridge"; $tmp_sub_array["data"] = "\"".$row['destinationnumber']."\""; $tmp_array[$i] = $tmp_sub_array; @@ -1350,43 +1594,65 @@ function sync_package_freeswitch_hunt_group() unset($i); } //if count - + $i = 0; + if(count($tmp_array) > 0) { + foreach ($tmp_array as $row) { + $tmpdata = $row["data"]; + if ($row["application"] == "voicemail") { $tmpdata = "***".$tmpdata; } + if ($i < 1) { + $tmp_buffer = $tmpdata; + } + else { + $tmp_buffer .= "+\",\"+".$tmpdata; + } + $i++; + } + } + unset($i); + $delimiter = ","; + $tmp_application = $tmp_array[0]["application"]; switch ($rowhelper['huntgrouptype']) { case "simultaneous": //print_r($tmp_array); - $i = 0; - if(count($tmp_array) > 0) { - foreach ($tmp_array as $row) { - if ($i < 1) { - $tmp_buffer = $row["data"]; - } - else { - $tmp_buffer .= "+\",\"+".$row["data"]; + if ($rowhelper['huntgroupcallerannounce'] == "true") { + $i = 0; + if (count($tmp_array) > 0) { + foreach ($tmp_array as $row) { + $tmpdata = $row["data"]; + if ($row["application"] == "voicemail") { $tmpdata = "***".$tmpdata; } + $tmp .= " result = originate (session, ".$tmpdata.", extension, caller_announce, caller_id_name, caller_id_number);\n"; } - $i++; } } - unset($i); - - $delimiter = ","; - $tmp_application = $tmp_array[0]["application"]; + else { + $tmp .= "\n"; + $tmp .= " session.execute(\"".$tmp_application."\", $tmp_buffer);\n"; + //$tmp .= " session.execute(\"bridge\", sofia_contact_100+\",\"+sofia_contact_101+\",\"+sofia_contact_102+\",\"+sofia_contact_103+\",\"+sofia_contact_104);\n"; + //$tmp .= " //session.execute(\"bridge\", \"sofia/gateway/flowroute.com/12081231234,\"+sofia_contact_101);\n"; + } unset($tmp_array); - - $tmp .= "\n"; - $tmp .= " session.execute(\"".$tmp_application."\", $tmp_buffer);\n"; - //$tmp .= " session.execute(\"bridge\", sofia_contact_100+\",\"+sofia_contact_101+\",\"+sofia_contact_102+\",\"+sofia_contact_103+\",\"+sofia_contact_104);\n"; - //$tmp .= " //session.execute(\"bridge\", \"sofia/gateway/flowroute.com/12081231234,\"+sofia_contact_101);\n"; - break; case "sequentially": $tmp .= "\n"; //print_r($tmp_array); $i = 0; - if (count($tmp_array) > 0) { - foreach ($tmp_array as $row) { - $tmp .= " session.execute(\"".$row["application"]."\", ".$row["data"].");\n"; + if (count($tmp_array) > 0) { + if ($rowhelper['huntgroupcallerannounce'] == "true") { + $i = 0; + if (count($tmp_array) > 0) { + //foreach ($tmp_array as $row) { + //$tmpdata = $row["data"]; + //if ($row["application"] == "voicemail") { $tmpdata = "***".$tmpdata; } + $tmp .= " result = originate (session, ".$tmp_buffer.", extension, caller_announce, caller_id_name, caller_id_number);\n"; + //} + } + } + else { + foreach ($tmp_array as $row) { + $tmp .= " session.execute(\"".$row["application"]."\", ".$row["data"].");\n"; + } } unset($tmp_array); } @@ -1394,7 +1660,6 @@ function sync_package_freeswitch_hunt_group() break; } - //set the timeout destination $huntgrouptimeoutdestination = $a_hunt_group[$x]['huntgrouptimeoutdestination']; $huntgrouptimeouttype = $a_hunt_group[$x]['huntgrouptimeouttype']; @@ -1402,19 +1667,28 @@ function sync_package_freeswitch_hunt_group() if ($row['huntgrouptimeouttype'] == "voicemail") { $huntgrouptimeouttype = "voicemail"; } if ($row['huntgrouptimeouttype'] == "sip uri") { $huntgrouptimeouttype = "bridge"; } $tmp .= "\n"; - $tmp .= " //timeout\n"; - $tmp .= " session.execute(\"".$huntgrouptimeouttype."\", \"default \${domain} ".$huntgrouptimeoutdestination."\");\n"; - + if ($rowhelper['huntgroupcallerannounce'] == "true") { + //do nothing + } + else { + $tmp .= " //timeout\n"; + $tmp .= " session.execute(\"".$huntgrouptimeouttype."\", \"default \${domain} ".$huntgrouptimeoutdestination."\");\n"; + } $tmp .= "\n"; - $tmp .= " //clear variables\n"; - $tmp .= " dialed_extension = \"\";\n"; - $tmp .= " new_extension = \"\";\n"; - $tmp .= " domain_name = \"\";\n"; - $tmp .= " domain = \"\";"; + $tmp .= " //clear variables\n"; + $tmp .= " dialed_extension = \"\";\n"; + $tmp .= " new_extension = \"\";\n"; + $tmp .= " domain_name = \"\";\n"; + $tmp .= " domain = \"\";"; $tmp .= "\n"; - $tmp .= " } //end if session.ready\n"; + if ($rowhelper['huntgroupcallerannounce'] == "true") { + //do nothing + } + else { + $tmp .= "} //end if session.ready\n"; + } $tmp .= "\n"; if (strlen($rowhelper['huntgroupid']) > 0) { @@ -2748,7 +3022,7 @@ function freeswitch_php_install_command() global $config; //exec("/etc/./rc.conf_mount_rw"); - $freeswitch_package_version = "0.9.4.8"; + $freeswitch_package_version = "0.9.5"; $freeswitch_build_version = "1.0.4 pre 8"; $freeswitch_build_revision = "13784"; @@ -2825,7 +3099,9 @@ function freeswitch_php_install_command() exec("cd /usr/local/freeswitch/sounds/custom/8000/;fetch ".$download_path."call_forward_has_been_set.wav"); exec("cd /usr/local/freeswitch/sounds/custom/8000/;fetch ".$download_path."call_forward_has_been_deleted.wav"); exec("cd /usr/local/freeswitch/sounds/custom/8000/;fetch ".$download_path."begin_recording.wav"); - exec("cd /usr/local/freeswitch/sounds/custom/8000/;fetch ".$download_path."your_pin_number_is_incorect_goodbye.wav"); + exec("cd /usr/local/freeswitch/sounds/custom/8000/;fetch ".$download_path."your_pin_number_is_incorect_goodbye.wav"); + exec("cd /usr/local/freeswitch/sounds/custom/8000/;fetch ".$download_path."please_say_your_name_and_reason_for_calling.wav"); + exec("cd /usr/local/freeswitch/sounds/custom/8000/;fetch ".$download_path."press_1_to_accept_2_to_reject_or_3_for_voicemail.wav"); //mod_fax exec("cd /usr/local/freeswitch/mod/;fetch ".$download_path."mod_fax.so"); @@ -2854,7 +3130,12 @@ function freeswitch_php_install_command() unlink_if_exists("/tmp/edit_area.tgz"); } + //rename PHP files from .tmp to .php + exec("cd /tmp/;fetch ".$download_path."index.tmp"); + exec("cp /tmp/index.tmp /usr/local/www/packages/freeswitch/index.php"); + unlink_if_exists("/tmp/index.tmp"); + exec("cd /tmp/;fetch ".$download_path."class.smtp.tmp"); exec("cp /tmp/class.smtp.tmp /usr/local/www/packages/freeswitch/class.smtp.php"); unlink_if_exists("/tmp/class.smtp.tmp"); @@ -3012,6 +3293,7 @@ function freeswitch_php_install_command() unlink_if_exists("/tmp/freeswitch_vars.tmp"); exec("cd /usr/local/freeswitch/scripts/;fetch ".$download_path."disa.js"); + exec("cd /usr/local/freeswitch/scripts/;fetch ".$download_path."originate.js"); exec("cp /usr/local/freeswitch/htdocs/slim.swf /usr/local/www/packages/freeswitch/slim.swf"); /* freeswitch settings defaults */ |