Changeset 3406

Show
Ignore:
Timestamp:
12/21/06 19:41:20 (5 years ago)
Author:
p_lindheimer
Message:

core changes required for new ringallv2 ring strategy added to followme. This strategy allows the primary extension in a followme to start ringing for the pre-ring time, and if present in its own ringgroup (the typical behavior), it will continue ringing and not hangup and then re-ring. This avoids the double missed calls on many phones from the normal modes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/trunk/amp_conf/agi-bin/dialparties.agi

    r3395 r3406  
    6060$pr_dialstatus  = get_var( $AGI, "PR_DIALSTATUS" ); 
    6161 
     62$fmgrp  = get_var( $AGI, "FMGRP" ); 
    6263$nodest = get_var( $AGI, "NODEST" ); 
    6364if (empty($nodest)) $nodest = ''; 
    6465 
     66$ringgroup_index  = get_var( $AGI, "RINGGROUP_INDEX" ); 
    6567$use_confirmation = get_var( $AGI, "USE_CONFIRMATION" ); 
    66 $ringgroup_index  = get_var( $AGI, "RINGGROUP_INDEX" ); 
     68if (empty($use_confirmation)) $use_confirmation = "FALSE"; 
     69debug("USE_CONFIRMATION:  '$use_confirmation'", 4); 
     70debug("RINGGROUP_INDEX:   '$ringgroup_index'", 4); 
    6771 
    6872if (empty($timer))  $timer    = 0; 
     
    7074if (empty($rgmethod)) $rgmethod = "none"; 
    7175 
    72 if (empty($use_confirmation)) $use_confirmation = "FALSE"; 
    7376 
    7477debug("Methodology of ring is  '$rgmethod'", 1); 
    75 debug("USE_CONFIRMATION:  '$use_confirmation'", 4); 
    76 debug("RINGGROUP_INDEX:   '$ringgroup_index'", 4); 
    7778 
    7879// reset the ringgroup method to its fundamental algorithm and pull out if 
    7980// master mode. 
     81 
     82$recall_mastermode=$rgmethod; 
    8083 
    8184if ($rgmethod == "ringall-prim") { 
     
    8992  $mastermode = 1; 
    9093} else  
     94} elseif ($rgmethod == "ringallv2-prim")  
     95{ 
     96  $rgmethod = "ringallv2"; 
     97  $mastermode = 1; 
    9198  $mastermode = 0; 
    9299 
     
    96103// if they set a -prim mode in one of the others 
    97104// 
    98 if ( ($use_confirmation != "FALSE") && ($rgmethod != "ringall") ) { 
    99   debug("Unsupported RingMethod reset to: '$rgmethod'", 1); 
     105if ( ($use_confirmation != "FALSE") && (trim($rgmethod) != "ringall") && (trim($rgmethod) != "ringallv2") ) { 
     106  debug("Unsupported RingMethod: '$rgmethod' resetting to ringall", 1); 
    100107  $rgmethod = "ringall"; 
    101108} 
     
    119126   
    120127  $arg_cnt++; 
     128} 
     129 
     130// FollowMe Preparation for Pre-Ring: 
     131// 
     132// If the primary extension is in the ringgroup list, then it should be rung 
     133// during both the pre-ring time and the list time, so it's real prering time 
     134// is the entire time. If it is not in the list, then it should only ring 
     135// for the pre-ring time. This section determines the times and then adds it 
     136// to the list if not already there, so that the dialstring is computed 
     137// appropriately. This section also makes sure that the primary extension 
     138// is at the top of the list. 
     139// 
     140// Notes before I forget. The primary may have been in the list and screwed 
     141// above. So ... do I need to move this up, probably. 
     142// 
     143if ($rgmethod == "ringallv2" && $fmgrp != "") { 
     144 
     145  $fmgrp_primaryremoved = 0; 
     146 
     147  $fmgrp_prering  = $AGI->database_get('AMPUSER', $fmgrp."/followme/prering");  
     148  $fmgrp_prering  = $fmgrp_prering['data'] > 1 ? $fmgrp_prering['data'] : 2; 
     149      
     150  $fmgrp_grptime  = $AGI->database_get('AMPUSER', $fmgrp."/followme/grptime");  
     151  $fmgrp_grptime  = $fmgrp_grptime['data']; 
     152 
     153  debug("got fmgrp_prering: $fmgrp_prering, fmgrp_grptime: $fmgrp_grptime",4); 
     154 
     155  $fmgrp_totalprering = $fmgrp_grptime + $fmgrp_prering; 
     156 
     157  debug("fmgrp_totalprering: $fmgrp_totalprering",4); 
     158 
     159  if (in_array($fmgrp, $ext)) { 
     160    debug("found extension in pre-ring and array",4); 
     161    $fmgrp_realprering = $fmgrp_totalprering; 
     162    if ($ext[0] != $fmgrp) { 
     163      $tmpx=array_flip($ext); 
     164      unset($ext[$tmpx[$fmgrp]]); 
     165      array_unshift($ext,$fmgrp); 
     166    } 
     167  } else { 
     168    debug("extension not in group list, ringging only during perring time",4); 
     169    $fmgrp_realprering = $fmgrp_prering; 
     170    array_unshift($ext,$fmgrp); 
     171  } 
     172debug("ringallv2 ring times: REALPRERING: $fmgrp_realprering, PRERING: $fmgrp_prering",4); 
    121173} 
    122174 
     
    164216// Now check for DND 
    165217foreach ( $ext as $k ) 
    166 {  //if ( !preg_match($k, "/\#/", $matches) ) 
     218{ 
    167219  if ( (strpos($k,"#")==0) ) 
    168220  { 
     
    180232      { 
    181233        $dndprimary = 1; 
     234        $fmgrp_primaryremoved = 1; 
    182235        debug("Primary extension is DND, so if mastermode, all should be dnd", 4); 
    183236      } 
     
    190243 
    191244// Main calling loop 
     245// 
    192246$skipremaining = 0; // used to allow primary to ring but skip the rest 
    193  
    194247$ds = ''; 
    195248foreach ( $ext as $k ) 
     
    343396    { 
    344397      $dsarray[$realext] = 1;  // could be dial string i suppose but currently only using for duplicate check 
    345       $extds = get_dial_string( $AGI, $extnum, $use_confirmation, $ringgroup_index); 
    346       if (strlen($extds)) $ds .= $extds . '&'; 
     398 
     399        $extds = get_dial_string( $AGI, $extnum, $use_confirmation, $ringgroup_index); 
     400        if (strlen($extds)) $ds .= $extds . '&'; 
    347401     
    348402      // Update Caller ID for calltrace application 
     
    422476if (!strlen($ds)) 
    423477{ 
     478// FollowMe Changes: 
     479// 
     480// We need to determine if the generated dialstring can be dialed as is. This will be the case if there are no 
     481// or is only a single extension to dial.  
     482// 
     483// First, unset any blank fields so we know how many extensions there are to call. 
     484// 
     485// If mastermode (skipremaining == 1) was triggered then we just set the ringtime to what the primary extension 
     486// should ring for and let this dialstring go. 
     487// 
     488// If there is only one extension in the list, then we need to determine how long to ring it (depending on if it 
     489// was the primary or another extension, then let the generated dialstring ring it. 
     490// 
     491// Otherwise, we need to re-create the dialstring to be processed by our special dialplan that will ring the 
     492// primary extension and hold the group list for the required delay. Also - if we are in a call confirmation mode 
     493// then we need to reset the call confirm variables with one level of inheritance so that they remain in the new 
     494// channels but don't get further propogated after that. We also clear it for the remainder of this instance since 
     495// we are not yet triggering further actions until the next call. 
     496// 
     497// Notes: $fmgrp_primaryremoved is set to 1 if the primary has been removed from the list so we know that it was dnd-ed. 
     498//        this only matters in non-prim mode, where we need to know if the remaining list contains the primary extension 
     499//        or not. 
     500// 
     501if ($rgmethod == 'ringallv2') { 
     502  $count = 0; 
     503  foreach ($ext as $x) { 
     504    if ($x == '') { 
     505      unset($ext[$count]); 
     506    } 
     507    $count++; 
     508  } 
     509 
     510  if (($skipremaining == 1) || (count($ext) == 1 && $fmgrp_primaryremoved == 0)) { 
     511    $timer = $fmgrp_realprering; 
     512  } elseif (count($ext) == 1 && $fmgrp_primaryremoved == 1) { 
     513    $timer = $fmgrp_grptime; 
     514  } elseif (count($ext) == 1) { 
     515    $timer = $fmgrp_totalprering; // not sure what would trigger this ? 
     516  } else { 
     517    $timer = $fmgrp_totalprering;  
     518    $ds = "Local/FMPR-".array_shift($ext)."@from-internal&Local/FMGL-".implode('-',$ext)."@from-internal"; 
     519 
     520    $fmgrp_fmunique = $AGI->request['agi_channel']; 
     521    $AGI->set_variable('_FMUNIQUE',$fmgrp_fmunique);             
     522    $AGI->set_variable('_RingGroupMethod',"ringall");            
     523    $fmgrp_prering -= 2; 
     524    $AGI->set_variable('_FMPRERING',$fmgrp_prering);             
     525    $AGI->set_variable('_FMREALPRERING',$fmgrp_realprering);             
     526    $AGI->set_variable('_FMGRPTIME',$fmgrp_grptime);             
     527    $AGI->set_variable('_FMPRIME',($recall_mastermode == "ringallv2")?"FALSE":"TRUE");             
     528 
     529    debug("FMUNIQUE: $fmgrp_fmunique, FMRERING: $fmgrp_prering, FMREALPRERING: $fmgrp_realprering, FMGRPTIME: $fmgrp_grptime",4); 
     530 
     531    if ($use_confirmation != 'FALSE') { 
     532      $AGI->set_variable('_USE_CONFIRMATION',$use_confirmation);             
     533      $AGI->set_variable('_RINGGROUP_INDEX',$ringgroup_index);             
     534      $use_confirmation = 'FALSE'; 
     535    } 
     536  } 
     537} 
     538 
     539if ($nodest != '' && $use_confirmation == 'FALSE') { 
     540  if (strpos($dialopts,"M(auto-blkvm)") > 0  || strpos($dialopts,"M(auto-blkvm)") === 0 || 
     541      strpos($dialopts,"M(auto-confirm") > 0 || strpos($dialopts,"M(auto-confirm") === 0 || 
     542      strpos($dialopts,"M(confirm") > 0      || strpos($dialopts,"M(confirm") === 0) { 
     543    debug("NODEST: $nodest blkvm enabled macro already in dialopts: $dialopts",4); 
     544  } else { 
     545    $dialopts .= "M(auto-blkvm)"; 
     546    debug("NODEST: $nodest adding M(auto-blkvm) to dialopts: $dialopts",4); 
     547  } 
     548} 
     549 
    424550  $AGI->noop(''); 
    425551} else { 
  • freepbx/trunk/amp_conf/astetc/extensions.conf

    r3395 r3406  
    281281; Cleanup any remaining RG flag 
    282282; 
    283 exten => s,n,GotoIf($[ "foo${USE_CONFIRMATION}" = "foo" | "foo${RINGGROUP_INDEX}" = "foo" | "${CHANNEL}" != "${UNIQCHAN}"]?skiprg) 
     283exten => s,n,GotoIf($[ "x${USE_CONFIRMATION}" = "x" | "x${RINGGROUP_INDEX}" = "x" | "${CHANNEL}" != "${UNIQCHAN}"]?skiprg) 
    284284exten => s,n,Noop(Cleaning Up Confirmation Flag: RG/${RINGGROUP_INDEX}/${CHANNEL}) 
    285285exten => s,n,DBDel(RG/${RINGGROUP_INDEX}/${CHANNEL}) 
     
    287287; Cleanup any remaining BLKVM flag 
    288288; 
    289 exten => s,n(skiprg),GotoIf($[ "foo${BLKVM_BASE}" = "foo" | "BLKVM/${BLKVM_BASE}/${CHANNEL}" != "${BLKVM_OVERRIDE}" ]?theend
     289exten => s,n(skiprg),GotoIf($[ "x${BLKVM_BASE}" = "x" | "BLKVM/${BLKVM_BASE}/${CHANNEL}" != "${BLKVM_OVERRIDE}" ]?skipblkvm
    290290exten => s,n,Noop(Cleaning Up Block VM Flag: ${BLKVM_OVERRIDE}) 
    291291exten => s,n,DBDel(${BLKVM_OVERRIDE}) 
    292292 
    293 exten => s,n(theend),Wait(5) 
     293; Cleanup any remaining FollowMe DND flags 
     294
     295exten => s,n(skipblkvm),GotoIf($[ "x${FMGRP}" = "x" | "x${FMUNIQUE}" = "x" | "${CHANNEL}" != "${FMUNIQUE}" ]?theend) 
     296exten => s,n,DBDel(FM/DND/${FMGRP}/${CHANNEL}) 
     297 
     298exten => s,n(theend),Wait(2) 
    294299exten => s,n,Hangup 
    295300 
     
    802807exten => s,n,Playtones(congestion) 
    803808exten => s,n,Congestion(5) 
     809include => findmefollow-ringallv2 
    804810exten => h,1,NoOp(Hangup) 
    805811exten => i,1,NoOp(Invalid) 
     
    10481054;------------------------------------------------------------------------ 
    10491055 
     1056;------------------------------------------------------------------------ 
     1057; [findmefollow-ringallv2] 
     1058;------------------------------------------------------------------------ 
     1059; This context, to be included in from-internal, implements the PreRing part of findmefollow 
     1060; as well as the GroupRing part. It also communicates between the two so that if DND is set 
     1061; on the primary extension, and mastermode is enabled, then the other extensions will not ring 
     1062; 
     1063;------------------------------------------------------------------------ 
     1064[findmefollow-ringallv2] 
     1065exten => _FMPR-.,1,Noop(In FMPR ${FMGRP} with ${EXTEN:5}) 
     1066exten => _FMPR-.,n,Set(RingGroupMethod=) 
     1067exten => _FMPR-.,n,Set(USE_CONFIRMATION=) 
     1068exten => _FMPR-.,n,Set(RINGGROUP_INDEX=) 
     1069exten => _FMPR-.,n,Macro(simple-dial,${EXTEN:5},${FMREALPRERING}) 
     1070exten => _FMPR-.,n,GotoIf($["${DIALSTATUS}" != "BUSY"]?nodnd) 
     1071exten => _FMPR-.,n,Set(DB(FM/DND/${FMGRP}/${FMUNIQUE})=DND) 
     1072exten => _FMPR-.,n(nodnd),Noop(Ending FMPR ${FMGRP} with ${EXTEN:5} and dialstatus ${DIALSTATUS}) 
     1073exten => _FMPR-.,n,Hangup() 
     1074 
     1075exten => _FMGL-.,1,Noop(In FMGL ${FMGRP} with ${EXTEN:5}) 
     1076exten => _FMGL-.,n,Wait(1) 
     1077exten => _FMGL-.,n,GotoIf($["${DB(FM/DND/${FMGRP}/${FMUNIQUE})}" = "DND"]?dodnd) 
     1078exten => _FMGL-.,n,Wait(1) 
     1079exten => _FMGL-.,n,GotoIf($["${DB(FM/DND/${FMGRP}/${FMUNIQUE})}" = "DND"]?dodnd) 
     1080exten => _FMGL-.,n,Wait(${FMPRERING}) 
     1081exten => _FMGL-.,n,GotoIf($["${DB(FM/DND/${FMGRP}/${FMUNIQUE})}" = "DND"]?dodnd) 
     1082exten => _FMGL-.,n,DBDel(FM/DND/${FMGRP}/${FMUNIQUE}) 
     1083exten => _FMGL-.,n(dodial),Macro(dial,${FMGRPTIME},${DIAL_OPTIONS},${EXTEN:5}) 
     1084exten => _FMGL-.,n,Noop(Ending FMGL ${FMGRP} with ${EXTEN:5} and dialstatus ${DIALSTATUS}) 
     1085exten => _FMGL-.,n,Hangup() 
     1086exten => _FMGL-.,n+10(dodnd),DBDel(FM/DND/${FMGRP}/${FMUNIQUE}) 
     1087exten => _FMGL-.,n,GotoIf($["${FMPRIME}" = "FALSE"]?dodial) 
     1088exten => _FMGL-.,n,Noop(Got DND in FMGL ${FMGRP} with ${EXTEN:5} in ${RingGroupMethod} mode, aborting) 
     1089exten => _FMGL-.,n,Hangup() 
     1090 
     1091;------------------------------------------------------------------------ 
     1092 
    10501093; ############################################################################ 
    10511094; Extension Contexts [ext]