Show
Ignore:
Timestamp:
02/13/11 19:56:05 (2 years ago)
Author:
p_lindheimer
Message:

Merged revisions 11370 via svnmerge from
http://www.freepbx.org/v2/svn/modules/branches/2.9

........

r11370 | p_lindheimer | 2011-02-13 16:52:10 -0800 (Sun, 13 Feb 2011) | 1 line


fixes #4408, fixes #4540, fixes #4745 adds extension option 'Queue State Detection' that can be configured to 'Ignore State' which will make the queue code always ignore state information for the given user/extension

........
publishing deferred until feedback is provided by some testers that this
addresses the reported issues and does not break anything.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.8

    • Property svnmerge-integrated changed from /modules/branches/2.9:1-10122,10411-10428,10430-10440,10442-10444,10447,10449-10451,10453-10510,10512-10526,10529-10533,10536-10539,10542-10543,10545-10549,10556-10564,10572-10576,10578-10581,10597-10599,10602,10605,10607,10611,10658,10690,10771,11295,11327 /modules/branches/2.7:1-9074,9105,10001,10196,10253,10264,10295,10355,10399-10422,10424-10426,10428-10430,10432-10433,10436-10458,10628,10802,10816,10823,10869,10875-10876 to /modules/branches/2.7:1-9074,9105,10001,10196,10253,10264,10295,10355,10399-10422,10424-10426,10428-10430,10432-10433,10436-10458,10628,10802,10816,10823,10869,10875-10876 /modules/branches/2.9:1-10122,10411-10428,10430-10440,10442-10444,10447,10449-10451,10453-10510,10512-10526,10529-10533,10536-10539,10542-10543,10545-10549,10556-10564,10572-10576,10578-10581,10597-10599,10602,10605,10607,10611,10658,10690,10771,11295,11327,11370
  • modules/branches/2.8/queues/functions.inc.php

    r10661 r11371  
    4545    $ver16 = version_compare($ast_version, '1.6', 'ge'); 
    4646    $ast_ge_14_25 = version_compare($ast_version,'1.4.25','ge'); 
     47    $ast_ge_18 = version_compare($ast_version,'1.8','ge'); 
    4748     
    4849    // legacy but in case someone was using this we will leave it 
     
    142143      // Now pull out all the memebers, one line for each 
    143144      // 
    144       if ($amp_conf['USEQUEUESTATE']) { 
     145      if ($ast_ge_18 || $amp_conf['USEQUEUESTATE']) { 
    145146        foreach ($members as $member) { 
    146147          preg_match("/^Local\/([\d]+)\@*/",$member,$matches); 
     
    148149            $name = $users[$matches[1]]; 
    149150            str_replace(',','\,',$name); 
    150             $output .= "member=$member,$name,hint:".$matches[1]."@ext-local\n"; 
     151             
     152            $qnostate = queues_get_qnostate($matches[1]); 
     153            if ($qnostate == 'ignorestate') { 
     154              $output .= "member=$member,$name\n"; 
     155            } else { 
     156              $output .= "member=$member,$name,hint:".$matches[1]."@ext-local\n"; 
     157            } 
    151158          } else { 
    152159            $output .= "member=".$member."\n"; 
     
    159166            $name = $users[$matches[1]]; 
    160167            str_replace(',','\,',$name); 
    161             $output .= "member=$member,$name,".$devices[$matches[1]]."\n"; 
     168            $qnostate = queues_get_qnostate($matchecs[1]); 
     169            if ($qnostate == 'ignorestate') { 
     170              $output .= "member=$member,$name\n"; 
     171            } else { 
     172              $output .= "member=$member,$name,".$devices[$matches[1]]."\n"; 
     173            } 
    162174          } else { 
    163175            $output .= "member=".$member."\n"; 
     
    297309      $ast_ge_16 = version_compare($version,'1.6','ge'); 
    298310      $ast_ge_14_25 = version_compare($version,'1.4.25','ge'); 
     311      $ast_ge_18 = version_compare($version,'1.8','ge'); 
    299312 
    300313      $has_extension_state = $ast_ge_16; 
     
    566579 
    567580 
    568       if ($amp_conf['USEQUEUESTATE']) { 
    569         $ext->add($context, $exten, '', new ext_execif('$[${DB_EXISTS(AMPUSER/${CALLBACKNUM}/cidname)} = 1]', 'AddQueueMember', '${ARG1},Local/${CALLBACKNUM}@from-queue/n,${DB(QPENALTY/${ARG1}/agents/${CALLBACKNUM})},,${DB(AMPUSER/${CALLBACKNUM}/cidname)},hint:${CALLBACKNUM}@ext-local')); 
     581      if ($ast_ge_18 || $amp_conf['USEQUEUESTATE']) { 
     582        $ext->add($context, $exten, '', new ext_execif('$[${DB_EXISTS(AMPUSER/${CALLBACKNUM}/cidname)} = 1 & "${DB(AMPUSER/${CALLBACKNUM}/queues/qnostate)}" != "ignorestate"]', 'AddQueueMember', '${ARG1},Local/${CALLBACKNUM}@from-queue/n,${DB(QPENALTY/${ARG1}/agents/${CALLBACKNUM})},,${DB(AMPUSER/${CALLBACKNUM}/cidname)},hint:${CALLBACKNUM}@ext-local')); 
     583        $ext->add($context, $exten, '', new ext_execif('$[${DB_EXISTS(AMPUSER/${CALLBACKNUM}/cidname)} = 1 & "${DB(AMPUSER/${CALLBACKNUM}/queues/qnostate)}" = "ignorestate"]', 'AddQueueMember', '${ARG1},Local/${CALLBACKNUM}@from-queue/n,${DB(QPENALTY/${ARG1}/agents/${CALLBACKNUM})},,${DB(AMPUSER/${CALLBACKNUM}/cidname)}')); 
    570584        $ext->add($context, $exten, '', new ext_execif('$[${DB_EXISTS(AMPUSER/${CALLBACKNUM}/cidname)} = 0]', 'AddQueueMember', '${ARG1},Local/${CALLBACKNUM}@from-queue/n,${DB(QPENALTY/${ARG1}/agents/${CALLBACKNUM})}')); 
    571585      } else if ($ast_ge_14_25) { 
    572586        $ext->add($context, $exten, '', new ext_set('THISDEVICE', '${IF($[${LEN(${THISDEVICE})}=0]?${DB(DEVICE/${CUT(DB(AMPUSER/${CALLBACKNUM}/device),&,1)}/dial)}:${THISDEVICE})}')); 
    573         $ext->add($context, $exten, '', new ext_execif('$[${LEN(${THISDEVICE})}!=0]', 'AddQueueMember', '${ARG1},Local/${CALLBACKNUM}@from-queue/n,${DB(QPENALTY/${ARG1}/agents/${CALLBACKNUM})},,${DB(AMPUSER/${CALLBACKNUM}/cidname)},${THISDEVICE}')); 
     587        $ext->add($context, $exten, '', new ext_execif('$[${LEN(${THISDEVICE})}!=0 & "${DB(AMPUSER/${CALLBACKNUM}/queues/qnostate)}" != "ignorestate"]', 'AddQueueMember', '${ARG1},Local/${CALLBACKNUM}@from-queue/n,${DB(QPENALTY/${ARG1}/agents/${CALLBACKNUM})},,${DB(AMPUSER/${CALLBACKNUM}/cidname)},${THISDEVICE}')); 
     588        $ext->add($context, $exten, '', new ext_execif('$[${LEN(${THISDEVICE})}!=0 & "${DB(AMPUSER/${CALLBACKNUM}/queues/qnostate)}" = "ignorestate"]', 'AddQueueMember', '${ARG1},Local/${CALLBACKNUM}@from-queue/n,${DB(QPENALTY/${ARG1}/agents/${CALLBACKNUM})},,${DB(AMPUSER/${CALLBACKNUM}/cidname)}')); 
    574589        $ext->add($context, $exten, '', new ext_execif('$[${LEN(${THISDEVICE})}=0]', 'AddQueueMember', '${ARG1},Local/${CALLBACKNUM}@from-queue/n,${DB(QPENALTY/${ARG1}/agents/${CALLBACKNUM})}')); 
    575590      } else { 
     
    10501065 
    10511066  $ast_ge_14_25 = version_compare($version,'1.4.25','ge'); 
     1067  $ast_ge_18 = version_compare($version,'1.8','ge'); 
    10521068  $id = "macro-toggle-add-agent"; // The context to be included 
    10531069 
     
    10591075  //TODO: check if it's not a user for some reason and abort? 
    10601076  $ext->add($id, $c, '', new ext_gotoif('$["${DB(QPENALTY/${QUEUENO}/dynmemberonly)}" = "yes" & ${DB_EXISTS(QPENALTY/${QUEUENO}/agents/${CALLBACKNUM})} != 1]', 'invalid')); 
    1061   if ($amp_conf['USEQUEUESTATE']) { 
    1062     $ext->add($id, $c, '', new ext_addqueuemember('${QUEUENO}','Local/${CALLBACKNUM}@from-queue/n,${DB(QPENALTY/${QUEUENO}/agents/${CALLBACKNUM})},,${DB(AMPUSER/${CALLBACKNUM}/cidname)},hint:${CALLBACKNUM}@ext-local')); 
     1077  if ($ast_ge_18 || $amp_conf['USEQUEUESTATE']) { 
     1078    $ext->add($id, $c, '', new ext_execif('$["${DB(AMPUSER/${CALLBACKNUM}/queues/qnostate)}" != "ignorestate"]', 'AddQueueMember', '${QUEUENO},Local/${CALLBACKNUM}@from-queue/n,${DB(QPENALTY/${QUEUENO}/agents/${CALLBACKNUM})},,${DB(AMPUSER/${CALLBACKNUM}/cidname)},hint:${CALLBACKNUM}@ext-local')); 
     1079    $ext->add($id, $c, '', new ext_execif('$["${DB(AMPUSER/${CALLBACKNUM}/queues/qnostate)}" = "ignorestate"]', 'AddQueueMember', '${QUEUENO},Local/${CALLBACKNUM}@from-queue/n,${DB(QPENALTY/${QUEUENO}/agents/${CALLBACKNUM})},,${DB(AMPUSER/${CALLBACKNUM}/cidname)}')); 
     1080 
    10631081  } else if ($ast_ge_14_25) { 
    1064     $ext->add($id, $c, '', new ext_addqueuemember('${QUEUENO}','Local/${CALLBACKNUM}@from-queue/n,${DB(QPENALTY/${QUEUENO}/agents/${CALLBACKNUM})},,${DB(AMPUSER/${CALLBACKNUM}/cidname)},${DB(DEVICE/${REALCALLERIDNUM}/dial)}')); 
     1082    $ext->add($id, $c, '', new ext_execif('$["${DB(AMPUSER/${CALLBACKNUM}/queues/qnostate)}" != "ignorestate"]', 'AddQueueMember', '${QUEUENO},Local/${CALLBACKNUM}@from-queue/n,${DB(QPENALTY/${QUEUENO}/agents/${CALLBACKNUM})},,${DB(AMPUSER/${CALLBACKNUM}/cidname)},${DB(DEVICE/${REALCALLERIDNUM}/dial)}')); 
     1083    $ext->add($id, $c, '', new ext_execif('$["${DB(AMPUSER/${CALLBACKNUM}/queues/qnostate)}" = "ignorestate"]', 'AddQueueMember', '${QUEUENO},Local/${CALLBACKNUM}@from-queue/n,${DB(QPENALTY/${QUEUENO}/agents/${CALLBACKNUM})},,${DB(AMPUSER/${CALLBACKNUM}/cidname)}')); 
    10651084  } else { 
    10661085    $ext->add($id, $c, '', new ext_addqueuemember('${QUEUENO}','Local/${CALLBACKNUM}@from-queue/n,${DB(QPENALTY/${QUEUENO}/agents/${CALLBACKNUM})}')); 
     
    10891108  $ext->add($id, $c, '', new ext_macroexit()); 
    10901109} 
     1110 
     1111/************************************************************************************************************ 
     1112 * Hook Exentions/Users to allow an extension to indicate if the Queue should ignore it's state information 
     1113 * when it is acting as a Queue Member (Agent). 
     1114 */ 
     1115function queues_get_qnostate($exten) { 
     1116  global $astman; 
     1117 
     1118  // Retrieve the qnostate configuraiton from this user from ASTDB 
     1119  if ($astman) { 
     1120    $qnostate = $astman->database_get("AMPUSER",$exten."/queues/qnostate"); 
     1121  } else { 
     1122    fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]); 
     1123  } 
     1124  // If it's blank, set it to 'usestate' 
     1125  // 
     1126  return ($qnostate == 'ignorestate' ? $qnostate : 'usestate'); 
     1127} 
     1128 
     1129function queues_set_qnostate($exten,$qnostate) { 
     1130  global $astman; 
     1131   
     1132  // Update the settings in ASTDB 
     1133  if ($astman) { 
     1134    $astman->database_put("AMPUSER",$exten."/queues/qnostate",$qnostate); 
     1135  } else { 
     1136    fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]); 
     1137  } 
     1138} 
     1139 
     1140function queues_applyhooks() { 
     1141  global $currentcomponent; 
     1142 
     1143  $currentcomponent->addoptlistitem('qnostate', 'usestate', _('Use State')); 
     1144  $currentcomponent->addoptlistitem('qnostate', 'ignorestate',_('Ignore State')); 
     1145  $currentcomponent->setoptlistopts('qnostate', 'sort', false); 
     1146 
     1147  // Add the 'process' function - this gets called when the page is loaded, to hook into  
     1148  // displaying stuff on the page. 
     1149  $currentcomponent->addguifunc('queues_configpageload'); 
     1150 
     1151} 
     1152 
     1153function queues_configpageinit($pagename) { 
     1154  global $currentcomponent; 
     1155 
     1156  $action = isset($_REQUEST['action'])?$_REQUEST['action']:null; 
     1157  $extdisplay = isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:null; 
     1158  $extension = isset($_REQUEST['extension'])?$_REQUEST['extension']:null; 
     1159  $tech_hardware = isset($_REQUEST['tech_hardware'])?$_REQUEST['tech_hardware']:null; 
     1160 
     1161  // We only want to hook 'users' or 'extensions' pages. 
     1162  if ($pagename != 'users' && $pagename != 'extensions')  
     1163    return true; 
     1164  // On a 'new' user, 'tech_hardware' is set, and there's no extension. Hook into the page. 
     1165  if ($tech_hardware != null || $pagename == 'users') { 
     1166    queues_applyhooks(); 
     1167    $currentcomponent->addprocessfunc('queues_configprocess', 8); 
     1168  } elseif ($action=="add") { 
     1169    // We don't need to display anything on an 'add', but we do need to handle returned data. 
     1170    $currentcomponent->addprocessfunc('queues_configprocess', 8); 
     1171  } elseif ($extdisplay != '') { 
     1172    // We're now viewing an extension, so we need to display _and_ process. 
     1173    queues_applyhooks(); 
     1174    $currentcomponent->addprocessfunc('queues_configprocess', 8); 
     1175  } 
     1176} 
     1177 
     1178// This is called before the page is actually displayed, so we can use addguielem(). 
     1179function queues_configpageload() { 
     1180  global $currentcomponent; 
     1181 
     1182  // Init vars from $_REQUEST[] 
     1183  $action = isset($_REQUEST['action'])?$_REQUEST['action']:null; 
     1184  $extdisplay = isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:null; 
     1185   
     1186  // Don't display this stuff it it's on a 'This xtn has been deleted' page. 
     1187  if ($action != 'del') { 
     1188 
     1189    $qnostate = queues_get_qnostate($extdisplay); 
     1190 
     1191    $section = _('Extension Options'); 
     1192    $currentcomponent->addguielem($section, new gui_selectbox('qnostate', $currentcomponent->getoptlist('qnostate'), $qnostate, _('Queue State Detection'), _("If this extension is part of a Queue then the Queue will attempt to use the user's extension state or device state information when determining if this queue member should be called. In some uncommon situations such as a Follow-Me with no physical device, or some virtual extension scenarios, the state information will indicate that this member is not available when they are. Setting this to 'Ignore State' will make the Queue ignore all state information thus always trying to contact this member. Certain side affects can occur when this route is taken due to the nature of how Queues handle Local channels, such as subseqeuent transfers will continue to show the member as busy until the original call is terminated. In most cases, this SHOULD BE set to 'Use State'."), false)); 
     1193  } 
     1194} 
     1195 
     1196function queues_configprocess() { 
     1197  //create vars from the request 
     1198  $action = isset($_REQUEST['action'])?$_REQUEST['action']:null; 
     1199  $ext = isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:null; 
     1200  $extn = isset($_REQUEST['extension'])?$_REQUEST['extension']:null; 
     1201  $qnostate = isset($_REQUEST['qnostate'])?$_REQUEST['qnostate']:null; 
     1202 
     1203  if ($ext==='') {  
     1204    $extdisplay = $extn;  
     1205  } else { 
     1206    $extdisplay = $ext; 
     1207  }  
     1208  if ($action == "add" || $action == "edit") { 
     1209    if (!isset($GLOBALS['abort']) || $GLOBALS['abort'] !== true) { 
     1210      queues_set_qnostate($extdisplay, $qnostate); 
     1211    } 
     1212  } // if 'del' then core will remove the entire tree 
     1213} 
    10911214?>