Skip to content

Commit

Permalink
Cleaned up the display of Outbound Routes so its not so confusing, fi…
Browse files Browse the repository at this point in the history
…xed page display issue for blacklist module
  • Loading branch information
tm1000 committed Jul 12, 2011
1 parent be57b77 commit f623870
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 17 deletions.
90 changes: 75 additions & 15 deletions functions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,49 @@ function sak_hook_core($viewing_itemid, $target_menuid) {
global $db;
$sak_settings =& $db->getAssoc("SELECT var_name, value FROM sak_settings");
$html = '';


if ($target_menuid == 'routing') {
$html .= '<tr><td colspan="2">&nbsp;</td></tr>';
if($sak_settings['dial_plan']) {
$html = '<tr><td colspan="2"><h5>';
$html .= _("Bulk Dial Patterns");
$html .= '<hr></h5></td></tr>';
//$html .= '<tr><td colspan="2"><h5>';
//$html .= _("Bulk Dial Patterns");
//$html .= '<hr></h5></td></tr>';
$html .= '<tr><td colspan="2">This Effectively Disables the \'Dial Plan Wizard\' Below. <br/>Entering Anything in the \'Dial Plan Wizard\' will be ignored</td></tr>';
$html .= '<tr>';
$html .= '<td><a href="#" class="info">';
$html .= _("Source").'<span>'._("Each Pattern Should Be Entered On A New Line").'.</span></a>:</td>';
$html .= '<td><textarea name="bulk_patterns" rows="10" cols="40">';
if(isset($_REQUEST['extdisplay'])) {
$sql = 'SELECT `match_pattern_pass` FROM `outbound_route_patterns` WHERE `route_id` = '. $_REQUEST['extdisplay'];
$sql = 'SELECT match_pattern_prefix, match_pattern_pass, match_cid, prepend_digits FROM outbound_route_patterns WHERE route_id = '. $_REQUEST['extdisplay'];
$result = $db->query($sql);
while($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)) {
/***
$prepend = ($row['prepend_digits'] != '') ? '('.$row['prepend_digits'].')' : '';
$match_pattern_prefix = ($row['match_pattern_prefix'] != '') ? '+'.$row['match_pattern_prefix'].'|' : '';
$match_cid = ($row['match_cid'] != '') ? '/'.$row['match_cid'] : '';
if(($prepend != '') OR ($match_pattern_prefix != '') OR ($match_cid != '')) {
$html .= $prepend . $match_pattern_prefix . '[' . $row['match_pattern_pass'] . $match_cid . "]\n";
} else {
$html .= $prepend . $match_pattern_prefix . $row['match_pattern_pass']."\n";
}
*/

$html .= $row['match_pattern_pass']."\n";

}

}
$html .= '</textarea></td></tr>';
$html .= '<tr><td colspan="2">&nbsp;</td></tr>';
}
if(($sak_settings['dial_plan_exp']) && ($viewing_itemid != '')) {
$html = '<tr><td colspan="2"><h5>';
$html .= _("Export Dial Patterns");
$html .= '<hr></h5></td></tr>';
$html .= '<tr><td colspan="2">Click <a href="config.php?type=tool&amp;display=sak_advanced_settings&amp;quietmode=1&amp;orid='.$viewing_itemid.'" target="_blank">Here</a> to Export All Dial Patterns for this Route</td></tr>';
//$html .= '<tr><td colspan="2"><h5>';
//$html .= _("Export Dial Patterns");
//$html .= '<hr></h5></td></tr>';
$html .= '<tr><td colspan="2"><a href="config.php?type=tool&amp;display=sak_advanced_settings&amp;quietmode=1&amp;orid='.$viewing_itemid.'" target="_blank">Click Here to Export All Dial Patterns for this Route</a>';
$html .= '</td></tr>';
$html .= '<tr><td colspan="2">&nbsp;</td></tr>';
}
}
return $html;
Expand All @@ -37,14 +55,56 @@ function sak_hook_core($viewing_itemid, $target_menuid) {
function sak_hookProcess_core($viewing_itemid, $request) {
global $db;
$sak_settings =& $db->getAssoc("SELECT var_name, value FROM sak_settings");
if (($request['display'] == 'routing') && ($sak_settings['dial_plan']) && (isset($request['bulk_patterns']))) {
if (($request['display'] == 'routing') && ($sak_settings['dial_plan']) && (isset($request['bulk_patterns']))) {
$_POST['pattern_pass'] = "";
$data = explode("\n",$request['bulk_patterns']);
$_POST['pattern_pass'] = $data;
$count = count($data);
$_POST['prepend_digit'] = array_fill(0, $count, '');
$_POST['pattern_prefix'] = array_fill(0, $count, '');
$_POST['match_cid'] = array_fill(0, $count, '');

$prepend = '/\((.*)?\)/';
$prefix = '/\+(.*?)\|/';
$match_pattern = '/\[(.*?)\//';
$callerid = '/\/(.*?)\]/';
$i = 0;
/***
foreach($data as $list) {
$found = FALSE;
$found = preg_match($prepend, $list, $matches) ? TRUE : FALSE;
$pp[$i] = (isset($matches[1])) ? $matches[1] : '';
$list = preg_replace($prepend, '', $list);
$found = preg_match($prefix, $list, $matches);
preg_match($prefix, $list, $matches);
$pf[$i] = (isset($matches[1])) ? $matches[1] : '';
$list = preg_replace($prefix, '', $list);
$found = preg_match($callerid, $list, $matches);
preg_match($callerid, $list, $matches);
$cid[$i] = (isset($matches[1])) ? $matches[1] : '';
$list = preg_replace($callerid, '', $list);
$found = preg_match($match_pattern, $list, $matches);
preg_match($match_pattern, $list, $matches);
$mp[$i] = (isset($matches[1])) ? $matches[1] : '';
$mp[$i] = $found ? $mp[$i] : $list;
$i++;
}
*/

foreach($data as $list) {
$pp[$i] = '';
$pf[$i] = '';
$cid[$i] = '';

$mp[$i] = $list;

$i++;
}

$_POST['pattern_pass'] = $mp;
$_POST['prepend_digit'] = $pp;
$_POST['pattern_prefix'] = $pf;
$_POST['match_cid'] = $cid;

/*
$sql = 'DELETE FROM `outbound_route_patterns` WHERE `outbound_route_patterns`.`route_id` = '.$_REQUEST['extdisplay'];
Expand Down
4 changes: 3 additions & 1 deletion module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<rawname>sak</rawname>
<repo>standard</repo>
<name>Swiss Army Knife</name>
<version>1.0</version>
<version>1.0.1</version>
<publisher>Andrew Nagy</publisher>
<license>MPLv1.1</license>
<type>tool</type>
Expand All @@ -13,6 +13,8 @@
</menuitems>
<description>I miss a feature. So it winds up here</description>
<changelog>
*1.0.1* Cleaned up the display of Outbound Routes so its not so confusing, fixed page display issue for blacklist module
*1.0* Initial Release
</changelog>
<depends>
<module>core ge 2.5.1.2</module>
Expand Down
2 changes: 1 addition & 1 deletion page.sak_blacklist_mod.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

isset($_REQUEST['editnumber'])?$editnumber = $_REQUEST['editnumber']:$editnumber='';

$dispnum = "blacklist_mod"; //used for switch on config.php
$dispnum = "sak_blacklist_mod"; //used for switch on config.php

//if submitting form, update database

Expand Down

0 comments on commit f623870

Please sign in to comment.