root/contributed_modules/modules/bulkdialpatterns/functions.inc.php

Revision 10056, 1.9 kB (checked in by tm1000, 3 years ago)

Something I whipped up after reading: http://www.freepbx.org/forum/freepbx/beta-program-issues/2-8-dial-pattern-and-rules to help me understand how hooks work in FreePBX

It's a simple bulkdialpatterns module that hooks into Outbound Routes.

  • Property svn:eol-style set to native
Line 
1 <?PHP
2 /*
3 This File is placed here for FreePBX Module Purposes. FreePBX calls unpon this module everytime FreePBX is reloaded.
4
5 Thoughts are to perhaps allow phone reboots and rebuilds when the user reloads freepbx configuration
6
7 1866NXXXXXX
8 1866NXXXXXXX
9 1877NXXXXXX
10 1888NXXXXXX
11 2800NXXXXXX
12 911
13 NXXNXXXXXX
14 NXXXXXX
15 ZNXXNXXXXXX
16
17 */
18 function bulkdialpatterns_hook_core($viewing_itemid, $target_menuid) {
19     global $db;
20     if ($target_menuid == 'routing')    {
21         $html = '<tr><td colspan="2"><h5>';
22         $html .= _("Bulk Dial Patterns");
23         $html .= '<hr></h5></td></tr>';
24         $html .= '<tr>';
25         $html .= '<td><a href="#" class="info">';
26         $html .= _("Source").'<span>'._("Each Pattern Should Be Entered On A New Line").'.</span></a>:</td>';
27         $html .= '<td><textarea name="bulk_patterns" rows="10" cols="40">';
28         if(isset($_REQUEST['extdisplay'])) {
29             $sql = 'SELECT `match_pattern_pass` FROM `outbound_route_patterns` WHERE `route_id` = '. $_REQUEST['extdisplay'];
30             $result = $db->query($sql);
31             while($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)) {
32                 $html .= $row['match_pattern_pass']."\n";
33             }
34             
35         }
36         $html .= '</textarea></td></tr>';
37         return $html;
38     }
39 }
40
41 function bulkdialpatterns_hookProcess_core($viewing_itemid, $request) {
42     global $db;
43     if (($request['display'] == 'routing') && (isset($request['bulk_patterns'])))    {
44         $_POST['pattern_pass'] = "";
45         $data = explode("\n",$request['bulk_patterns']);
46         $_POST['pattern_pass'] = $data;
47         $count = count($data);
48         $_POST['prepend_digit'] = array_fill(0, $count, '');
49         $_POST['pattern_prefix'] = array_fill(0, $count, '');
50         $_POST['match_cid'] = array_fill(0, $count, '');
51         
52         /*
53         $sql = 'DELETE FROM `outbound_route_patterns` WHERE `outbound_route_patterns`.`route_id` = '.$_REQUEST['extdisplay'];
54         $db->query($sql);
55         
56         foreach($data as $value){
57             $sql = "INSERT INTO outbound_route_patterns (route_id, match_pattern_pass) VALUES ('".$_REQUEST['extdisplay']."','".$value."')";
58             $db->query($sql);
59         }
60                 */
61     }
62 }
63 ?>
Note: See TracBrowser for help on using the browser.