Changeset 6170
- Timestamp:
- 07/24/08 18:21:08 (4 months ago)
- Files:
-
- modules/branches/2.5/queues/functions.inc.php (modified) (12 diffs)
- modules/branches/2.5/queues/install.php (modified) (2 diffs)
- modules/branches/2.5/queues/module.xml (modified) (3 diffs)
- modules/branches/2.5/queues/page.queues.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/branches/2.5/queues/functions.inc.php
r5993 r6170 144 144 } else { 145 145 return false; 146 } 147 } 148 149 function queues_recordings_usage($recording_id) { 150 global $active_modules; 151 152 $results = sql("SELECT `extension`, `descr` FROM `queues_config` WHERE `agentannounce_id` = '$recording_id' OR `joinannounce_id` = '$recording_id'","getAll",DB_FETCHMODE_ASSOC); 153 if (empty($results)) { 154 return array(); 155 } else { 156 //$type = isset($active_modules['queues']['type'])?$active_modules['queues']['type']:'setup'; 157 foreach ($results as $result) { 158 $usage_arr[] = array( 159 'url_query' => 'config.php?display=queues&extdisplay='.urlencode($result['extension']), 160 'description' => "Queue: ".$result['descr'], 161 ); 162 } 163 return $usage_arr; 164 } 165 } 166 167 function queues_ivr_usage($ivr_id) { 168 global $active_modules; 169 170 $results = sql("SELECT `extension`, `descr` FROM `queues_config` WHERE `ivr_id` = '$ivr_id'","getAll",DB_FETCHMODE_ASSOC); 171 if (empty($results)) { 172 return array(); 173 } else { 174 foreach ($results as $result) { 175 $usage_arr[] = array( 176 'url_query' => 'config.php?display=queues&extdisplay='.urlencode($result['extension']), 177 'description' => "Queue: ".$result['descr'], 178 ); 179 } 180 return $usage_arr; 146 181 } 147 182 } … … 208 243 209 244 $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}')); 210 $joinannounce = (isset($q['joinannounce'])?$q['joinannounce']:''); 211 if($joinannounce != "") { 245 $joinannounce_id = (isset($q['joinannounce_id'])?$q['joinannounce_id']:''); 246 if($joinannounce_id) { 247 $joinannounce = recordings_get_file($joinannounce_id); 212 248 $ext->add('ext-queues', $exten, '', new ext_playback($joinannounce)); 213 249 } … … 223 259 $ext->add('ext-queues', $exten, '', new ext_setvar('_CWIGNORE', 'TRUE')); 224 260 } 225 $agentannounce = (isset($q['agentannounce'])?$q['agentannounce']:''); 261 $agentannounce_id = (isset($q['agentannounce_id'])?$q['agentannounce_id']:''); 262 if ($agentannounce_id) { 263 $agentannounce = recordings_get_file($agentannounce_id); 264 } else { 265 $agentannounce = ''; 266 } 226 267 $ext->add('ext-queues', $exten, '', new ext_queue($exten,$options,'',$agentannounce,$q['maxwait'])); 227 268 … … 276 317 } 277 318 278 function queues_add($account,$name,$password,$prefix,$goto,$agentannounce ,$members,$joinannounce,$maxwait,$alertinfo='',$cwignore='no',$qregex='') {319 function queues_add($account,$name,$password,$prefix,$goto,$agentannounce_id,$members,$joinannounce_id,$maxwait,$alertinfo='',$cwignore='no',$qregex='') { 279 320 global $db; 280 321 … … 285 326 286 327 //add to extensions table 287 if (empty($agentannounce ) || $agentannounce == 'None') {288 $agentannounce ="";328 if (empty($agentannounce_id)) { 329 $agentannounce_id=""; 289 330 } 290 331 … … 333 374 $grppre = isset($prefix) ? addslashes($prefix):''; 334 375 $alertinfo = isset($alertinfo) ? addslashes($alertinfo):''; 335 $joinannounce = strtolower($joinannounce) != 'none' ? $joinannounce:'';376 //$joinannounce_id = $joinannounce_id; 336 377 $ringing = isset($_REQUEST['rtone']) ? $_REQUEST['rtone']:''; 337 $agentannounce = strtolower($agentannounce) != 'none' ? $agentannounce:'';378 //$agentannounce_id = $agentannounce_id; 338 379 $maxwait = isset($maxwait) ? $maxwait:''; 339 380 $password = isset($password) ? $password:''; … … 344 385 345 386 // Assumes it has just been deleted 346 $sql = "INSERT INTO queues_config (extension, descr, grppre, alertinfo, joinannounce , ringing, agentannounce, maxwait, password, ivr_id, dest, cwignore, qregex)347 VALUES ('$extension', '$descr', '$grppre', '$alertinfo', '$joinannounce ', '$ringing', '$agentannounce', '$maxwait', '$password', '$ivr_id', '$dest', '$cwignore', '$qregex') ";387 $sql = "INSERT INTO queues_config (extension, descr, grppre, alertinfo, joinannounce_id, ringing, agentannounce_id, maxwait, password, ivr_id, dest, cwignore, qregex) 388 VALUES ('$extension', '$descr', '$grppre', '$alertinfo', '$joinannounce_id', '$ringing', '$agentannounce_id', '$maxwait', '$password', '$ivr_id', '$dest', '$cwignore', '$qregex') "; 348 389 $results = sql($sql); 349 390 return true; … … 445 486 446 487 $compound_recordings = array(); 447 $sql = "SELECT extension, descr, agentannounce , ivr_id FROM queues_config WHERE (ivr_id != 'none' AND ivr_id != '') OR agentannounce!= ''";488 $sql = "SELECT extension, descr, agentannounce_id, ivr_id FROM queues_config WHERE (ivr_id != 'none' AND ivr_id != '') OR agentannounce_id != ''"; 448 489 $results = sql($sql, "getAll",DB_FETCHMODE_ASSOC); 449 490 … … 459 500 460 501 foreach ($results as $result) { 461 if (strpos($result['agentannounce'],"&") !== false) { 502 $agentannounce = $result['agentannounce_id'] ? recordings_get_file($result['agentannounce_id']):''; 503 if (strpos($agentannounce,"&") !== false) { 462 504 $compound_recordings[] = array( 463 505 'extension' => $result['extension'], … … 467 509 } 468 510 if ($result['ivr_id'] != 'none' && $result['ivr_id'] != '' && $check_ivr) { 469 if (strpos($ivr_hash[$result['ivr_id']]['announcement'],"&") !== false) { 511 $id = $ivr_hash[$result['ivr_id']]['announcement_id']; 512 $announce = $id ? recordings_get_file($id) : ''; 513 if (strpos($announce,"&") !== false) { 470 514 $compound_recordings[] = array( 471 515 'extension' => $result['extension'], … … 526 570 // We need to strip off all but the first sound file of any compound sound files 527 571 // 528 $agentannounce_ arr = explode("&", $config['agentannounce']);529 $results['agentannounce '] = $agentannounce_arr[0];572 $agentannounce_id_arr = explode("&", $config['agentannounce_id']); 573 $results['agentannounce_id'] = $agentannounce_id_arr[0]; 530 574 } else { 531 575 $sql = "SELECT * FROM queues_config WHERE extension = $account"; … … 534 578 $results['prefix'] = $config['grppre']; 535 579 $results['alertinfo'] = $config['alertinfo']; 536 $results['agentannounce '] = $config['agentannounce'];580 $results['agentannounce_id'] = $config['agentannounce_id']; 537 581 $results['maxwait'] = $config['maxwait']; 538 582 $results['name'] = $config['descr']; 539 $results['joinannounce '] = $config['joinannounce'];583 $results['joinannounce_id'] = $config['joinannounce_id']; 540 584 $results['password'] = $config['password']; 541 585 $results['goto'] = $config['dest']; modules/branches/2.5/queues/install.php
r5949 r6170 301 301 } 302 302 303 304 305 306 303 // Version 2.5 upgrade 307 304 outn(_("checking for qregex field..")); … … 320 317 } 321 318 319 // Version 2.5 migrate to recording ids 320 // Note: we purposely did not chnage the inital creation of the 321 // recording ids as it is safer with all the complex 322 // migration code to simply stick with what works and 323 // then convert it here even if new. 324 // 325 outn(_("Checking if recordings need migration..")); 326 $sql = "SELECT agentannounce_id FROM queues_config"; 327 $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 328 if(DB::IsError($check)) { 329 // Add recording_id field 330 // 331 out("migrating"); 332 outn(_("adding agentannounce_id field..")); 333 $sql = "ALTER TABLE queues_config ADD agentannounce_id INTEGER"; 334 $result = $db->query($sql); 335 if(DB::IsError($result)) { 336 out(_("fatal error")); 337 die_freepbx($result->getDebugInfo()); 338 } else { 339 out(_("ok")); 340 } 341 outn(_("adding joinannounce_id field..")); 342 $sql = "ALTER TABLE queues_config ADD joinannounce_id INTEGER"; 343 $result = $db->query($sql); 344 if(DB::IsError($result)) { 345 out(_("fatal error")); 346 die_freepbx($result->getDebugInfo()); 347 } else { 348 out(_("ok")); 349 } 350 351 // Get all the valudes and replace them with recording_id 352 // 353 outn(_("migrate agentannounce to ids..")); 354 $sql = "SELECT `extension`, `agentannounce` FROM `queues_config`"; 355 $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 356 if(DB::IsError($results)) { 357 out(_("fatal error")); 358 die_freepbx($results->getDebugInfo()); 359 } 360 $migrate_arr = array(); 361 $count = 0; 362 foreach ($results as $row) { 363 if (trim($row['agentannounce']) != '') { 364 $rec_id = recordings_get_or_create_id($row['agentannounce'], 'queues'); 365 $migrate_arr[] = array($rec_id, $row['extension']); 366 $count++; 367 } 368 } 369 if ($count) { 370 $compiled = $db->prepare('UPDATE `queues_config` SET `agentannounce_id` = ? WHERE `extension` = ?'); 371 $result = $db->executeMultiple($compiled,$migrate_arr); 372 if(DB::IsError($result)) { 373 out(_("fatal error")); 374 die_freepbx($result->getDebugInfo()); 375 } 376 } 377 out(sprintf(_("migrated %s entries"),$count)); 378 379 outn(_("migrate joinannounce to ids..")); 380 $sql = "SELECT `extension`, `joinannounce` FROM `queues_config`"; 381 $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 382 if(DB::IsError($results)) { 383 out(_("fatal error")); 384 die_freepbx($results->getDebugInfo()); 385 } 386 $migrate_arr = array(); 387 $count = 0; 388 foreach ($results as $row) { 389 if (trim($row['joinannounce']) != '') { 390 $rec_id = recordings_get_or_create_id($row['joinannounce'], 'queues'); 391 $migrate_arr[] = array($rec_id, $row['extension']); 392 $count++; 393 } 394 } 395 if ($count) { 396 $compiled = $db->prepare('UPDATE `queues_config` SET `joinannounce_id` = ? WHERE `extension` = ?'); 397 $result = $db->executeMultiple($compiled,$migrate_arr); 398 if(DB::IsError($result)) { 399 out(_("fatal error")); 400 die_freepbx($result->getDebugInfo()); 401 } 402 } 403 out(sprintf(_("migrated %s entries"),$count)); 404 405 // Now remove the old recording field replaced by new id field 406 // 407 outn(_("dropping agentannounce field..")); 408 $sql = "ALTER TABLE `queues_config` DROP `agentannounce`"; 409 $result = $db->query($sql); 410 if(DB::IsError($result)) { 411 out(_("no agentannounce field???")); 412 } else { 413 out(_("ok")); 414 } 415 outn(_("dropping joinannounce field..")); 416 $sql = "ALTER TABLE `queues_config` DROP `joinannounce`"; 417 $result = $db->query($sql); 418 if(DB::IsError($result)) { 419 out(_("no joinannounce field???")); 420 } else { 421 out(_("ok")); 422 } 423 } else { 424 out("already migrated"); 425 } 426 322 427 ?> modules/branches/2.5/queues/module.xml
r6097 r6170 2 2 <rawname>queues</rawname> 3 3 <name>Queues</name> 4 <version>2.5. 0.1</version>4 <version>2.5.1</version> 5 5 <type>setup</type> 6 6 <category>Inbound Call Control</category> … … 9 9 </description> 10 10 <changelog> 11 *2.5.1* #2068 recordings_id, don't list IVRs with compound messages 11 12 *2.5.0.1* #2875, #2768 12 13 *2.5.0.0* #2976 Add Optional Regex to filter user agent numbers that they can input … … 48 49 <depends> 49 50 <version>2.5.0alpha1</version> 51 <module>recordings ge 3.3.8</module> 50 52 </depends> 51 53 <menuitems> modules/branches/2.5/queues/page.queues.php
r6163 r6170 21 21 isset($_REQUEST['name'])?$name = $_REQUEST['name']:$name=''; 22 22 isset($_REQUEST['password'])?$password = $_REQUEST['password']:$password=''; 23 isset($_REQUEST['agentannounce '])?$agentannounce = $_REQUEST['agentannounce']:$agentannounce='';23 isset($_REQUEST['agentannounce_id'])?$agentannounce_id = $_REQUEST['agentannounce_id']:$agentannounce_id=''; 24 24 isset($_REQUEST['prefix'])?$prefix = $_REQUEST['prefix']:$prefix=''; 25 25 isset($_REQUEST['alertinfo'])?$alertinfo = $_REQUEST['alertinfo']:$alertinfo=''; 26 isset($_REQUEST['joinannounce '])?$joinannounce = $_REQUEST['joinannounce']:$joinannounce='';26 isset($_REQUEST['joinannounce_id'])?$joinannounce_id = $_REQUEST['joinannounce_id']:$joinannounce_id=''; 27 27 $maxwait = isset($_REQUEST['maxwait'])?$_REQUEST['maxwait']:''; 28 28 $cwignore = isset($_REQUEST['cwignore'])?$_REQUEST['cwignore']:'0'; … … 98 98 $conflict_url = framework_display_extension_usage_alert($usage_arr); 99 99 } else { 100 queues_add($account,$name,$password,$prefix,$goto,$agentannounce ,$members,$joinannounce,$maxwait,$alertinfo,$cwignore,$qregex);100 queues_add($account,$name,$password,$prefix,$goto,$agentannounce_id,$members,$joinannounce_id,$maxwait,$alertinfo,$cwignore,$qregex); 101 101 needreload(); 102 102 redirect_standard(); … … 110 110 case "edit": //just delete and re-add 111 111 queues_del($account); 112 queues_add($account,$name,$password,$prefix,$goto,$agentannounce ,$members,$joinannounce,$maxwait,$alertinfo,$cwignore,$qregex);112 queues_add($account,$name,$password,$prefix,$goto,$agentannounce_id,$members,$joinannounce_id,$maxwait,$alertinfo,$cwignore,$qregex); 113 113 needreload(); 114 114 redirect_standard('extdisplay'); … … 244 244 <td><a href="#" class="info"><?php echo _("Agent Announcement:")?><span><?php echo _("Announcement played to the Agent prior to bridging in the caller <br><br> Example: \"the Following call is from the Sales Queue\" or \"This call is from the Technical Support Queue\".<br><br>To add additional recordings please use the \"System Recordings\" MENU to the left. Compound recordings composed of 2 or more sound files are not displayed as options since this feature can not accept such recordings.")?></span></a></td> 245 245 <td> 246 <select name="agentannounce " tabindex="<?php echo ++$tabindex;?>">246 <select name="agentannounce_id" tabindex="<?php echo ++$tabindex;?>"> 247 247 <?php 248 248 $tresults = recordings_list(false); 249 $default = (isset($agentannounce ) ? $agentannounce : 'None');250 251 echo '<option value=" None">'._("None").'</option>';249 $default = (isset($agentannounce_id) ? $agentannounce_id : ''); 250 251 echo '<option value="">'._("None").'</option>'; 252 252 if (isset($tresults[0])) { 253 253 foreach ($tresults as $tresult) { 254 echo '<option value="'.$tresult[ 2].'" '.($tresult[2] == $default ? 'SELECTED' : '').'>'.$tresult[1]."</option>\n";;254 echo '<option value="'.$tresult['id'].'"'.($tresult['id'] == $default ? ' SELECTED' : '').'>'.$tresult['displayname']."</option>\n"; 255 255 } 256 256 } … … 264 264 <td> 265 265 <?php 266 $default = (isset($agentannounce ) ? $agentannounce: '');266 $default = (isset($agentannounce_id) ? $agentannounce_id : ''); 267 267 ?> 268 <input type="hidden" name="agentannounce" value="<?php echo $default; ?>"><?php echo ($default != '' ? $default : 'None'); ?> 269 </td> 270 </tr> 271 <?php } ?> 272 273 <?php if(function_exists('music_list')) { //only include if music module is enabled?> 268 <input type="hidden" name="agentannounce_id" value="<?php echo $default; ?>"><?php echo ($default != '' ? $default : ''); ?> 269 </td> 270 </tr> 271 <?php 272 } 273 if(function_exists('recordings_list')) { //only include if recordings is enabled ?> 274 <tr> 275 <td><a href="#" class="info"><?php echo _("Join Announcement:")?><span><?php echo _("Announcement played to callers once prior to joining the queue.<br><br>To add additional recordings please use the \"System Recordings\" MENU to the left")?></span></a></td> 276 <td> 277 <select name="joinannounce_id" tabindex="<?php echo ++$tabindex;?>"> 278 <?php 279 $tresults = recordings_list(); 280 $default = (isset($joinannounce_id) ? $joinannounce_id : ''); 281 echo '<option value="None">'._("None"); 282 if (isset($tresults[0])) { 283 foreach ($tresults as $tresult) { 284 echo '<option value="'.$tresult['id'].'"'.($tresult['id'] == $default ? ' SELECTED' : '').'>'.$tresult['displayname']."</option>\n"; 285 } 286 } 287 ?> 288 </select> 289 </td> 290 </tr> 291 <?php } else { ?> 292 <tr> 293 <td><a href="#" class="info"><?php echo _("Join Announcement:")?><span><?php echo _("Announcement played to callers once prior to joining the queue.<br><br>You must install and enable the \"Systems Recordings\" Module to edit this option")?></span></a></td> 294 <td> 295 <?php 296 $default = (isset($joinannounce_id) ? $joinannounce_id : ''); 297 ?> 298 <input type="hidden" name="joinannounce_id" value="<?php echo $default; ?>"><?php echo ($default != '' ? $default : ''); ?> 299 </td> 300 </tr> 301 <?php 302 } 303 304 if(function_exists('music_list')) { //only include if music module is enabled?> 274 305 <tr> 275 306 <td><a href="#" class="info"><?php echo _("Music on Hold Class:")?><span><?php echo _("Music (or Commercial) played to the caller while they wait in line for an available agent. Choose \"inherit\" if you want the MoH class to be what is currently selected, such as by the inbound route.<br><br> This music is defined in the \"Music on Hold\" Menu to the left.")?></span></a></td> … … 559 590 560 591 //query for exisiting aa_N contexts 592 // 593 // If a previous bogus IVR was listed, we will leave it in with an error but will no longer show such IVRs as valid options. 561 594 $unique_aas = ivr_list(); 562 595 … … 571 604 if (strpos($unique_aa['announcement'],"&") === false) { 572 605 echo '<option value="'.$menu_id.'" '.($default == $menu_id ? 'SELECTED' : '').'>'.($menu_name ? $menu_name : _("Menu ID ").$menu_id)."</option>\n"; 573 } else { 606 } 607 else { 574 608 $compound_recordings = true; 575 echo '<option style="color:red" value="'.$menu_id.'" '.($default == $menu_id ? 'SELECTED' : '').'>'.($menu_name ? $menu_name : _("Menu ID ").$menu_id)." (**)</option>\n";576 609 if ($menu_id == $default) { 610 echo '<option style="color:red" value="'.$menu_id.'" '.($default == $menu_id ? 'SELECTED' : '').'>'.($menu_name ? $menu_name : _("Menu ID ").$menu_id)." (**)</option>\n"; 577 611 $is_error = true; 578 612 } … … 583 617 </select> 584 618 <?php 585 if ($ compound_recordings) {619 if ($is_error) { 586 620 ?> 587 621 <small><a style="color:red" href="#" class="info"><?php echo ($is_error ? _("(**) ERRORS") : _("(**) Warning Potential Errors"))?> … … 589 623 <?php 590 624 if ($is_error) { 591 echo _("ERROR: You have selected an IVR's that use Announcements created from compound sound files. The Queue is not able to play these announcements. This IVR's recording will be truncated to use only the first sound file. You can correct the problem by selecting a different annoucement for this IVR that is not from a compound sound file. The IVR itself can play such files, but the Queue subsystem can not"); 592 } else { 593 echo _("You have IVR's that use Announcements created from compound sound files. The Queue is not able to play these announcements. If you choose one of these the recording used with be truncated to use only the first sound file. You can choose this IVR now and then correct the problem by selecting a different annoucement for your IVR that is not from a compound sound file. The IVR itself can play such files, but the Queue subsystem can not"); 625 echo _("ERROR: You have selected an IVR's that use Announcements created from compound sound files. The Queue is not able to play these announcements. This IVR's recording will be truncated to use only the first sound file. You can correct the problem by selecting a different annoucement for this IVR that is not from a compound sound file. The IVR itself can play such files, but the Queue subsystem can not").'<br />'._("Earlier versions of this module allowed such queues to be chosen, once changing this setting, it will no longer appear as an option"); 594 626 } 595 627 ?> … … 619 651 <?php } else { 620 652 echo "<input type=\"hidden\" name=\"announcemenu\" value=\"none\">"; 621 } 622 623 if(function_exists('recordings_list')) { //only include if recordings is enabled ?> 624 <tr> 625 <td><a href="#" class="info"><?php echo _("Join Announcement:")?><span><?php echo _("Announcement played to callers once prior to joining the queue.<br><br>To add additional recordings please use the \"System Recordings\" MENU to the left")?></span></a></td> 626 <td> 627 <select name="joinannounce" tabindex="<?php echo ++$tabindex;?>"> 628 <?php 629 $tresults = recordings_list(); 630 $default = (isset($joinannounce) ? $joinannounce : 'None'); 631 echo '<option value="None">'._("None"); 632 if (isset($tresults[0])) { 633 foreach ($tresults as $tresult) { 634 echo '<option value="'.$tresult[2].'" '.($tresult[2] == $default ? 'SELECTED' : '').'>'.$tresult[1]."</option>\n";; 635 } 636 } 637 ?> 638 </select> 639 </td> 640 </tr> 641 <?php } else { ?> 642 <tr> 643 <td><a href="#" class="info"><?php echo _("Join Announcement:")?><span><?php echo _("Announcement played to callers once prior to joining the queue.<br><br>You must install and enable the \"Systems Recordings\" Module to edit this option")?></span></a></td> 644 <td> 645 <?php 646 $default = (isset($joinannounce) ? $joinannounce : ''); 647 ?> 648 <input type="hidden" name="joinannounce" value="<?php echo $default; ?>"><?php echo ($default != '' ? $default : 'None'); ?> 649 </td> 650 </tr> 651 <?php } ?> 652 <?php 653 } 653 654 // implementation of module hook 654 655 // object was initialized in config.php
