Changeset 5949

Show
Ignore:
Timestamp:
07/07/08 16:35:33 (4 years ago)
Author:
p_lindheimer
Message:

#2976 Add Optional Regex to filter user agent numbers that they can input

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.5/queues/functions.inc.php

    r5834 r5949  
    159159          $grppre = (isset($q['prefix'])?$q['prefix']:''); 
    160160          $alertinfo = (isset($q['alertinfo'])?$q['alertinfo']:''); 
     161 
     162          // Not sure why someone would ever have a ; in the regex, but since Asterisk has problems with them 
     163          // it would need to be escaped 
     164          // 
     165          $qregex = (isset($q['qregex'])?$q['qregex']:''); 
     166          str_replace(';','\;',$qregex); 
    161167           
    162168          $ext->add('ext-queues', $exten, '', new ext_macro('user-callerid')); 
     
    227233           
    228234          //dynamic agent login/logout 
     235          if (trim($qregex) != '') { 
     236            $ext->add('ext-queues', $exten."*", '', new ext_setvar('QREGEX', $qregex)); 
     237          } 
    229238          $ext->add('ext-queues', $exten."*", '', new ext_macro('agent-add',$exten.",".$q['password'])); 
    230239          $ext->add('ext-queues', $exten."**", '', new ext_macro('agent-del',$exten.",".$exten)); 
     
    261270} 
    262271 
    263 function queues_add($account,$name,$password,$prefix,$goto,$agentannounce,$members,$joinannounce,$maxwait,$alertinfo='',$cwignore='no') { 
     272function queues_add($account,$name,$password,$prefix,$goto,$agentannounce,$members,$joinannounce,$maxwait,$alertinfo='',$cwignore='no',$qregex='') { 
    264273  global $db; 
    265274 
     
    324333  $dest          = isset($goto) ? $goto:''; 
    325334  $cwignore      = isset($cwignore) ? $cwignore:'0'; 
     335  $qregex        = isset($qregex) ? addslashes($qregex):''; 
    326336 
    327337  // Assumes it has just been deleted 
    328   $sql = "INSERT INTO queues_config (extension, descr, grppre, alertinfo, joinannounce, ringing, agentannounce, maxwait, password, ivr_id, dest, cwignore
    329           VALUES ('$extension', '$descr', '$grppre', '$alertinfo', '$joinannounce', '$ringing', '$agentannounce', '$maxwait', '$password', '$ivr_id', '$dest', '$cwignore') "; 
     338  $sql = "INSERT INTO queues_config (extension, descr, grppre, alertinfo, joinannounce, ringing, agentannounce, maxwait, password, ivr_id, dest, cwignore, qregex
     339          VALUES ('$extension', '$descr', '$grppre', '$alertinfo', '$joinannounce', '$ringing', '$agentannounce', '$maxwait', '$password', '$ivr_id', '$dest', '$cwignore', '$qregex')  "; 
    330340  $results = sql($sql); 
    331341  return true; 
     
    524534    $results['rtone']         = $config['ringing']; 
    525535    $results['cwignore']      = $config['cwignore']; 
     536    $results['qregex']        = $config['qregex']; 
    526537  } 
    527538 
  • modules/branches/2.5/queues/install.php

    r5546 r5949  
    301301  } 
    302302 
     303 
     304 
     305 
     306  // Version 2.5 upgrade 
     307  outn(_("checking for qregex field..")); 
     308  $sql = "SELECT `qregex` FROM queues_config"; 
     309  $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
     310  if(DB::IsError($check)) { 
     311    // add new field 
     312    $sql = "ALTER TABLE queues_config ADD `qregex` VARCHAR( 255 ) NULL ;"; 
     313    $result = $db->query($sql); 
     314    if(DB::IsError($result)) { 
     315      die_freepbx($result->getDebugInfo()); 
     316    } 
     317    out(_("OK")); 
     318  } else { 
     319    out(_("already exists")); 
     320  } 
     321 
    303322?> 
  • modules/branches/2.5/queues/module.xml

    r5835 r5949  
    22  <rawname>queues</rawname> 
    33  <name>Queues</name> 
    4   <version>2.4.0.8</version> 
     4  <version>2.5.0.0</version> 
    55  <type>setup</type> 
    66  <category>Inbound Call Control</category> 
     
    99  </description> 
    1010  <changelog> 
     11    *2.5.0.0* #2976 Add Optional Regex to filter user agent numbers that they can input 
    1112    *2.4.0.8* #2757 allow spaces and other alphanumeric characters in description 
    1213    *2.4.0.7* #2604, #2707, #2843 fix mal-formed html tags, typo, Russian Translation, add oldstyle module hook 
  • modules/branches/2.5/queues/page.queues.php

    r5919 r5949  
    2828$cwignore = isset($_REQUEST['cwignore'])?$_REQUEST['cwignore']:'0'; 
    2929$rtone = isset($_REQUEST['rtone'])?$_REQUEST['rtone']:'0'; 
     30$qregex = isset($_REQUEST['qregex'])?$_REQUEST['qregex']:''; 
    3031 
    3132if (isset($_REQUEST['goto0']) && isset($_REQUEST[$_REQUEST['goto0']."0"])) { 
     
    9798          $conflict_url = framework_display_extension_usage_alert($usage_arr); 
    9899        } else { 
    99           queues_add($account,$name,$password,$prefix,$goto,$agentannounce,$members,$joinannounce,$maxwait,$alertinfo,$cwignore); 
     100          queues_add($account,$name,$password,$prefix,$goto,$agentannounce,$members,$joinannounce,$maxwait,$alertinfo,$cwignore,$qregex); 
    100101          needreload(); 
    101102          redirect_standard(); 
     
    109110      case "edit":  //just delete and re-add 
    110111        queues_del($account); 
    111         queues_add($account,$name,$password,$prefix,$goto,$agentannounce,$members,$joinannounce,$maxwait,$alertinfo,$cwignore); 
     112        queues_add($account,$name,$password,$prefix,$goto,$agentannounce,$members,$joinannounce,$maxwait,$alertinfo,$cwignore,$qregex); 
    112113        needreload(); 
    113114        redirect_standard('extdisplay'); 
     
    524525      </select> 
    525526    </td> 
     527  </tr> 
     528 
     529  <tr> 
     530    <td><a href="#" class="info"><?php echo _("Agent Regex Filter")?><span><?php echo _("Provides an optional regex expression that will be applied against the agent callback number. If the callback number does not pass the regex filter then it will be treated as invalid. This can be used to restrict agents to extensions within a range, not allow callbacks to include keys like *, or any other use that may be appropriate. An examle input might be:<br />^([2-4][0-9]{3})$<br />This would restrict agents to extensions 2000-4999. Or <br />^([0-9]+)$ would allow any number of any length, but restrict the * key.<br />WARNING: make sure you undertand what you are doing or otherwise leave this blank!")?></span></a></td> 
     531    <td><input type="text" name="qregex" value="<?php echo (isset($qregex) ? $qregex : ''); ?>"></td> 
    526532  </tr> 
    527533 
     
    705711 
    706712function checkQ(theForm) { 
    707         var bad = "false"; 
    708  
    709         var whichitem = 0; 
    710         while (whichitem < theForm.goto0.length) { 
    711                 if (theForm.goto0[whichitem].checked) { 
    712                         theForm.goto0.value=theForm.goto0[whichitem].value; 
    713                 } 
    714                 whichitem++; 
    715         } 
    716  
    717         if (!isInteger(theForm.account.value)) { 
    718                 <?php echo "alert('"._("Queue Number must not be blank")."')"?>; 
    719                 bad="true"; 
    720         } 
    721  
    722         defaultEmptyOK = false;  
    723         if (!isAlphanumeric(theForm.name.value)) { 
    724                 <?php echo "alert('"._("Queue name must not be blank and must contain only alpha-numberic characters")."')"?>; 
    725                 bad="true"; 
    726         } 
    727  
    728         if (bad == "false") { 
    729                 theForm.submit(); 
    730         } 
     713  var bad = "false"; 
     714  var msgWarnRegex = "<?php echo _("Using a Regex filter is fairly advanced, please confirm you know what you are doing or leave this blank"); ?>"; 
     715 
     716  var whichitem = 0; 
     717  while (whichitem < theForm.goto0.length) { 
     718    if (theForm.goto0[whichitem].checked) { 
     719      theForm.goto0.value=theForm.goto0[whichitem].value; 
     720    } 
     721    whichitem++; 
     722  } 
     723 
     724  if (!isInteger(theForm.account.value)) { 
     725    <?php echo "alert('"._("Queue Number must not be blank")."')"?>; 
     726    bad="true"; 
     727  } 
     728 
     729  defaultEmptyOK = false;  
     730  if (!isAlphanumeric(theForm.name.value)) { 
     731    <?php echo "alert('"._("Queue name must not be blank and must contain only alpha-numberic characters")."')"?>; 
     732    bad="true"; 
     733  } 
     734  if (!isEmpty(theForm.qregex.value)) { 
     735    if (!confirm(msgWarnRegex)) { 
     736      bad="true"; 
     737    } 
     738  } 
     739 
     740  if (bad == "false") { 
     741    theForm.submit(); 
     742  } 
    731743} 
    732744