| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
class queues_conf { |
|---|
| 4 |
|
|---|
| 5 |
// files named like pinset_N |
|---|
| 6 |
function get_filename() { |
|---|
| 7 |
return "queues_additional.conf"; |
|---|
| 8 |
} |
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
function generateConf() { |
|---|
| 12 |
|
|---|
| 13 |
global $db; |
|---|
| 14 |
global $version; |
|---|
| 15 |
|
|---|
| 16 |
$additional = ""; |
|---|
| 17 |
$output = ""; |
|---|
| 18 |
|
|---|
| 19 |
// |
|---|
| 20 |
$ver12 = version_compare($version, '1.4', 'lt'); |
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
// |
|---|
| 24 |
$sql = "SELECT keyword,data FROM queues_details WHERE id='-1' AND keyword <> 'account'"; |
|---|
| 25 |
$results = $db->getAll($sql, DB_FETCHMODE_ASSOC); |
|---|
| 26 |
if(DB::IsError($results)) { |
|---|
| 27 |
die($results->getMessage()); |
|---|
| 28 |
} |
|---|
| 29 |
foreach ($results as $result) { |
|---|
| 30 |
if (!$ver12 && trim($result['data']) == '') { |
|---|
| 31 |
continue; |
|---|
| 32 |
} |
|---|
| 33 |
$additional .= $result['keyword']."=".$result['data']."\n"; |
|---|
| 34 |
} |
|---|
| 35 |
|
|---|
| 36 |
$results = queues_list(); |
|---|
| 37 |
foreach ($results as $result) { |
|---|
| 38 |
$output .= "[".$result[0]."]\n"; |
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
// and nothing else |
|---|
| 42 |
// |
|---|
| 43 |
$results2 = queues_get($result[0], true); |
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
// and then generate each later |
|---|
| 47 |
// |
|---|
| 48 |
$members = $results2['member']; |
|---|
| 49 |
unset($results2['member']); |
|---|
| 50 |
|
|---|
| 51 |
foreach ($results2 as $keyword => $data) { |
|---|
| 52 |
if ($ver12){ |
|---|
| 53 |
$output .= $keyword."=".$data."\n"; |
|---|
| 54 |
}else{ |
|---|
| 55 |
switch($keyword){ |
|---|
| 56 |
case (trim($data) == ''): |
|---|
| 57 |
case 'monitor-join': |
|---|
| 58 |
break; |
|---|
| 59 |
case 'monitor-format': |
|---|
| 60 |
if (strtolower($data) != 'no'){ |
|---|
| 61 |
$output .= "monitor-type=mixmonitor\n"; |
|---|
| 62 |
$output .= $keyword."=".$data."\n"; |
|---|
| 63 |
} |
|---|
| 64 |
break; |
|---|
| 65 |
default: |
|---|
| 66 |
$output .= $keyword."=".$data."\n"; |
|---|
| 67 |
break; |
|---|
| 68 |
} |
|---|
| 69 |
} |
|---|
| 70 |
} |
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
// |
|---|
| 74 |
foreach ($members as $member) { |
|---|
| 75 |
$output .= "member=".$member."\n"; |
|---|
| 76 |
} |
|---|
| 77 |
$output .= $additional."\n"; |
|---|
| 78 |
} |
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
// if there are any truncated compound recrodings and if so |
|---|
| 82 |
// crate a noticication. |
|---|
| 83 |
// |
|---|
| 84 |
$nt = notifications::create($db); |
|---|
| 85 |
|
|---|
| 86 |
$compound_recordings = queues_check_compoundrecordings(); |
|---|
| 87 |
if (empty($compound_recordings)) { |
|---|
| 88 |
$nt->delete('queues', 'COMPOUNDREC'); |
|---|
| 89 |
} else { |
|---|
| 90 |
$str = _("Warning, there are compound recordings configured in one or more Queue configurations. Queues can not play these so they have been truncated to the first sound file. You should correct this problem.<br />Details:<br /><br />"); |
|---|
| 91 |
foreach ($compound_recordings as $item) { |
|---|
| 92 |
$str .= sprintf(_("Queue - %s (%s): %s<br />"), $item['extension'], $item['descr'], $item['error']); |
|---|
| 93 |
} |
|---|
| 94 |
$nt->add_error('queues', 'COMPOUNDREC', _("Compound Recordings in Queues Detected"), $str); |
|---|
| 95 |
} |
|---|
| 96 |
return $output; |
|---|
| 97 |
} |
|---|
| 98 |
} |
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
function queues_destinations() { |
|---|
| 103 |
|
|---|
| 104 |
$results = queues_list(); |
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
if (isset($results)) { |
|---|
| 108 |
foreach($results as $result){ |
|---|
| 109 |
$extens[] = array('destination' => 'ext-queues,'.$result['0'].',1', 'description' => $result['1'].' <'.$result['0'].'>'); |
|---|
| 110 |
} |
|---|
| 111 |
} |
|---|
| 112 |
|
|---|
| 113 |
if (isset($extens)) |
|---|
| 114 |
return $extens; |
|---|
| 115 |
else |
|---|
| 116 |
return null; |
|---|
| 117 |
} |
|---|
| 118 |
|
|---|
| 119 |
function queues_getdest($exten) { |
|---|
| 120 |
return array('ext-queues,'.$exten.',1'); |
|---|
| 121 |
} |
|---|
| 122 |
|
|---|
| 123 |
function queues_getdestinfo($dest) { |
|---|
| 124 |
global $active_modules; |
|---|
| 125 |
|
|---|
| 126 |
if (substr(trim($dest),0,11) == 'ext-queues,') { |
|---|
| 127 |
$exten = explode(',',$dest); |
|---|
| 128 |
$exten = $exten[1]; |
|---|
| 129 |
$thisexten = queues_get($exten); |
|---|
| 130 |
if (empty($thisexten)) { |
|---|
| 131 |
return array(); |
|---|
| 132 |
} else { |
|---|
| 133 |
|
|---|
| 134 |
return array('description' => 'Queue '.$exten.' : '.$thisexten['name'], |
|---|
| 135 |
'edit_url' => 'config.php?display=queues&extdisplay='.urlencode($exten), |
|---|
| 136 |
); |
|---|
| 137 |
} |
|---|
| 138 |
} else { |
|---|
| 139 |
return false; |
|---|
| 140 |
} |
|---|
| 141 |
} |
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 |
function queues_get_config($engine) { |
|---|
| 147 |
global $ext; |
|---|
| 148 |
switch($engine) { |
|---|
| 149 |
case "asterisk": |
|---|
| 150 |
|
|---|
| 151 |
$ext->addInclude('from-internal-additional','ext-queues'); |
|---|
| 152 |
$qlist = queues_list(); |
|---|
| 153 |
if (is_array($qlist)) { |
|---|
| 154 |
foreach($qlist as $item) { |
|---|
| 155 |
|
|---|
| 156 |
$exten = $item[0]; |
|---|
| 157 |
$q = queues_get($exten); |
|---|
| 158 |
|
|---|
| 159 |
$grppre = (isset($q['prefix'])?$q['prefix']:''); |
|---|
| 160 |
$alertinfo = (isset($q['alertinfo'])?$q['alertinfo']:''); |
|---|
| 161 |
|
|---|
| 162 |
$ext->add('ext-queues', $exten, '', new ext_macro('user-callerid')); |
|---|
| 163 |
$ext->add('ext-queues', $exten, '', new ext_answer('')); |
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 |
// line to clear this flag so that subsequent transfers can occur. |
|---|
| 167 |
// |
|---|
| 168 |
$ext->add('ext-queues', $exten, '', new ext_setvar('__BLKVM_OVERRIDE', 'BLKVM/${EXTEN}/${CHANNEL}')); |
|---|
| 169 |
$ext->add('ext-queues', $exten, '', new ext_setvar('__BLKVM_BASE', '${EXTEN}')); |
|---|
| 170 |
$ext->add('ext-queues', $exten, '', new ext_setvar('DB(${BLKVM_OVERRIDE})', 'TRUE')); |
|---|
| 171 |
$ext->add('ext-queues', $exten, '', new ext_setvar('_DIAL_OPTIONS', '${DIAL_OPTIONS}M(auto-blkvm)')); |
|---|
| 172 |
|
|---|
| 173 |
|
|---|
| 174 |
// |
|---|
| 175 |
$ext->add('ext-queues', $exten, '', new ext_setvar('__NODEST', '${EXTEN}')); |
|---|
| 176 |
|
|---|
| 177 |
|
|---|
| 178 |
// Use the same variable as ringgroups/followme so that we can manage chaines of calls |
|---|
| 179 |
// but strip only if you plan on setting a new one |
|---|
| 180 |
// |
|---|
| 181 |
if ($grppre != '') { |
|---|
| 182 |
$ext->add('ext-queues', $exten, '', new ext_gotoif('$["foo${RGPREFIX}" = "foo"]', 'REPCID')); |
|---|
| 183 |
$ext->add('ext-queues', $exten, '', new ext_gotoif('$["${RGPREFIX}" != "${CALLERID(name):0:${LEN(${RGPREFIX})}}"]', 'REPCID')); |
|---|
| 184 |
$ext->add('ext-queues', $exten, '', new ext_noop('Current RGPREFIX is ${RGPREFIX}....stripping from Caller ID')); |
|---|
| 185 |
$ext->add('ext-queues', $exten, '', new ext_setvar('CALLERID(name)', '${CALLERID(name):${LEN(${RGPREFIX})}}')); |
|---|
| 186 |
$ext->add('ext-queues', $exten, '', new ext_setvar('_RGPREFIX', '')); |
|---|
| 187 |
$ext->add('ext-queues', $exten, 'REPCID', new ext_noop('CALLERID(name) is ${CALLERID(name)}')); |
|---|
| 188 |
$ext->add('ext-queues', $exten, '', new ext_setvar('_RGPREFIX', $grppre)); |
|---|
| 189 |
$ext->add('ext-queues', $exten, '', new ext_setvar('CALLERID(name)','${RGPREFIX}${CALLERID(name)}')); |
|---|
| 190 |
} |
|---|
| 191 |
|
|---|
| 192 |
|
|---|
| 193 |
if ($alertinfo != '') { |
|---|
| 194 |
$ext->add('ext-queues', $exten, '', new ext_setvar('__ALERT_INFO', str_replace(';', '\;', $alertinfo))); |
|---|
| 195 |
} |
|---|
| 196 |
|
|---|
| 197 |
$ext->add('ext-queues', $exten, '', new ext_setvar('MONITOR_FILENAME','/var/spool/asterisk/monitor/q${EXTEN}-${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${UNIQUEID}')); |
|---|
| 198 |
$joinannounce = (isset($q['joinannounce'])?$q['joinannounce']:''); |
|---|
| 199 |
if($joinannounce != "") { |
|---|
| 200 |
$ext->add('ext-queues', $exten, '', new ext_playback($joinannounce)); |
|---|
| 201 |
} |
|---|
| 202 |
$options = 't'; |
|---|
| 203 |
if ($q['rtone'] == 1) |
|---|
| 204 |
$options .= 'r'; |
|---|
| 205 |
if (isset($q['music'])) { |
|---|
| 206 |
$ext->add('ext-queues', $exten, '', new ext_setvar('__MOHCLASS', $q['music'])); |
|---|
| 207 |
} |
|---|
| 208 |
|
|---|
| 209 |
// stalling the ACD. |
|---|
| 210 |
if ($q['cwignore']) { |
|---|
| 211 |
$ext->add('ext-queues', $exten, '', new ext_setvar('_CWIGNORE', 'TRUE')); |
|---|
| 212 |
} |
|---|
| 213 |
$agentannounce = (isset($q['agentannounce'])?$q['agentannounce']:''); |
|---|
| 214 |
$ext->add('ext-queues', $exten, '', new ext_queue($exten,$options,'',$agentannounce,$q['maxwait'])); |
|---|
| 215 |
|
|---|
| 216 |
$ext->add('ext-queues', $exten, '', new ext_dbdel('${BLKVM_OVERRIDE}')); |
|---|
| 217 |
|
|---|
| 218 |
// |
|---|
| 219 |
$ext->add('ext-queues', $exten, '', new ext_setvar('__NODEST', '')); |
|---|
| 220 |
|
|---|
| 221 |
|
|---|
| 222 |
$goto_context = strtok($q['goto'],','); |
|---|
| 223 |
$goto_exten = strtok(','); |
|---|
| 224 |
$goto_pri = strtok(','); |
|---|
| 225 |
|
|---|
| 226 |
$ext->add('ext-queues', $exten, '', new ext_goto($goto_pri,$goto_exten,$goto_context)); |
|---|
| 227 |
|
|---|
| 228 |
|
|---|
| 229 |
$ext->add('ext-queues', $exten."*", '', new ext_macro('agent-add',$exten.",".$q['password'])); |
|---|
| 230 |
$ext->add('ext-queues', $exten."**", '', new ext_macro('agent-del',$exten.",".$exten)); |
|---|
| 231 |
} |
|---|
| 232 |
} |
|---|
| 233 |
break; |
|---|
| 234 |
} |
|---|
| 235 |
} |
|---|
| 236 |
|
|---|
| 237 |
function queues_timeString($seconds, $full = false) { |
|---|
| 238 |
if ($seconds == 0) { |
|---|
| 239 |
return "0 ".($full ? "seconds" : "s"); |
|---|
| 240 |
} |
|---|
| 241 |
|
|---|
| 242 |
$minutes = floor($seconds / 60); |
|---|
| 243 |
$seconds = $seconds % 60; |
|---|
| 244 |
|
|---|
| 245 |
$hours = floor($minutes / 60); |
|---|
| 246 |
$minutes = $minutes % 60; |
|---|
| 247 |
|
|---|
| 248 |
$days = floor($hours / 24); |
|---|
| 249 |
$hours = $hours % 24; |
|---|
| 250 |
|
|---|
| 251 |
if ($full) { |
|---|
| 252 |
return substr( |
|---|
| 253 |
($days ? $days." day".(($days == 1) ? "" : "s").", " : ""). |
|---|
| 254 |
($hours ? $hours." hour".(($hours == 1) ? "" : "s").", " : ""). |
|---|
| 255 |
($minutes ? $minutes." minute".(($minutes == 1) ? "" : "s").", " : ""). |
|---|
| 256 |
($seconds ? $seconds." second".(($seconds == 1) ? "" : "s").", " : ""), |
|---|
| 257 |
0, -2); |
|---|
| 258 |
} else { |
|---|
| 259 |
return substr(($days ? $days."d, " : "").($hours ? $hours."h, " : "").($minutes ? $minutes."m, " : "").($seconds ? $seconds."s, " : ""), 0, -2); |
|---|
| 260 |
} |
|---|
| 261 |
} |
|---|
| 262 |
|
|---|
| 263 |
function queues_add($account,$name,$password,$prefix,$goto,$agentannounce,$members,$joinannounce,$maxwait,$alertinfo='',$cwignore='no') { |
|---|
| 264 |
global $db; |
|---|
| 265 |
|
|---|
| 266 |
if (trim($account) == '') { |
|---|
| 267 |
echo "<script>javascript:alert('"._("Bad Queue Number, can not be blank")."');</script>"; |
|---|
| 268 |
return false; |
|---|
| 269 |
} |
|---|
| 270 |
|
|---|
| 271 |
|
|---|
| 272 |
if (empty($agentannounce) || $agentannounce == 'None') { |
|---|
| 273 |
$agentannounce=""; |
|---|
| 274 |
} |
|---|
| 275 |
|
|---|
| 276 |
$fields = array( |
|---|
| 277 |
array($account,'maxlen',($_REQUEST['maxlen'])?$_REQUEST['maxlen']:'0',0), |
|---|
| 278 |
array($account,'joinempty',($_REQUEST['joinempty'])?$_REQUEST['joinempty']:'yes',0), |
|---|
| 279 |
array($account,'leavewhenempty',($_REQUEST['leavewhenempty'])?$_REQUEST['leavewhenempty']:'no',0), |
|---|
| 280 |
array($account,'strategy',($_REQUEST['strategy'])?$_REQUEST['strategy']:'ringall',0), |
|---|
| 281 |
array($account,'timeout',(isset($_REQUEST['timeout']))?$_REQUEST['timeout']:'15',0), |
|---|
| 282 |
array($account,'retry',(isset($_REQUEST['retry']) && $_REQUEST['retry'] != '')?$_REQUEST['retry']:'5',0), |
|---|
| 283 |
array($account,'wrapuptime',($_REQUEST['wrapuptime'])?$_REQUEST['wrapuptime']:'0',0), |
|---|
| 284 |
array($account,'announce-frequency',($_REQUEST['announcefreq'])?$_REQUEST['announcefreq']:'0',0), |
|---|
| 285 |
array($account,'announce-holdtime',($_REQUEST['announceholdtime'])?$_REQUEST['announceholdtime']:'no',0), |
|---|
| 286 |
array($account,'queue-youarenext',($_REQUEST['announceposition']=='no')?'silence/1':'queue-youarenext',0), |
|---|
| 287 |
array($account,'queue-thereare',($_REQUEST['announceposition']=='no')?'silence/1':'queue-thereare',0), |
|---|
| 288 |
array($account,'queue-callswaiting',($_REQUEST['announceposition']=='no')?'silence/1':'queue-callswaiting',0), |
|---|
| 289 |
array($account,'queue-thankyou',($_REQUEST['announceposition']=='no')?'':'queue-thankyou',0), |
|---|
| 290 |
array($account,'periodic-announce-frequency',($_REQUEST['pannouncefreq'])?$_REQUEST['pannouncefreq']:'0',0), |
|---|
| 291 |
array($account,'monitor-format',($_REQUEST['monitor-format'])?$_REQUEST['monitor-format']:'',0), |
|---|
| 292 |
array($account,'monitor-join','yes',0), |
|---|
| 293 |
array($account,'eventwhencalled',($_REQUEST['eventwhencalled'])?$_REQUEST['eventwhencalled']:'no',0), |
|---|
| 294 |
array($account,'eventmemberstatus',($_REQUEST['eventmemberstatus'])?$_REQUEST['eventmemberstatus']:'no',0)); |
|---|
| 295 |
|
|---|
| 296 |
if ($_REQUEST['music'] != 'inherit') { |
|---|
| 297 |
$fields[] = array($account,'music',($_REQUEST['music'])?$_REQUEST['music']:'default',0); |
|---|
| 298 |
} |
|---|
| 299 |
|
|---|
| 300 |
|
|---|
| 301 |
if (isset($members)) { |
|---|
| 302 |
$count = 0; |
|---|
| 303 |
foreach ($members as $member) { |
|---|
| 304 |
$fields[] = array($account,'member',$member,$count); |
|---|
| 305 |
$count++; |
|---|
| 306 |
} |
|---|
| 307 |
} |
|---|
| 308 |
|
|---|
| 309 |
$compiled = $db->prepare('INSERT INTO queues_details (id, keyword, data, flags) values (?,?,?,?)'); |
|---|
| 310 |
$result = $db->executeMultiple($compiled,$fields); |
|---|
| 311 |
if(DB::IsError($result)) { |
|---|
| 312 |
die_freepbx($result->getMessage()."<br><br>error adding to queues_details table"); |
|---|
| 313 |
} |
|---|
| 314 |
$extension = $account; |
|---|
| 315 |
$descr = isset($name) ? $name:''; |
|---|
| 316 |
$grppre = isset($prefix) ? $prefix:''; |
|---|
| 317 |
$alertinfo = isset($alertinfo) ? $alertinfo:''; |
|---|
| 318 |
$joinannounce = strtolower($joinannounce) != 'none' ? $joinannounce:''; |
|---|
| 319 |
$ringing = isset($_REQUEST['rtone']) ? $_REQUEST['rtone']:''; |
|---|
| 320 |
$agentannounce = strtolower($agentannounce) != 'none' ? $agentannounce:''; |
|---|
| 321 |
$maxwait = isset($maxwait) ? $maxwait:''; |
|---|
| 322 |
$password = isset($password) ? $password:''; |
|---|
| 323 |
$ivr_id = isset($_REQUEST['announcemenu']) ? $_REQUEST['announcemenu']:'none'; |
|---|
| 324 |
$dest = isset($goto) ? $goto:''; |
|---|
| 325 |
$cwignore = isset($cwignore) ? $cwignore:'0'; |
|---|
| 326 |
|
|---|
| 327 |
|
|---|
| 328 |
$sql = "INSERT INTO queues_config (extension, descr, grppre, alertinfo, joinannounce, ringing, agentannounce, maxwait, password, ivr_id, dest, cwignore) |
|---|
| 329 |
VALUES ('$extension', '$descr', '$grppre', '$alertinfo', '$joinannounce', '$ringing', '$agentannounce', '$maxwait', '$password', '$ivr_id', '$dest', '$cwignore') "; |
|---|
| 330 |
$results = sql($sql); |
|---|
| 331 |
return true; |
|---|
| 332 |
} |
|---|
| 333 |
|
|---|
| 334 |
function queues_del($account) { |
|---|
| 335 |
global $db; |
|---|
| 336 |
|
|---|
| 337 |
$sql = "DELETE FROM queues_details WHERE id = '$account'"; |
|---|
| 338 |
$result = $db->query($sql); |
|---|
| 339 |
if(DB::IsError($result)) { |
|---|
| 340 |
die_freepbx($result->getMessage().$sql); |
|---|
| 341 |
} |
|---|
| 342 |
$sql = "DELETE FROM queues_config WHERE extension = '$account'"; |
|---|
| 343 |
$result = $db->query($sql); |
|---|
| 344 |
if(DB::IsError($result)) { |
|---|
| 345 |
die_freepbx($result->getMessage().$sql); |
|---|
| 346 |
} |
|---|
| 347 |
|
|---|
| 348 |
} |
|---|
| 349 |
|
|---|
| 350 |
|
|---|
| 351 |
function queues_list() { |
|---|
| 352 |
global $db; |
|---|
| 353 |
$sql = "SELECT extension, descr FROM queues_config ORDER BY extension"; |
|---|
| 354 |
$results = $db->getAll($sql); |
|---|
| 355 |
if(DB::IsError($results)) { |
|---|
| 356 |
$results = array(); |
|---|
| 357 |
} |
|---|
| 358 |
|
|---|
| 359 |
foreach($results as $result){ |
|---|
| 360 |
if (checkRange($result[0])){ |
|---|
| 361 |
$extens[] = array($result[0],$result[1]); |
|---|
| 362 |
} |
|---|
| 363 |
} |
|---|
| 364 |
if (isset($extens)) { |
|---|
| 365 |
return $extens; |
|---|
| 366 |
} else { |
|---|
| 367 |
return array(); |
|---|
| 368 |
} |
|---|
| 369 |
} |
|---|
| 370 |
|
|---|
| 371 |
function queues_check_extensions($exten=true) { |
|---|
| 372 |
global $active_modules; |
|---|
| 373 |
|
|---|
| 374 |
$extenlist = array(); |
|---|
| 375 |
if (is_array($exten) && empty($exten)) { |
|---|
| 376 |
return $extenlist; |
|---|
| 377 |
} |
|---|
| 378 |
$sql = "SELECT extension, descr FROM queues_config "; |
|---|
| 379 |
if (is_array($exten)) { |
|---|
| 380 |
$sql .= "WHERE extension in ('".implode("','",$exten)."')"; |
|---|
| 381 |
} |
|---|
| 382 |
$sql .= " ORDER BY extension"; |
|---|
| 383 |
$results = sql($sql,"getAll",DB_FETCHMODE_ASSOC); |
|---|
| 384 |
|
|---|
| 385 |
|
|---|
| 386 |
foreach ($results as $result) { |
|---|
| 387 |
$thisexten = $result['extension']; |
|---|
| 388 |
$extenlist[$thisexten]['description'] = _("Queue: ").$result['descr']; |
|---|
| 389 |
$extenlist[$thisexten]['status'] = 'INUSE'; |
|---|
| 390 |
$extenlist[$thisexten]['edit_url'] = 'config.php?display=queues&extdisplay='.urlencode($thisexten); |
|---|
| 391 |
} |
|---|
| 392 |
return $extenlist; |
|---|
| 393 |
} |
|---|
| 394 |
|
|---|
| 395 |
function queues_check_destinations($dest=true) { |
|---|
| 396 |
global $active_modules; |
|---|
| 397 |
|
|---|
| 398 |
$destlist = array(); |
|---|
| 399 |
if (is_array($dest) && empty($dest)) { |
|---|
| 400 |
return $destlist; |
|---|
| 401 |
} |
|---|
| 402 |
$sql = "SELECT extension, descr, dest FROM queues_config"; |
|---|
| 403 |
if ($dest !== true) { |
|---|
| 404 |
$sql .= " WHERE dest in ('".implode("','",$dest)."')"; |
|---|
| 405 |
} |
|---|
| 406 |
$sql .= " ORDER BY extension"; |
|---|
| 407 |
|
|---|
| 408 |
$results = sql($sql,"getAll",DB_FETCHMODE_ASSOC); |
|---|
| 409 |
|
|---|
| 410 |
|
|---|
| 411 |
|
|---|
| 412 |
foreach ($results as $result) { |
|---|
| 413 |
$thisdest = $result['dest']; |
|---|
| 414 |
$thisid = $result['extension']; |
|---|
| 415 |
$destlist[] = array( |
|---|
| 416 |
'dest' => $thisdest, |
|---|
| 417 |
'description' => 'Queue: '.$result['descr'].'('.$thisid.')', |
|---|
| 418 |
'edit_url' => 'config.php?display=queues&extdisplay='.urlencode($thisid), |
|---|
| 419 |
); |
|---|
| 420 |
} |
|---|
| 421 |
return $destlist; |
|---|
| 422 |
} |
|---|
| 423 |
|
|---|
| 424 |
function queues_check_compoundrecordings() { |
|---|
| 425 |
global $db; |
|---|
| 426 |
|
|---|
| 427 |
$compound_recordings = array(); |
|---|
| 428 |
$sql = "SELECT extension, descr, agentannounce, ivr_id FROM queues_config WHERE (ivr_id != 'none' AND ivr_id != '') OR agentannounce != ''"; |
|---|
| 429 |
$results = sql($sql, "getAll",DB_FETCHMODE_ASSOC); |
|---|
| 430 |
|
|---|
| 431 |
if (function_exists('ivr_list')) { |
|---|
| 432 |
$ivr_details = ivr_list(); |
|---|
| 433 |
foreach ($ivr_details as $item) { |
|---|
| 434 |
$ivr_hash[$item['ivr_id']] = $item; |
|---|
| 435 |
} |
|---|
| 436 |
$check_ivr = true; |
|---|
| 437 |
} else { |
|---|
| 438 |
$check_ivr = false; |
|---|
| 439 |
} |
|---|
| 440 |
|
|---|
| 441 |
foreach ($results as $result) { |
|---|
| 442 |
if (strpos($result['agentannounce'],"&") !== false) { |
|---|
| 443 |
$compound_recordings[] = array( |
|---|
| 444 |
'extension' => $result['extension'], |
|---|
| 445 |
'descr' => $result['descr'], |
|---|
| 446 |
'error' => _("Agent Announce Msg"), |
|---|
| 447 |
); |
|---|
| 448 |
} |
|---|
| 449 |
if ($result['ivr_id'] != 'none' && $result['ivr_id'] != '' && $check_ivr) { |
|---|
| 450 |
if (strpos($ivr_hash[$result['ivr_id']]['announcement'],"&") !== false) { |
|---|
| 451 |
$compound_recordings[] = array( |
|---|
| 452 |
'extension' => $result['extension'], |
|---|
| 453 |
'descr' => $result['descr'], |
|---|
| 454 |
'error' => sprintf(_("IVR Announce: %s"),$ivr_hash[$result['ivr_id']]['displayname']), |
|---|
| 455 |
); |
|---|
| 456 |
} |
|---|
| 457 |
} |
|---|
| 458 |
} |
|---|
| 459 |
return $compound_recordings; |
|---|
| 460 |
} |
|---|
| 461 |
|
|---|
| 462 |
|
|---|
| 463 |
function queues_get($account, $queues_conf_only=false) { |
|---|
| 464 |
global $db; |
|---|
| 465 |
|
|---|
| 466 |
if ($account == "") |
|---|
| 467 |
{ |
|---|
| 468 |
return array(); |
|---|
| 469 |
} |
|---|
| 470 |
|
|---|
| 471 |
$account = q($account); |
|---|
| 472 |
|
|---|
| 473 |
$sql = "SELECT keyword,data FROM queues_details WHERE id = $account"; |
|---|
| 474 |
$results = $db->getAssoc($sql); |
|---|
| 475 |
if (empty($results)) { |
|---|
| 476 |
return array(); |
|---|
| 477 |
} |
|---|
| 478 |
|
|---|
| 479 |
|
|---|
| 480 |
$sql = "SELECT data FROM queues_details WHERE id = $account AND keyword = 'member' order by flags"; |
|---|
| 481 |
$results['member'] = $db->getCol($sql); |
|---|
| 482 |
|
|---|
| 483 |
|
|---|
| 484 |
if (!$queues_conf_only) { |
|---|
| 485 |
if(isset($results['queue-youarenext']) && $results['queue-youarenext'] == 'queue-youarenext') { |
|---|
| 486 |
$results['announce-position'] = 'yes'; |
|---|
| 487 |
} else { |
|---|
| 488 |
$results['announce-position'] = 'no'; |
|---|
| 489 |
} |
|---|
| 490 |
} |
|---|
| 491 |
|
|---|
| 492 |
|
|---|
| 493 |
if(isset($results['eventmemberstatusoff'])) { |
|---|
| 494 |
if (strtolower($results['eventmemberstatusoff']) == 'yes') { |
|---|
| 495 |
$results['eventmemberstatus'] = 'no'; |
|---|
| 496 |
} else { |
|---|
| 497 |
$results['eventmemberstatus'] = 'yes'; |
|---|
| 498 |
} |
|---|
| 499 |
} elseif (!isset($results['eventmemberstatus'])){ |
|---|
| 500 |
$results['eventmemberstatus'] = 'no'; |
|---|
| 501 |
} |
|---|
| 502 |
|
|---|
| 503 |
if ($queues_conf_only) { |
|---|
| 504 |
$sql = "SELECT ivr_id FROM queues_config WHERE extension = $account"; |
|---|
| 505 |
$config = sql($sql, "getRow",DB_FETCHMODE_ASSOC); |
|---|
| 506 |
|
|---|
| 507 |
|
|---|
| 508 |
// |
|---|
| 509 |
$agentannounce_arr = explode("&", $config['agentannounce']); |
|---|
| 510 |
$results['agentannounce'] = $agentannounce_arr[0]; |
|---|
| 511 |
} else { |
|---|
| 512 |
$sql = "SELECT * FROM queues_config WHERE extension = $account"; |
|---|
| 513 |
$config = sql($sql, "getRow",DB_FETCHMODE_ASSOC); |
|---|
| 514 |
|
|---|
| 515 |
$results['prefix'] = $config['grppre']; |
|---|
| 516 |
$results['alertinfo'] = $config['alertinfo']; |
|---|
| 517 |
$results['agentannounce'] = $config['agentannounce']; |
|---|
| 518 |
$results['maxwait'] = $config['maxwait']; |
|---|
| 519 |
$results['name'] = $config['descr']; |
|---|
| 520 |
$results['joinannounce'] = $config['joinannounce']; |
|---|
| 521 |
$results['password'] = $config['password']; |
|---|
| 522 |
$results['goto'] = $config['dest']; |
|---|
| 523 |
$results['announcemenu'] = $config['ivr_id']; |
|---|
| 524 |
$results['rtone'] = $config['ringing']; |
|---|
| 525 |
$results['cwignore'] = $config['cwignore']; |
|---|
| 526 |
} |
|---|
| 527 |
|
|---|
| 528 |
$results['context'] = ''; |
|---|
| 529 |
$results['periodic-announce'] = ''; |
|---|
| 530 |
|
|---|
| 531 |
if ($config['ivr_id'] != 'none' && $config['ivr_id'] != '') { |
|---|
| 532 |
if (function_exists('ivr_get_details')) { |
|---|
| 533 |
$results['context'] = "ivr-".$config['ivr_id']; |
|---|
| 534 |
$arr = ivr_get_details($config['ivr_id']); |
|---|
| 535 |
if( isset($arr['announcement']) && $arr['announcement'] != '') { |
|---|
| 536 |
|
|---|
| 537 |
|
|---|
| 538 |
// |
|---|
| 539 |
$periodic_arr = explode("&", $arr['announcement']); |
|---|
| 540 |
$results['periodic-announce'] = $periodic_arr[0]; |
|---|
| 541 |
} |
|---|
| 542 |
} |
|---|
| 543 |
} |
|---|
| 544 |
|
|---|
| 545 |
return $results; |
|---|
| 546 |
} |
|---|
| 547 |
?> |
|---|
| 548 |
|
|---|