Changeset 9817

Show
Ignore:
Timestamp:
06/10/10 16:37:02 (2 years ago)
Author:
naftali5
Message:

re #1447, re #1690 - simple changes, just enough to make CustomContexts work with 2.8

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • contributed_modules/modules/customcontexts/functions.inc.php

    r9591 r9817  
    5151                $i = 0; 
    5252          foreach ($ext->_includes[$section] as $include) { 
     53            $i = $i + 1; 
    5354            if ($section == 'outbound-allroutes') { 
    54               $i = $i + 1; 
    55               $sql = "update customcontexts_includes_list  set missing = 0, sort = $i where context = '$section' and include = '$include'"; 
    56               $db->query($sql); 
    57 //fix prioritized contexts       , description = '$include' 
    58               $sql = "update customcontexts_includes_list  set include = '$include', description = '$include', missing = 0, sort = $i where missing = 1 and context = '$section' and substring(include,1,6) = 'outrt-' and substring(include,10) = substring('$include',10)"; 
    59               $db->query($sql); 
    60 //fix allowed prioritized contexts  (i did not do , sort = $i, maybe i should)    context = '$section' and 
    61               $sql = "update customcontexts_includes set include = '$include' where substr(include,1,6) = 'outrt-' and substr(include,10) = substr('$include',10)"; 
     55              $sql = "update customcontexts_includes_list  set missing = 0, sort = $i, description = '$include[comment]' where context = '$section' and include = '$include[include]'"; 
    6256              $db->query($sql); 
    6357            } else { 
    64               $sql = "update customcontexts_includes_list  set missing = 0, sort = $i where context = '$section' and include = '$include'"; 
     58              $sql = "update customcontexts_includes_list  set missing = 0, sort = $i where context = '$section' and include = '$include[include]'"; 
    6559              $db->query($sql); 
    66                        
    67             $sql = "INSERT IGNORE INTO customcontexts_includes_list (context, include, description, sort) VALUES ('$section', '$include', '$include', $i)"; 
     60           
     61            $sql = "INSERT IGNORE INTO customcontexts_includes_list (context, include, description, sort) VALUES ('$section', '$include[include]', '$include[include]', $i)"; 
    6862            $db->query($sql); 
    6963          } 
     
    9387  } 
    9488} 
    95  
    96 //this is to catch any rename reorder or delete route, so i can fix custom contexts 
    97 function customcontexts_hookProcess_core($viewing_itemid, $request) { 
    98   switch ($request['display']) { 
    99         case 'routing': 
    100       if(isset($request['Submit'])) { 
    101 //        $route = substr($viewing_itemid,4); 
    102 //        $priority = (int)(substr($viewing_itemid,0,3)); 
    103       }  
    104       switch ($request['action']) { 
    105         case 'delroute': 
    106 //          $route = substr($viewing_itemid,4); 
    107           $priority = (int)(substr($viewing_itemid,0,3)); 
    108           customcontexts_routing_prioritize($request['action'],$priority); 
    109         break; 
    110         case 'prioritizeroute': 
    111           $fullroute = $viewing_itemid; 
    112           if (isset($request['reporoutekey'])) { 
    113                     $outbound_routes = core_routing_getroutenames(); 
    114             $fullroute = $outbound_routes[(int)$request['reporoutekey']][0]; 
    115                 } 
    116 //          $route = substr($fullroute,4); 
    117           $priority = (int)(substr($fullroute,0,3)); 
    118           $direction = $request['reporoutedirection']; 
    119           customcontexts_routing_prioritize($request['action'],$priority,$direction); 
    120         break; 
    121         case 'renameroute'; 
    122           $newname = $request['newroutename']; 
    123           $route = $viewing_itemid; 
    124           $priority = (substr($viewing_itemid,0,3)); 
    125                     $fullnewname = 'outrt-'.$priority.'-'.$newname; 
    126                     $fullroutename = 'outrt-'.$route; 
    127           customcontexts_routing_editname($fullroutename,$fullnewname); 
    128         break; 
    129         default: 
    130      
    131         break; 
    132       } 
    133     break; 
    134   } 
    135 } 
    136  
    137 function customcontexts_routing_editname($route,$newname) { 
    138   global $db; 
    139 //fix renamed contexts       , description = '$include' 
    140   $sql = "update customcontexts_includes_list  set include = '$newname', description = '$newname', missing = 0 where context = 'outbound-allroutes' and include = '$route'"; 
    141   $db->query($sql); 
    142 //fix allowed renamed contexts  (i did not do , sort = $i, maybe i should)   context = 'outbound-allroutes' and 
    143   $sql = "update customcontexts_includes set include = '$newname' where include = '$route'"; 
    144   $db->query($sql); 
    145 }     
    146  
    147 function customcontexts_routing_prioritize($action,$priority,$direction=null) { 
    148     global $db; 
    149   $outbound_routes = core_routing_getroutenames(); 
    150   foreach ($outbound_routes as $route) { 
    151         $routename = $route[0]; 
    152         $routepriority = (int)(substr($routename,0,3)); 
    153         switch ($action) { 
    154             case 'prioritizeroute': 
    155         $addpriority = ($direction=='up')?-1:1; 
    156               if ($priority + $addpriority == $routepriority) { 
    157           $newpriority = str_pad($priority, 3, "0", STR_PAD_LEFT); 
    158                     $newroute = 'outrt-'.$newpriority.'-'.substr($routename,4); 
    159         } elseif ($priority == $routepriority) { 
    160           $newpriority = str_pad($priority + $addpriority, 3, "0", STR_PAD_LEFT); 
    161                     $newroute = 'outrt-'.$newpriority.'-'.substr($routename,4); 
    162         } 
    163         if (isset($newroute)) { 
    164 //fix prioritized contexts    , description = '$newroute' 
    165           $sql = "update customcontexts_includes_list  set include = '$newroute', description = '$newroute', missing = 0, sort = $newpriority where context = 'outbound-allroutes' and include= 'outrt-$routename'"; 
    166 //echo $sql; 
    167           $db->query($sql); 
    168 //fix allowed prioritized contexts  (i did not do , sort = $i, maybe i should)    context = 'outbound-allroutes' and 
    169           $sql = "update customcontexts_includes set include = '$newroute' where include = 'outrt-$routename'"; 
    170 //echo $sql; 
    171           $db->query($sql); 
    172         } 
    173         unset($newroute); 
    174             break; 
    175             case 'delroute'; 
    176               if ($routepriority > $priority) { 
    177           $newpriority = str_pad($routepriority - 1, 3, "0", STR_PAD_LEFT); 
    178                     $newroute = 'outrt-'.$newpriority.'-'.substr($routename,4); 
    179 //fix prioritized contexts   , description = '$newroute' 
    180           $sql = "update customcontexts_includes_list  set include = '$newroute', description = '$newroute', missing = 0, sort = $newpriority where context = 'outbound-allroutes' and include= 'outrt-$routename'"; 
    181 //echo $sql; 
    182           $db->query($sql); 
    183 //fix allowed prioritized contexts  (i did not do , sort = $i, maybe i should)   context = 'outbound-allroutes' and 
    184           $sql = "update customcontexts_includes set include = '$newroute' where include = 'outrt-$routename'"; 
    185 //echo $sql; 
    186           $db->query($sql); 
    187         } 
    188         unset($newroute); 
    189             break; 
    190     }             
    191   } 
    192 } 
    193  
    19489 
    19590//this lists all includes from the sql database (for the requsted context) which we parsed out of the dialplan 
     
    488383         $currentcomponent->addguielem('_top', new gui_hidden('action', ($extdisplay ? 'edit' : 'add'))); 
    489384    $currentcomponent->addguielem('_bottom', new gui_link('help', _(customcontexts_getmodulevalue('moduledisplayname')." v".customcontexts_getmodulevalue('moduleversion')), 'http://www.freepbx.org/support/documentation/module-documentation/third-party-unsupported-modules/customcontexts', true, false), 0); 
    490     $currentcomponent->addguielem('_bottom', new gui_link('bounty', 'Module Going END OF LIFE - Click For Details', 'http://www.freepbx.org/bounties/custom-context', true, false), 0); 
    491385    if (!$extdisplay) { 
    492386      $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Add Context"), false), 0); 
     
    652546    $info = 'The custom context to make will be available in your dialplan. These contexts can be used as a context for a device/extension to allow them limited access to your dialplan.'; 
    653547    $currentcomponent->addguielem('_bottom', new gui_link('ver', _(customcontexts_getmodulevalue('moduledisplayname')." v".customcontexts_getmodulevalue('moduleversion')), 'http://www.freepbx.org/support/documentation/module-documentation/third-party-unsupported-modules/customcontexts', true, false), 0); 
    654     $currentcomponent->addguielem('_bottom', new gui_link('bounty', 'Module Going END OF LIFE - Click For Details', 'http://www.freepbx.org/bounties/custom-context', true, false), 0); 
    655548    if (!$extdisplay) { 
    656549      $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Add Context"), false), 0); 
     
    906799    $info = ''; 
    907800    $currentcomponent->addguielem('_bottom', new gui_link('ver', _(customcontexts_getmodulevalue('moduledisplayname')." v".customcontexts_getmodulevalue('moduleversion')), 'http://www.freepbx.org/support/documentation/module-documentation/third-party-unsupported-modules/customcontexts', true, false), 0); 
    908     $currentcomponent->addguielem('_bottom', new gui_link('bounty', 'Module Going END OF LIFE - Click For Details', 'http://www.freepbx.org/bounties/custom-context', true, false), 0); 
    909801    if (!$extdisplay) { 
    910802      $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Add Time Group"), false), 0); 
  • contributed_modules/modules/customcontexts/module.xml

    r9592 r9817  
    22  <rawname>customcontexts</rawname> 
    33  <name>Custom Contexts</name> 
    4   <version>0.3.6</version> 
     4  <version>2.8.0.1</version> 
    55  <type>setup</type> 
    66  <category>Third Party Addon</category> 
     
    2020  </menuitems> 
    2121        <depends> 
    22           <version>lt 2.8.0alpha1</version> 
     22          <version>ge 2.8.0alpha1</version> 
    2323          <module>core</module> 
    2424        </depends> 
    2525        <changelog> 
     26                *2.8.0.1* remove End of Life warning, change dependency requirement, fix for FreePBX 2.8 
    2627                *0.3.6* fix version, End of Life warning, dependency requirement 
    2728                *0.3.5* #3994 current context on extension page not sticking 
     
    5657    REMEMBER! Any device placed in a restricted context will have no access to the dialplan if this module is disabled until it is placed in a normal context! 
    5758  </attention> 
    58   <location>contributed_modules/release/customcontexts-0.3.6.tgz</location> 
    59   <md5sum>d1c83f26c53eb3dfbf5d83263155e3eb</md5sum> 
     59  <location>contributed_modules/release/customcontexts-2.8.0.1.tgz</location> 
     60  <md5sum></md5sum> 
    6061</module>