| 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)"; |
|---|
| | 95 | |
|---|
| | 96 | function 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 | |
|---|
| | 106 | function 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 | |
|---|