Changeset 9818

Show
Ignore:
Timestamp:
06/11/10 09:44:15 (2 years ago)
Author:
mbrevda
Message:

re: #1447, #1690; reverting changes to make way for #4335

Files:

Legend:

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

    r9817 r9818  
    4949        $section = $val[0]; 
    5050        if (isset($ext->_includes[$section])) { 
    51                $i = 0; 
     51          $i = 0; 
    5252          foreach ($ext->_includes[$section] as $include) { 
    53             $i = $i + 1; 
    5453            if ($section == 'outbound-allroutes') { 
    55               $sql = "update customcontexts_includes_list  set missing = 0, sort = $i, description = '$include[comment]' where context = '$section' and include = '$include[include]'"; 
     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)"; 
    5662              $db->query($sql); 
    5763            } else { 
    58               $sql = "update customcontexts_includes_list  set missing = 0, sort = $i where context = '$section' and include = '$include[include]'"; 
     64              $sql = "update customcontexts_includes_list  set missing = 0, sort = $i where context = '$section' and include = '$include'"; 
    5965              $db->query($sql); 
    60            
    61             $sql = "INSERT IGNORE INTO customcontexts_includes_list (context, include, description, sort) VALUES ('$section', '$include[include]', '$include[include]', $i)"; 
     66           
     67            $sql = "INSERT IGNORE INTO customcontexts_includes_list (context, include, description, sort) VALUES ('$section', '$include', '$include', $i)"; 
    6268            $db->query($sql); 
    6369          } 
     
    8793  } 
    8894} 
     95 
     96function customcontexts_routing_editname($route,$newname) { 
     97  global $db; 
     98//fix renamed contexts       , description = '$include' 
     99  $sql = "update customcontexts_includes_list  set include = '$newname', description = '$newname', missing = 0 where context = 'outbound-allroutes' and include = '$route'"; 
     100  $db->query($sql); 
     101//fix allowed renamed contexts  (i did not do , sort = $i, maybe i should)   context = 'outbound-allroutes' and 
     102  $sql = "update customcontexts_includes set include = '$newname' where include = '$route'"; 
     103  $db->query($sql); 
     104}     
     105 
     106function customcontexts_routing_prioritize($action,$priority,$direction=null) { 
     107    global $db; 
     108  $outbound_routes = core_routing_getroutenames(); 
     109  foreach ($outbound_routes as $route) { 
     110        $routename = $route[0]; 
     111        $routepriority = (int)(substr($routename,0,3)); 
     112        switch ($action) { 
     113            case 'prioritizeroute': 
     114        $addpriority = ($direction=='up')?-1:1; 
     115              if ($priority + $addpriority == $routepriority) { 
     116          $newpriority = str_pad($priority, 3, "0", STR_PAD_LEFT); 
     117                    $newroute = 'outrt-'.$newpriority.'-'.substr($routename,4); 
     118        } elseif ($priority == $routepriority) { 
     119          $newpriority = str_pad($priority + $addpriority, 3, "0", STR_PAD_LEFT); 
     120                    $newroute = 'outrt-'.$newpriority.'-'.substr($routename,4); 
     121        } 
     122        if (isset($newroute)) { 
     123//fix prioritized contexts    , description = '$newroute' 
     124          $sql = "update customcontexts_includes_list  set include = '$newroute', description = '$newroute', missing = 0, sort = $newpriority where context = 'outbound-allroutes' and include= 'outrt-$routename'"; 
     125//echo $sql; 
     126          $db->query($sql); 
     127//fix allowed prioritized contexts  (i did not do , sort = $i, maybe i should)    context = 'outbound-allroutes' and 
     128          $sql = "update customcontexts_includes set include = '$newroute' where include = 'outrt-$routename'"; 
     129//echo $sql; 
     130          $db->query($sql); 
     131        } 
     132        unset($newroute); 
     133            break; 
     134            case 'delroute'; 
     135              if ($routepriority > $priority) { 
     136          $newpriority = str_pad($routepriority - 1, 3, "0", STR_PAD_LEFT); 
     137                    $newroute = 'outrt-'.$newpriority.'-'.substr($routename,4); 
     138//fix prioritized contexts   , description = '$newroute' 
     139          $sql = "update customcontexts_includes_list  set include = '$newroute', description = '$newroute', missing = 0, sort = $newpriority where context = 'outbound-allroutes' and include= 'outrt-$routename'"; 
     140//echo $sql; 
     141          $db->query($sql); 
     142//fix allowed prioritized contexts  (i did not do , sort = $i, maybe i should)   context = 'outbound-allroutes' and 
     143          $sql = "update customcontexts_includes set include = '$newroute' where include = 'outrt-$routename'"; 
     144//echo $sql; 
     145          $db->query($sql); 
     146        } 
     147        unset($newroute); 
     148            break; 
     149    }             
     150  } 
     151} 
     152 
    89153 
    90154//this lists all includes from the sql database (for the requsted context) which we parsed out of the dialplan 
     
    546610    $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.'; 
    547611    $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); 
     612    $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); 
    548613    if (!$extdisplay) { 
    549614      $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Add Context"), false), 0);