Changeset 5303

Show
Ignore:
Timestamp:
11/27/07 13:24:42 (4 years ago)
Author:
p_lindheimer
Message:

2.3.0beta1 directory and infrastructure includes conversion to incoming table for Zap Channel DIDs

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/trunk/CHANGES

    r5136 r5303  
     12.4.0 
     2 
     3- Implementation of a distributed Extension and Destination Registry through callbacks 
     4  in all modules and supporting APIs in framework. The Extension Registry provides the 
     5  needed information and APIs to detect and allow a module to block the creation of an 
     6  extension number that is used elsewhere. The Destination Registry provides a 
     7  mechanism for a module to detrmine if any of it's entities are being used as a 
     8  destination by other modules so it can provide warnings or feedback about the impact 
     9  of deleting such entities. Both registries are checked when reloading a configuration 
     10  and any inegrity issues are supplied to the notification panel. All supported modules 
     11  should be instrumented to use these once updated. 
     12- Module admin changed so that 'problem' modules that have dependency issues will not 
     13  block other modules from being downloaded and/or installed. A warning is still generated 
     14  but the action is allowed to proceed with any modules that have all their dependencies 
     15  met. 
     16- Custom destinations will no longer show up under the destination selections unless there 
     17  is already one configured or an unknown destination is detected (which are one and the 
     18  same). Misc Applications module will continue to support custom destinations. Users must create 
     19  a Misc Application for any required custom destinations, and then use Misc Dest to access 
     20  that destination so that it will appear as an option to other modules. This is more 
     21  cumbersome but ultimately less error prone and more supportable for the user. 
     22- Removed Channel Routing from 'Inbound Routes.' Added 'Zap Channel DIDs' to core modules 
     23  to assign DIDs to Zap Channels which can then use 'Inbound Routes' to route them with 
     24  all the same flexibility that is there today and without some of the issues that the 
     25  previous Channel routing implementation provided. Existing Channel routes will be 
     26  converted and entries inserted into the 'Zap Channel DIDs' tables. 
     27 
     28  WARNING: changes were made to some of the core_did_XXXX() API calls that could effect 
     29  any custom applications that were depending on these. 
     30 
     31- Several changes and enhancements have been made to improve the usability of Users/Devices 
     32  mode particularyly around Adhoc devices. Some highlights: 
     33  - Default user information is retained and the device returned to that user upon a logout 
     34  - Editing devices in FreePBX will no longer erase current logged in device information 
     35  - Hints are initially generated properly for Adhoc devices 
     36  - Hints are dynamically added/deleted as part of the logon/logoff process 
     37  - There are still issues if reloading from the CLI. A script and some instructions will 
     38    be supplied on ways to address this until a more permanent solution can be determined. 
     39- Pulled some agi scripts and macro calls out of dialout-trunk / dialout-enum into the outbound  
     40  route code so they would only be called once when the call sequence has to try multiple 
     41  trunks. 
     42- Added reload option to CLI module_admin to peform same task as the reload bar. 
     43- Added support in macro-user-callerid to support per-user/extension language changes. 
     44- Misc other bug fixes and some feature requests that can be obtained through the SVN log. 
     45 
    1462.3.1 
    247 
  • freepbx/trunk/SQL/newinstall.sql

    r4993 r5303  
    283283  `privacyman` tinyint(1) default NULL, 
    284284  `alertinfo` varchar(255) default NULL, 
    285   `channel` varchar(20) default NULL, 
    286285  `ringing` varchar(20) default NULL, 
    287286  `mohclass` varchar(80) NOT NULL default 'default', 
    288287  `description` varchar(80) default NULL, 
    289288  `grppre` varchar (80) default NULL  
     289); 
     290 
     291-- 
     292-- Table structure for table `zapchandids` 
     293-- 
     294 
     295DROP TABLE IF EXISTS `zapchandids`; 
     296CREATE TABLE `zapchandids` ( 
     297  `channel` int(11) NOT NULL default '0', 
     298  `description` varchar(40) NOT NULL default '', 
     299  `did` varchar(60) NOT NULL default '', 
     300  PRIMARY KEY  (channel) 
    290301); 
    291302 
  • freepbx/trunk/SQL/newinstall.sqlite3.sql

    r4993 r5303  
    285285  `privacyman` tinyint(1) default NULL, 
    286286  `alertinfo` varchar(255) default NULL, 
    287   `channel` varchar(20) default NULL, 
    288287  `ringing` varchar(20) default NULL, 
    289288  `mohclass` varchar(80) NOT NULL default 'default', 
     
    293292 
    294293-- 
    295 -- Dumping data for table `incoming` 
    296 -- 
    297  
     294-- Table structure for table `zapchandids` 
     295-- 
     296 
     297DROP TABLE IF EXISTS `zapchandids`; 
     298CREATE TABLE `zapchandids` ( 
     299  `channel` int(11) NOT NULL default '0', 
     300  `description` varchar(40) NOT NULL default '', 
     301  `did` varchar(60) NOT NULL default '', 
     302  PRIMARY KEY  (channel) 
     303); 
    298304 
    299305/*!40000 ALTER TABLE `incoming` DISABLE KEYS */; 
  • freepbx/trunk/upgrades/2.4.0beta1/tables.php

    r4993 r5303  
    11<?php 
    22 
    3 /* merge_ext_followme_priv($dest) { 
    4  *  
    5  * The purpose of this function is to take a destination 
    6  * that was either a core extension OR a findmefollow-destination 
    7  * and convert it so that they are merged and handled just like 
    8  * direct-did routing 
     3/** Remove the old Zap Channel Routing in favor of assigning DIDs to Zap Channels 
     4 *  and then use starndard DID routing for all incoming calls. This increases the 
     5 *  flexibility since multiple channels can point to the same DID if desired and 
     6 *  then DID or DID+CID routing can be used. 
    97 * 
    10  * Assuming an extension number of 222: 
    11  * 
    12  * The two formats that existed for findmefollow were: 
    13  * 
    14  * ext-findmefollow,222,1 
    15  * ext-findmefollow,FM222,1 
    16  * 
    17  * The one format that existed for core was: 
    18  * 
    19  * ext-local,222,1 
    20  * 
    21  * In all those cases they should be converted to: 
    22  * 
    23  * from-did-direct,222,1 
    24  * 
     8 *  1. Check if zapchandids table exists by trying to create it. If the table creation 
     9 *     fails then it must already exist (or something else is wrong) so we stop. 
     10 *  2. Select all channel routes in incoming and create entries in zapchandids table. 
     11 *     point to a special DID (zapchan<nn>) which can later be changed if desired. 
     12 *  3. Update old Zap Channel entries in 'incoming' table to the new DID. 
     13 *  4. Drop the old channel field in incoming which is no longer needed. 
    2514 */ 
    26 function merge_ext_followme_priv($dest) { 
    27  
    28   if (preg_match("/^\s*ext-findmefollow,(FM)?(\d+),(\d+)/",$dest,$matches) || 
    29       preg_match("/^\s*ext-local,(FM)?(\d+),(\d+)/",$dest,$matches) ) { 
    30         // matches[2] => extn 
    31         // matches[3] => priority 
    32     return "from-did-direct,".$matches[2].",".$matches[3]; 
     15outn("Trying to create zapchandids table.."); 
     16$sql = " 
     17CREATE TABLE zapchandids ( 
     18  channel int(11) NOT NULL default '0', 
     19  description varchar(40) NOT NULL default '', 
     20  did varchar(60) NOT NULL default '', 
     21  PRIMARY KEY  (channel) 
     22)"; 
     23$results = $db->query($sql); 
     24if(!DB::IsError($results)) { 
     25  out("Created, Starting Conversion"); 
     26  outn("Creating Zap Channel DIDs and converting old routes to DIDs.."); 
     27  $chan_prefix = 'zapchan'; 
     28  $sql="SELECT channel, description FROM incoming WHERE channel != ''"; 
     29  $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
     30  if(DB::IsError($results)) { 
     31    out("FATAL ERROR: ".$results->getMessage()); 
    3332  } else { 
    34     return $dest; 
    35   } 
    36 
    37  
    38 outn("Upgrading Inbound Routing to allow for Music on Hold per DID.."); 
    39  
    40 $sql = "SELECT mohclass FROM incoming"; 
    41 $confs = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
    42 if (!DB::IsError($confs)) { // no error... Already done 
    43   out("Not Required"); 
    44 } else { 
    45   $sql = "ALTER TABLE incoming ADD mohclass VARCHAR ( 80 ) DEFAULT \"default\""; 
    46   $results = $db->query($sql); 
    47   if(DB::IsError($results)) { 
    48           die($results->getMessage()); 
    49   } 
    50   out("Done"); 
    51 
    52  
    53 outn("Upgrading Inbound Routing to provide a description field.."); 
    54  
    55 $sql = "SELECT description FROM incoming"; 
    56 $confs = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
    57 if (!DB::IsError($confs)) { // no error... Already done 
    58   out("Not Required"); 
    59 } else { 
    60   $sql = "ALTER TABLE incoming ADD description VARCHAR ( 80 ) NULL"; 
    61   $results = $db->query($sql); 
    62   if(DB::IsError($results)) { 
    63           die($results->getMessage()); 
    64   } 
    65   out("Done"); 
    66 
    67  
    68 outn("Upgrading Inbound Routing to provide a CID Prefix field.."); 
    69  
    70 $sql = "SELECT grppre FROM incoming"; 
    71 $confs = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
    72 if (!DB::IsError($confs)) { // no error... Already done 
    73   out("Not Required"); 
    74 } else { 
    75   $sql = "ALTER TABLE incoming ADD grppre VARCHAR ( 80 ) NULL"; 
    76   $results = $db->query($sql); 
    77   if(DB::IsError($results)) { 
    78           die($results->getMessage()); 
    79   } 
    80   out("Done"); 
    81 
    82  
    83 outn("Upgrading Users/Extension Table to allow for Music on Hold per Direct DID.."); 
    84  
    85 $sql = "SELECT mohclass FROM users"; 
    86 $confs = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
    87 if (!DB::IsError($confs)) { // no error... Already done 
    88   out("Not Required"); 
    89 } else { 
    90   $sql = "ALTER TABLE users ADD mohclass VARCHAR ( 80 ) DEFAULT \"default\""; 
    91   $results = $db->query($sql); 
    92   if(DB::IsError($results)) { 
    93           die($results->getMessage()); 
    94   } 
    95   out("Done"); 
    96 
    97  
    98 $sql = "SELECT sipname FROM users"; 
    99 $confs = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
    100 if (!DB::IsError($confs)) { // no error... Already done 
    101   out("Not Required"); 
    102 } else { 
    103   $sql = "ALTER TABLE users ADD sipname VARCHAR ( 50 ) NULL "; 
    104   $results = $db->query($sql); 
    105   if(DB::IsError($results)) { 
    106           die($results->getMessage()); 
    107   } 
    108   out("Done"); 
    109 
    110  
    111 outn("Checking for Global var VMX_CONTEXT.."); 
    112 $nrows = $db->getOne("SELECT count(*) from globals where variable='VMX_CONTEXT'"); 
    113 if (!$nrows) { 
    114   $db->query("insert into globals values ('VMX_CONTEXT', 'from-internal')"); 
    115   out("Created"); 
    116 } else { 
    117   out("Already exists!"); 
    118 
    119  
    120 outn("Checking for Global var VMX_PRI.."); 
    121 $nrows = $db->getOne("SELECT count(*) from globals where variable='VMX_PRI'"); 
    122 if (!$nrows) { 
    123   $db->query("insert into globals values ('VMX_PRI', '1')"); 
    124   out("Created"); 
    125 } else { 
    126   out("Already exists!"); 
    127 
    128  
    129 outn("Checking for Global var VMX_TIMEDEST_CONTEXT.."); 
    130 $nrows = $db->getOne("SELECT count(*) from globals where variable='VMX_TIMEDEST_CONTEXT'"); 
    131 if (!$nrows) { 
    132   $db->query("insert into globals values ('VMX_TIMEDEST_CONTEXT', '')"); 
    133   out("Created"); 
    134 } else { 
    135   out("Already exists!"); 
    136 
    137  
    138 outn("Checking for Global var VMX_TIMEDEST_EXT.."); 
    139 $nrows = $db->getOne("SELECT count(*) from globals where variable='VMX_TIMEDEST_EXT'"); 
    140 if (!$nrows) { 
    141   $db->query("insert into globals values ('VMX_TIMEDEST_EXT', 'dovm')"); 
    142   out("Created"); 
    143 } else { 
    144   out("Already exists!"); 
    145 
    146  
    147 outn("Checking for Global var VMX_TIMEDEST_PRI.."); 
    148 $nrows = $db->getOne("SELECT count(*) from globals where variable='VMX_TIMEDEST_PRI'"); 
    149 if (!$nrows) { 
    150   $db->query("insert into globals values ('VMX_TIMEDEST_PRI', '1')"); 
    151   out("Created"); 
    152 } else { 
    153   out("Already exists!"); 
    154 
    155  
    156 outn("Checking for Global var VMX_LOOPDEST_CONTEXT.."); 
    157 $nrows = $db->getOne("SELECT count(*) from globals where variable='VMX_LOOPDEST_CONTEXT'"); 
    158 if (!$nrows) { 
    159   $db->query("insert into globals values ('VMX_LOOPDEST_CONTEXT', '')"); 
    160   out("Created"); 
    161 } else { 
    162   out("Already exists!"); 
    163 
    164  
    165 outn("Checking for Global var VMX_LOOPDEST_EXT.."); 
    166 $nrows = $db->getOne("SELECT count(*) from globals where variable='VMX_LOOPDEST_EXT'"); 
    167 if (!$nrows) { 
    168   $db->query("insert into globals values ('VMX_LOOPDEST_EXT', 'dovm')"); 
    169   out("Created"); 
    170 } else { 
    171   out("Already exists!"); 
    172 
    173  
    174 outn("Checking for Global var VMX_LOOPDEST_PRI.."); 
    175 $nrows = $db->getOne("SELECT count(*) from globals where variable='VMX_LOOPDEST_PRI'"); 
    176 if (!$nrows) { 
    177   $db->query("insert into globals values ('VMX_LOOPDEST_PRI', '1')"); 
    178   out("Created"); 
    179 } else { 
    180   out("Already exists!"); 
    181 
    182  
    183 outn("Checking for Global var VMX_OPTS_TIMEOUT.."); 
    184 $nrows = $db->getOne("SELECT count(*) from globals where variable='VMX_OPTS_TIMEOUT'"); 
    185 if (!$nrows) { 
    186   $db->query("insert into globals values ('VMX_OPTS_TIMEOUT', '')"); 
    187   out("Created"); 
    188 } else { 
    189   out("Already exists!"); 
    190 
    191  
    192 outn("Checking for Global var VMX_OPTS_LOOP.."); 
    193 $nrows = $db->getOne("SELECT count(*) from globals where variable='VMX_OPTS_LOOP'"); 
    194 if (!$nrows) { 
    195   $db->query("insert into globals values ('VMX_OPTS_LOOP', '')"); 
    196   out("Created"); 
    197 } else { 
    198   out("Already exists!"); 
    199 
    200  
    201 outn("Checking for Global var VMX_OPTS_DOVM.."); 
    202 $nrows = $db->getOne("SELECT count(*) from globals where variable='VMX_OPTS_DOVM'"); 
    203 if (!$nrows) { 
    204   $db->query("insert into globals values ('VMX_OPTS_DOVM', '')"); 
    205   out("Created"); 
    206 } else { 
    207   out("Already exists!"); 
    208 
    209  
    210 outn("Checking for Global var VMX_TIMEOUT.."); 
    211 $nrows = $db->getOne("SELECT count(*) from globals where variable='VMX_TIMEOUT'"); 
    212 if (!$nrows) { 
    213   $db->query("insert into globals values ('VMX_TIMEOUT', '2')"); 
    214   out("Created"); 
    215 } else { 
    216   out("Already exists!"); 
    217 
    218  
    219 outn("Checking for Global var VMX_REPEAT.."); 
    220 $nrows = $db->getOne("SELECT count(*) from globals where variable='VMX_REPEAT'"); 
    221 if (!$nrows) { 
    222   $db->query("insert into globals values ('VMX_REPEAT', '1')"); 
    223   out("Created"); 
    224 } else { 
    225   out("Already exists!"); 
    226 
    227  
    228 outn("Checking for Global var VMX_LOOPS.."); 
    229 $nrows = $db->getOne("SELECT count(*) from globals where variable='VMX_LOOPS'"); 
    230 if (!$nrows) { 
    231   $db->query("insert into globals values ('VMX_LOOPS', '1')"); 
    232   out("Created"); 
    233 } else { 
    234   out("Already exists!"); 
    235 
    236  
    237 outn("Checking for Global var TRANSFER_CONTEXT.."); 
    238 $nrows = $db->getOne("SELECT count(*) from globals where variable='TRANSFER_CONTEXT'"); 
    239 if (!$nrows) { 
    240   $db->query("insert into globals values ('TRANSFER_CONTEXT', 'from-internal-xfer')"); 
    241   out("Created"); 
    242 } else { 
    243   out("Already exists!"); 
    244 
    245  
    246 outn("Alter tables incoming to increase field length.. "); 
    247 $db->query("ALTER TABLE incoming CHANGE alertinfo alertinfo VARCHAR( 255 ) NULL"); 
    248 out("Altered"); 
    249  
    250 outn("Merging findmefollow and core extension destinations for incoming routes.."); 
    251  
    252 $results = array(); 
    253 $sql = "SELECT cidnum, extension, destination FROM incoming"; 
    254 $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
    255 if (DB::IsError($results)) { // error - table must not be there 
    256   out("Not Required"); 
    257 } else { 
    258   foreach ($results as $result) { 
    259     $old_dest  = $result['destination']; 
    260     $extension = $result['extension']; 
    261     $cidnum    = $result['cidnum']; 
    262  
    263     $new_dest = merge_ext_followme_priv(trim($old_dest)); 
    264     if ($new_dest != $old_dest) { 
    265       $sql = "UPDATE incoming SET destination = '$new_dest' WHERE cidnum = '$cidnum' AND extension = '$extension' AND destination = '$old_dest'"; 
     33    outn("Got ".count($results)." channels, converting.."); 
     34    foreach ($results as $row) { 
     35      $channel     = $row['channel']; 
     36      $description = $row['description']; 
     37      $did         = $chan_prefix.$channel; 
     38      $sql = "INSERT INTO zapchandids (channel, description, did) VALUES ('$channel', '$description', '$did')"; 
    26639      $results = $db->query($sql); 
    267       if(DB::IsError($results)) { 
    268         die($results->getMessage()); 
     40      if (DB::IsError($results)) {  
     41        out("ERROR: ".$channel); 
     42        out("Error inserting $channel to zapchandids: ".$results->getMessage()); 
     43        outn("Continuing.."); 
     44      } else { 
     45        outn($channel."."); 
     46      } 
     47    } 
     48    out(".OK"); 
     49    outn("Updating old zap routes to did routes.."); 
     50    // Now update the incoming table: 
     51    $sql = "UPDATE incoming SET extension=CONCAT('$chan_prefix',channel), channel='' WHERE channel != ''"; 
     52    $results = $db->query($sql); 
     53    if (DB::IsError($results)) {  
     54      out("FATAL: failed to transform old routes: ".$results->getMessage()); 
     55    } else { 
     56      out("OK"); 
     57      outn("Removing deprecated channel field from incoming.."); 
     58      $sql = "ALTER TABLE incoming DROP channel"; 
     59      $results = $db->query($sql); 
     60      if (DB::IsError($results)) {  
     61        out("ERROR: failed: ".$results->getMessage()); 
     62      } else { 
     63        out("OK"); 
    26964      } 
    27065    } 
    27166  } 
    272   out("Done"); 
     67} else { 
     68  out("already exists, no conversion will be done"); 
    27369} 
    27470