Changeset 5898

Show
Ignore:
Timestamp:
07/04/08 00:56:12 (3 months ago)
Author:
p_lindheimer
Message:

Modified User Page (in Users Mode) to list each device that is either
a fixed device to the user or is Adhoc with the this user as default.
Each list item a link to edit the device.

Merged directdids to inbound routing and then made the following changes:
- any did that has extension as destination is listed with an edit link

under with the destination. This includes DID/CID pairs.

- you can add a did/cid pair to an extension but once added you can not

delete it. The link takes you to the inbound routes page.

- modified inbound routes to provide filters to see just directdids,

just non-directdid, or routes with no destination.

- added a "Clear Destination & Submit" button to clear a destination prior

to submiting.

- core_get_config will not create ext-did contexts for dids with no

destination.

- old core_direct_did() functions have been deprecrated and return an

empty array(), the equivalent as if there were not directdids found.

- Question to ponder - if there is an any/any route, should we send

un-assigned did's to it?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.5/core/functions.inc.php

    r5895 r5898  
    744744                                $catchall_context='ext-did-catchall'; 
    745745                                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']; 
    749751 
    750752                                        $exten = (empty($exten)?"s":$exten); 
     
    827829                                        //the goto destination 
    828830                                        // destination field in 'incoming' database is backwards from what ext_goto expects 
    829                                         $goto_context = strtok($did['destination'],','); 
     831                                        $goto_context = strtok($item['destination'],','); 
    830832                                        $goto_exten = strtok(','); 
    831833                                        $goto_pri = strtok(','); 
     
    845847                                } 
    846848                                         
    847                         } 
    848  
    849                         /* MODIFIED (PL) 
    850                          * 
    851                          * Add Direct DIDs 
    852                          * 
    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 or 
    858                          * in extensions_custom.conf and it should look something like: 
    859                          * 
    860                          * [from-did-direct] 
    861                          * include => ext-findmefollow 
    862                          * include => ext-local 
    863                          * 
    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 name 
    879                                         $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") { // NVFaxDetect 
    899                                                 $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                                 } 
    917849                        } 
    918850 
     
    16551587        if (($extension != $old_extension) || ($cidnum != $old_cidnum)) { 
    16561588                $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)) { 
    16671592                core_did_del($old_extension,$old_cidnum); 
    16681593                core_did_add($incoming); 
    16691594                return true; 
    16701595        } 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 
     1601function core_did_add($incoming,$target=false){ 
    16811602        foreach ($incoming as $key => $val) { ${$key} = addslashes($val); } // create variables from request 
    16821603 
     
    16841605        // 
    16851606        $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'}; 
    16941610                $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')"; 
    16951611                sql($sql); 
    16961612                return true; 
    16971613        } 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>"; 
    17031615                return false; 
    17041616        } 
     
    17081620 
    17091621 
    1710  
    1711  
    1712  
    1713  
    1714  
    17151622/* begin page.devices.php functions */ 
    17161623 
    17171624//get the existing devices 
    1718 function core_devices_list($tech="all") { 
    1719         $sql = "SELECT id,description FROM devices"; 
     1625function 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        } 
    17201631        switch (strtoupper($tech)) { 
    17211632                case "IAX": 
     
    17311642        } 
    17321643        $sql .= ' ORDER BY id'; 
    1733         $results = sql($sql,"getAll"); 
    1734  
     1644        $results = sql($sql,"getAll",DB_FETCHMODE_ASSOC); 
     1645 
     1646        $extens = null; 
    17351647        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                        /* 
    17371658                        $extens[] = array( 
    17381659                                0=>$result[0],  // for backwards compatibility 
     
    17411662                                'description'=>$result[1], 
    17421663                        ); 
    1743                 } 
    1744         } 
    1745         if (isset($extens)) { 
    1746                 return $extens; 
    1747         } else {  
    1748                 return null; 
    1749         } 
     1664                        */ 
     1665                } 
     1666        } 
     1667        return $extens; 
    17501668} 
    17511669 
     
    24302348        } 
    24312349 
    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 
    24332356        // 
    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>"; 
    24442365                        return false; 
    24452366                } 
     
    24732394        } 
    24742395 
    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 database 
    2479         // then add directdid to the insert command. 
    2480         // 
    24812396        // Clean replace any <> with () in display name - should have javascript stopping this but ... 
    24822397        // 
     
    24842399         
    24852400        //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 (\""; 
    24872402        $sql.= "$extension\", \""; 
    24882403        $sql.= isset($password)?$password:''; 
     
    25002415        $sql.= isset($outboundcid)?$outboundcid:''; 
    25012416        $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.= "\", \""; 
    25152417        $sql.= isset($privacyman)?$privacyman:''; 
    2516         $sql.= "\", \""; 
    2517         $sql.= isset($mohclass)?$mohclass:''; 
    25182418        $sql.= "\", \""; 
    25192419        $sql.= isset($sipname)?$sipname:''; 
     
    25882488                fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]); 
    25892489        } 
     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 
    25902514        return true; 
    25912515} 
     
    26592583 
    26602584function 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(); 
    26672586} 
    26682587 
     
    26992618        } 
    27002619         
    2701         $directdid=$vars['directdid']; 
    2702         $directdid = preg_replace("/[^0-9._XxNnZz\[\]\-\+]/" ,"", trim($directdid)); 
    27032620        // clean and check the did to make sure it is not being used by another extension or in did routing 
    27042621        // 
    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>"; 
    27142637                        return false; 
    27152638                } 
     
    27262649 
    27272650function 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
    27332653 
    27342654function core_zapchandids_add($description, $channel, $did) { 
     
    39653885} 
    39663886 
     3887// Used below in usort 
     3888function 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 
    39673896function core_users_configpageload() { 
    39683897        global $currentcomponent; 
     
    39703899 
    39713900        // 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; 
    39743902 
    39753903        // Init vars from $_REQUEST[] 
     
    39933921                if ( is_string($extdisplay) ) {  
    39943922 
    3995                         if (!isset($GLOBALS['abort']) || $GLOBALS['abort'] !== true) { 
     3923                        if (!isset($_GLOBALS['abort']) || $_GLOBALS['abort'] !== true) { 
    39963924                                $extenInfo=core_users_get($extdisplay); 
    39973925                                extract($extenInfo); 
     
    40023930                        if ( $display == 'extensions' ) { 
    40033931                                $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) { 
    40053933                                        $currentcomponent->addguielem('_top', new gui_link('del', _("Delete Extension")." $extdisplay", $delURL, true, false), 0); 
    40063934 
     
    40123940                        } else { 
    40133941                                $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) { 
    40153943                                        $currentcomponent->addguielem('_top', new gui_link('del', _("Delete User")." $extdisplay", $delURL, true, false), 0); 
    40163944 
     
    40463974                        $section = ($extdisplay ? _("Edit User") : _("Add User")); 
    40473975                } 
    4048                 if ( $extdisplay ) { 
     3976                if ( trim($extdisplay) != '' ) { 
    40493977                        $currentcomponent->addguielem($section, new gui_hidden('extension', $extdisplay), 2); 
    40503978                } else { 
     
    40603988                $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)); 
    40613989                $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  = '&nbsp;'; 
     4005                                        $device_label .=  _('Edit:'); 
     4006                                        $device_label .= '&nbsp;'.$device_item['id'].'&nbsp;'.$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                } 
    40624016                 
    40634017                $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\" &lt;#######&gt;</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\" &lt;#######&gt;</b><br><br>Leave this field blank to disable the outbound callerid feature for this user."), '!isCallerID()', $msgInvalidOutboundCID, true),3); 
    40704019                $ringtimer = (isset($ringtimer) ? $ringtimer : '0'); 
    40714020                $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)); 
     
    40794028                $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)); 
    40804029 
     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 
    40814058                $section = 'Recording Options'; 
    40824059                $currentcomponent->addguielem($section, new gui_selectbox('record_in', $currentcomponent->getoptlist('recordoptions'), $record_in, 'Record Incoming', _("Record all inbound calls received at this extension."), false)); 
     
    41124089        if (isset($extension) && !checkRange($extension)){ 
    41134090                echo "<script>javascript:alert('". _("Warning! Extension")." ".$extension." "._("is not allowed for your account").".');</script>"; 
    4114                 $GLOBALS['abort'] = true; 
     4091                $_GLOBALS['abort'] = true; 
    41154092        } else { 
    41164093                //if submitting form, update database 
     
    41214098                                $usage_arr = framework_check_extension_usage($_REQUEST['extension']); 
    41224099                                if (!empty($usage_arr)) { 
    4123                                         $GLOBALS['abort'] = true; 
     4100                                        $_GLOBALS['abort'] = true; 
    41244101                                        $conflict_url = framework_display_extension_usage_alert($usage_arr,true); 
    41254102                                        global $currentcomponent; 
     
    41364113                                        // this like voicemail! 
    41374114                                        // 
    4138                                         $GLOBALS['abort'] = true; 
     4115                                        $_GLOBALS['abort'] = true; 
    41394116                                } 
    41404117                        break; 
     
    41544131                                } else { 
    41554132                                        // really bad hack - but if core_users_edit fails, want to stop core_devices_edit 
    4156                                         $GLOBALS['abort'] = true; 
     4133                                        $_GLOBALS['abort'] = true; 
    41574134                                } 
    41584135                        break; 
     
    44034380                case "add": 
    44044381                // 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) { 
    44064383                        if (core_devices_add($deviceid,$tech,$devinfo_dial,$devicetype,$deviceuser,$description,$emergency_cid)) { 
    44074384                                needreload(); 
     
    44194396                case "edit":  //just delete and re-add 
    44204397                        // 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) { 
    44224399                                core_devices_del($extdisplay,true); 
    44234400                                core_devices_add($deviceid,$tech,$devinfo_dial,$devicetype,$deviceuser,$description,$emergency_cid,true); 
  • modules/branches/2.5/core/install.php

    r5563 r5898  
    11<?php 
     2 
     3if (! function_exists("out")) { 
     4        function out($text) { 
     5                echo $text."<br />"; 
     6        } 
     7} 
     8 
     9if (! function_exists("outn")) { 
     10        function outn($text) { 
     11                echo $text; 
     12        } 
     13} 
     14 
     15function 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} 
    238 
    339$fcc = new featurecode('core', 'userlogon'); 
     
    6197unset($fcc); 
    6298 
     99 
     100// Version 2.5 Upgrade needs to migrate directdid user info to incoming table 
     101// 
     102outn(_("Checking if directdids need migrating..")); 
     103$sql = "SELECT `directdid` FROM `users`"; 
     104$check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
     105if(!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} 
    63151?> 
  • modules/branches/2.5/core/page.did.php

    r5762 r5898  
    2020$ringing = isset($_REQUEST['ringing'])?$_REQUEST['ringing']:''; 
    2121$description = isset($_REQUEST['description'])?$_REQUEST['description']:''; 
     22if (isset($_REQUEST['submitclear'])) { 
     23        $_REQUEST[$goto0.'0'] = ''; 
     24} 
    2225 
    2326if (isset($_REQUEST['extension']) && isset($_REQUEST['cidnum'])) { 
    2427        $extdisplay = $_REQUEST['extension']."/".$_REQUEST['cidnum']; 
    2528} 
     29 
     30$didfilter = isset($_REQUEST['didfilter'])?$_REQUEST['didfilter']:''; 
    2631 
    2732//update db if submiting form 
     
    5459</div> 
    5560 
     61<?php 
     62$display_link = isset($extdisplay) && $extdispaly != '' ? "&amp;extdisplay=".$extdisplay : ''; 
     63?> 
    5664<div class="rnav"> 
    5765<ul> 
    5866        <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).'&amp;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).'&amp;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).'&amp;didfilter=unassigned'.$display_link?>"><?php echo _("View Un-Assigned")?></a></li> 
    5971<?php  
    6072//get unique incoming routes 
    6173$inroutes = core_did_list('description'); 
     74switch ($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} 
    62100if (isset($inroutes)) { 
    63101        foreach ($inroutes as $inroute) { 
     
    65103                $displaycid = ( empty($inroute['cidnum'])? _("any CID") : $inroute['cidnum'] ); 
    66104                $desc = ( empty($inroute['description'])? "" : $inroute['description']."<br />" );