Changeset 9823
- Timestamp:
- 06/13/10 11:47:05 (3 years ago)
- Files:
-
- contributed_modules/modules/customcontexts/functions.inc.php (modified) (31 diffs)
- contributed_modules/modules/customcontexts/install.php (modified) (2 diffs)
- contributed_modules/modules/customcontexts/install.sql (deleted)
- contributed_modules/modules/customcontexts/module.xml (modified) (3 diffs)
- contributed_modules/modules/customcontexts/page.customcontexts.php (modified) (1 diff)
- contributed_modules/modules/customcontexts/uninstall.php (modified) (1 diff)
- contributed_modules/modules/customcontexts/uninstall.sql (deleted)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
contributed_modules/modules/customcontexts/functions.inc.php
r9821 r9823 5 5 function customcontexts_getmodulevalue($id) { 6 6 global $db; 7 8 switch ($id) { 9 case 'moduledisplayname': 10 $module_info = module_getinfo('customcontexts'); 11 return($module_info['customcontexts']['name']); 12 break; 13 14 case 'moduleversion': 15 $module_info = module_getinfo('customcontexts'); 16 return($module_info['customcontexts']['version']); 17 break; 18 19 default: 20 $sql = "select value from customcontexts_module where id = '$id'"; 21 $results = $db->getAll($sql); 22 if(DB::IsError($results)) 23 $results = null; 24 return isset($results)?$results[0][0]:null; 25 } 7 switch ($id) { 8 case 'moduledisplayname': 9 $module_info = module_getinfo('customcontexts'); 10 return($module_info['customcontexts']['name']); 11 break; 12 case 'moduleversion': 13 $module_info = module_getinfo('customcontexts'); 14 return($module_info['customcontexts']['version']); 15 break; 16 default: 17 $sql = "select value from customcontexts_module where id = '$id'"; 18 $results = $db->getAll($sql); 19 if(DB::IsError($results)) { 20 $results = null; 21 } 22 return isset($results)?$results[0][0]:null; 23 } 26 24 } 27 25 … … 39 37 switch($engine) { 40 38 case 'asterisk': 41 $sql = "update customcontexts_includes_list set missing = 1 where context not in (select context from customcontexts_contexts_list where locked = 1)"; 39 $sql = 'UPDATE customcontexts_includes_list SET missing = 1 WHERE context 40 NOT IN (SELECT context FROM customcontexts_contexts_list WHERE locked = 1)'; 42 41 $db->query($sql); 43 $sql = "select context from customcontexts_contexts_list";44 $ results = $db->getAll($sql);42 $sql = 'SELECT context FROM customcontexts_contexts_list'; 43 $sections = $db->getAll($sql); 45 44 if(DB::IsError($results)) { 46 45 $results = null; 47 46 } 48 foreach ($results as $val) { 49 $section = $val[0]; 47 foreach ($sections as $section) { 48 $section = $section[0]; 49 $i = 0; 50 50 if (isset($ext->_includes[$section])) { 51 $i = 0;52 51 foreach ($ext->_includes[$section] as $include) { 52 $i = $i + 1; 53 53 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)"; 54 $sql = 'INSERT INTO customcontexts_includes_list 55 (context, include, description, missing, sort) 56 VALUES ("'.$section.'", "'.$include['include'].'", 57 "'.$include['comment'].'", "0", "'.$i.'") 58 ON DUPLICATE KEY UPDATE sort = "'.$i.'", missing = "0"'; 62 59 $db->query($sql); 63 60 } else { 64 $sql = "update customcontexts_includes_list set missing = 0, sort = $i where context = '$section' and include = '$include'"; 61 $sql = 'UPDATE customcontexts_includes_list SET missing = "0", sort = "'.$i.'" 62 WHERE context = "'.$section.'" and include = "'.$include['include'].'"'; 65 63 $db->query($sql); 66 } 67 $sql = "INSERT IGNORE INTO customcontexts_includes_list (context, include, description, sort) VALUES ('$section', '$include', '$include', $i)"; 64 } 65 $sql = 'INSERT IGNORE INTO customcontexts_includes_list 66 (context, include, description, sort) 67 VALUES ("'.$section.'", "'.$include['include'].'", 68 "'.$include['include'].'", "'.$i.'")'; 68 69 $db->query($sql); 69 70 } … … 81 82 // only provide display for outbound routing 82 83 case 'routing': 83 /* 84 $route = substr($viewing_itemid,4); 85 $hookhtml = ''; 86 return $hookhtml; 87 */ 84 /*$route = substr($viewing_itemid,4);$hookhtml = '';return $hookhtml;*/ 88 85 return ''; 89 86 break; … … 94 91 } 95 92 96 //this is to catch any rename reorder or delete route, so i can fix custom contexts97 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 93 function customcontexts_routing_editname($route,$newname) { 138 94 global $db; 139 //fix renamed contexts, description = '$include'95 //fix renamed contexts, description = '$include' 140 96 $sql = "update customcontexts_includes_list set include = '$newname', description = '$newname', missing = 0 where context = 'outbound-allroutes' and include = '$route'"; 141 97 $db->query($sql); 142 //fix allowed renamed contexts (i did not do , sort = $i, maybe i should) context = 'outbound-allroutes' and98 //fix allowed renamed contexts (i did not do , sort = $i, maybe i should) context = 'outbound-allroutes' and 143 99 $sql = "update customcontexts_includes set include = '$newname' where include = '$route'"; 144 100 $db->query($sql); … … 146 102 147 103 function customcontexts_routing_prioritize($action,$priority,$direction=null) { 148 global $db;104 global $db; 149 105 $outbound_routes = core_routing_getroutenames(); 150 106 foreach ($outbound_routes as $route) { … … 162 118 } 163 119 if (isset($newroute)) { 164 //fix prioritized contexts, description = '$newroute'120 //fix prioritized contexts , description = '$newroute' 165 121 $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;122 //echo $sql; 167 123 $db->query($sql); 168 //fix allowed prioritized contexts (i did not do , sort = $i, maybe i should) context = 'outbound-allroutes' and124 //fix allowed prioritized contexts (i did not do , sort = $i, maybe i should) context = 'outbound-allroutes' and 169 125 $sql = "update customcontexts_includes set include = '$newroute' where include = 'outrt-$routename'"; 170 //echo $sql;126 //echo $sql; 171 127 $db->query($sql); 172 128 } … … 175 131 case 'delroute'; 176 132 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' and184 $sql = "update customcontexts_includes set include = '$newroute' where include = 'outrt-$routename'";185 //echo $sql;186 $db->query($sql);187 }188 unset($newroute);189 break;133 $newpriority = str_pad($routepriority - 1, 3, "0", STR_PAD_LEFT); 134 $newroute = 'outrt-'.$newpriority.'-'.substr($routename,4); 135 //fix prioritized contexts , description = '$newroute' 136 $sql = "update customcontexts_includes_list set include = '$newroute', description = '$newroute', missing = 0, sort = $newpriority where context = 'outbound-allroutes' and include= 'outrt-$routename'"; 137 //echo $sql; 138 $db->query($sql); 139 //fix allowed prioritized contexts (i did not do , sort = $i, maybe i should) context = 'outbound-allroutes' and 140 $sql = "update customcontexts_includes set include = '$newroute' where include = 'outrt-$routename'"; 141 //echo $sql; 142 $db->query($sql); 143 } 144 unset($newroute); 145 break; 190 146 } 191 147 } … … 199 155 global $db; 200 156 // $sql = "select include, description from customcontexts_includes_list where context = '".$context."' order by description"; 201 $sql = "select include, customcontexts_includes_list.description, count(customcontexts_contexts_list.context) as preemptcount from customcontexts_includes_list left outer join customcontexts_contexts_list on include = customcontexts_contexts_list.context where customcontexts_includes_list.context = '$context' group by include, customcontexts_includes_list.description order by customcontexts_includes_list.description"; 157 $sql = "SELECT include, customcontexts_includes_list.description, 158 COUNT(customcontexts_contexts_list.context) AS preemptcount 159 FROM customcontexts_includes_list 160 LEFT OUTER JOIN customcontexts_contexts_list 161 ON include = customcontexts_contexts_list.context 162 WHERE customcontexts_includes_list.context = '$context' 163 GROUP BY include, customcontexts_includes_list.description 164 ORDER BY customcontexts_includes_list.sort, 165 customcontexts_includes_list.description"; 202 166 $results = $db->getAll($sql); 203 if(DB::IsError($results)) 167 if(DB::IsError($results)) { 204 168 $results = null; 205 foreach ($results as $val) 169 } 170 foreach ($results as $val) { 206 171 $tmparray[] = array($val[0], $val[1], $val[2]); 172 } 207 173 return $tmparray; 208 174 } … … 213 179 $sql = "select context, description from customcontexts_contexts_list order by description"; 214 180 $results = $db->getAll($sql); 215 if(DB::IsError($results)) 181 if(DB::IsError($results)) { 216 182 $results = null; 217 foreach ($results as $val) 183 } 184 foreach ($results as $val) { 218 185 $tmparray[] = array($val[0], $val[1]); 186 } 219 187 return $tmparray; 220 188 } … … 224 192 global $db; 225 193 // $sql = "select customcontexts_contexts_list.context, customcontexts_contexts_list.description as contextdescription, customcontexts_includes_list.include, customcontexts_includes_list.description, if(saved.include is null, 'no', if(saved.timegroupid is null, 'yes', saved.timegroupid)) as allow, saved.sort from customcontexts_contexts_list inner join customcontexts_includes_list on customcontexts_contexts_list.context = customcontexts_includes_list.context left outer join (select * from customcontexts_includes where context = '$context') saved on customcontexts_includes_list.include = saved.include order by customcontexts_contexts_list.description, customcontexts_includes_list.description"; 226 $sql = "select customcontexts_contexts_list.context, customcontexts_contexts_list.description as contextdescription, customcontexts_includes_list.include, customcontexts_includes_list.description, if(saved.include is null, 'no', if(saved.timegroupid is null, if(saved.userules is null, 'yes', saved.userules), saved.timegroupid)) as allow, if(saved.sort is null,customcontexts_includes_list.sort,saved.sort) as sort, count(preemptcheck.context) as preemptcount from customcontexts_contexts_list inner join customcontexts_includes_list on customcontexts_contexts_list.context = customcontexts_includes_list.context left outer join (select * from customcontexts_includes where context = '$context ') saved on customcontexts_includes_list.include = saved.include left outer join customcontexts_contexts_list preemptcheck on customcontexts_includes_list.include = preemptcheck.context group by customcontexts_contexts_list.context, customcontexts_contexts_list.description, customcontexts_includes_list.include, customcontexts_includes_list.description, if(saved.include is null, 'no', if(saved.timegroupid is null, 'yes', saved.timegroupid)), saved.sort order by customcontexts_contexts_list.description, if(saved.sort is null,101,saved.sort), customcontexts_includes_list.description;"; 194 $sql = "SELECT customcontexts_contexts_list.context, 195 customcontexts_contexts_list.description AS contextdescription, 196 customcontexts_includes_list.include, 197 customcontexts_includes_list.description, 198 IF(saved.include is null, 'no', 199 IF(saved.timegroupid is null, IF(saved.userules is null, 'yes', saved.userules), 200 saved.timegroupid)) AS allow, 201 IF(saved.sort is null,customcontexts_includes_list.sort,saved.sort) AS sort, 202 COUNT(preemptcheck.context) AS preemptcount FROM customcontexts_contexts_list 203 INNER JOIN customcontexts_includes_list 204 ON customcontexts_contexts_list.context = customcontexts_includes_list.context 205 LEFT OUTER JOIN (SELECT * from customcontexts_includes WHERE context = '$context') AS saved 206 ON customcontexts_includes_list.include = saved.include 207 LEFT OUTER JOIN customcontexts_contexts_list preemptcheck 208 ON customcontexts_includes_list.include = preemptcheck.context 209 GROUP BY customcontexts_contexts_list.context, 210 customcontexts_contexts_list.description, 211 customcontexts_includes_list.include, 212 customcontexts_includes_list.description, 213 IF(saved.include is null, 'no', 214 IF(saved.timegroupid is null, 'yes', saved.timegroupid)), 215 saved.sort, 216 customcontexts_contexts_list.description 217 ORDER BY customcontexts_contexts_list.description, 218 IF(saved.sort is null,101,saved.sort), 219 customcontexts_includes_list.description"; 227 220 $results = $db->getAll($sql); 228 if(DB::IsError($results)) 221 if(DB::IsError($results)) { 229 222 $results = null; 230 foreach ($results as $val) 223 } 224 foreach ($results as $val){ 231 225 $tmparray[] = array($val[0], $val[1], $val[2], $val[3], $val[4], $val[5], $val[6]); 232 // 0-context 1-contextdescription 2-include 3-description 4-allow 5-sort 6-preemptcount 226 } 227 //0-context 1-contextdescription 2-include 3-description 4-allow 5-sort 6-preemptcount 233 228 return $tmparray; 234 229 } … … 279 274 } 280 275 281 //allow reload to get our config 282 //we add all user custom contexts ad include his selected includes 283 //also maybe allow the user to specify invalid destination 276 /* 277 * allow reload to get our config 278 * we add all user custom contexts ad include his selected includes 279 * also maybe allow the user to specify invalid destination 280 */ 284 281 function customcontexts_get_config($engine) { 285 282 global $ext; … … 287 284 case 'asterisk': 288 285 global $db; 289 $sql = "select context, dialrules, faildestination, featurefaildestination, failpin, featurefailpin from customcontexts_contexts"; 286 $sql = "SELECT context, dialrules, faildestination, featurefaildestination, 287 failpin, featurefailpin FROM customcontexts_contexts"; 290 288 $results = $db->getAll($sql); 291 if(DB::IsError($results)) 289 if(DB::IsError($results)) { 292 290 $results = null; 291 } 293 292 foreach ($results as $val) { 294 293 $context = $val[0]; 295 //$ext->_exts[$context][] = null;296 //partially stolen from outbound routing294 //$ext->_exts[$context][] = null; 295 //partially stolen from outbound routing 297 296 $dialpattern = explode("\n",$val[1]); 298 297 if (!$dialpattern) { … … 304 303 305 304 // remove blanks 306 if ($dialpattern[$key] == "") unset($dialpattern[$key]); 305 if ($dialpattern[$key] == "") { 306 unset($dialpattern[$key]); 307 } 307 308 308 309 // remove leading underscores (we do that on backend) 309 if ($dialpattern[$key][0] == "_") $dialpattern[$key] = substr($dialpattern[$key],1); 310 if ($dialpattern[$key][0] == "_") { 311 $dialpattern[$key] = substr($dialpattern[$key],1); 312 } 310 313 } 311 314 // check for duplicates, and re-sequence … … 333 336 } 334 337 } 335 //switch to first line to deny all access when time group deleted 336 // $sql = "select include, time from customcontexts_includes left outer join customcontexts_timegroups_detail on customcontexts_includes.timegroupid = customcontexts_timegroups_detail.timegroupid where context = '".$context."' and (customcontexts_includes.timegroupid is null or customcontexts_timegroups_detail.timegroupid is not null) order by sort"; 337 $sql = "select include, time, userules from customcontexts_includes left outer join customcontexts_timegroups_detail on customcontexts_includes.timegroupid = customcontexts_timegroups_detail.timegroupid where context = '".$context."' order by sort"; 338 //switch to first line to deny all access when time group deleted 339 //$sql = "select include, time from customcontexts_includes left outer join customcontexts_timegroups_detail on customcontexts_includes.timegroupid = customcontexts_timegroups_detail.timegroupid where context = '".$context."' and (customcontexts_includes.timegroupid is null or customcontexts_timegroups_detail.timegroupid is not null) order by sort"; 340 $sql = "SELECT include, time, userules, seq FROM customcontexts_includes 341 LEFT OUTER JOIN customcontexts_timegroups_detail 342 ON customcontexts_includes.timegroupid = customcontexts_timegroups_detail.timegroupid 343 LEFT OUTER JOIN outbound_route_sequence 344 ON REPLACE(include,'outrt-','') = outbound_route_sequence.route_id 345 WHERE context = '$context' ORDER BY sort, seq"; 338 346 $results2 = $db->getAll($sql); 339 if(DB::IsError($results2)) 347 if(DB::IsError($results2)) { 340 348 $results2 = null; 349 } 341 350 foreach ($results2 as $inc) { 351 dbug('$results2',$inc); 342 352 $time = isset($inc[1])?'|'.$inc[1]:''; 343 353 switch ($inc[2]) { … … 358 368 } 359 369 } 360 //these go in funny "exten => s,1,Macro(hangupcall,)"361 //i'd rather use the base extension class to type it normally, but there is a bug in the class see ticket http://www.freepbx.org/trac/ticket/1453370 //these go in funny "exten => s,1,Macro(hangupcall,)" 371 //i'd rather use the base extension class to type it normally, but there is a bug in the class see ticket http://www.freepbx.org/trac/ticket/1453 362 372 $ext->add($context,'s', '', new ext_macro('hangupcall')); 363 373 $ext->add($context,'h', '', new ext_macro('hangupcall')); … … 439 449 function customcontexts_devices_configpageload() { 440 450 global $currentcomponent; 441 //should get current context if possible451 //should get current context if possible 442 452 $extdisplay = isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:null; 443 453 $query="SELECT `data` FROM `sip` WHERE `keyword`='context' AND `id`='".$extdisplay."'"; … … 449 459 function customcontexts_extensions_configpageload() { 450 460 global $currentcomponent; 451 //should get current context if possible461 //should get current context if possible 452 462 $extdisplay = isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:null; 453 463 $query="SELECT `data` FROM `sip` WHERE `keyword`='context' AND `id`='".$extdisplay."'"; … … 456 466 } 457 467 458 //admin page helper 459 //we are using gui styles so there is very little on the page 460 //the admin page is used to list _existing_ contexts for us to parse for includes 461 //these contexts/includes can be tagged with a description for the user to select on the custom contexts page 468 /* 469 * admin page helper 470 * we are using gui styles so there is very little on the page 471 * the admin page is used to list _existing_ contexts for us to parse for includes 472 * these contexts/includes can be tagged with a description for the user to select on the custom contexts page 473 */ 462 474 function customcontexts_customcontextsadmin_configpageinit($dispnum) { 463 475 global $currentcomponent; … … 479 491 if ($action == 'del') { 480 492 $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Context").": $extdisplay"." deleted!", false), 0); 481 } 482 else 483 { 484 //need to get module name/type dynamically 493 } else { 494 //need to get module name/type dynamically 485 495 $query = ($_SERVER['QUERY_STRING'])?$_SERVER['QUERY_STRING']:'type=tool&display=customcontextsadmin&extdisplay='.$extdisplay; 486 496 $delURL = $_SERVER['PHP_SELF'].'?'.$query.'&action=del'; 487 497 $info = 'The context which contains includes which you would like to make available to '.customcontexts_getmodulevalue('moduledisplayname').'. Any context you enter here will be parsed for includes and you can then include them in your own '.customcontexts_getmodulevalue('moduledisplayname').'. Removing them here does NOT delete the context, rather makes them unavailable to your '.customcontexts_getmodulevalue('moduledisplayname').'.'; 488 $currentcomponent->addguielem('_top', new gui_hidden('action', ($extdisplay ? 'edit' : 'add')));498 $currentcomponent->addguielem('_top', new gui_hidden('action', ($extdisplay ? 'edit' : 'add'))); 489 499 $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); 500 $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); 490 501 if (!$extdisplay) { 491 502 $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Add Context"), false), 0); 492 503 $currentcomponent->addguielem('Context', new gui_textbox('extdisplay', '', 'Context', $info, 'isWhitespace() || !isFilename()', $contexterr, false), 3); 493 504 $currentcomponent->addguielem('Context', new gui_textbox('description', '', 'Description', 'This will display as a heading for the available includes on the '.customcontexts_getmodulevalue('moduledisplayname').' page.', '!isAlphanumeric() || isWhitespace()', $descerr, false), 3); 494 } 495 else 496 { 505 } else { 497 506 $savedcontext = customcontexts_customcontextsadmin_get($extdisplay); 498 507 $context = $savedcontext[0]; … … 512 521 foreach ($inclist as $val) { 513 522 if ($val[2] > 0) { 514 //$gui1 = new gui_textbox('includes['.$val[0].']', $val[1], '<font color="red"><strong>'.$val[0].'</strong></font>', 'This will display as the name of the include on the '.customcontexts_getmodulevalue('moduledisplayname').' page.<BR><font color="red"><strong>NOTE: This include should have a description denoting the fact that allowing it may allow another ENTIRE context!</strong></font>', '!isAlphanumeric() || isWhitespace()', $descerr, false);515 //$inchtml = $gui1->generatehtml();516 //$inchtml = '<tr><td colspan="2"><table><tr><td colspan="2">'.$inchtml.'</td></tr></table></td></tr>'.$inchtml;517 //$currentcomponent->addguielem('Includes Descriptions', new guielement('$val[0]',$inchtml,''),3);518 523 $currentcomponent->addguielem('Includes Descriptions', new gui_textbox('includes['.$val[0].']', $val[1], '<font color="red"><strong>'.$val[0].'</strong></font>', 'This will display as the name of the include on the '.customcontexts_getmodulevalue('moduledisplayname').' page.<BR><font color="red"><strong>NOTE: This include should have a description denoting the fact that allowing it may allow another ENTIRE context!</strong></font>', '!isAlphanumeric() || isWhitespace()', $descerr, false), 3); 519 524 } else { … … 601 606 //--------------------------------------------- 602 607 603 //custom contexts page helper 604 //we are using gui styles so there is very little on the page 605 //the custom contexts page is used to create _new_ contexts for use in the dialplan 606 //these contexts can include any includes which were made available from admin 608 /* custom contexts page helper 609 * we are using gui styles so there is very little on the page 610 * the custom contexts page is used to create _new_ contexts for use in the dialplan 611 * these contexts can include any includes which were made available from admin 612 */ 607 613 function customcontexts_customcontexts_configpageinit($dispnum) { 608 614 global $currentcomponent; … … 640 646 if ($action == 'del') { 641 647 $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Context").": $extdisplay"." deleted!", false), 0); 642 } 643 else 644 { 645 //need to get page name/type dynamically 646 //caused trouble on dup or del after dup or rename 647 // $query = ($_SERVER['QUERY_STRING'])?$_SERVER['QUERY_STRING']:'type=setup&display=customcontexts&extdisplay='.$extdisplay; 648 } else { 649 //need to get page name/type dynamically 650 //caused trouble on dup or del after dup or rename 651 //$query = ($_SERVER['QUERY_STRING'])?$_SERVER['QUERY_STRING']:'type=setup&display=customcontexts&extdisplay='.$extdisplay; 648 652 $query = 'type=setup&display=customcontexts&extdisplay='.$extdisplay; 649 653 $delURL = $_SERVER['PHP_SELF'].'?'.$query.'&action=del'; … … 651 655 $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.'; 652 656 $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); 657 $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); 653 658 if (!$extdisplay) { 654 659 $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Add Context"), false), 0); 655 660 $currentcomponent->addguielem('Context', new gui_textbox('extdisplay', '', 'Context', $info, 'isWhitespace() || !isFilename()', $contexterr, false), 3); 656 661 $currentcomponent->addguielem('Context', new gui_textbox('description', '', 'Description', 'This will display as the name of this custom context.', '!isAlphanumeric() || isWhitespace()', $descerr, false), 3); 657 } 658 else 659 { 662 } else { 660 663 $savedcontext = customcontexts_customcontexts_get($extdisplay); 661 664 $context = $savedcontext[0]; … … 668 671 $currentcomponent->addguielem('_top', new gui_hidden('extdisplay', $extdisplay)); 669 672 $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Edit Context").": $description", false), 0); 670 //$currentcomponent->addguielem('_top', new gui_link('del', _("Delete Context")." $context", $delURL, true, false), 0);673 //$currentcomponent->addguielem('_top', new gui_link('del', _("Delete Context")." $context", $delURL, true, false), 0); 671 674 $currentcomponent->addguielem('_top', new guielement('del', '<tr><td colspan ="2"><a href="'.$delURL.'" onclick="return confirm(\'Are you sure you want to delete '.$context.'?\')">Delete Context '.$context.'</a></td></tr>', ''),3); 672 675 $currentcomponent->addguielem('_top', new gui_link('dup', _("Duplicate Context")." $context", $dupURL, true, false), 3); 673 676 $showsort = customcontexts_getmodulevalue('displaysortforincludes'); 674 677 if ($showsort == 1) { 675 //$sortURL = $_SERVER['PHP_SELF'].'?'.$query.'&showsort=0';676 //$currentcomponent->addguielem('_top', new gui_link('showsort', "Hide Sort Option", $sortURL, true, false), 0);678 //$sortURL = $_SERVER['PHP_SELF'].'?'.$query.'&showsort=0'; 679 //$currentcomponent->addguielem('_top', new gui_link('showsort', "Hide Sort Option", $sortURL, true, false), 0); 677 680 } else { 678 681 $sortURL = $_SERVER['PHP_SELF'].'?'.$query.'&showsort=1'; … … 684 687 $ruleshtml = '<tr><td valign="top"><a href="#" class="info">Dial Rules<span>'.$ruledesc.'</span></a></td><td><textarea cols="20" rows="5" id="dialpattern" name="dialpattern">'.$rulestext.'</textarea></td></tr>'; 685 688 $currentcomponent->addguielem('Context', new guielement('rulesbox',$ruleshtml,''), 3); 686 // !isDialpattern 689 687 690 $currentcomponent->addguielem('Failover Destination', new gui_textbox('failpin', $failpin, 'PIN', 'Enter a numeric PIN to require authentication before continuing to destination.', '!isPINList()', 'PIN must be numeric!', true), 4); 688 $selhtml = drawselects($faildest ,0);689 $currentcomponent->addguielem('Failover Destination', new guielement('dest0', $selhtml, ''),4);690 691 $currentcomponent->addguielem('Feature Code Failover Destination', new gui_textbox('featurefailpin', $featurefailpin, 'PIN', 'Enter a numeric PIN to require authentication before continuing to destination.', '!isPINList()', 'PIN must be numeric!', true), 4); 691 $ selhtml = drawselects($featurefaildest ,1);692 $currentcomponent->addguielem('Feature Code Failover Destination', new gui element('dest1', $selhtml, ''),4);692 $currentcomponent->addguielem('Failover Destination', new gui_drawselects('dest0', 0, $faildest, 'Failover Destination')); 693 $currentcomponent->addguielem('Feature Code Failover Destination', new gui_drawselects('dest1', 1, $featurefaildest, 'Failover Destination')); 693 694 $currentcomponent->addguielem('Set All', new gui_selectbox('setall', $currentcomponent->getoptlist('includeyn'), '', 'Set All To:', 'Choose allow to allow access to all includes, choose deny to deny access.',true,'javascript:for (i=0;i<document.forms[\'frm_customcontexts\'].length;i++) {if(document.forms[\'frm_customcontexts\'][i].type==\'select-one\' && document.forms[\'frm_customcontexts\'][i].name.indexOf(\'[allow]\') >= 0 ) {document.forms[\'frm_customcontexts\'][i].selectedIndex = document.forms[\'frm_customcontexts\'][\'setall\'].selectedIndex-1;}}'),2); 694 695 $inclist = customcontexts_getincludes($extdisplay); 695 696 foreach ($inclist as $val) { 696 697 if ($showsort == 1) { 697 //$gui1 = new gui_textbox('includes['.$val[0].']', $val[1], '<font color="red"><strong>'.$val[0].'</strong></font>', 'This will display as the name of the include on the '.customcontexts_getmodulevalue('moduledisplayname').' page.<BR><font color="red"><strong>NOTE: This include should have a description denoting the fact that allowing it may allow another ENTIRE context!</strong></font>', '!isAlphanumeric() || isWhitespace()', $descerr, false);698 //$inchtml = $gui1->generatehtml();699 //$inchtml = '<tr><td colspan="2"><table><tr><td colspan="2">'.$inchtml.'</td></tr></table></td></tr>'.$inchtml;700 //$currentcomponent->addguielem('Includes Descriptions', new guielement('$val[0]',$inchtml,''),3);701 698 if ($val[6] > 0) { 702 // $currentcomponent->addguielem($val[1], new gui_selectbox('includes['.$val[2].'][allow]', $currentcomponent->getoptlist('includeyn'), $val[4], '<font color="red"><strong>'.$val[3].'</strong></font>', $val[2].': Choose allow to allow access to this include, choose deny to deny access.<BR><font color="red"><strong>NOTE: Allowing this include may automatically allow another ENTIRE context!</strong></font>',false)); 703 $gui1 = new gui_selectbox('includes['.$val[2].'][allow]', $currentcomponent->getoptlist('includeyn'), $val[4], '<font color="red"><strong>'.$val[3].'</strong></font>', $val[2].': Choose allow to allow access to this include, choose deny to deny access.<BR><font color="red"><strong>NOTE: Allowing this include may automatically allow another ENTIRE context!</strong></font>',false); 699 //$currentcomponent->addguielem($val[1], new gui_selectbox('includes['.$val[2].'][allow]', $currentcomponent->getoptlist('includeyn'), $val[4], '<font color="red"><strong>'.$val[3].'</strong></font>', $val[2].': Choose allow to allow access to this include, choose deny to deny access.<BR><font color="red"><strong>NOTE: Allowing this include may automatically allow another ENTIRE context!</strong></font>',false)); 700 $gui1 = new gui_selectbox('includes['.$val[2].'][allow]', 701 $currentcomponent->getoptlist('includeyn'), $val[4], 702 '<font color="red"><strong>'.$val[3].'</strong></font>', 703 $val[2].': Choose allow to allow access to this include, choose deny to deny access.<BR><font color="red"><strong>NOTE: Allowing this include may automatically allow another ENTIRE context!</strong></font>',false); 704 704 } else { 705 // $currentcomponent->addguielem($val[1], new gui_selectbox('includes['.$val[2].'][allow]', $currentcomponent->getoptlist('includeyn'), $val[4], $val[3], $val[2].': Choose allow to allow access to this include, choose deny to deny access.',false)); 706 $gui1 = new gui_selectbox('includes['.$val[2].'][allow]', $currentcomponent->getoptlist('includeyn'), $val[4], $val[3], $val[2].': Choose allow to allow access to this include, choose deny to deny access.',false); 705 //$currentcomponent->addguielem($val[1], new gui_selectbox('includes['.$val[2].'][allow]', $currentcomponent->getoptlist('includeyn'), $val[4], $val[3], $val[2].': Choose allow to allow access to this include, choose deny to deny access.',false)); 706 $gui1 = new gui_selectbox('includes['.$val[2].'][allow]', 707 $currentcomponent->getoptlist('includeyn'), $val[4], $val[3], 708 $val[2].': Choose allow to allow access to this include, choose deny to deny access.',false); 707 709 } 708 //$currentcomponent->addguielem($val[1], new gui_selectbox('includes['.$val[2].'][sort]', $currentcomponent->getoptlist('includesort'), $val[5], '<div align="right">Priority</div>', 'Choose a priority with which to sort this option. Lower numbers have a higher priority.',false));710 //$currentcomponent->addguielem($val[1], new gui_selectbox('includes['.$val[2].'][sort]', $currentcomponent->getoptlist('includesort'), $val[5], '<div align="right">Priority</div>', 'Choose a priority with which to sort this option. Lower numbers have a higher priority.',false)); 709 711 $guisort = new gui_selectbox('includes['.$val[2].'][sort]', $currentcomponent->getoptlist('includesort'), $val[5], '<div align="right">Priority</div>', 'Choose a priority with which to sort this option. Lower numbers have a higher priority.',false); 710 712 $inchtml = '<tr><td colspan="2"><table width="100%"><tr><td></td><td width="50"></td></tr>'.$gui1->generatehtml().'</table></td><td><table>'.$guisort->generatehtml().'</table></td></tr>'; … … 712 714 } else { 713 715 if ($val[6] > 0) { 714 $currentcomponent->addguielem($val[1], new gui_selectbox('includes['.$val[2].'][allow]', $currentcomponent->getoptlist('includeyn'), $val[4], '<font color="red"><strong>'.$val[3].'</strong></font>', $val[2].': Choose allow to allow access to this include, choose deny to deny access.<BR><font color="red"><strong>NOTE: Allowing this include may automatically allow another ENTIRE context!</strong></font>',false)); 716 $currentcomponent->addguielem($val[1], new gui_selectbox('includes['.$val[2].'][allow]', 717 $currentcomponent->getoptlist('includeyn'), $val[4], 718 '<font color="red"><strong>'.$val[3].'</strong></font>', $val[2].': Choose allow to allow access to this include, choose deny to deny access.<BR><font color="red"><strong>NOTE: Allowing this include may automatically allow another ENTIRE context!</strong></font>',false)); 715 719 } else { 716 $currentcomponent->addguielem($val[1], new gui_selectbox('includes['.$val[2].'][allow]', $currentcomponent->getoptlist('includeyn'), $val[4], $val[3], $val[2].': Choose allow to allow access to this include, choose deny to deny access.',false)); 720 $currentcomponent->addguielem($val[1], new gui_selectbox('includes['.$val[2].'][allow]', 721 $currentcomponent->getoptlist('includeyn'), $val[4], 722 $val[3], $val[2].': Choose allow to allow access to this include, choose deny to deny access.',false)); 717 723 } 718 724 } … … 874 880 //--------------------------------------------- 875 881 876 //custom contexts timegroups page helper 877 //we are using gui styles so there is very little on the page 878 //the custom contexts timegroups page is used to create time conditions 879 //to allow the user to limit when to include each context on the custom contexts page 882 /*custom contexts timegroups page helper 883 * we are using gui styles so there is very little on the page 884 * the custom contexts timegroups page is used to create time conditions 885 * to allow the user to limit when to include each context on the custom contexts page 886 */ 880 887 function customcontexts_customcontextstimes_configpageinit($dispnum) { 881 888 global $currentcomponent; … … 896 903 if ($action == 'del') { 897 904 $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Time Group").": $extdisplay"." deleted!", false), 0); 898 } 899 else 900 { 901 //need to get page name/type dynamically 905 } else { 906 //need to get page name/type dynamically 902 907 $query = ($_SERVER['QUERY_STRING'])?$_SERVER['QUERY_STRING']:'type=setup&display=customcontextstimes&extdisplay='.$extdisplay; 903 908 $delURL = $_SERVER['PHP_SELF'].'?'.$query.'&action=del'; 904 909 $info = ''; 905 910 $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); 911 $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); 906 912 if (!$extdisplay) { 907 913 $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Add Time Group"), false), 0); 908 914 $currentcomponent->addguielem('Time Group', new gui_textbox('description', '', 'Description', 'This will display as the name of this Time Group.', '!isAlphanumeric() || isWhitespace()', $descerr, false), 3); 909 } 910 else 911 { 915 } else{ 912 916 $savedtimegroup= customcontexts_customcontextstimes_get($extdisplay); 913 917 $timegroup = $savedtimegroup[0]; … … 916 920 $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Edit Time Group").": $description", false), 0); 917 921 $currentcomponent->addguielem('_top', new gui_link('del', _("Delete Time Group")." $timegroup", $delURL, true, false), 0); 918 //$currentcomponent->addguielem('_top', new gui_subheading('subtitle', "Time Group", false), 0);922 //$currentcomponent->addguielem('_top', new gui_subheading('subtitle', "Time Group", false), 0); 919 923 $currentcomponent->addguielem('Time Group', new gui_textbox('description', $description, 'Description', 'This will display as the name of this Time Group.', '', '', false), 3); 920 924 $timelist = customcontexts_gettimes($extdisplay); 921 925 foreach ($timelist as $val) { 922 //add gui here923 $timehtml = drawtimeselects('times['.$val[0].']',$val[1]);924 $timehtml = '<tr><td colspan="2"><table>'.$timehtml.'</table></td></tr>';925 $currentcomponent->addguielem($val[1], new guielement('dest0', $timehtml, ''),5);926 //add gui here 927 $timehtml = drawtimeselects('times['.$val[0].']',$val[1]); 928 $timehtml = '<tr><td colspan="2"><table>'.$timehtml.'</table></td></tr>'; 929 $currentcomponent->addguielem($val[1], new guielement('dest0', $timehtml, ''),5); 926 930 } 927 931 $timehtml = drawtimeselects('times[new]',null); … … 938 942 $timegroup= isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:null; 939 943 $description= isset($_REQUEST['description'])?$_REQUEST['description']:null; 940 //addslashes944 //addslashes 941 945 switch ($action) { 942 946 case 'add': … … 1344 1348 1345 1349 function customcontexts_customcontextstimes_buildtime( $hour_start, $minute_start, $hour_finish, $minute_finish, $wday_start, $wday_finish, $mday_start, $mday_finish, $month_start, $month_finish) { 1346 1347 //----- Time Hour Interval proccess ---- 1348 if ($minute_start == '-') { 1349 $time_minute_start = "00"; 1350 } else { 1351 $time_minute_start = sprintf("%02d",$minute_start); 1352 } 1353 if ($minute_finish == '-') { 1354 $time_minute_finish = "00"; 1355 } else { 1356 $time_minute_finish = sprintf("%02d",$minute_finish); 1357 } 1358 if ($hour_start == '-') { 1359 $time_hour_start = '*'; 1360 } else { 1361 $time_hour_start = sprintf("%02d",$hour_start) . ':' . $time_minute_start; 1362 } 1363 if ($hour_finish == '-') { 1364 $time_hour_finish = '*'; 1365 } else { 1366 $time_hour_finish = sprintf("%02d",$hour_finish) . ':' . $time_minute_finish; 1367 } 1368 if ($time_hour_start === '*') {$time_hour_start = $time_hour_finish;} 1369 if ($time_hour_finish === '*') {$time_hour_finish = $time_hour_start;} 1370 if ($time_hour_start == $time_hour_finish) { 1371 $time_hour = $time_hour_start; 1372 } else { 1373 $time_hour = $time_hour_start . '-' . $time_hour_finish; 1374 } 1375 //----- Time Week Day Interval proccess ----- 1376 if ($wday_start == '-') { 1377 $time_wday_start = '*'; 1378 } else { 1379 $time_wday_start = $wday_start; 1380 } 1381 if ($wday_finish == '-') { 1382 $time_wday_finish = '*'; 1383 } else { 1384 $time_wday_finish = $wday_finish; 1385 } 1386 if ($time_wday_start === '*') {$time_wday_start = $time_wday_finish;} 1387 if ($time_wday_finish === '*') {$time_wday_finish = $time_wday_start;} 1388 if ($time_wday_start == $time_wday_finish) { 1389 $time_wday = $time_wday_start; 1390 } else { 1391 $time_wday = $time_wday_start . '-' . $time_wday_finish; 1392 } 1393 //----- Time Month Day Interval proccess ----- 1394 if ($mday_start == '-') { 1395 $time_mday_start = '*'; 1396 } else { 1397 $time_mday_start = $mday_start; 1398 } 1399 if ($mday_finish == '-') { 1400 $time_mday_finish = '*'; 1401 } else { 1402 $time_mday_finish = $mday_finish; 1403 } 1404 if ($time_mday_start === '*') {$time_mday_start = $time_mday_finish;} 1405 if ($time_mday_finish === '*') {$time_mday_finish = $time_mday_start;} 1406 if ($time_mday_start == $time_mday_finish) { 1407 $time_mday = $time_mday_start; 1408 } else { 1409 $time_mday = $time_mday_start . '-' . $time_mday_finish; 1410 } 1411 //----- Time Month Interval proccess ----- 1412 if ($month_start == '-') { 1413 $time_month_start = '*'; 1414 } else { 1415 $time_month_start = $month_start; 1416 } 1417 if ($month_finish == '-') { 1418 $time_month_finish = '*'; 1419 } else { 1420 $time_month_finish = $month_finish; 1421 } 1422 if ($time_month_start === '*') {$time_month_start = $time_month_finish;} 1423 if ($time_month_finish === '*') {$time_month_finish = $time_month_start;} 1424 if ($time_month_start == $time_month_finish) { 1425 $time_month = $time_month_start; 1426 } else { 1427 $time_month = $time_month_start . '-' . $time_month_finish; 1428 } 1429 $time = $time_hour . '|' . $time_wday . '|' . $time_mday . '|' . $time_month; 1430 return $time; 1431 } 1432 1433 1350 //----- Time Hour Interval proccess ---- 1351 if ($minute_start == '-') { 1352 $time_minute_start = "00"; 1353 } else { 1354 $time_minute_start = sprintf("%02d",$minute_start); 1355 } 1356 if ($minute_finish == '-') { 1357 $time_minute_finish = "00"; 1358 } else { 1359 $time_minute_finish = sprintf("%02d",$minute_finish); 1360 } 1361 if ($hour_start == '-') { 1362 $time_hour_start = '*'; 1363 } else { 1364 $time_hour_start = sprintf("%02d",$hour_start) . ':' . $time_minute_start; 1365 } 1366 if ($hour_finish == '-') { 1367 $time_hour_finish = '*'; 1368 } else { 1369 $time_hour_finish = sprintf("%02d",$hour_finish) . ':' . $time_minute_finish; 1370 } 1371 if ($time_hour_start === '*') {$time_hour_start = $time_hour_finish;} 1372 if ($time_hour_finish === '*') {$time_hour_finish = $time_hour_start;} 1373 if ($time_hour_start == $time_hour_finish) { 1374 $time_hour = $time_hour_start; 1375 } else { 1376 $time_hour = $time_hour_start . '-' . $time_hour_finish; 1377 } 1378 //----- Time Week Day Interval proccess ----- 1379 if ($wday_start == '-') { 1380 $time_wday_start = '*'; 1381 } else { 1382 $time_wday_start = $wday_start; 1383 } 1384 if ($wday_finish == '-') { 1385 $time_wday_finish = '*'; 1386 } else { 1387 $time_wday_finish = $wday_finish; 1388 } 1389 if ($time_wday_start === '*') {$time_wday_start = $time_wday_finish;} 1390 if ($time_wday_finish === '*') {$time_wday_finish = $time_wday_start;} 1391 if ($time_wday_start == $time_wday_finish) { 1392 $time_wday = $time_wday_start; 1393 } else { 1394 $time_wday = $time_wday_start . '-' . $time_wday_finish; 1395 } 1396 //----- Time Month Day Interval proccess ----- 1397 if ($mday_start == '-') { 1398 $time_mday_start = '*'; 1399 } else { 1400 $time_mday_start = $mday_start; 1401 } 1402 if ($mday_finish == '-') { 1403 $time_mday_finish = '*'; 1404 } else { 1405 $time_mday_finish = $mday_finish; 1406 } 1407 if ($time_mday_start === '*') {$time_mday_start = $time_mday_finish;} 1408 if ($time_mday_finish === '*') {$time_mday_finish = $time_mday_start;} 1409 if ($time_mday_start == $time_mday_finish) { 1410 $time_mday = $time_mday_start; 1411 } else { 1412 $time_mday = $time_mday_start . '-' . $time_mday_finish; 1413 } 1414 //----- Time Month Interval proccess ----- 1415 if ($month_start == '-') { 1416 $time_month_start = '*'; 1417 } else { 1418 $time_month_start = $month_start; 1419 } 1420 if ($month_finish == '-') { 1421 $time_month_finish = '*'; 1422 } else { 1423 $time_month_finish = $month_finish; 1424 } 1425 if ($time_month_start === '*') {$time_month_start = $time_month_finish;} 1426 if ($time_month_finish === '*') {$time_month_finish = $time_month_start;} 1427 if ($time_month_start == $time_month_finish) { 1428 $time_month = $time_month_start; 1429 } else { 1430 $time_month = $time_month_start . '-' . $time_month_finish; 1431 } 1432 $time = $time_hour . '|' . $time_wday . '|' . $time_mday . '|' . $time_month; 1433 return $time; 1434 } 1434 1435 1435 1436 //---------------------------end stolen from timeconditions------------------------------------- contributed_modules/modules/customcontexts/install.php
r9821 r9823 16 16 --> 17 17 <?php 18 19 global $db; 20 global $amp_conf; 21 22 if (! function_exists("out")) { 23 function out($text) { 24 echo $text."<br />"; 25 } 26 } 27 28 if (! function_exists("outn")) { 29 function outn($text) { 30 echo $text; 31 } 32 } 33 34 35 $sql[] ="CREATE TABLE IF NOT EXISTS `customcontexts_contexts` ( 36 `context` varchar(100) NOT NULL default '', 37 `description` varchar(100) NOT NULL default '', 38 PRIMARY KEY (`context`), 39 UNIQUE KEY `description` (`description`) 40 )"; 41 42 43 $sql[] ="CREATE TABLE IF NOT EXISTS `customcontexts_contexts_list` ( 44 `context` varchar(100) NOT NULL default '', 45 `description` varchar(100) NOT NULL default '', 46 `locked` tinyint(1) NOT NULL default '0', 47 PRIMARY KEY (`context`), 48 UNIQUE KEY `description` (`description`) 49 )"; 50 51 $sql[] ="INSERT IGNORE INTO `customcontexts_contexts_list` 52 (`context`, `description`, `locked`) 53 VALUES ('from-internal', 'Default Internal Context', 1), 54 ('from-internal-additional', 'Internal Dialplan', 0),('outbound-allroutes', 'Outbound Routes', 0)"; 55 56 $sql[] ="CREATE TABLE IF NOT EXISTS `customcontexts_includes` ( 57 `context` varchar(100) NOT NULL default '', 58 `include` varchar(100) NOT NULL default '', 59 `timegroupid` int(11) default NULL, 60 `sort` int(11) NOT NULL default '0', 61 PRIMARY KEY (`context`,`include`), 62 KEY `sort` (`sort`) 63 )"; 64 65 $sql[] ="ALTER IGNORE TABLE `customcontexts_includes` ADD `timegroupid` INT NULL AFTER `include`"; 66 67 $sql[] ="CREATE TABLE IF NOT EXISTS `customcontexts_includes_list` ( 68 `context` varchar(100) NOT NULL default '', 69 `include` varchar(100) NOT NULL default '', 70 `description` varchar(100) NOT NULL default '', 71 PRIMARY KEY (`context`,`include`) 72 )"; 73 74 $sql[] ="ALTER IGNORE TABLE `customcontexts_includes_list` ADD `missing` BOOL NOT NULL DEFAULT '0'"; 75 76 77 $sql[] ="INSERT IGNORE INTO `customcontexts_includes_list` (`context`, `include`, `description`) VALUES ('from-internal', 'parkedcalls', 'Call Parking'), 78 ('from-internal', 'from-internal-custom', 'Custom Internal Dialplan'), 79 ('from-internal', 'ext-fax', 'Fax')"; 80 81 $sql[] ="INSERT IGNORE INTO `customcontexts_includes_list` (`context`, `include`, `description`) VALUES ('from-internal-additional', 'outbound-allroutes', 'ALL OUTBOUND ROUTES'), 82 ('from-internal', 'from-internal-additional', 'ENTIRE Basic Internal Dialplan')"; 83 84 $sql[] ="UPDATE `customcontexts_includes_list` SET `description` = 'ALL OUTBOUND ROUTES' WHERE `context` = 'from-internal-additional' AND `include` = 'outbound-allroutes'"; 85 86 $sql[] ="CREATE TABLE IF NOT EXISTS `customcontexts_module` ( 87 `id` varchar(50) NOT NULL default '', 88 `value` varchar(100) NOT NULL default '', 89 PRIMARY KEY (`id`) 90 )"; 91 92 $sql[] ="INSERT IGNORE INTO `customcontexts_module` (`id`, `value`) VALUES ('modulerawname', 'customcontexts'), 93 ('moduledisplayname', 'Custom Contexts'), 94 ('moduleversion', '0.3.2'), 95 ('displaysortforincludes', 1)"; 96 97 $sql[] ="UPDATE `customcontexts_module` set `value` = '0.3.2' where `id` = 'moduleversion';"; 98 99 $sql[] ="CREATE TABLE IF NOT EXISTS `customcontexts_timegroups` ( 100 `id` int(11) NOT NULL auto_increment, 101 `description` varchar(50) NOT NULL default '', 102 PRIMARY KEY (`id`), 103 UNIQUE KEY `display` (`description`) 104 ) AUTO_INCREMENT=4 "; 105 106 $sql[] ="CREATE TABLE IF NOT EXISTS `customcontexts_timegroups_detail` ( 107 `id` int(11) NOT NULL auto_increment, 108 `timegroupid` int(11) NOT NULL default '0', 109 `time` varchar(100) NOT NULL default '', 110 PRIMARY KEY (`id`) 111 ) AUTO_INCREMENT=20"; 112 113 foreach ($sql as $q){ 114 $db->query($sql); 115 } 116 18 117 customcontexts_updatedb(); 19 118 … … 38 137 $db->query($sql); 39 138 } 139 140 outn(_("checking if migration required...")); 141 $modinfo = module_getinfo('customcontexts'); 142 if (is_array($modinfo)) { 143 $ver = $modinfo['customcontexts']['dbversion']; 144 if (version_compare($ver,'0.3.6','le')) { 145 outn(_("migrating..")); 146 /* We need to now migrate from from the old format of dispname_id where the only supported dispname 147 so far has been "routing" and the "id" used was the imperfect nnn-name. As it truns out, it was 148 possible to have the same route name perfiously so we will try to detect that. This was really ugly 149 so if we can't find stuff we will simply report errors and let the user go back and fix things. 150 */ 151 $sql = "SELECT * FROM customcontexts_includes_list WHERE context = 'outbound-allroutes'"; 152 $includes = $db->getAll($sql, DB_FETCHMODE_ASSOC); 153 if(DB::IsError($result) || !isset($includes)) { 154 out(_("Unknown error fetching table data or no data to migrate")); 155 out(_("Migration aborted")); 156 } else { 157 /* If there are any rows then lets get our route information. We will force this module to depend on 158 * the new core, so we can count on the APIs being available. If there are indentical names, then 159 * oh well... 160 */ 161 $routes = core_routing_list(); 162 $newincludes = array(); 163 foreach ($includes as $myinclude) { 164 $include = explode('-',$myinclude['include'],3); 165 $include[1] = (int)$include[1]; 166 167 foreach ($routes as $route) { 168 //if we have a trunk with the same name or the same number mathc it and take it out of the list 169 if ($include[2] == $route['name'] || $include[1] == $route['route_id']){ 170 $newincludes[] = array('new' => 'outrt-'.$route['route_id'], 171 'sort' => $route['seq'], 'old' => $include); 172 unset($includes[$myinclude]); 173 } 174 } 175 } 176 177 //alert user of unmigrated routes 178 foreach ($includes as $include) { 179 out(_('FAILED to migrating route '.$include['description'].'. NO MATCH FOUND')); 180 outn(_("continuing...")); 181 } 182 183 // We new have all the indices, so lets save them 184 // 185 $sql = $db->prepare('UPDATE customcontexts_includes_list SET include = ?, sort = ? WHERE include = ?'); 186 //$result = $db->executeMultiple($sql,$newincludes); 187 if(DB::IsError($result)) { 188 out("FATAL: ".$result->getDebugInfo()."\n".'error updating customcontexts_includes_list table. Aborting!'); 189 } else { 190 //now update the next table 191 foreach ($newincludes as $newinclude){ 192 unset($newincludes[$newinclude]['sort']); 193 } 194 $sql = $db->prepare('UPDATE customcontexts_includes SET include = ?, WHERE include = ?'); 195 //$result = $db->executeMultiple($sql,$newincludes); 196 if(DB::IsError($result)) { 197 out("FATAL: ".$result->getDebugInfo()."\n".'error updating customcontexts_includes table. Aborting!'); 198 } else { 199 out(_("done")); 200 } 201 } 202 } 203 } 204 } 205 206 40 207 ?> contributed_modules/modules/customcontexts/module.xml
r9822 r9823 2 2 <rawname>customcontexts</rawname> 3 3 <name>Custom Contexts</name> 4 <version> 0.3.7</version>4 <version>2.8.0beta1.0</version> 5 5 <type>setup</type> 6 6 <category>Third Party Addon</category> 7 7 <description> 8 Creates custom contexts which can be used to allow limited access to dialplan applications. 9 Allows for time restrictions on any dialplan access. 10 Allows for pattern matching to allow/deny. 11 Allows for failover destinations, and PIN protected failover. 12 This can be very useful for multi-tennant systems. 13 Inbound routing can be done using DID or zap channel routing, this module allows for selective outbound routing. 14 House/public phones can be placed in a restricted context allowing them only internal calls. 8 Creates custom contexts which can be used to allow limited access to dialplan applications. Allows for time restrictions on any dialplan access. Allows for pattern matching to allow/deny. Allows for failover destinations, and PIN protected failover. This can be very useful for multi-tennant systems. Inbound routing can be done using DID or zap channel routing, this module allows for selective outbound routing. House/public phones can be placed in a restricted context allowing them only internal calls. 15 9 </description> 16 10 <menuitems> … … 20 14 </menuitems> 21 15 <depends> 22 <version> lt2.8.0alpha1</version>16 <version> 2.8.0alpha1</version> 23 17 <module>core</module> 24 18 </depends> 25 19 <changelog> 26 *0.3.7* remove EOL warnings 27 *0.3.6* fix version, End of Life warning, dependency requirement 28 *0.3.5* #3994 current context on extension page not sticking 29 *0.3.4* see http://freepbx.org/forum/freepbx/users/custom-contexts-broken-in-freepbx-2-3-1-3 30 *0.3.3* Added Set All option to quickly allow/deny all. 31 Fixed bug which caused routes to be denied after rename/sort/or delete other route. 32 *0.3.2* Optional PIN to protect failover destination. 33 Contexts can now be used as destinations. An IVR menu, Time Condition, etc. can now send a caller into a custom context. 34 (This last feature requires a bugfix in 2.2 after rc1. bug #1549) 35 *0.3.1* Now prompts on delete. After duplicate you are editing new context. Allows rename context. 36 *0.3.0* New Features: 37 Allow or Deny based on pattern matching. 38 Failover Destination (one for regular extension, one for failed feature codes) 39 Bugfixes: 40 Adjusted Gui, Duplicate context, now duplicates the description too. 41 *0.2.2* Bugfix: Duplicate Context now copies the priority also. 42 *0.2.1* Added Duplicate Context option to easily copy an entire set of rules. 43 *0.2.0* Added priority feature to allow the user to control in what order the allowed contexts are included. 44 *0.1.3* Made it obvious when allowing one include may allow another entire context. 45 *0.1.2* Bugfixes- deleted routes, etc. now are removed. 46 Context tests for spaces and illegal chars. 47 Moved admin to tools to reduce confusion. 48 Added option to allow entire internal dialplan. (Usefull for time limit on everything) 49 Made description for outbound-allroutes clearer that allowing overrides to allow all routes. 50 *0.1.1* Still Beta, added time groups and bugfixes 51 *0.0.1* Beta release 20 *2.8.0beta1.0* migration and changes to support 2.8 21 *0.3.7* remove EOL warnings 22 *0.3.6* fix version, End of Life warning, dependency requirement 23 *0.3.5* #3994 current context on extension page not sticking 24 *0.3.4* see http://freepbx.org/forum/freepbx/users/custom-contexts-broken-in-freepbx-2-3-1-3 25 *0.3.3* Added Set All option to quickly allow/deny all. Fixed bug which caused routes to be denied after rename/sort/or delete other route. 26 *0.3.2* Optional PIN to protect failover destination. Contexts can now be used as destinations. An IVR menu, Time Condition, etc. can now send a caller into a custom context. (This last feature requires a bugfix in 2.2 after rc1. bug #1549) 27 *0.3.1* Now prompts on delete. After duplicate you are editing new context. Allows rename context. 28 *0.3.0* New Features: Allow or Deny based on pattern matching. Failover Destination (one for regular extension, one for failed feature codes) Bugfixes: Adjusted Gui, Duplicate context, now duplicates the description too. 29 *0.2.2* Bugfix: Duplicate Context now copies the priority also. 30 *0.2.1* Added Duplicate Context option to easily copy an entire set of rules. 31 *0.2.0* Added priority feature to allow the user to control in what order the allowed contexts are included. 32 *0.1.3* Made it obvious when allowing one include may allow another entire context. 33 *0.1.2* Bugfixes- deleted routes, etc. now are removed. Context tests for spaces and illegal chars. Moved admin to tools to reduce confusion. Added option to allow entire internal dialplan. (Usefull for time limit on everything) Made description for outbound-allroutes clearer that allowing overrides to allow all routes. 34 *0.1.1* Still Beta, added time groups and bugfixes 35 *0.0.1* Beta release 52 36 </changelog> 53 37 <attention> … … 57 41 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! 58 42 </attention> 59 <location>contributed_modules/release/customcontexts-0.3. 7.tgz</location>60 <md5sum> f4fd5fd77afb3a9c41d56efb34577d29</md5sum>43 <location>contributed_modules/release/customcontexts-0.3.5.tgz</location> 44 <md5sum>69192c610cb8985dc3baee543ffe9ef0</md5sum> 61 45 </module> contributed_modules/modules/customcontexts/page.customcontexts.php
r9821 r9823 12 12 13 13 $dispnum = 'customcontexts'; //used for switch on config.php 14 15 14 ?> 16 15 contributed_modules/modules/customcontexts/uninstall.php
r9821 r9823 10 10 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 //GNU General Public License for more details. 12 13 $sql[] = "DROP TABLE IF EXISTS `customcontexts_contexts`"; 14 $sql[] = "DROP TABLE IF EXISTS `customcontexts_contexts_list`"; 15 $sql[] = "DROP TABLE IF EXISTS `customcontexts_includes`"; 16 $sql[] = "DROP TABLE IF EXISTS `customcontexts_includes_list`"; 17 $sql[] = "DROP TABLE IF EXISTS `customcontexts_module`"; 18 $sql[] = "DROP TABLE IF EXISTS `customcontexts_timegroups`"; 19 $sql[] = "DROP TABLE IF EXISTS `customcontexts_timegroups_detail`"; 20 foreach ($sql as $q){ 21 $db->query($sql); 22 } 12 23 ?> 13 24 <font color="red"><strong>You have uninstalled the Custom Contexts Module!<BR>
