Changeset 1611 for freepbx/trunk/amp_conf/agi-bin
- Timestamp:
- 04/16/06 13:04:29 (7 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
freepbx/trunk/amp_conf/agi-bin/dialparties.agi.php
r1605 r1611 95 95 // Start with Arg Count set to 3 as two args are used 96 96 $arg_cnt = 3; 97 while( $arg = get_var($AGI,"ARG". $arg_cnt) )97 while( ($arg = get_var($AGI,"ARG". $arg_cnt)) ) 98 98 { 99 99 if ($arg == '-') … … 135 135 foreach ( $ext as $k ) 136 136 { 137 if ( !preg_match($k, "/\#/", $matches) ) 137 //if ( !preg_match($k, "/\#/", $matches) ) 138 if ( (strpos($k,"#")==0) ) 138 139 { 139 140 // no point in doing if cf is enabled … … 163 164 $extcfb = $extcfb['data']; 164 165 $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; 165 169 166 170 // Dump details in level 4 … … 169 173 debug("exthascfb: $exthascfb",4); 170 174 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 174 179 // 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); 194 220 } 195 221 else 196 { // no reason why this will ever happen! but kept in for clarity197 debug("Extension $extnum has call waiting enabled",1);222 { 223 debug("Extension $extnum is available",1); 198 224 } 199 }200 elseif ($extstate < 0)201 { // -1 means couldn't read status or chan unavailable202 debug("ExtensionState for $extnum could not be read...assuming ok",3);203 }204 else205 {206 debug("Extension $extnum is available...skipping checks",1);207 225 } 208 226 } … … 333 351 $dialstring = ''; 334 352 335 // if ($extnum =~ s/#//) 353 // if ($extnum =~ s/#//) 336 354 if (strpos($extnum,'#') != 0) 337 355 { 338 356 // "#" 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); 340 359 $dialstring = 'Local/'.$extnum.'@from-internal'; 341 360 } … … 386 405 387 406 $status = $status['Status']; 407 debug("ExtensionState: $status", 4); 388 408 return $status; 389 409 … … 441 461 { 442 462 $file = file($filename); 463 $matches = array(); 464 $matchpattern = '/^\s*([a-zA-Z0-9]+)\s*=\s*(.*)\s*([;#].*)?/'; 443 465 foreach ($file as $line) 444 466 { 445 if (preg_match( "/^\s*([a-zA-Z0-9]+)\s*=\s*(.*)\s*([;#].*)?/",$line,$matches))467 if (preg_match($matchpattern, $line, $matches)) 446 468 { 447 469 $conf[ $matches[1] ] = $matches[2];
