Changeset 3254

Show
Ignore:
Timestamp:
12/02/06 00:26:50 (5 years ago)
Author:
p_lindheimer
Message:

add the ability to set the moh class for outbound routes as well as for inbound routes and direct did routes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/trunk/SQL/newinstall.sql

    r3221 r3254  
    262262  `alertinfo` varchar(32) default NULL, 
    263263  `channel` varchar(20) default NULL, 
    264   `ringing` varchar(20) default NULL 
     264  `ringing` varchar(20) default NULL, 
     265  `mohclass` varchar(80) NOT NULL default 'default' 
    265266) ENGINE=MyISAM; 
    266267 
     
    365366  `answer` tinyint(1) default NULL, 
    366367  `wait` int(2) default NULL, 
    367   `privacyman` tinyint(1) default NULL 
     368  `privacyman` tinyint(1) default NULL, 
     369  `mohclass` varchar(80) NOT NULL default 'default' 
    368370) ENGINE=MyISAM; 
    369371 
  • freepbx/trunk/SQL/newinstall.sqlite.sql

    r3066 r3254  
    185185CREATE TABLE devices (id VARCHAR( 20 ) NOT NULL , tech VARCHAR( 10 ) NOT NULL , dial VARCHAR( 50 ) NOT NULL , devicetype VARCHAR( 5 ) NOT NULL , user VARCHAR( 50 ) , description VARCHAR( 50 ), emergency_cid VARCHAR( 100 )); 
    186186 
    187 CREATE TABLE IF NOT EXISTS users (extension VARCHAR( 20 ) NOT NULL , password VARCHAR( 20 ) , name VARCHAR( 50 ) , voicemail VARCHAR( 50 ) , ringtimer INT(3) , noanswer VARCHAR( 100 ) , recording VARCHAR( 50 ) ,  outboundcid VARCHAR( 50 ) , directdid VARCHAR( 50 ) NULL, didalert VARCHAR ( 50 ) NULL,  faxexten VARCHAR( 20 ) , faxemail VARCHAR( 50 ) , answer TINYINT( 1 ) , wait INT( 2 ) , privacyman TINYINT( 1 ) ); 
     187CREATE TABLE IF NOT EXISTS users (extension VARCHAR( 20 ) NOT NULL , password VARCHAR( 20 ) , name VARCHAR( 50 ) , voicemail VARCHAR( 50 ) , ringtimer INT(3) , noanswer VARCHAR( 100 ) , recording VARCHAR( 50 ) ,  outboundcid VARCHAR( 50 ) , directdid VARCHAR( 50 ) NULL, didalert VARCHAR ( 50 ) NULL,  faxexten VARCHAR( 20 ) , faxemail VARCHAR( 50 ) , answer TINYINT( 1 ) , wait INT( 2 ) , privacyman TINYINT( 1 ) , mohclass varchar(80) NOT NULL default 'default'); 
    188188 
    189189 
     
    191191-- Need to incorporate their changes, comment out for now 
    192192-- 
    193 CREATE TABLE incoming ( cidnum VARCHAR( 20 ) , extension VARCHAR( 20 ) , destination VARCHAR( 50 ) , faxexten VARCHAR( 20 ) , faxemail VARCHAR( 50 ) , answer TINYINT( 1 ) , wait INT( 2 ) , privacyman TINYINT( 1 ) , alertinfo VARCHAR( 32 ) , channel VARCHAR( 20 )); 
     193CREATE TABLE incoming ( cidnum VARCHAR( 20 ) , extension VARCHAR( 20 ) , destination VARCHAR( 50 ) , faxexten VARCHAR( 20 ) , faxemail VARCHAR( 50 ) , answer TINYINT( 1 ) , wait INT( 2 ) , privacyman TINYINT( 1 ) , alertinfo VARCHAR( 32 ) , channel VARCHAR( 20 ) , mohclass varchar(80) NOT NULL default 'default'); 
    194194-- 
    195195-- 
  • freepbx/trunk/amp_conf/astetc/extensions.conf

    r3249 r3254  
    372372exten => s,n,Set(OUTNUM=${OUTPREFIX_${DIAL_TRUNK}}${DIAL_NUMBER}) ; OUTNUM is the final dial number 
    373373exten => s,n,Set(custom=${CUT(OUT_${DIAL_TRUNK},:,1)}) ; Custom trunks are prefixed with "AMP:" 
    374 exten => s,n,GotoIf($["${custom}" = "AMP"]?customtrunk) 
     374 
     375; Back to normal processing, whether intracompany or not. 
     376; But add the macro-setmusic if we don't want music on this outbound call 
     377
     378exten => s,n,GotoIf($[$["${MOHCLASS}" = "default"] | $["foo${MOHCLASS}" = "foo"]]?gocall) ; Set to YES if we should pump silence 
     379exten => s,n,Set(DIAL_TRUNK_OPTIONS=M(setmusic^${MOHCLASS})${DIAL_TRUNK_OPTIONS})   ; set MoH or off 
     380 
     381exten => s,n(gocall),GotoIf($["${custom}" = "AMP"]?customtrunk) 
    375382exten => s,n,Dial(${OUT_${DIAL_TRUNK}}/${OUTNUM},300,${DIAL_TRUNK_OPTIONS}) ; Regular Trunk Dial 
    376383exten => s,n,Goto(s-${DIALSTATUS},1) 
     
    872879exten => s,n,Goto(from-pstn,${DID},1) 
    873880 
     881;------------------------------------------------------------------------ 
     882; [macro-setmusic] 
     883;------------------------------------------------------------------------ 
     884; CONTEXT:      macro-setmusic 
     885; PURPOSE:      to turn off moh on routes where it is not desired 
     886; 
     887;------------------------------------------------------------------------ 
     888[macro-setmusic] 
     889exten => s,1,NoOp(Setting Outbound Route MoH To: ${ARG1}) 
     890exten => s,2,SetMusicOnHold(${ARG1}) 
     891;------------------------------------------------------------------------ 
     892 
    874893; ########################################## 
    875894; ## Ring Groups with Confirmation macros ## 
  • freepbx/trunk/amp_conf/htdocs/admin/modules/core/functions.inc.php

    r3235 r3254  
    191191          // extensions_custom.conf 
    192192          $ext->add($context, $exten, '', new ext_setvar('FROM_DID',$exten)); 
     193 
     194          if (!empty($item['mohclass']) && trim($item['mohclass']) != 'default') { 
     195              $ext->add($context, $exten, '', new ext_setmusiconhold($item['mohclass'])); 
     196          } 
    193197 
    194198          // If we require RINGING, signal it as soon as we enter. 
     
    299303          $ext->add($context, $exten, '', new ext_setvar('FROM_DID',$exten)); 
    300304 
     305          if (!empty($item['mohclass']) && trim($item['mohclass']) != 'default') { 
     306            $ext->add($context, $exten, '', new ext_setmusiconhold($item['mohclass'])); 
     307          } 
    301308           
    302309          if ($item['faxexten'] != "default") { 
     
    381388          if(strpos($exten['args'],"INTRACOMPANYROUTE") !== false) 
    382389            $ext->add($outrt['application'], $exten['extension'], '', new ext_setvar("INTRACOMPANYROUTE",substr($exten['args'],18))); 
     390          if(strpos($exten['args'],"MOHCLASS") !== false) 
     391            $ext->add($outrt['application'], $exten['extension'], '', new ext_setvar("MOHCLASS",substr($exten['args'],9))); 
    383392          if(strpos($exten['args'],"dialout-trunk") !== false) 
    384393            $ext->add($outrt['application'], $exten['extension'], '', new ext_macro($exten['args'])); 
     
    486495  if (empty($existing)) { 
    487496    $destination=${$goto_indicate0.'0'}; 
    488     $sql="INSERT INTO incoming (cidnum,extension,destination,faxexten,faxemail,answer,wait,privacyman,alertinfo, channel, ringing) values ('$cidnum','$extension','$destination','$faxexten','$faxemail','$answer','$wait','$privacyman','$alertinfo', '$channel', '$ringing')"; 
     497    $sql="INSERT INTO incoming (cidnum,extension,destination,faxexten,faxemail,answer,wait,privacyman,alertinfo, channel, ringing, mohclass) values ('$cidnum','$extension','$destination','$faxexten','$faxemail','$answer','$wait','$privacyman','$alertinfo', '$channel', '$ringing', '$mohclass')"; 
    489498    sql($sql); 
    490499  } else { 
     
    11051114   
    11061115  //insert into users table 
    1107   $sql="INSERT INTO users (extension,password,name,voicemail,ringtimer,noanswer,recording,outboundcid,directdid,didalert,faxexten,faxemail,answer,wait,privacyman) values (\""; 
     1116  $sql="INSERT INTO users (extension,password,name,voicemail,ringtimer,noanswer,recording,outboundcid,directdid,didalert,faxexten,faxemail,answer,wait,privacyman,mohclass) values (\""; 
    11081117  $sql.= "$extension\", \""; 
    11091118  $sql.= isset($password)?$password:''; 
     
    11351144  $sql.= "\", \""; 
    11361145  $sql.= isset($privacyman)?$privacyman:''; 
    1137  
     1146  $sql.= "\", \""; 
     1147        $sql.= isset($mohclass)?$mohclass:''; 
    11381148  $sql.= "\")"; 
    11391149  sql($sql); 
     
    12441254 
    12451255function core_directdid_list(){ 
    1246   $sql = "SELECT extension, directdid, didalert, faxexten, faxemail, answer, wait, privacyman FROM users WHERE directdid IS NOT NULL AND directdid != ''"; 
     1256  $sql = "SELECT extension, directdid, didalert, mohclass, faxexten, faxemail, answer, wait, privacyman FROM users WHERE directdid IS NOT NULL AND directdid != ''"; 
    12471257  return sql($sql,"getAll",DB_FETCHMODE_ASSOC); 
    12481258} 
     
    18301840 
    18311841 
    1832 function core_routing_add($name, $patterns, $trunks, $method, $pass, $emergency = "", $intracompany = "") { 
     1842function core_routing_add($name, $patterns, $trunks, $method, $pass, $emergency = "", $intracompany = "", $mohsilence = "") { 
     1843 
    18331844  global $db; 
    18341845 
     
    19111922    } 
    19121923 
     1924    // Next Priority (either first, second or third depending on above) 
     1925    if(!empty($mohsilence) && trim($mohsilence) != 'default') { 
     1926         $startpriority += 1; 
     1927         $sql = "INSERT INTO extensions (context, extension, priority, application, args, descr) VALUES "; 
     1928         $sql .= "('outrt-".$name."', "; 
     1929         $sql .= "'".$pattern."', "; 
     1930         $sql .= "'".$startpriority."', "; 
     1931         $sql .= "'SetVar', "; 
     1932         $sql .= "'MOHCLASS=".$mohsilence."', "; 
     1933         $sql .= "'Do not play moh on this route')"; 
     1934         $result = $db->query($sql); 
     1935        if(DB::IsError($result)) { 
     1936             die($result->getMessage()); 
     1937        } 
     1938    } 
     1939 
    19131940    $first_trunk = 1; 
    19141941    foreach ($trunks as $priority => $trunk) { 
     
    19922019} 
    19932020 
    1994 function core_routing_edit($name, $patterns, $trunks, $pass, $emergency="", $intracompany = "") { 
     2021function core_routing_edit($name, $patterns, $trunks, $pass, $emergency="", $intracompany = "", $mohsilence="") { 
    19952022  core_routing_del($name); 
    1996   core_routing_add($name, $patterns, $trunks,"edit", $pass, $emergency, $intracompany); 
     2023  core_routing_add($name, $patterns, $trunks,"edit", $pass, $emergency, $intracompany, $mohsilence); 
    19972024} 
    19982025 
     
    21452172       } 
    21462173       return $intracompany; 
     2174} 
     2175 
     2176//get mohsilence routing status for this route 
     2177function core_routing_getroutemohsilence($route) { 
     2178 
     2179       global $db; 
     2180       $sql = "SELECT DISTINCT args FROM extensions WHERE context = 'outrt-".$route."' AND (args LIKE 'MOHCLASS%') "; 
     2181       $results = $db->getOne($sql); 
     2182       if(DB::IsError($results)) { 
     2183               die($results->getMessage()); 
     2184       } 
     2185       if (preg_match('/^.*=(.*)/', $results, $matches)) { 
     2186               $mohsilence = $matches[1]; 
     2187       } else { 
     2188               $mohsilence = ""; 
     2189       } 
     2190       return $mohsilence; 
    21472191} 
    21482192 
     
    22392283    $currentcomponent->setoptlistopts('faxdestoptions', 'sort', false); 
    22402284 
     2285    if (function_exists('music_list')) { 
     2286        $tresults = music_list("/var/lib/asterisk/mohmp3"); 
     2287        if (isset($tresults[0])) { 
     2288      foreach ($tresults as $tresult) { 
     2289          $currentcomponent->addoptlistitem('mohclass', $tresult, $tresult); 
     2290      } 
     2291        $currentcomponent->setoptlistopts('mohclass', 'sort', false); 
     2292        } 
     2293    } 
     2294 
    22412295    //get unique devices to finishoff faxdestoptions list 
    22422296    $devices = core_devices_list(); 
     
    22622316  // Ensure variables possibly extracted later exist 
    22632317  $name = $directdid = $didalert = $outboundcid = $answer = null; 
    2264   $record_in = $record_out = $faxexten = $faxemail = null; 
     2318  $record_in = $record_out = $faxexten = $faxemail = $mohclass =  null; 
    22652319 
    22662320  // Init vars from $_REQUEST[] 
     
    23342388    $currentcomponent->addguielem($section, new gui_textbox('directdid', $directdid, 'Direct DID', "The direct DID that is associated with this extension. The DID should be in the same format as provided by the provider (e.g. full number, 4 digits for 10x4, etc).<br><br>Format should be: <b>XXXXXXXXXX</b><br><br>Leave this field blank to disable the direct DID feature for this extension. All non-numeric characters will be stripped."), 3); 
    23352389    $currentcomponent->addguielem($section, new gui_textbox('didalert', $didalert, 'DID Alert Info', "Alert Info can be used for distinctive ring on SIP phones. Set this value to the desired Alert Info to be sent to the phone when this DID is called. Leave blank to use default values. Will have no effect if no Direct DID is set")); 
     2390    if (function_exists('music_list')) { 
     2391        $currentcomponent->addguielem($section, new gui_selectbox('mohclass', $currentcomponent->getoptlist('mohclass'), $mohclass, 'Music on Hold', "Set the MoH class that will be used for calls that come in on this Direct DID. For example, choose a type appropriate for a originating country which may have announcements in their language. Only effects MoH class when the call came in from the Direct DID.", false)); 
     2392    } 
    23362393    $currentcomponent->addguielem($section, new gui_textbox('outboundcid', $outboundcid, 'Outbound CID', "Overrides the caller id when dialing out a trunk. Any setting here will override the common outbound caller id set in the Trunks admin.<br><br>Format: <b>\"caller name\" &lt;#######&gt;</b><br><br>Leave this field blank to disable the outbound callerid feature for this user.", '!isCallerID()', $msgInvalidOutboundCID, true)); 
    23372394 
  • freepbx/trunk/amp_conf/htdocs/admin/modules/core/page.did.php

    r3205 r3254  
    126126if (!isset($alertinfo)) 
    127127  $alertinfo = 0; 
     128if (!isset($mohclass)) 
     129  $mohclass = 'default'; 
    128130?> 
    129131          <option value="default" <?php  echo ($faxexten == 'default' ? 'SELECTED' : '')?>><?php echo _("freePBX default")?> 
     
    193195      <td><input type="text" name="alertinfo" size="10" value="<?php echo ($alertinfo)?$alertinfo:'' ?>"></td> 
    194196    </tr> 
     197<?php   if (function_exists('music_list')) { ?> 
     198    <tr> 
     199      <td><a href="#" class="info"><?php echo _("Music On Hold?")?><span><?php echo _("Set the MoH class that will be used for calls that come in on this route. For example, choose a type appropriate for routes coming in from a country which may have announcements in their language.")?></span></a></td> 
     200      <td> 
     201        &nbsp;&nbsp;<select name="mohclass"/> 
     202        <?php 
     203          $tresults = music_list("/var/lib/asterisk/mohmp3"); 
     204          $cur = (isset($mohclass) && $mohclass != "" ? $mohclass : 'default'); 
     205          echo '<option value="none">'._("No Music")."</option>"; 
     206          if (isset($tresults[0])) { 
     207            foreach ($tresults as $tresult) { 
     208              echo '<option value="'.$tresult.'"'.($tresult == $cur ? ' SELECTED' : '').'>'.$tresult."</option>\n"; 
     209            } 
     210          } 
     211        ?>     
     212        </select>    
     213      </td> 
     214    </tr> 
     215<?php } ?> 
    195216    <tr> 
    196217      <td><a href="#" class="info"><?php echo _("Signal RINGING")?><span><?php echo _('Some devices or providers require RINGING to be sent before ANSWER. You\'ll notice this happening if you can send calls directly to a phone, but if you send it to an IVR, it won\'t connect the call.')?></span></a>:</td> 
  • freepbx/trunk/amp_conf/htdocs/admin/modules/core/page.routing.php

    r3205 r3254  
    8686$emergency = isset($_REQUEST["emergency"]) ? $_REQUEST["emergency"] : ""; 
    8787$intracompany = isset($_REQUEST["intracompany"]) ? $_REQUEST["intracompany"] : ""; 
     88$mohsilence = isset($_REQUEST["mohsilence"]) ? $_REQUEST["mohsilence"] : ""; 
    8889 
    8990//if submitting form, update database 
    9091switch ($action) { 
    9192  case "addroute": 
    92     core_routing_add($routename, $dialpattern, $trunkpriority,"new", $routepass, $emergency, $intracompany); 
     93    core_routing_add($routename, $dialpattern, $trunkpriority,"new", $routepass, $emergency, $intracompany, $mohsilence); 
    9394    needreload(); 
    9495    redirect_standard(); 
    9596  break; 
    9697  case "editroute": 
    97     core_routing_edit($routename, $dialpattern, $trunkpriority, $routepass, $emergency, $intracompany); 
     98    core_routing_edit($routename, $dialpattern, $trunkpriority, $routepass, $emergency, $intracompany, $mohsilence); 
    9899    needreload(); 
    99100    redirect_standard('extdisplay'); 
     
    253254    $intracompany = core_routing_getrouteintracompany($extdisplay); 
    254255  } 
     256 
     257  if (!isset($_REQUEST["mohsilence"])) { 
     258    $mohsilence = core_routing_getroutemohsilence($extdisplay); 
     259  } 
    255260   
    256261  echo "<h2>"._("Edit Route")."</h2>"; 
     
    320325      <td><input type="checkbox" name="intracompany" value="yes" <?php echo ($intracompany ? "CHECKED" : "") ?> /></td> 
    321326    </tr> 
     327<?php   if (function_exists('music_list')) { ?> 
     328    <tr> 
     329      <td><a href="#" class="info"><?php echo _("Music On Hold?")?><span><?php echo _("You can choose to disable Music on Hold for this route. This is useful for know conference bridge lines or other calls where you don't want to broadcast music when you put a call on hold. You can alternatively choose which music category to use. For example, choose a type appropriate for a destination country which may have announcements in the appropriate language.")?></span></a></td> 
     330      <td> 
     331        &nbsp;&nbsp;<select name="mohsilence"/> 
     332        <?php 
     333          $tresults = music_list("/var/lib/asterisk/mohmp3"); 
     334          $cur = (isset($mohsilence) && $mohsilence != "" ? $mohsilence : 'default'); 
     335          if (isset($tresults[0])) { 
     336            foreach ($tresults as $tresult) { 
     337              echo '<option value="'.$tresult.'"'.($tresult == $cur ? ' SELECTED' : '').'>'.$tresult."</option>\n"; 
     338            } 
     339          } 
     340        ?>     
     341        </select>    
     342      </td> 
     343    </tr> 
     344<?php } ?> 
    322345    <tr> 
    323346      <td colspan="2">