Show
Ignore:
Timestamp:
04/16/06 13:04:29 (7 years ago)
Author:
mheydon1973
Message:

Fixed minor typo's + added support for up and coming Call Forward on No Answer / Unavailable

Functionatlity should now match the perl version exactly

Files:

Legend:

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

    r1605 r1611  
    9595// Start with Arg Count set to 3 as two args are used 
    9696$arg_cnt = 3; 
    97 while($arg = get_var($AGI,"ARG". $arg_cnt) ) 
     97while( ($arg = get_var($AGI,"ARG". $arg_cnt)) ) 
    9898{ 
    9999  if ($arg == '-')  
     
    135135foreach ( $ext as $k ) 
    136136{ 
    137   if ( !preg_match($k, "/\#/", $matches) ) 
     137  //if ( !preg_match($k, "/\#/", $matches) ) 
     138  if ( (strpos($k,"#")==0) ) 
    138139  {    
    139140    // no point in doing if cf is enabled 
     
    163164  $extcfb    = $extcfb['data']; 
    164165  $exthascfb = (strlen($extcfb) > 0) ? 1 : 0; 
     166  $extcfu    = $AGI->database_get('CFU', $extnum);// ? 1 : 0; 
     167  $extcfu    = $extcfu['data']; 
     168  $exthascfu = (strlen($extcfu) > 0) ? 1 : 0; 
    165169   
    166170  // Dump details in level 4 
     
    169173  debug("exthascfb: $exthascfb",4); 
    170174  debug("extcfb: $extcfb",4); 
    171    
    172   // if CF is not in use; AND 
    173   // CW is not in use or CFB is in use on this extension, then we need to check! 
     175  debug("exthascfu: $exthascfu",4); 
     176  debug("extcfu: $extcfu",4); 
     177   
     178  // if CF is not in use 
    174179  //   if (($ext{$k} =~ /\#/)!=1 && (($exthascw == 0) || ($exthascfb == 1))) { 
    175   if ((strpos($k,"#")==0) && (($exthascw == 0) || ($exthascfb == 1)) ) 
    176   { 
    177     debug("Checking CW and CFB status for extension $extnum",3); 
    178     $extstate = is_ext_avail($extnum); 
    179     debug("extstate: $extstate",4); 
    180      
    181     if ($extstate > 0)  
    182     { // extension in use 
    183       debug("Extension $extnum is not available to be called",1); 
    184      
    185       if ($exthascfb == 1)  
    186       { // CFB is in use 
    187         debug("Extension $extnum has call forward on busy set to $extcfb",1); 
    188         $extnum = $extcfb . '#';   # same method as the normal cf, i.e. send to Local 
    189       }  
    190       elseif ($exthascw == 0)  
    191       { // CW not in use 
    192         debug("Extension $extnum has call waiting disabled",1); 
    193         $extnum = ''; 
     180  if ( (strpos($k,"#")==0) ) 
     181  { 
     182    // CW is not in use or CFB is in use on this extension, then we need to check! 
     183    if ( ($exthascw == 0) || ($exthascfb == 1) || ($exthascfu == 1) ) 
     184    { 
     185      // get ExtensionState: 0-idle; 1-busy; 4-unavail <--- these are unconfirmed 
     186      $extstate = is_ext_avail($extnum); 
     187   
     188      if ( ($exthascfu == 1) && ($extstate == 4) ) // Ext has CFU and is Unavailable 
     189      { 
     190        debug("Extension $extnum has call forward on no answer set and is unavailable",1); 
     191        $extnum = $extcfu . '#';   # same method as the normal cf, i.e. send to Local 
     192      } 
     193      elseif ( ($exthascw == 0) || ($exthascfb == 1) )  
     194      {  
     195        debug("Checking CW and CFB status for extension $extnum",3); 
     196       
     197        if ($extstate > 0) 
     198        { // extension in use 
     199          debug("Extension $extnum is not available to be called", 1); 
     200           
     201          if ($exthascfb == 1) // extension in use 
     202          { // CFB is in use 
     203            debug("Extension $extnum has call forward on busy set to $extcfb",1); 
     204            $extnum = $extcfb . '#';   # same method as the normal cf, i.e. send to Local 
     205          }  
     206          elseif ($exthascw == 0)  
     207          { // CW not in use 
     208            debug("Extension $extnum has call waiting disabled",1); 
     209            $extnum = ''; 
     210          }  
     211          else  
     212          { 
     213            debug("Extension $extnum has call waiting enabled",1); 
     214          } 
     215        } 
     216      } 
     217      elseif ($extstate < 0) 
     218      { // -1 means couldn't read status usually due to missing HINT 
     219        debug("ExtensionState for $extnum could not be read...assuming ok",3); 
    194220      }  
    195221      else  
    196       {  // no reason why this will ever happen! but kept in for clarity 
    197         debug("Extension $extnum has call waiting enabled",1); 
     222      { 
     223        debug("Extension $extnum is available",1); 
    198224      } 
    199     } 
    200     elseif ($extstate < 0)  
    201     { // -1 means couldn't read status or chan unavailable 
    202       debug("ExtensionState for $extnum could not be read...assuming ok",3); 
    203     }  
    204     else  
    205     { 
    206       debug("Extension $extnum is available...skipping checks",1); 
    207225    } 
    208226  } 
     
    333351  $dialstring = ''; 
    334352   
    335 //  if ($extnum =~ s/#//)   
     353//  if ($extnum =~ s/#//) 
    336354  if (strpos($extnum,'#') != 0) 
    337355  {                        
    338356    // "#" used to identify external numbers in forwards and callgourps 
    339     str_replace("#", "", $extnum); 
     357    debug("Extnum '$extnum' contains '#'...removing", 4); 
     358    $extnum = str_replace("#", "", $extnum); 
    340359    $dialstring = 'Local/'.$extnum.'@from-internal'; 
    341360  }  
     
    386405     
    387406  $status = $status['Status']; 
     407  debug("ExtensionState: $status", 4); 
    388408  return $status; 
    389409   
     
    441461{ 
    442462  $file = file($filename); 
     463  $matches = array(); 
     464  $matchpattern = '/^\s*([a-zA-Z0-9]+)\s*=\s*(.*)\s*([;#].*)?/'; 
    443465  foreach ($file as $line)  
    444466  { 
    445     if (preg_match("/^\s*([a-zA-Z0-9]+)\s*=\s*(.*)\s*([;#].*)?/",$line,$matches))  
     467    if (preg_match($matchpattern, $line, $matches))  
    446468    { 
    447469      $conf[ $matches[1] ] = $matches[2];