Changeset 12979
- Timestamp:
- 11/28/11 21:18:57 (2 years ago)
- Files:
-
- modules/branches/2.10/queues/agi-bin/queue_devstate.agi (modified) (2 diffs)
- modules/branches/2.10/queues/functions.inc.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/branches/2.10/queues/agi-bin/queue_devstate.agi
r11808 r12979 52 52 $agi->set_variable('QUEUESTAT',$queuestat); 53 53 break; 54 case 'getall': 55 $new_user = get_login_user(); 56 sortqueues(); 57 file_put_contents("/tmp/queue_debug.log",print_r($logged_agents_array,true),FILE_APPEND); 58 file_put_contents("/tmp/queue_debug.log",print_r($static_agents_array,true),FILE_APPEND); 59 debug("Looking up queues for agent:r $new_user"); 60 $agent_queues = get_agent_queues($new_user); 61 foreach ($agent_queues as $q) { 62 debug("Agent is in: $q"); 63 } 64 $all_queues_state = get_agent_allqueue_state($new_user, $agent_queues); 65 debug("Agent $new_user is $all_queues_state for at least one of their queues"); 66 put_agent_overall_status($all_queues_state, $agent_queues); 67 break; 54 68 default: 55 69 debug("Got unknown action: $action, exiting"); … … 63 77 global $argv; 64 78 return strtolower(trim($argv['1'])); 79 } 80 81 function get_agent_queues($user) { 82 global $astman; 83 $this_agents_queues == array(); 84 85 $get=$astman->database_show('QPENALTY'); 86 if ($get) foreach($get as $key => $value){ 87 // 0: QPENALTY 88 // 1: QueueNum 89 // 2: agents (or dynmembers) 90 // 3: AgentNum (if agents) 91 // 92 $key=explode('/',trim($key,'/')); // get rid of leading '/' 93 if ($key[2] == 'agents' && $key[3] == $user) { 94 $this_agents_queues[] = $key[1]; 95 } 96 } 97 return $this_agents_queues; 98 } 99 100 // if they are logged into any of the queues provided, they are considered logged in and we will log them out of all 101 // 102 function get_agent_allqueue_state($user, $queues) { 103 global $logged_agents_array; 104 global $static_agents_array; 105 106 if (empty($queues)) { 107 debug("no queues for this agent"); 108 return 'NOQUEUES'; 109 } 110 foreach ($queues as $q) { 111 debug("checking if logged into queue: $q"); 112 if (array_search($user,$logged_agents_array[$q]) && ! array_search($user,$static_agents_array[$q])) { 113 debug("Yes logged into queue: $q"); 114 return 'LOGGEDIN'; 115 } 116 } 117 debug("Nothing found so logged out"); 118 return 'LOGGEDOUT'; 119 } 120 121 function put_agent_overall_status($status, $queues) { 122 global $agi; 123 124 $agi->set_variable('QUEUESTAT',$status); 125 $queues_string = implode('-',$queues); 126 $agi->set_variable('USERQUEUES',$queues_string); 65 127 } 66 128 modules/branches/2.10/queues/functions.inc.php
r12969 r12979 344 344 if ($que_code != '') { 345 345 queue_app_toggle($que_code); 346 queue_app_all_toggle(); 346 347 queue_agent_del_toggle(); 347 348 queue_agent_add_toggle(); … … 352 353 $from_queue_exten_internal = 'from-queue-exten-internal'; 353 354 354 if ( is_array($qlist)) {355 if (!empty($qlist)) { 355 356 foreach($qlist as $item) { 356 357 … … 577 578 $ext->add('from-queue', $exten, '', new ext_goto('1','${QAGENT}',$agent_context)); 578 579 } 580 // Create *45 all queue toggle 581 // 582 if ($que_code != '') { 583 $ext->add('ext-queues', $que_code, '', new ext_goto('start','s','app-all-queue-toggle')); 584 } 579 585 } 580 586 // We need to have a hangup here, if call is ended by the caller during Playback it will end in the … … 1085 1091 return $results; 1086 1092 } 1093 1094 function queue_app_all_toggle() { 1095 global $ext; 1096 global $amp_conf; 1097 1098 $id = "app-all-queue-toggle"; // The context to be included 1099 $c = 's'; 1100 1101 $ext->add($id, $c, 'start', new ext_answer('')); 1102 $ext->add($id, $c, '', new ext_wait('1')); 1103 $ext->add($id, $c, '', new ext_macro('user-callerid')); 1104 $ext->add($id, $c, '', new ext_agi('queue_devstate.agi,getall,${AMPUSER}')); 1105 $ext->add($id, $c, '', new ext_gotoif('$["${QUEUESTAT}" = "NOQUEUES"]', 'skip')); 1106 $ext->add($id, $c, '', new ext_set('TOGGLE_MACRO', '${IF($["${QUEUESTAT}"="LOGGEDOUT"]?toggle-add-agent:toggle-del-agent)}')); 1107 if ($amp_conf['USEDEVSTATE']) { 1108 $ext->add($id, $c, '', new ext_set('STATE', '${IF($["${QUEUESTAT}"="LOGGEDOUT"]?INUSE:NOT_INUSE)}')); 1109 } 1110 $ext->add($id, $c, '', new ext_set('LOOPCNTALL', '${FIELDQTY(USERQUEUES,-)}')); 1111 $ext->add($id, $c, '', new ext_set('ITERALL', '1')); 1112 $ext->add($id, $c, 'begin', new ext_set('QUEUENO', '${CUT(USERQUEUES,-,${ITERALL})}')); 1113 $ext->add($id, $c, '', new ext_set('ITERALL', '$[${ITERALL}+1]')); 1114 $ext->add($id, $c, '', new ext_macro('${TOGGLE_MACRO}')); 1115 if ($amp_conf['USEDEVSTATE']) { 1116 $ext->add($id, $c, '', new ext_gosub('1', 'sstate', 'app-queue-toggle')); 1117 } 1118 $ext->add($id, $c, '', new ext_gotoif('$[${ITERALL} <= ${LOOPCNTALL}]', 'begin')); 1119 $ext->add($id, $c, 'skip', new ext_execif('$["${QUEUESTAT}"="LOGGEDIN" | "${QUEUESTAT}"="NOQUEUES"]', 'Playback', 'agent-loggedoff')); 1120 $ext->add($id, $c, '', new ext_execif('$["${QUEUESTAT}"="LOGGEDOUT"]', 'Playback', 'agent-loginok')); 1121 $ext->add($id, $c, '', new ext_execif('$["${QUEUESTAT}"="LOGGEDOUT"]', 'SayDigits', '${AMPUSER}')); 1122 $ext->add($id, $c, '', new ext_macro('hangupcall')); 1123 } 1124 1125 1087 1126 /* Trial DEVSTATE */ 1088 1127 function queue_app_toggle($c) {
