Ticket #2543: functions.inc.php.diff

File functions.inc.php.diff, 8.0 kB (added by prolfe, 4 years ago)
  • functions.inc.php

    old new  
    324324          $ext->add($context, 'fax', '', new ext_goto('1','in_fax','ext-fax')); 
    325325        } 
    326326        foreach($directdidlist as $item) { 
    327           $exten = $item['directdid']; 
    328           $ext->add($context, $exten, '', new ext_setvar('__FROM_DID','${EXTEN}')); 
    329           // always set callerID name 
    330           $ext->add($context, $exten, '', new ext_gotoif('$[ "${CALLERID(name)}" != "" ] ','cidok')); 
    331           $ext->add($context, $exten, '', new ext_setvar('CALLERID(name)','${CALLERID(num)}')); 
    332           $ext->add($context, $exten, 'cidok', new ext_noop('CallerID is ${CALLERID(all)}')); 
    333  
    334           if (!empty($item['mohclass']) && trim($item['mohclass']) != 'default') { 
    335             $ext->add($context, $exten, '', new ext_setmusiconhold($item['mohclass'])); 
    336             $ext->add($context, $exten, '', new ext_setvar('__MOHCLASS',$item['mohclass'])); 
    337           } 
     327          $did_string = $item['directdid']; 
     328          $did_list = explode(",",$did_string); 
     329          foreach($did_list as $exten) 
     330          { 
     331            /* $exten = $item['directdid']; */ 
     332            $ext->add($context, $exten, '', new ext_setvar('__FROM_DID','${EXTEN}')); 
     333            // always set callerID name 
     334            $ext->add($context, $exten, '', new ext_gotoif('$[ "${CALLERID(name)}" != "" ] ','cidok')); 
     335            $ext->add($context, $exten, '', new ext_setvar('CALLERID(name)','${CALLERID(num)}')); 
     336            $ext->add($context, $exten, 'cidok', new ext_noop('CallerID is ${CALLERID(all)}')); 
     337 
     338            if (!empty($item['mohclass']) && trim($item['mohclass']) != 'default') { 
     339              $ext->add($context, $exten, '', new ext_setmusiconhold($item['mohclass'])); 
     340              $ext->add($context, $exten, '', new ext_setvar('__MOHCLASS',$item['mohclass'])); 
     341            } 
    338342           
    339           if ($item['faxexten'] != "default") { 
    340             $ext->add($context, $exten, '', new ext_setvar('FAX_RX',$item['faxexten'])); 
    341           } 
    342           if (!empty($item['faxemail'])) { 
    343             $ext->add($context, $exten, '', new ext_setvar('FAX_RX_EMAIL',$item['faxemail'])); 
    344           } 
    345           if ($item['answer'] == "1") { 
    346             $ext->add($context, $exten, '', new ext_answer('')); 
    347             $ext->add($context, $exten, '', new ext_wait($item['wait'])); 
    348           } 
    349           if ($item['answer'] == "2") { // NVFaxDetect 
    350             $ext->add($context, $exten, '', new ext_answer('')); 
    351             $ext->add($context, $exten, '', new ext_playtones('ring')); 
    352             $ext->add($context, $exten, '', new ext_nvfaxdetect($item['wait'])); 
    353           } 
    354           if ($item['privacyman'] == "1") { 
    355             $ext->add($context, $exten, '', new ext_macro('privacy-mgr')); 
    356           } 
    357  
    358  
    359           if (!empty($item['didalert'])) { 
    360             $ext->add($context, $exten, '', new ext_setvar("_ALERT_INFO", str_replace(';', '\;', $item['didalert']))); 
     343            if ($item['faxexten'] != "default") { 
     344              $ext->add($context, $exten, '', new ext_setvar('FAX_RX',$item['faxexten'])); 
     345            } 
     346            if (!empty($item['faxemail'])) { 
     347              $ext->add($context, $exten, '', new ext_setvar('FAX_RX_EMAIL',$item['faxemail'])); 
     348            } 
     349            if ($item['answer'] == "1") { 
     350              $ext->add($context, $exten, '', new ext_answer('')); 
     351              $ext->add($context, $exten, '', new ext_wait($item['wait'])); 
     352            } 
     353            if ($item['answer'] == "2") { // NVFaxDetect 
     354              $ext->add($context, $exten, '', new ext_answer('')); 
     355              $ext->add($context, $exten, '', new ext_playtones('ring')); 
     356              $ext->add($context, $exten, '', new ext_nvfaxdetect($item['wait'])); 
     357            } 
     358            if ($item['privacyman'] == "1") { 
     359              $ext->add($context, $exten, '', new ext_macro('privacy-mgr')); 
     360            } 
     361             
     362             
     363            if (!empty($item['didalert'])) { 
     364              $ext->add($context, $exten, '', new ext_setvar("_ALERT_INFO", str_replace(';', '\;', $item['didalert']))); 
     365            } 
     366            $goto_context = 'from-did-direct'; 
     367            $goto_exten = $item['extension']; 
     368            $goto_pri = 1; 
     369            $ext->add($context, $exten, '', new ext_goto($goto_pri,$goto_exten,$goto_context)); 
    361370          } 
    362           $goto_context = 'from-did-direct'; 
    363           $goto_exten = $item['extension']; 
    364           $goto_pri = 1; 
    365           $ext->add($context, $exten, '', new ext_goto($goto_pri,$goto_exten,$goto_context)); 
    366  
    367371        } 
    368372      } 
    369373 
     
    13401344 
    13411345  // clean and check the did to make sure it is not being used by another extension or in did routing 
    13421346  // 
    1343   $directdid = preg_replace("/[^0-9._XxNnZz\[\]\-\+]/" ,"", trim($directdid)); 
     1347  $directdid = preg_replace("/[^0-9._XxNnZz\[\]\-\+,]/" ,"", trim($directdid)); 
     1348  $final_did = array(); 
     1349   
    13441350  if (trim($directdid) != "") { 
    1345     $existing=core_did_get($directdid,"",""); 
    1346     $existing_directdid = empty($existing)?core_users_directdid_get($directdid):$existing; 
    1347     if (!empty($existing) || !empty($existing_directdid)) { 
    1348       if (!empty($existing)) { 
    1349         echo "<script>javascript:alert('"._("A route with this DID already exists:")." ".$existing['extension']."')</script>"; 
     1351    $did_list = explode(",",$directdid); 
     1352    foreach($did_list as $test_did) 
     1353    { 
     1354      $existing=core_did_get($test_did,"",""); 
     1355      $existing_directdid = empty($existing)?core_users_directdid_get($test_did):$existing; 
     1356      if (!empty($existing) || !empty($existing_directdid)) { 
     1357        if (!empty($existing)) { 
     1358          echo "<script>javascript:alert('"._("A route with this DID already exists:")." ".$existing['extension']."')</script>"; 
     1359        } else { 
     1360          echo "<script>javascript:alert('"._("This DID is already associated with extension:")." ".$existing_directdid['extension']." (".$existing_directdid['name'].")')</script>"; 
     1361        } 
    13501362      } else { 
    1351         echo "<script>javascript:alert('"._("This DID is already associated with extension:")." ".$existing_directdid['extension']." (".$existing_directdid['name'].")')</script>"
     1363        array_push($final_did,$test_did)
    13521364      } 
    1353       return false; 
    13541365    } 
    13551366  } 
     1367   
     1368  $directdid = implode(",",$final_did); 
    13561369 
    13571370  $sipname = preg_replace("/\s/" ,"", trim($sipname)); 
    13581371  if (! core_sipname_check($sipname, $extension)) { 
     
    28572870    $currentcomponent->addguielem($section, new gui_textbox('sipname', $sipname, 'SIP Alias', "If you want to support direct sip dialing of users internally or through anonymous sip calls, you can supply a friendly name that can be used in addition to the users extension to call them.")); 
    28582871     
    28592872    $section = 'Extension Options'; 
    2860     $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); 
     2873    $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>Multiple DID numbers can be seperated by a comma<br><br>Leave this field blank to disable the direct DID feature for this extension. All non-numeric characters will be stripped."), 3); 
    28612874    $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")); 
    28622875    if (function_exists('music_list')) { 
    28632876        $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));