Changeset 7836

Show
Ignore:
Timestamp:
06/20/09 11:09:39 (3 years ago)
Author:
p_lindheimer
Message:

make validation messages less verbose, add display of error box and new styling

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.6/sipsettings/functions.inc.php

    r7835 r7836  
    328328    switch ($key) { 
    329329      case 'bindaddr': 
    330         $msg = _("Bind Address (bindaddr) must be a properly formatted IP address."); 
     330        $msg = _("Bind Address (bindaddr) must be an IP address."); 
    331331        $save_settings[] = array($key,$db->escapeSimple($vd->is_ip($val,$key,$msg)),'0',NORMAL); 
    332332      break; 
    333333 
    334334      case 'bindport': 
    335         $msg = _("Bind Port (bindport) must be a proper IP port from 1024 to 65535, typically 5060."); 
     335        $msg = _("Bind Port (bindport) must be between 1024..65535, default 5060"); 
    336336        $save_settings[] = array($key,$db->escapeSimple($vd->is_ip_port($val, $key, $msg)),'0',NORMAL); 
    337337      break; 
     
    341341        //$vd->log_error(); 
    342342        if ($val < $sip_settings['rtptimeout']) { 
    343           $msg = _("The rtpholdtimeout must be bigger than the rtptimeout"); 
     343          $msg = _("rtpholdtimeout must be higher than rtptimeout"); 
    344344          $vd->log_error($val, $key, $msg); 
    345345        } 
    346         $msg = _("The rtptimeout settng must be a non-negative interger value of seconds"); 
     346        $msg = _("rtptimeout must be a non-negative interger"); 
    347347        $save_settings[] = array($key,$db->escapeSimple($vd->is_int($val, $key, $msg)),'0',NORMAL); 
    348348      break; 
     
    356356      case 'maxexpiry': 
    357357      case 'defaultexpiry': 
    358         $msg = sprintf(_("The Asterisk setting: %s must be a non-negative interger value in seconds."),$key); 
     358        $msg = sprintf(_("%s must be a non-negative interger"),$key); 
    359359        $save_settings[] = array($key,$db->escapeSimple($vd->is_int($val,$key,$msg)),'0',NORMAL); 
    360360      break; 
     
    364364      case 'jbmaxsize': 
    365365      case 'jbresyncthreshold': 
    366         $msg = sprintf(_("The Asterisk setting: %s must be a non-negative interger value."),$key); 
     366        $msg = sprintf(_("%s must be a non-negative interger"),$key); 
    367367        $save_settings[] = array($key,$db->escapeSimple($vd->is_int($val,$key,$msg)),'0',NORMAL); 
    368368      break; 
    369369 
    370370      case 'sip_language': 
    371         $msg = sprintf(_("The language value must be alphanumeric and should be a supported and installed language."),$key); 
     371        $msg = sprintf(_("Language must be alphanumeric and installed"),$key); 
    372372        $save_settings[] = array($key,$db->escapeSimple($vd->is_alphanumeric($val,$key,$msg)),'0',NORMAL); 
    373373      break; 
     
    396396        // ip validate this and store 
    397397        $seq = substr($key,9); 
    398         $msg = _("Localnet setting must be a valid IP address format."); 
     398        $msg = _("Localnet setting must be an IP address"); 
    399399        $save_settings[] = array($key,$db->escapeSimple($vd->is_ip($val,$key,$msg)),$seq,NORMAL);  
    400400      } else if (substr($key,0,8) == "netmask_") { 
    401401        // ip validate this and store 
    402402        $seq = substr($key,8); 
    403         $msg = _("Localnet mask must be in a proper netmask format such as 255.255.255.0 or 24."); 
     403        $msg = _("Localnet netmask must be formated properly (e.g. 255.255.255.0 or 24)"); 
    404404        $save_settings[] = array($key,$db->escapeSimple($vd->is_netmask($val,$key,$msg)),$seq,NORMAL);  
    405405      } else if (substr($key,0,15) == "sip_custom_key_") { 
  • modules/branches/2.6/sipsettings/page.sipsettings.php

    r7835 r7836  
    138138 
    139139</div> 
    140  
    141140<div class="content"> 
    142141  <h2><?php echo _("Edit Settings"); ?></h2> 
     142 
    143143<?php 
    144   if (!empty($error_displays)) { 
    145 ?> 
    146     <div class="sip-errors"> 
    147 <?php 
    148     foreach ($error_displays as $div_disp) { 
    149       echo "<p>".$div_disp['div']."</p>"; 
    150     } 
    151 ?> 
    152     </div> 
    153 <?php 
    154   } 
    155144 
    156145  /* We massaged these above or they came from sipsettings_get() if this is not 
     
    167156 
    168157?> 
    169   <form autocomplete="off" name="editSip" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return checkConf();"
     158  <form autocomplete="off" name="editSip" action="<?php $_SERVER['PHP_SELF'] ?>" method="post"
    170159  <input type="hidden" name="action" value="edit"> 
    171160  <table width="570px"> 
     161 
     162<?php 
     163  /* if there were erros on the submit then create error box */ 
     164  if (!empty($error_displays)) { 
     165?> 
     166  <tr> 
     167    <td colspan="2"> 
     168      <div class="sip-errors"> 
     169        <p><?php echo _("ERRORS") ?></p> 
     170        <ul> 
     171<?php 
     172    foreach ($error_displays as $div_disp) { 
     173      echo "<li>".$div_disp['div']."</li>"; 
     174    } 
     175?> 
     176        </ul> 
     177      </div> 
     178    </td> 
     179  </tr> 
     180<?php 
     181  } 
     182?> 
    172183 
    173184  <tr> 
     
    281292    <td><br \> 
    282293      <input type="button" id="nat-auto-configure"  value="<?php echo _("Auto Configure")?>" class="nat-settings" /> 
    283       <input type="button" id="localnet-add"  value="<?php echo _("Add Local Network")?>" class="nat-settings" /> 
     294      <input type="button" id="localnet-add"  value="<?php echo _("Add Local Network Field")?>" class="nat-settings" /> 
    284295    </td> 
    285296  </tr> 
     
    909920  '); 
    910921} 
    911  
    912 /* TODO: All The ERROR Checking client side */ 
    913  
    914 /* Validation classes: (blanks all ok) 
    915   * 
    916   * validate-int 
    917   * is integer only, can be 0 
    918   * 
    919   * validate-ip 
    920   * is proper ip format: \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} 
    921   * 
    922   * validate-ip-port 
    923   * warning if is integer between 0-1023 TODO: or do we just error this out? 
    924   * error if not integer or > 65535 
    925   * 
    926   * validate-netmask 
    927   * is integer 8-24 or is proper ip format 255\.\d{1,3}\.\d{1,3}\.\d{1,3} 
    928   * 
    929   * validate-alphanumeric 
    930   * valid alphanumerics that asterisk is ok with (probably no punctuations) 
    931   * 
    932  */ 
    933 function checkConf() 
    934 { 
    935  
    936   /* 
    937      TODO: look at jquery validate and/or finish below 
    938  
    939   $('validation-error').removeClass('validation-error'); 
    940  
    941   $('validate-int').each(function(){ 
    942     // regex this.value for integer 
    943     if (!is_integer(this.value)) { 
    944       $('#'+this.id).addClass('validation-error'); 
    945     } 
    946   }); 
    947   $('validate-ip').each(function(){ 
    948     // regex this.value for ip 
    949     $('#'+this.id).addClass('validation-error'); 
    950   }); 
    951   $('validate-ip-port').each(function(){ 
    952     // number 1024 <= this.value < 65536 
    953     $('#'+this.id).addClass('validation-error'); 
    954   }); 
    955   $('validate-netmask').each(function(){ 
    956     // number 8 <= this.value <= 24 
    957     // or regex ip format 255\.\d{1,3}\.\d{1,3}\.\d{1,3} 
    958     $('#'+this.id).addClass('validation-error'); 
    959   }); 
    960   $('validate-alphanumeric').each(function(){ 
    961     // regex this.value for alphanumeric 
    962     $('#'+this.id).addClass('validation-error'); 
    963   }); 
    964    */ 
    965  
    966   return true; 
    967 } 
    968  
    969  
    970922//--> 
    971923</script> 
    972924</form> 
    973925<?php    
    974      
     926 
     927/********** UTILITY FUNCTIONS **********/ 
     928 
    975929function process_errors($errors) { 
    976930  foreach($errors as $error) {