| 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)}')); |
|---|
| 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)}')); |
|---|
| 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 | |
|---|
| 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)}')); |
|---|
| | 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 | */ |
|---|
| | 1115 | function 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 | |
|---|
| | 1129 | function 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 | |
|---|
| | 1140 | function 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 | |
|---|
| | 1153 | function 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(). |
|---|
| | 1179 | function 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 | |
|---|
| | 1196 | function 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 | } |
|---|