Changeset 8839

Show
Ignore:
Timestamp:
02/16/10 23:36:28 (2 years ago)
Author:
p_lindheimer
Message:

closes #4050 add external CID manipulation re #1718 in followme, initial check-in not yet tested

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.7/ringgroups/functions.inc.php

    r8769 r8839  
    118118          $ext->add($contextname, $grpnum, 'skipov', new ext_setvar('RRNODEST', '${NODEST}')); 
    119119          $ext->add($contextname, $grpnum, 'skipvmblk', new ext_setvar('__NODEST', '${EXTEN}')); 
     120 
     121          $ext->add($contextname, $grpnum, '', new ext_gosubif('$[${DB_EXISTS(RINGGROUP/'.$grpnum.'/changecid)} = 1 & "${DB(RINGGROUP/'.$grpnum.'/changecid)}" != "default" & "${DB(RINGGROUP/'.$grpnum.'/changecid)}" != ""]', 'sub-rgsetcid,s,1')); 
    120122           
    121123          // deal with group CID prefix 
     
    196198          $ext->add($contextname, $grpnum, 'nodest', new ext_noop('SKIPPING DEST, CALL CAME FROM Q/RG: ${RRNODEST}')); 
    197199        } 
     200        /* 
     201          ASTDB Settings: 
     202          RINGGROUP/nnn/changecid default | did | fixed | extern 
     203          RINGGROUP/nnn/fixedcid XXXXXXXX 
     204 
     205          changecid: 
     206            default   - works as always, same as if not present 
     207            fixed     - set to the fixedcid 
     208            extern    - set to the fixedcid if the call is from the outside only 
     209            did       - set to the DID that the call came in on or leave alone, treated as foreign 
     210            forcedid  - set to the DID that the call came in on or leave alone, not treated as foreign 
     211           
     212          BLKVM_BASE - has the exten num called, hoaky if that goes away but for now use it 
     213        */ 
     214        if (count($ringlist)) { 
     215          $contextname = 'sub-rgsetcid'; 
     216          $exten = 's'; 
     217          $ext->add($contextname, $exten, '', new ext_goto('1','s-${DB(RINGGROUP/${BLKVM_BASE}/changecid)}')); 
     218 
     219          $exten = 's-fixed'; 
     220          $ext->add($contextname, $exten, '', new ext_execif('$["${REGEX("^[\+]?[0-9]+$" ${DB(RINGGROUP/${BLKVM_BASE}/fixedcid)})}" = "1"]', 'Set', '__TRUNKCIDOVERRIDE=${DB(RINGGROUP/${BLKVM_BASE}/fixedcid)}')); 
     221          $ext->add($contextname, $exten, '', new ext_return('')); 
     222 
     223          $exten = 's-extern'; 
     224          $ext->add($contextname, $exten, '', new ext_execif('$["${REGEX("^[\+]?[0-9]+$" ${DB(RINGGROUP/${BLKVM_BASE}/fixedcid)})}" == "1" & "${FROM_DID}" != ""]', 'Set', '__TRUNKCIDOVERRIDE=${DB(RINGGROUP/${BLKVM_BASE}/fixedcid)}')); 
     225          $ext->add($contextname, $exten, '', new ext_return('')); 
     226 
     227          $exten = 's-did'; 
     228          $ext->add($contextname, $exten, '', new ext_execif('$["${REGEX("^[\+]?[0-9]+$" ${FROM_DID})}" = "1"]', 'Set', '__REALCALLERIDNUM=${FROM_DID}')); 
     229          $ext->add($contextname, $exten, '', new ext_return('')); 
     230 
     231          $exten = 's-forcedid'; 
     232          $ext->add($contextname, $exten, '', new ext_execif('$["${REGEX("^[\+]?[0-9]+$" ${FROM_DID})}" = "1"]', 'Set', '__TRUNKCIDOVERRIDE=${FROM_DID}')); 
     233          $ext->add($contextname, $exten, '', new ext_return('')); 
     234 
     235          $exten = '_s-.'; 
     236          $ext->add($contextname, $exten, '', new ext_noop('Unknown value for RINGGROUP/${BLKVM_BASE}/changecid of ${DB(RINGGROUP/${BLKVM_BASE}/changecid)} set to "default"')); 
     237          $ext->add($contextname, $exten, '', new ext_setvar('DB(RINGGROUP/${BLKVM_BASE}/changecid)', 'default')); 
     238          $ext->add($contextname, $exten, '', new ext_return('')); 
     239        } 
    198240      } 
    199241    break; 
     
    201243} 
    202244 
    203 function ringgroups_add($grpnum,$strategy,$grptime,$grplist,$postdest,$desc,$grppre='',$annmsg_id='',$alertinfo,$needsconf,$remotealert_id,$toolate_id,$ringing,$cwignore,$cfignore) { 
     245function ringgroups_add($grpnum,$strategy,$grptime,$grplist,$postdest,$desc,$grppre='',$annmsg_id='',$alertinfo,$needsconf,$remotealert_id,$toolate_id,$ringing,$cwignore,$cfignore,$changecid='default',$fixedcid='') { 
    204246  global $db; 
    205247 
     
    217259  $sql = "INSERT INTO ringgroups (grpnum, strategy, grptime, grppre, grplist, annmsg_id, postdest, description, alertinfo, needsconf, remotealert_id, toolate_id, ringing, cwignore, cfignore) VALUES ('".$db->escapeSimple($grpnum)."', '".$db->escapeSimple($strategy)."', ".$db->escapeSimple($grptime).", '".$db->escapeSimple($grppre)."', '".$db->escapeSimple($grplist)."', '".$annmsg_id."', '".$db->escapeSimple($postdest)."', '".$db->escapeSimple($desc)."', '".$db->escapeSimple($alertinfo)."', '$needsconf', '$remotealert_id', '$toolate_id', '$ringing', '$cwignore', '$cfignore')"; 
    218260  $results = sql($sql); 
     261 
     262  // from followme, put these in astdb, should migrate more settings to astdb from sql so that user portal control can be 
     263  // added. So consider this a start. 
     264  if ($astman) { 
     265    $astman->database_put("RINGGROUP",$grpnum."/changecid",$changecid); 
     266    $fixedcid = preg_replace("/[^0-9\+]/" ,"", trim($fixedcid)); 
     267    $astman->database_put("RINGGROUP",$grpnum."/fixedcid",$fixedcid); 
     268  } else { 
     269    fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]); 
     270  } 
    219271  return true; 
    220272} 
     
    224276 
    225277  $results = sql("DELETE FROM ringgroups WHERE grpnum = '".$db->escapeSimple($grpnum)."'","query"); 
     278  if ($astman) { 
     279    $astman->database_deltree("RINGGROUP/".$grpnum); 
     280  } else { 
     281    fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]); 
     282  } 
    226283} 
    227284 
     
    296353 
    297354  $results = sql("SELECT grpnum, strategy, grptime, grppre, grplist, annmsg_id, postdest, description, alertinfo, needsconf, remotealert_id, toolate_id, ringing, cwignore, cfignore FROM ringgroups WHERE grpnum = '".$db->escapeSimple($grpnum)."'","getRow",DB_FETCHMODE_ASSOC); 
     355  if ($astman) { 
     356    $astdb_changecid = strtolower($astman->database_get("RINGGROUP",$grpnum."/changecid")); 
     357    switch($astdb_changecid) { 
     358      case 'default': 
     359      case 'did': 
     360      case 'forcedid': 
     361      case 'fixed': 
     362      case 'extern': 
     363        break; 
     364      default: 
     365        $astdb_changecid = 'default'; 
     366    } 
     367    $results['changecid'] = $astdb_changecid; 
     368    $fixedcid = $astman->database_get("RINGGROUP",$grpnum."/fixedcid"); 
     369    $results['fixedcid'] = preg_replace("/[^0-9\+]/" ,"", trim($fixedcid)); 
     370  } else { 
     371    fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]); 
     372  } 
    298373  return $results; 
    299374} 
  • modules/branches/2.7/ringgroups/module.xml

    r8189 r8839  
    22  <rawname>ringgroups</rawname> 
    33  <name>Ring Groups</name> 
    4   <version>2.6.0.1</version> 
     4  <version>2.7.0.0</version> 
    55  <publisher>FreePBX</publisher> 
    66  <license>GPLv2+</license> 
     
    1111  </description> 
    1212  <changelog> 
     13    *2.7.0.0* #4050 
    1314    *2.6.0.1* #3610 
    1415    *2.6.0.0* #3697 
  • modules/branches/2.7/ringgroups/page.ringgroups.php

    r8103 r8839  
    3131isset($_REQUEST['ringing'])?$ringing = $_REQUEST['ringing']:$ringing=''; 
    3232 
     33isset($_REQUEST['changecid'])?$changecid = $_REQUEST['changecid']:$changecid='default'; 
     34isset($_REQUEST['fixedcid'])?$fixedcid = $_REQUEST['fixedcid']:$fixedcid=''; 
     35 
    3336if (isset($_REQUEST['goto0']) && isset($_REQUEST[$_REQUEST['goto0']."0"])) { 
    3437        $goto = $_REQUEST[$_REQUEST['goto0']."0"]; 
     
    7780        $conflict_url = framework_display_extension_usage_alert($usage_arr); 
    7881 
    79       } elseif (ringgroups_add($account,$strategy,$grptime,implode("-",$grplist),$goto,$description,$grppre,$annmsg_id,$alertinfo,$needsconf,$remotealert_id,$toolate_id,$ringing,$cwignore,$cfignore)) { 
     82      } elseif (ringgroups_add($account,$strategy,$grptime,implode("-",$grplist),$goto,$description,$grppre,$annmsg_id,$alertinfo,$needsconf,$remotealert_id,$toolate_id,$ringing,$cwignore,$cfignore,$changecid,$fixedcid)) { 
    8083        needreload(); 
    8184        redirect_standard(); 
     
    9396    if ($action == 'edtGRP') { 
    9497      ringgroups_del($account);  
    95       ringgroups_add($account,$strategy,$grptime,implode("-",$grplist),$goto,$description,$grppre,$annmsg_id,$alertinfo,$needsconf,$remotealert_id,$toolate_id,$ringing,$cwignore,$cfignore); 
     98      ringgroups_add($account,$strategy,$grptime,implode("-",$grplist),$goto,$description,$grppre,$annmsg_id,$alertinfo,$needsconf,$remotealert_id,$toolate_id,$ringing,$cwignore,$cfignore,$changecid,$fixedcid); 
    9699      needreload(); 
    97100      redirect_standard('extdisplay'); 
     
    139142    $toolate_id = $thisgrp['toolate_id']; 
    140143    $ringing = $thisgrp['ringing']; 
     144    $changecid   = isset($thisgrp['changecid'])   ? $thisgrp['changecid']   : 'default'; 
     145    $fixedcid    = isset($thisgrp['fixedcid'])    ? $thisgrp['fixedcid']    : ''; 
    141146    unset($grpliststr); 
    142147    unset($thisgrp); 
     
    390395      </tr> 
    391396<?php } ?> 
     397      <tr><td colspan="2"><h5><?php echo _("Change External CID Configuration") ?><hr></h5></td></tr> 
     398      <tr> 
     399        <td> 
     400        <a href="#" class="info"><?php echo _("Mode")?>: 
     401        <span> 
     402          <b><?php echo _("Default")?></b>:  <?php echo _("Transmits the Callers CID if allowed by the trunk.")?><br> 
     403          <b><?php echo _("Fixed CID Value")?></b>:  <?php echo _("Always transmit the Fixed CID Value below.")?><br> 
     404          <b><?php echo _("Outside Calls Fixed CID Value")?></b>: <?php echo _("Transmit the Fixed CID Value below on calls that come in from outside only. Internal extension to extension calls will continue to operate in default mode.")?><br> 
     405          <b><?php echo _("Use Dialed Number")?></b>: <?php echo _("Transmit the number that was dialed as the CID for calls coming from outside. Internal extension to extension calls will continue to operate in default mode. There must be a DID on the inbound route for this. This will be BLOCKED on trunks that block foreign callerid")?><br> 
     406          <b><?php echo _("Force Dialed Number")?></b>: <?php echo _("Transmit the number that was dialed as the CID for calls coming from outside. Internal extension to extension calls will continue to operate in default mode. There must be a DID on the inbound route for this. This WILL be transmitted on trunks that block foreign callerid")?><br> 
     407        </span> 
     408        </a> 
     409        </td> 
     410        <td> 
     411          <select name="changecid" id="changecid" tabindex="<?php echo ++$tabindex;?>"> 
     412          <?php 
     413            $default = (isset($changecid) ? $changecid : 'default'); 
     414            echo '<option value="default" '.($default == 'default' ? 'SELECTED' : '').'>'._("Default"); 
     415            echo '<option value="fixed" '.($default == 'fixed' ? 'SELECTED' : '').'>'._("Fixed CID Value"); 
     416            echo '<option value="extern" '.($default == 'extern' ? 'SELECTED' : '').'>'._("Outside Calls Fixed CID Value"); 
     417            echo '<option value="did" '.($default == 'did' ? 'SELECTED' : '').'>'._("Use Dialed Number"); 
     418            echo '<option value="forcedid" '.($default == 'forcedid' ? 'SELECTED' : '').'>'._("Force Dialed Number"); 
     419            $fixedcid_disabled = ($default != 'fixed' && $default != 'extern') ? 'disabled = "disabled"':''; 
     420          ?>     
     421          </select> 
     422        </td> 
     423      </tr> 
     424 
     425      <tr> 
     426        <td><a href="#" class="info"><?php echo _("Fixed CID Value")?>:<span><?php echo _('Fixed value to replace the CID with used with some of the modes above. Should be in a format of digits only with an option of E164 format using a leading "+".')?></span></a></td> 
     427        <td><input size="30" type="text" name="fixedcid" id="fixedcid" value="<?php  echo $fixedcid ?>" tabindex="<?php echo ++$tabindex;?>" <?php echo $fixedcid_disabled ?>></td> 
     428      </tr> 
     429       
    392430<?php 
    393431      // implementation of module hook 
     
    416454<script language="javascript"> 
    417455<!-- 
     456 
     457$(document).ready(function(){ 
     458  $("#changecid").change(function(){ 
     459    state = (this.value == "fixed" || this.value == "extern") ? "" : "disabled"; 
     460    $("#fixedcid").attr("disabled",state); 
     461  }); 
     462}); 
    418463 
    419464function insertExten() { 
     
    455500    return warnInvalid(theForm.grplist, msgInvalidExtList); 
    456501 
     502  if (!theForm.fixedcid.disabled) { 
     503    fixedcid = $.trim(theForm.fixedcid.value); 
     504    if (!fixedcid.match('^[+]{0,1}[0-9]+$')) { 
     505      return warnInvalid(theForm.fixedcid, msgInvalidCID); 
     506    } 
     507  } 
     508 
    457509  defaultEmptyOK = false; 
    458510  if (!isInteger(theForm.grptime.value)) {