Changeset 10373

Show
Ignore:
Timestamp:
10/06/10 13:48:26 (3 years ago)
Author:
mickecarlsson
Message:

Close #2418 add comment box to Blacklisted entries. Note: Requires Asterisk 1.6.x or later

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.9/blacklist/functions.inc.php

    r10244 r10373  
    1616// 
    1717//  Copyright (C) 2006 Magnus Ullberg (magnus@ullberg.us) 
     18//  Portions Copyright (C) 2010 Mikael Carlsson (mickecamino@gmail.com) 
    1819// 
    1920 
     
    2526  global $version; 
    2627  global $astman; 
     28 
    2729  switch($engine) { 
    2830    case "asterisk": 
     
    4446        $ext->add($id, $c, 'check-blocked', new ext_gotoif('$["${DB(blacklist/blocked)}" = "1"]','blacklisted')); 
    4547      } 
    46  
     48       
    4749      if (version_compare($version, "1.6", "ge")) { 
    4850        $ext->add($id, $c, 'check', new ext_gotoif('$["${BLACKLIST()}"="1"]', 'blacklisted')); 
     
    5153        $ext->add($id, $c, '', new ext_gotoif('$["${LOOKUPBLSTATUS}"="FOUND"]', 'blacklisted')); 
    5254      } 
    53       $ext->add($id, $c, '', new ext_setvar('CALLED_BLACKLIST','1')); 
     55         $ext->add($id, $c, '', new ext_setvar('CALLED_BLACKLIST','1')); 
    5456      $ext->add($id, $c, '', new ext_return('')); 
    5557      $ext->add($id, $c, 'blacklisted', new ext_answer('')); 
     
    211213  global $astman; 
    212214 
     215$engineinfo = engine_getinfo(); 
     216$astver =  $engineinfo['version']; 
    213217        if ($astman) { 
    214     $list = $astman->database_show(); 
    215     foreach ($list as $k => $v) { 
    216       if (substr($k, 1, 9) == 'blacklist') 
    217       { 
    218         $numbers[substr($k, 11)] = substr($k, 11); 
    219       } 
    220     } 
    221  
    222     if (isset($numbers) && is_array($numbers)) 
    223       natcasesort($numbers); 
    224  
    225     return isset($numbers)?$numbers:null; 
     218    $list = $astman->database_show('blacklist'); 
     219    if(version_compare($astver, "1.6", "ge")) { 
     220        foreach ($list as $k => $v) { 
     221      $numbers = substr($k, 11); 
     222      $blacklisted[] = array('number' => $numbers, 'description' => $v); 
     223      } 
     224        if (isset($blacklisted) && is_array($blacklisted)) 
     225      // Why this sorting? When used it does not yield the result I want 
     226      //    natsort($blacklisted); 
     227        return isset($blacklisted)?$blacklisted:null; 
     228    } else { 
     229        foreach ($list as $k => $v) { 
     230      $numbers[substr($k, 11)] = substr($k, 11); 
     231      } 
     232      if (isset($numbers) && is_array($numbers)) 
     233          natcasesort($numbers); 
     234      return isset($numbers)?$numbers:null; 
     235      } 
    226236        } else { 
    227237                fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]); 
     
    232242  global $amp_conf; 
    233243  global $astman; 
    234  
    235244  if ($astman) { 
    236245    $astman->database_del("blacklist",$number); 
     
    244253  global $astman; 
    245254 
     255$engineinfo = engine_getinfo(); 
     256$astver =  $engineinfo['version']; 
     257 
    246258  if(!blacklist_chk($post)) 
    247259    return false; 
     
    249261  extract($post); 
    250262  if ($astman) { 
    251     $astman->database_put("blacklist",$number, '1'); 
     263    if (version_compare($astver, "1.6", "ge")) { 
     264    $post['description']==""?$post['description'] = '1':$post['description']; 
     265    $astman->database_put("blacklist",$post['number'], '"'.$post['description'].'"'); 
     266        } else { 
     267              $astman->database_put("blacklist",$number, '1'); 
     268              } 
    252269    // Remove filtering for blocked/unknown cid 
    253270    $astman->database_del("blacklist","blocked"); 
  • modules/branches/2.9/blacklist/page.blacklist.php

    r9648 r10373  
    1515//    along with FreePBX.  If not, see <http://www.gnu.org/licenses/>. 
    1616// 
    17 //Copyright (C) 2006 Magnus Ullberg (magnus@ullberg.us) 
     17//    Copyright (C) 2006 Magnus Ullberg (magnus@ullberg.us) 
     18//    Portions Copyright (C) 2010 Mikael Carlsson (mickecamino@gmail.com) 
    1819// 
     20 
     21$engineinfo = engine_getinfo(); 
     22$astver =  $engineinfo['version']; 
     23 
    1924isset($_REQUEST['action'])?$action = $_REQUEST['action']:$action=''; 
     25isset($_REQUEST['number'])?$number = $_REQUEST['number']:$number=''; 
    2026 
    21 isset($_REQUEST['number'])?$number = $_REQUEST['number']:$number=''; 
     27if(version_compare($astver, "1,6", "ge")) { 
     28    isset($_REQUEST['description'])?$description = $_REQUEST['description']:$description=''; 
     29    } 
    2230 
    2331isset($_REQUEST['editnumber'])?$editnumber = $_REQUEST['editnumber']:$editnumber=''; 
    2432 
    2533$dispnum = "blacklist"; //used for switch on config.php 
    26  
     34     
    2735//if submitting form, update database 
    2836 
     
    4250      redirect_standard('editnumber'); 
    4351                break; 
    44  
    45  
    4652  } 
    4753} 
     
    6975 
    7076  <tr> 
    71     <td><b><?php echo _("Number") ?></b></td> 
    72     <td>&nbsp;</td> 
    73     <td>&nbsp;</td> 
     77     
     78  <?php 
     79  if(version_compare($astver, "1,6", "ge")) { 
     80      echo "<td><b>"._("Number")."</b></td>"; 
     81      echo "<td><b>"._("Description")."</b></td>"; 
     82    } else { 
     83    echo "<td><b>"._("Number")."</b></td>"; 
     84    echo "<td>&nbsp;</td>"; 
     85      } 
     86?>     
     87    <td>&nbsp;</td>    
    7488  </tr> 
    7589 
     
    8397    else  { 
    8498     
     99                if(version_compare($astver, "1,6", "ge")) { 
     100      print('<tr>'); 
     101      printf('<td>%s</td>', $num['number']); 
     102          printf('<td>%s</td>', $num['description']); 
     103      printf('<td><a href="%s?type=setup&display=%s&number=%s&action=delete">%s</a></td>',  
     104        $_SERVER['PHP_SELF'], urlencode($dispnum), urlencode($num['number']), _("Delete")); 
     105      printf('<td><a href="#" onClick="theForm.number.value = \'%s\';  
     106        theForm.editnumber.value = \'%s\' ; 
     107        theForm.description.value = \'%s\';  
     108        theForm.editdescription.value = \'%s\' ;  
     109        theForm.action.value = \'edit\' ; ">%s</a></td>',$num['number'], $num['number'], $num['description'], $num['description'], _("Edit")); 
     110      print('</tr>'); 
     111       
     112      } else { 
    85113      print('<tr>'); 
    86114      printf('<td>%s</td>', $num); 
     115              printf('<td>%s</td>', $description); 
    87116      printf('<td><a href="%s?type=setup&display=%s&number=%s&action=delete">%s</a></td>',  
    88117        $_SERVER['PHP_SELF'], urlencode($dispnum), urlencode($num), _("Delete")); 
    89118      printf('<td><a href="#" onClick="theForm.number.value = \'%s\'; theForm.editnumber.value = \'%s\' ; theForm.action.value = \'edit\' ; ">%s</a></td>',$num, $num, _("Edit")); 
    90119      print('</tr>'); 
     120      } 
    91121    } 
    92122  } 
    93  
    94123  print('</table>'); 
    95124} 
    96  
    97125?> 
    98  
    99126 
    100127<form autocomplete="off" name="edit" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return edit_onsubmit();"> 
     
    103130  <input type="hidden" name="editnumber" value=""> 
    104131 
     132  <?php if(version_compare($astver, "1,6", "ge")) { 
     133          echo "<input type=\"hidden\" name=\"editdescripton\" value=\"\">"; 
     134      }?> 
    105135  <table> 
    106136  <tr><td colspan="2"><h5><?php echo _("Add or replace entry") ?><hr></h5></td></tr> 
    107137 
    108138        <tr> 
    109                 <td><a href="#" class="info"><?php echo _("Number:")?> 
    110                 <span><?php echo _("Enter the number you want to block")?></span></a></td> 
     139   <td><a href="#" class="info"><?php echo _("Number:")?> 
     140   <span><?php echo _("Enter the number you want to block")?></span></a></td> 
    111141                <td><input type="text" name="number"></td> 
    112142        </tr> 
     143        <?php if(version_compare($astver, "1,6", "ge")) { 
     144        echo "<tr>"; 
     145                echo "<td><a href=\"#\" class=\"info\">"._("Description:"); 
     146                echo "<span>"._("Enter a description for the number you want to block")."</span></a></td>"; 
     147                echo "<td><input type=\"text\" name=\"description\"></td>"; 
     148        echo "</tr>";         
     149      }?> 
     150 
    113151        <tr> 
    114152                <td><a href="#" class="info"><?php echo _("Block Unknown/Blocked Caller ID:")?>