Changeset 123
- Timestamp:
- 03/02/05 15:26:23 (4 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/AMP2-UseAmportal/amp_conf/var/lib/asterisk/agi-bin/directory
r119 r123 28 28 29 29 /******************************************************************************/ 30 31 define("DEBUG", 0); 30 32 31 33 define("DIR_LAST", 0); … … 53 55 54 56 function output(&$var) { 55 global $logfile; 56 57 if (!isset($logfile)) return false; 58 59 ob_start(); 60 var_dump($var); 61 $output = ob_get_contents(); 62 ob_end_clean(); 63 fwrite($logfile, $output); 57 if (DEBUG) { 58 global $logfile; 59 60 if (!isset($logfile)) return false; 61 62 ob_start(); 63 var_dump($var); 64 $output = ob_get_contents(); 65 ob_end_clean(); 66 fwrite($logfile, $output); 67 } 64 68 } 65 69 … … 263 267 } 264 268 265 function do_directory($type, &$directory, $ vm_context, $dial_context, $say_exten, $operator) {269 function do_directory($type, &$directory, $dial_context, $say_exten, $operator) { 266 270 global $agi; 267 271 … … 274 278 case DIR_LAST: default: $intro = ($operator ? "dir-intro-oper" : "dir-intro"); break; 275 279 } 276 277 $intro = "digits/1";278 280 279 281 $loop = 0; … … 300 302 301 303 $i = 0; 304 $digit = false; 302 305 if (isset($directory[$digits]) && isset($directory[$digits][$i])) { 303 306 $loop = 0; // reset loop counter … … 305 308 $match = & $directory[$digits][$i]; 306 309 307 $maindirname = sprintf(VOICEMAIL_DIR, $ vm_context, $match["ext"]);310 $maindirname = sprintf(VOICEMAIL_DIR, $match["context"], $match["ext"]); 308 311 309 312 if (sound_file_exists($maindirname."/greet")) { … … 381 384 $agi = new AGI; 382 385 383 $logfile = fopen("/tmp/directory.log","w"); 384 386 if (DEBUG) $logfile = fopen("/tmp/directory.log","w"); 385 387 386 388 $vmconf = array(); … … 395 397 $vm_context = trim($argv[1]); 396 398 397 if (!isset($vmconf[$vm_context])) { 399 if (!isset($vmconf[$vm_context]) && ($vm_context != "general")) { 400 // we make an exception for "general" context,as it just includes other contexts 398 401 $agi->verbose("Cannot find context ".$vm_context." in ".DIRECTORY_FILE); 399 402 exit(1); … … 432 435 } 433 436 434 437 if ($vm_context == "general") { 438 $boxes = array(); 439 foreach ($vmconf as $context=>$arr) { 440 // skip if it's general context -- this doesn't contain mailboxes 441 if ($context == "general") continue; 442 443 foreach ($arr as $key=>$box) { 444 // we could do if !isset($boxes[$key]) to NOT override mailboxes 445 446 // add in the context, otherwise we don't know what it is 447 $box["context"] = $context; 448 449 $boxes[$key] = $box; 450 } 451 } 452 } else { 453 $boxes = &$vmconf[$vm_context]; 454 } 435 455 436 456 $directory = array(); 437 foreach ($ vmconf[$vm_context]as $box) {457 foreach ($boxes as $box) { 438 458 if (!empty($box["name"])) { 439 459 $name = explode(" ",$box["name"]); 460 461 if (isset($box["context"])) { 462 $context = $box["context"]; 463 } else { 464 $context = $vm_context; 465 } 466 440 467 switch ($dir_type) { 441 468 case DIR_FIRST: // first name only 442 469 $digits = string_to_digits($name[0]); 443 $directory[$digits][] = array("ext"=>$box["mailbox"], "name"=>$box["name"] );470 $directory[$digits][] = array("ext"=>$box["mailbox"], "name"=>$box["name"], "context"=>$context); 444 471 break; 445 472 case DIR_BOTH: // all names 446 473 foreach ($name as $temp) { 447 474 $digits = string_to_digits($temp); 448 $directory[$digits][] = array("ext"=>$box["mailbox"], "name"=>$box["name"] );475 $directory[$digits][] = array("ext"=>$box["mailbox"], "name"=>$box["name"], "context"=>$context); 449 476 } 450 477 break; 451 478 case DIR_LAST: default: // last name only 452 479 $digits = string_to_digits(end($name)); 453 $directory[$digits][] = array("ext"=>$box["mailbox"], "name"=>$box["name"]); 454 break; 455 } 456 } 457 } 458 459 output($argv); 460 output($dir_type); 461 output($directory); 462 463 do_directory($dir_type, $directory, $vm_context, $dial_context, $say_exten, $operator); 480 $directory[$digits][] = array("ext"=>$box["mailbox"], "name"=>$box["name"], "context"=>$context); 481 break; 482 } 483 } 484 } 485 486 if (DEBUG) { 487 output($argv); 488 output($dir_type); 489 output($directory); 490 } 491 492 do_directory($dir_type, $directory, $dial_context, $say_exten, $operator); 464 493 465 494 ?>
