Changeset 5898
- Timestamp:
- 07/04/08 00:56:12 (3 months ago)
- Files:
-
- modules/branches/2.5/core/functions.inc.php (modified) (30 diffs)
- modules/branches/2.5/core/images (added)
- modules/branches/2.5/core/images/email_edit.png (added)
- modules/branches/2.5/core/images/telephone_edit.png (added)
- modules/branches/2.5/core/images/telephone_key.png (added)
- modules/branches/2.5/core/install.php (modified) (2 diffs)
- modules/branches/2.5/core/page.did.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/branches/2.5/core/functions.inc.php
r5895 r5898 744 744 $catchall_context='ext-did-catchall'; 745 745 foreach($didlist as $item) { 746 $did = core_did_get($item['extension'],$item['cidnum']); 747 $exten = $did['extension']; 748 $cidnum = $did['cidnum']; 746 if (trim($item['destination']) == '') { 747 continue; 748 } 749 $exten = $item['extension']; 750 $cidnum = $item['cidnum']; 749 751 750 752 $exten = (empty($exten)?"s":$exten); … … 827 829 //the goto destination 828 830 // destination field in 'incoming' database is backwards from what ext_goto expects 829 $goto_context = strtok($ did['destination'],',');831 $goto_context = strtok($item['destination'],','); 830 832 $goto_exten = strtok(','); 831 833 $goto_pri = strtok(','); … … 845 847 } 846 848 847 }848 849 /* MODIFIED (PL)850 *851 * Add Direct DIDs852 *853 * This functions creates a new context, ext-did-direct, used to route an incoming DID directly to the specified user.854 * The purpose is to use when a user has a personal external DID. This keeps it clean and easy to administer.855 * Any conflict with those routes will depend on which of the two contexts are included first in the extensions.conf file.856 *857 * Calls are sent to context from-did-direct though this feature. You must create that context in extenions.conf or858 * in extensions_custom.conf and it should look something like:859 *860 * [from-did-direct]861 * include => ext-findmefollow862 * include => ext-local863 *864 * This is so that personal ring groups are used if they exist for the direct did and if not, then the local extension.865 * If the module is not implented, it will just go to the users extension.866 */867 868 $directdidlist = core_directdid_list();869 if(is_array($directdidlist)){870 $context = "ext-did";871 if(!is_array($didlist)){872 /* if not set above, add one here */873 $ext->add($context, 'fax', '', new ext_goto('1','in_fax','ext-fax'));874 }875 foreach($directdidlist as $item) {876 $exten = $item['directdid'];877 $ext->add($context, $exten, '', new ext_setvar('__FROM_DID','${EXTEN}'));878 // always set callerID name879 $ext->add($context, $exten, '', new ext_gotoif('$[ "${CALLERID(name)}" != "" ] ','cidok'));880 $ext->add($context, $exten, '', new ext_setvar('CALLERID(name)','${CALLERID(num)}'));881 $ext->add($context, $exten, 'cidok', new ext_noop('CallerID is ${CALLERID(all)}'));882 883 if (!empty($item['mohclass']) && trim($item['mohclass']) != 'default') {884 $ext->add($context, $exten, '', new ext_setmusiconhold($item['mohclass']));885 $ext->add($context, $exten, '', new ext_setvar('__MOHCLASS',$item['mohclass']));886 }887 888 if ($item['faxexten'] != "default") {889 $ext->add($context, $exten, '', new ext_setvar('FAX_RX',$item['faxexten']));890 }891 if (!empty($item['faxemail'])) {892 $ext->add($context, $exten, '', new ext_setvar('FAX_RX_EMAIL',$item['faxemail']));893 }894 if ($item['answer'] == "1") {895 $ext->add($context, $exten, '', new ext_answer(''));896 $ext->add($context, $exten, '', new ext_wait($item['wait']));897 }898 if ($item['answer'] == "2") { // NVFaxDetect899 $ext->add($context, $exten, '', new ext_answer(''));900 $ext->add($context, $exten, '', new ext_playtones('ring'));901 $ext->add($context, $exten, '', new ext_nvfaxdetect($item['wait']));902 }903 if ($item['privacyman'] == "1") {904 $ext->add($context, $exten, '', new ext_macro('privacy-mgr'));905 }906 907 908 if (!empty($item['didalert'])) {909 $ext->add($context, $exten, '', new ext_setvar("_ALERT_INFO", str_replace(';', '\;', $item['didalert'])));910 }911 $goto_context = 'from-did-direct';912 $goto_exten = $item['extension'];913 $goto_pri = 1;914 $ext->add($context, $exten, '', new ext_goto($goto_pri,$goto_exten,$goto_context));915 916 }917 849 } 918 850 … … 1655 1587 if (($extension != $old_extension) || ($cidnum != $old_cidnum)) { 1656 1588 $existing=core_did_get($extension,$cidnum); 1657 if (empty($existing) && (trim($cidnum) == "")) { 1658 $existing_directdid = core_users_directdid_get($extension); 1659 } else { 1660 $existing_directdid = ""; 1661 } 1662 } else { 1663 $existing = $existing_directdid = ""; 1664 } 1665 1666 if (empty($existing) && empty($existing_directdid)) { 1589 } 1590 1591 if (empty($existing)) { 1667 1592 core_did_del($old_extension,$old_cidnum); 1668 1593 core_did_add($incoming); 1669 1594 return true; 1670 1595 } else { 1671 if (!empty($existing)) { 1672 echo "<script>javascript:alert('"._("A route for this DID/CID already exists!")." => ".$existing['extension']."/".$existing['cidnum']."')</script>"; 1673 } else { 1674 echo "<script>javascript:alert('"._("A directdid for this DID is already associated with extension:")." ".$existing_directdid['extension']." (".$existing_directdid['name'].")')</script>"; 1675 } 1676 return false; 1677 } 1678 } 1679 1680 function core_did_add($incoming){ 1596 echo "<script>javascript:alert('"._("A route for this DID/CID already exists!")." => ".$existing['extension']."/".$existing['cidnum']."')</script>"; 1597 } 1598 return false; 1599 } 1600 1601 function core_did_add($incoming,$target=false){ 1681 1602 foreach ($incoming as $key => $val) { ${$key} = addslashes($val); } // create variables from request 1682 1603 … … 1684 1605 // 1685 1606 $existing=core_did_get($extension,$cidnum); 1686 if (empty($existing) && (trim($cidnum) == "")) { 1687 $existing_directdid = core_users_directdid_get($extension); 1688 } else { 1689 $existing_directdid = ""; 1690 } 1691 1692 if (empty($existing) && empty($existing_directdid)) { 1693 $destination=${$goto0.'0'}; 1607 1608 if (empty($existing)) { 1609 $destination= ($target) ? $target : ${$goto0.'0'}; 1694 1610 $sql="INSERT INTO incoming (cidnum,extension,destination,faxexten,faxemail,answer,wait,privacyman,alertinfo, ringing, mohclass, description, grppre) values ('$cidnum','$extension','$destination','$faxexten','$faxemail','$answer','$wait','$privacyman','$alertinfo', '$ringing', '$mohclass', '$description', '$grppre')"; 1695 1611 sql($sql); 1696 1612 return true; 1697 1613 } else { 1698 if (!empty($existing)) { 1699 echo "<script>javascript:alert('"._("A route for this DID/CID already exists!")." => ".$existing['extension']."/".$existing['cidnum']."')</script>"; 1700 } else { 1701 echo "<script>javascript:alert('"._("A directdid for this DID is already associated with extension:")." ".$existing_directdid['extension']." (".$existing_directdid['name'].")')</script>"; 1702 } 1614 echo "<script>javascript:alert('"._("A route for this DID/CID already exists!")." => ".$existing['extension']."/".$existing['cidnum']."')</script>"; 1703 1615 return false; 1704 1616 } … … 1708 1620 1709 1621 1710 1711 1712 1713 1714 1715 1622 /* begin page.devices.php functions */ 1716 1623 1717 1624 //get the existing devices 1718 function core_devices_list($tech="all") { 1719 $sql = "SELECT id,description FROM devices"; 1625 function core_devices_list($tech="all",$detail=false) { 1626 if (strtolower($detail) == 'full') { 1627 $sql = "SELECT * FROM devices"; 1628 } else { 1629 $sql = "SELECT id,description FROM devices"; 1630 } 1720 1631 switch (strtoupper($tech)) { 1721 1632 case "IAX": … … 1731 1642 } 1732 1643 $sql .= ' ORDER BY id'; 1733 $results = sql($sql,"getAll"); 1734 1644 $results = sql($sql,"getAll",DB_FETCHMODE_ASSOC); 1645 1646 $extens = null; 1735 1647 foreach($results as $result){ 1736 if (checkRange($result[0])){ 1648 if (checkRange($result['id'])){ 1649 1650 $record = array(); 1651 $record[0] = $result['id']; // for backwards compatibility 1652 $record[1] = $result['description']; // for backwards compatibility 1653 foreach ($result as $key => $value) { 1654 $record[$key] = $value; 1655 } 1656 $extens[] = $record; 1657 /* 1737 1658 $extens[] = array( 1738 1659 0=>$result[0], // for backwards compatibility … … 1741 1662 'description'=>$result[1], 1742 1663 ); 1743 } 1744 } 1745 if (isset($extens)) { 1746 return $extens; 1747 } else { 1748 return null; 1749 } 1664 */ 1665 } 1666 } 1667 return $extens; 1750 1668 } 1751 1669 … … 2430 2348 } 2431 2349 2432 // clean and check the did to make sure it is not being used by another extension or in did routing 2350 $newdid = isset($newdid) ? $newdid : ''; 2351 $newdid = preg_replace("/[^0-9._XxNnZz\[\]\-\+]/" ,"", trim($newdid)); 2352 $newdidcid = isset($newdidcid) ? $newdidcid : ''; 2353 $newdidcid = preg_replace("/[^0-9._XxNnZz\[\]\-\+]/" ,"", trim($newdidcid)); 2354 2355 // Asterisk does not want just CID set so if it is add _X. to the DID 2433 2356 // 2434 $directdid = preg_replace("/[^0-9._XxNnZz\[\]\-\+]/" ,"", trim($directdid)); 2435 if (trim($directdid) != "") { 2436 $existing=core_did_get($directdid,""); 2437 $existing_directdid = empty($existing)?core_users_directdid_get($directdid):$existing; 2438 if (!empty($existing) || !empty($existing_directdid)) { 2439 if (!empty($existing)) { 2440 echo "<script>javascript:alert('"._("A route with this DID already exists:")." ".$existing['extension']."')</script>"; 2441 } else { 2442 echo "<script>javascript:alert('"._("This DID is already associated with extension:")." ".$existing_directdid['extension']." (".$existing_directdid['name'].")')</script>"; 2443 } 2357 if ($newdid == '' && $newdidcid != '') { 2358 $newdid = '_X.'; 2359 } 2360 // Well more ugliness since the javascripts are already in here 2361 if ($newdid != '') { 2362 $existing = core_did_get($newdid, $newdidcid); 2363 if (! empty($existing)) { 2364 echo "<script>javascript:alert('"._("A route with this DID/CID already exists")."')</script>"."<pre>".print_r($existing,true)."</pre>"; 2444 2365 return false; 2445 2366 } … … 2473 2394 } 2474 2395 2475 // MODIFICATION: (PL)2476 // Added for directdid and didalert l for Alert Info distinctive ring)2477 //2478 // cleanup any non dial pattern characters prior to inserting into the database2479 // then add directdid to the insert command.2480 //2481 2396 // Clean replace any <> with () in display name - should have javascript stopping this but ... 2482 2397 // … … 2484 2399 2485 2400 //insert into users table 2486 $sql="INSERT INTO users (extension,password,name,voicemail,ringtimer,noanswer,recording,outboundcid, directdid,didalert,faxexten,faxemail,answer,wait,privacyman,mohclass,sipname) values (\"";2401 $sql="INSERT INTO users (extension,password,name,voicemail,ringtimer,noanswer,recording,outboundcid,privacyman,sipname) values (\""; 2487 2402 $sql.= "$extension\", \""; 2488 2403 $sql.= isset($password)?$password:''; … … 2500 2415 $sql.= isset($outboundcid)?$outboundcid:''; 2501 2416 $sql.= "\", \""; 2502 $sql.= isset($directdid)?$directdid:'';2503 $sql.= "\", \"";2504 $sql.= isset($didalert)?$didalert:'';2505 2506 $sql.= "\", \"";2507 $sql.= isset($faxexten)?$faxexten:'';2508 $sql.= "\", \"";2509 $sql.= isset($faxemail)?$faxemail:'';2510 $sql.= "\", \"";2511 $sql.= isset($answer)?$answer:'';2512 $sql.= "\", \"";2513 $sql.= isset($wait)?$wait:'';2514 $sql.= "\", \"";2515 2417 $sql.= isset($privacyman)?$privacyman:''; 2516 $sql.= "\", \"";2517 $sql.= isset($mohclass)?$mohclass:'';2518 2418 $sql.= "\", \""; 2519 2419 $sql.= isset($sipname)?$sipname:''; … … 2588 2488 fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]); 2589 2489 } 2490 2491 // OK - got this far, if they entered a new inbound DID/CID let's deal with it now 2492 // remember - in the nice and ugly world of this old code, $vars has been extracted 2493 // newdid and newdidcid 2494 2495 // Now if $newdid is set we need to add the DID to the routes 2496 // 2497 if ($newdid != '') { 2498 $did_dest = 'from-did-direct,'.$extension.',1'; 2499 $did_vars['extension'] = $newdid; 2500 $did_vars['cidnum'] = $newdidcid; 2501 $did_vars['faxexten'] = ''; 2502 $did_vars['faxemail'] = ''; 2503 $did_vars['answer'] = '0'; 2504 $did_vars['wait'] = '0'; 2505 $did_vars['privacyman'] = ''; 2506 $did_vars['alertinfo'] = ''; 2507 $did_vars['ringing'] = ''; 2508 $did_vars['mohclass'] = 'default'; 2509 $did_vars['description'] = ''; 2510 $did_vars['grppre'] = ''; 2511 core_did_add($did_vars, $did_dest); 2512 } 2513 2590 2514 return true; 2591 2515 } … … 2659 2583 2660 2584 function core_users_directdid_get($directdid=""){ 2661 if (empty($directdid)) { 2662 return array(); 2663 } else { 2664 $sql = "SELECT * FROM users WHERE directdid = \"$directdid\""; 2665 return sql($sql,"getRow",DB_FETCHMODE_ASSOC); 2666 } 2585 return array(); 2667 2586 } 2668 2587 … … 2699 2618 } 2700 2619 2701 $directdid=$vars['directdid'];2702 $directdid = preg_replace("/[^0-9._XxNnZz\[\]\-\+]/" ,"", trim($directdid));2703 2620 // clean and check the did to make sure it is not being used by another extension or in did routing 2704 2621 // 2705 if (trim($directdid) != "") { 2706 $existing=core_did_get($directdid,""); 2707 $existing_directdid = empty($existing)?core_users_directdid_get($directdid):$existing; 2708 if (!empty($existing) || (!empty($existing_directdid) && $existing_directdid['extension'] != $extension)) { 2709 if (!empty($existing)) { 2710 echo "<script>javascript:alert('"._("A route with this DID already exists:")." ".$existing['extension']."')</script>"; 2711 } else { 2712 echo "<script>javascript:alert('"._("This DID is already associated with extension:")." ".$existing_directdid['extension']." (".$existing_directdid['name'].")')</script>"; 2713 } 2622 $newdid = isset($vars['newdid']) ? $vars['newdid'] : ''; 2623 $newdid = preg_replace("/[^0-9._XxNnZz\[\]\-\+]/" ,"", trim($newdid)); 2624 $newdidcid = isset($vars['newdidcid']) ? $vars['newdidcid'] : ''; 2625 $newdidcid = preg_replace("/[^0-9._XxNnZz\[\]\-\+]/" ,"", trim($newdidcid)); 2626 2627 // Asterisk does not want just CID set so if it is add _X. to the DID 2628 // 2629 if ($newdid == '' && $newdidcid != '') { 2630 $newdid = '_X.'; 2631 } 2632 // Well more ugliness since the javascripts are already in here 2633 if ($newdid != '') { 2634 $existing = core_did_get($newdid, $newdidcid); 2635 if (! empty($existing)) { 2636 echo "<script>javascript:alert('"._("A route with this DID/CID already exists")."')</script>"; 2714 2637 return false; 2715 2638 } … … 2726 2649 2727 2650 function core_directdid_list(){ 2728 $sql = "SELECT extension, directdid, didalert, mohclass, faxexten, faxemail, answer, wait, privacyman FROM users WHERE directdid IS NOT NULL AND directdid != ''"; 2729 return sql($sql,"getAll",DB_FETCHMODE_ASSOC); 2730 } 2731 2732 2651 return array(); 2652 } 2733 2653 2734 2654 function core_zapchandids_add($description, $channel, $did) { … … 3965 3885 } 3966 3886 3887 // Used below in usort 3888 function dev_grp($a, $b) { 3889 if ($a['devicetype'] == $b['devicetype']) { 3890 return ($a['id'] < $b['id']) ? -1 : 1; 3891 } else { 3892 return ($a['devicetype'] > $b['devicetype']) ? -1 : 1; 3893 } 3894 } 3895 3967 3896 function core_users_configpageload() { 3968 3897 global $currentcomponent; … … 3970 3899 3971 3900 // Ensure variables possibly extracted later exist 3972 $name = $directdid = $didalert = $outboundcid = $answer = null; 3973 $record_in = $record_out = $faxexten = $faxemail = $mohclass = $sipname = $cid_masquerade = null; 3901 $name = $outboundcid = $record_in = $record_out = $sipname = $cid_masquerade = null; 3974 3902 3975 3903 // Init vars from $_REQUEST[] … … 3993 3921 if ( is_string($extdisplay) ) { 3994 3922 3995 if (!isset($ GLOBALS['abort']) || $GLOBALS['abort'] !== true) {3923 if (!isset($_GLOBALS['abort']) || $_GLOBALS['abort'] !== true) { 3996 3924 $extenInfo=core_users_get($extdisplay); 3997 3925 extract($extenInfo); … … 4002 3930 if ( $display == 'extensions' ) { 4003 3931 $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Extension").": $extdisplay", false), 0); 4004 if (!isset($ GLOBALS['abort']) || $GLOBALS['abort'] !== true) {3932 if (!isset($_GLOBALS['abort']) || $_GLOBALS['abort'] !== true) { 4005 3933 $currentcomponent->addguielem('_top', new gui_link('del', _("Delete Extension")." $extdisplay", $delURL, true, false), 0); 4006 3934 … … 4012 3940 } else { 4013 3941 $currentcomponent->addguielem('_top', new gui_pageheading('title', _("User").": $extdisplay", false), 0); 4014 if (!isset($ GLOBALS['abort']) || $GLOBALS['abort'] !== true) {3942 if (!isset($_GLOBALS['abort']) || $_GLOBALS['abort'] !== true) { 4015 3943 $currentcomponent->addguielem('_top', new gui_link('del', _("Delete User")." $extdisplay", $delURL, true, false), 0); 4016 3944 … … 4046 3974 $section = ($extdisplay ? _("Edit User") : _("Add User")); 4047 3975 } 4048 if ( $extdisplay) {3976 if ( trim($extdisplay) != '' ) { 4049 3977 $currentcomponent->addguielem($section, new gui_hidden('extension', $extdisplay), 2); 4050 3978 } else { … … 4060 3988 $currentcomponent->addguielem($section, new gui_textbox('cid_masquerade', $cid_masquerade, 'CID Num Alias', _("The CID Number to use for internal calls, if different from the extension number. This is used to masquerade as a different user. A common example is a team of support people who would like their internal callerid to display the general support number (a ringgroup or queue). There will be no effect on external calls."), '!isWhitespace() && !isInteger()', $msgInvalidCidNum, false)); 4061 3989 $currentcomponent->addguielem($section, new gui_textbox('sipname', $sipname, 'SIP Alias', _("If you want to support direct sip dialing of users internally or through anonymous sip calls, you can supply a friendly name that can be used in addition to the users extension to call them."))); 3990 3991 // If user mode, list devices associated with this user 3992 // 3993 if ($display == 'users' && trim($extdisplay != '')) { 3994 $section = _("User Devices"); 3995 $device_list = core_devices_list('all','full'); 3996 3997 usort($device_list,'dev_grp'); 3998 3999 $link_count = 0; 4000 foreach ($device_list as $device_item) { 4001 if ($device_item['user'] == $extdisplay) { 4002 $addURL = $_SERVER['PHP_SELF'].'?type=setup&display=devices&skip=0&extdisplay='.$device_item['id']; 4003 $device_icon = ($device_item['devicetype'] == 'fixed') ? 'images/telephone_key.png' : 'images/telephone_edit.png'; 4004 $device_label = ' '; 4005 $device_label .= _('Edit:'); 4006 $device_label .= ' '.$device_item['id'].' '.$device_item['description']; 4007 4008 $device_label = '<span> 4009 <img width="16" height="16" border="0" title="Edit Device" alt="Edit Device" src="'.$device_icon.'"/>'.$device_label. 4010 '</span> '; 4011 4012 $currentcomponent->addguielem($section, new gui_link($link_count++, $device_label, $addURL, true, false), 2); 4013 } 4014 } 4015 } 4062 4016 4063 4017 $section = 'Extension Options'; 4064 $currentcomponent->addguielem($section, new gui_textbox('directdid', $directdid, 'Direct DID', _("The direct DID that is associated with this extension. The DID should be in the same format as provided by the provider (e.g. full number, 4 digits for 10x4, etc).<br><br>Format should be: <b>XXXXXXXXXX</b><br><br>Leave this field blank to disable the direct DID feature for this extension. All non-numeric characters will be stripped.")), 3); 4065 $currentcomponent->addguielem($section, new gui_textbox('didalert', $didalert, 'DID Alert Info', _("Alert Info can be used for distinctive ring on SIP phones. Set this value to the desired Alert Info to be sent to the phone when this DID is called. Leave blank to use default values. Will have no effect if no Direct DID is set"))); 4066 if (function_exists('music_list')) { 4067 $currentcomponent->addguielem($section, new gui_selectbox('mohclass', $currentcomponent->getoptlist('mohclass'), $mohclass, 'Music on Hold', _("Set the MoH class that will be used for calls that come in on this Direct DID. For example, choose a type appropriate for a originating country which may have announcements in their language. Only effects MoH class when the call came in from the Direct DID."), false)); 4068 } 4069 $currentcomponent->addguielem($section, new gui_textbox('outboundcid', $outboundcid, 'Outbound CID', _("Overrides the caller id when dialing out a trunk. Any setting here will override the common outbound caller id set in the Trunks admin.<br><br>Format: <b>\"caller name\" <#######></b><br><br>Leave this field blank to disable the outbound callerid feature for this user."), '!isCallerID()', $msgInvalidOutboundCID, true)); 4018 $currentcomponent->addguielem($section, new gui_textbox('outboundcid', $outboundcid, 'Outbound CID', _("Overrides the caller id when dialing out a trunk. Any setting here will override the common outbound caller id set in the Trunks admin.<br><br>Format: <b>\"caller name\" <#######></b><br><br>Leave this field blank to disable the outbound callerid feature for this user."), '!isCallerID()', $msgInvalidOutboundCID, true),3); 4070 4019 $ringtimer = (isset($ringtimer) ? $ringtimer : '0'); 4071 4020 $currentcomponent->addguielem($section, new gui_selectbox('ringtimer', $currentcomponent->getoptlist('ringtime'), $ringtimer, 'Ring Time', _("Number of seconds to ring prior to going to voicemail. Default will use the value set in the General Tab. If no voicemail is configured this will be ignored."), false)); … … 4079 4028 $currentcomponent->addguielem($section, new gui_selectbox('callwaiting', $currentcomponent->getoptlist('callwaiting'), $callwaiting, 'Call Waiting', _("Set the initial/current Call Waiting state for this user's extension"), false)); 4080 4029 4030 4031 $section = _("Assigned DID/CID"); 4032 $dids = core_did_list('extension'); 4033 $did_count = 0; 4034 foreach ($dids as $did) { 4035 $did_dest = split(',',$did['destination']); 4036 if (isset($did_dest[1]) && $did_dest[1] == $extdisplay) { 4037 4038 $did_title = ($did['description'] != '') ? $did['description'] : _("DID / CID"); 4039 4040 $addURL = $_SERVER['PHP_SELF'].'?type=setup&display=did&&extdisplay='.$did['extension'].'/'.$did['cidnum']; 4041 $did_icon = 'images/email_edit.png'; 4042 $did_label = ' '.$did['extension']; 4043 if (trim($did['cidnum']) != '') { 4044 $did_label .= ' / '.$did['cidnum']; 4045 } 4046 4047 $did_label = '<span> 4048 <img width="16" height="16" border="0" title="'.$did_title.'" alt="" src="'.$did_icon.'"/>'.$did_label. 4049 '</span> '; 4050 4051 $currentcomponent->addguielem($section, new gui_link($did_count++, $did_label, $addURL, true, false), 4); 4052 } 4053 } 4054 $currentcomponent->addguielem($section, new gui_textbox('newdid', $newdid, 'Add Inbound DID', _("A direct DID that is associated with this extension. The DID should be in the same format as provided by the provider (e.g. full number, 4 digits for 10x4, etc).<br><br>Format should be: <b>XXXXXXXXXX</b><br><br>.An optional CID can also be associated with this DID by setting the next box")), 4); 4055 $currentcomponent->addguielem($section, new gui_textbox('newdidcid', $newdidcid, 'Add Inbound CID', _("Add a CID for more specific DID + CID routing. A CID must be specified in the above Add DID box")), 4); 4056 4057 4081 4058 $section = 'Recording Options'; 4082 4059 $currentcomponent->addguielem($section, new gui_selectbox('record_in', $currentcomponent->getoptlist('recordoptions'), $record_in, 'Record Incoming', _("Record all inbound calls received at this extension."), false)); … … 4112 4089 if (isset($extension) && !checkRange($extension)){ 4113 4090 echo "<script>javascript:alert('". _("Warning! Extension")." ".$extension." "._("is not allowed for your account").".');</script>"; 4114 $ GLOBALS['abort'] = true;4091 $_GLOBALS['abort'] = true; 4115 4092 } else { 4116 4093 //if submitting form, update database … … 4121 4098 $usage_arr = framework_check_extension_usage($_REQUEST['extension']); 4122 4099 if (!empty($usage_arr)) { 4123 $ GLOBALS['abort'] = true;4100 $_GLOBALS['abort'] = true; 4124 4101 $conflict_url = framework_display_extension_usage_alert($usage_arr,true); 4125 4102 global $currentcomponent; … … 4136 4113 // this like voicemail! 4137 4114 // 4138 $ GLOBALS['abort'] = true;4115 $_GLOBALS['abort'] = true; 4139 4116 } 4140 4117 break; … … 4154 4131 } else { 4155 4132 // really bad hack - but if core_users_edit fails, want to stop core_devices_edit 4156 $ GLOBALS['abort'] = true;4133 $_GLOBALS['abort'] = true; 4157 4134 } 4158 4135 break; … … 4403 4380 case "add": 4404 4381 // really bad hack - but if core_users_add fails, want to stop core_devices_add 4405 if (!isset($ GLOBALS['abort']) || $GLOBALS['abort'] !== true) {4382 if (!isset($_GLOBALS['abort']) || $_GLOBALS['abort'] !== true) { 4406 4383 if (core_devices_add($deviceid,$tech,$devinfo_dial,$devicetype,$deviceuser,$description,$emergency_cid)) { 4407 4384 needreload(); … … 4419 4396 case "edit": //just delete and re-add 4420 4397 // really bad hack - but if core_users_edit fails, want to stop core_devices_edit 4421 if (!isset($ GLOBALS['abort']) || $GLOBALS['abort'] !== true) {4398 if (!isset($_GLOBALS['abort']) || $_GLOBALS['abort'] !== true) { 4422 4399 core_devices_del($extdisplay,true); 4423 4400 core_devices_add($deviceid,$tech,$devinfo_dial,$devicetype,$deviceuser,$description,$emergency_cid,true); modules/branches/2.5/core/install.php
r5563 r5898 1 1 <?php 2 3 if (! function_exists("out")) { 4 function out($text) { 5 echo $text."<br />"; 6 } 7 } 8 9 if (! function_exists("outn")) { 10 function outn($text) { 11 echo $text; 12 } 13 } 14 15 function did_migrate($incoming){ 16 global $db; 17 18 foreach ($incoming as $key => $val) { 19 ${$key} = addslashes($val); 20 } 21 22 // Check to make sure the did is not being used elsewhere 23 // 24 $sql = "SELECT * FROM incoming WHERE cidnum = '' AND extension = '$extension'"; 25 $existing = $db->getAll($sql, DB_FETCHMODE_ASSOC); 26 if(DB::IsError($existing)) { 27 outn(sprintf(_("ERROR: trying to check if %s already in use"),$extension)); 28 return false; 29 } 30 if (empty($existing)) { 31 $sql="INSERT INTO incoming (cidnum,extension,destination,faxexten,faxemail,answer,wait,privacyman,alertinfo, ringing, mohclass, description, grppre) values ('$cidnum','$extension','$destination','$faxexten','$faxemail','$answer','$wait','$privacyman','$alertinfo', '$ringing', '$mohclass', '$description', '$grppre')"; 32 sql($sql); 33 return true; 34 } else { 35 return false; 36 } 37 } 2 38 3 39 $fcc = new featurecode('core', 'userlogon'); … … 61 97 unset($fcc); 62 98 99 100 // Version 2.5 Upgrade needs to migrate directdid user info to incoming table 101 // 102 outn(_("Checking if directdids need migrating..")); 103 $sql = "SELECT `directdid` FROM `users`"; 104 $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 105 if(!DB::IsError($check)) { 106 out(_("starting migration")); 107 $errors = 0; 108 $sql = "SELECT * FROM `users` WHERE `directdid` != '' AND `directdid` IS NOT NULL"; 109 $direct_dids_arr = $db->getAll($sql, DB_FETCHMODE_ASSOC); 110 if(!DB::IsError($direct_dids_arr)) { 111 foreach ($direct_dids_arr as $direct_dids) { 112 $did_vars['destination'] = 'from-did-direct,'.$direct_dids['extension'].',1'; 113 $did_vars['extension'] = $direct_dids['directdid']; 114 $did_vars['cidnum'] = ''; 115 $did_vars['faxexten'] = $direct_dids['faxexten']; 116 $did_vars['faxemail'] = $direct_dids['faxemail']; 117 $did_vars['answer'] = $direct_dids['answer']; 118 $did_vars['wait'] = $direct_dids['wait']; 119 $did_vars['privacyman'] = $direct_dids['privacyman']; 120 $did_vars['alertinfo'] = $direct_dids['didalert']; 121 $did_vars['ringing'] = ''; 122 $did_vars['mohclass'] = $direct_dids['mohclass']; 123 $did_vars['description'] = _("User: ").$direct_dids['extension']; 124 $did_vars['grppre'] = ''; 125 if (!did_migrate($did_vars)) { 126 out(sprintf(_("ERROR: failed to insert %s for user %s"),$direct_dids['directdid'],$direct_dids['extension'])); 127 $errors++; 128 } 129 } 130 if ($errors) { 131 out(sprintf(_("There were %s failures migrating directdids, users table not being changed"),$errors)); 132 } else { 133 $migrate_array = array('directdid', 'didalert', 'mohclass', 'faxexten', 'faxemail', 'answer', 'wait', 'privacyman'); 134 foreach ($migrate_array as $field) { 135 outn(sprintf(_("Removing field %s from users table.."),$field)); 136 $sql = "ALTER TABLE `users` DROP `".$field."`"; 137 $results = $db->query($sql); 138 if (DB::IsError($results)) { 139 out(_("not present")); 140 } else { 141 out(_("removed")); 142 } 143 } 144 } 145 } else { 146 out(_("ERROR: could not access user table to migrate directdids to incoming table, aborting")); 147 } 148 } else { 149 out(_("already done")); 150 } 63 151 ?> modules/branches/2.5/core/page.did.php
r5762 r5898 20 20 $ringing = isset($_REQUEST['ringing'])?$_REQUEST['ringing']:''; 21 21 $description = isset($_REQUEST['description'])?$_REQUEST['description']:''; 22 if (isset($_REQUEST['submitclear'])) { 23 $_REQUEST[$goto0.'0'] = ''; 24 } 22 25 23 26 if (isset($_REQUEST['extension']) && isset($_REQUEST['cidnum'])) { 24 27 $extdisplay = $_REQUEST['extension']."/".$_REQUEST['cidnum']; 25 28 } 29 30 $didfilter = isset($_REQUEST['didfilter'])?$_REQUEST['didfilter']:''; 26 31 27 32 //update db if submiting form … … 54 59 </div> 55 60 61 <?php 62 $display_link = isset($extdisplay) && $extdispaly != '' ? "&extdisplay=".$extdisplay : ''; 63 ?> 56 64 <div class="rnav"> 57 65 <ul> 58 66 <li><a <?php echo ($extdisplay=='' ? 'class="current"':'') ?> href="config.php?display=<?php echo urlencode($dispnum)?>"><?php echo _("Add Incoming Route")?></a></li> 67 <li><a <?php echo ($didfilter=='' ? 'class="current"':'') ?> href="config.php?display=<?php echo urlencode($dispnum).$display_link?>"><?php echo _("View All")?></a></li> 68 <li><a <?php echo ($didfilter=='directdid' ? 'class="current"':'') ?> href="config.php?display=<?php echo urlencode($dispnum).'&didfilter=directdid'.$display_link?>"><?php echo _("View Extensions")?></a></li> 69 <li><a <?php echo ($didfilter=='incoming' ? 'class="current"':'') ?> href="config.php?display=<?php echo urlencode($dispnum).'&didfilter=incoming'.$display_link?>"><?php echo _("View General")?></a></li> 70 <li><a <?php echo ($didfilter=='unassigned' ? 'class="current"':'') ?> href="config.php?display=<?php echo urlencode($dispnum).'&didfilter=unassigned'.$display_link?>"><?php echo _("View Un-Assigned")?></a></li> 59 71 <?php 60 72 //get unique incoming routes 61 73 $inroutes = core_did_list('description'); 74 switch ($didfilter) { 75 case 'directdid': 76 foreach ($inroutes as $key => $did_items) { 77 $did_dest = split(',',$did_items['destination']); 78 if (!isset($did_dest[0]) || $did_dest[0] != 'from-did-direct') { 79 unset($inroutes[$key]); 80 } 81 } 82 break; 83 case 'incoming': 84 foreach ($inroutes as $key => $did_items) { 85 $did_dest = split(',',$did_items['destination']); 86 if (!isset($did_dest[0]) || $did_dest[0] == 'from-did-direct') { 87 unset($inroutes[$key]); 88 } 89 } 90 break; 91 case 'unassigned': 92 foreach ($inroutes as $key => $did_items) { 93 if (isset($did_items['destination']) && $did_items['destination'] != '') { 94 unset($inroutes[$key]); 95 } 96 } 97 break; 98 default: 99 } 62 100 if (isset($inroutes)) { 63 101 foreach ($inroutes as $inroute) { … … 65 103 $displaycid = ( empty($inroute['cidnum'])? _("any CID") : $inroute['cidnum'] ); 66 104 $desc = ( empty($inroute['description'])? "" : $inroute['description']."<br />" );
