Ticket #4123: patch.diff

File patch.diff, 4.1 kB (added by mbrevda, 2 years ago)
  • amp_conf/htdocs/admin/components.class.php

    old new  
    516516   
    517517  var $html_input; 
    518518   
    519   function guiinput($elemname, $currentvalue = '', $prompttext = '', $helptext = '', $jsvalidation = '', $failvalidationmsg = '', $canbeempty = true) { 
     519  function guiinput($elemname, $currentvalue = '', $prompttext = '', $helptext = '', $jsvalidation = '', $failvalidationmsg = '', $canbeempty = true, $jsvalidationtest='') { 
    520520    // call parent class contructor 
    521521    guielement::guielement($elemname, '', ''); 
    522522     
     
    528528    $this->helptext = $helptext; 
    529529    // JavaScript validation field on the element 
    530530    $this->jsvalidation = $jsvalidation; 
     531    // JavaScript validation test 
     532    $this->jsvalidationtest = $jsvalidationtest; 
    531533    // Msg to use if above validation fails (forced to use gettext language stuff) 
    532534    $this->failvalidationmsg = $failvalidationmsg; 
    533535    // Can this field be empty ? 
     
    541543  function generatevalidation() { 
    542544    $output = ''; 
    543545     
    544     if ($this->jsvalidation != '') { 
    545       $thefld = "theForm." . $this->_elemname; 
    546       $thefldvalue = $thefld . ".value"; 
     546    if ($this->jsvalidation != '' ) { 
     547      if(!$this->jsvalidationtest){ 
     548        $thefld = "theForm." . $this->_elemname; 
     549        $thefldvalue = $thefld . ".value"; 
     550      }else{ 
     551        $thefld="theForm." . $this->_elemname; 
     552        $thefldvalue =$this->jsvalidationtest; 
     553      } 
    547554     
    548555      if ($this->canbeempty) { 
    549556        $output .= "\tdefaultEmptyOK = true;\n"; 
     
    719726    }      
    720727} 
    721728 
     729class gui_drawselects extends guiinput { 
     730  function gui_drawselects($elemname, $index, $prompttext = '', $helptext = '', $canbeempty = true, $failvalidationmsg='') { 
     731    $parent_class = get_parent_class($this); 
     732    if(!$canbeempty){ 
     733      $jsvalidation ='()'; 
     734      $jsvalidationtest ='!$("input[name=goto'.$index.']:submit").val()'; 
     735      $failvalidationmsg = _('Please select a valid destination.'); 
     736    } 
     737    parent::$parent_class($elemname, '', $prompttext, $helptext, $jsvalidation, $failvalidationmsg, '', $jsvalidationtest); 
     738     
     739    $this->html_input=drawselects($currentvalue, $index, false, false); 
     740  }    
     741} 
     742 
    722743/* 
    723744************************************************************ 
    724745** guitext is the base class of all text fields (e.g. h1) ** 
  • amp_conf/htdocs/admin/functions.inc.php

    old new  
    19611961    } 
    19621962} 
    19631963 
    1964 // $goto is the current goto destination setting 
    1965 // $i is the destination set number (used when drawing multiple destination sets in a single form ie: digital receptionist) 
    1966 // esnure that any form that includes this calls the setDestinations() javascript function on submit. 
    1967 // ie: if the form name is "edit", and drawselects has been called with $i=2 then use onsubmit="setDestinations(edit,2)" 
    1968 function drawselects($goto,$i,$show_custom=false) { 
     1964/* 
     1965 * $goto is the current goto destination setting 
     1966 * $i is the destination set number (used when drawing multiple destination sets in a single form ie: digital receptionist) 
     1967 * esnure that any form that includes this calls the setDestinations() javascript function on submit. 
     1968 * ie: if the form name is "edit", and drawselects has been called with $i=2 then use onsubmit="setDestinations(edit,2)" 
     1969 * $table specifies if the destinations will be drawn in a new <tr> and <td> 
     1970 *  
     1971 */    
     1972function drawselects($goto,$i,$show_custom=false, $table=true) { 
    19691973  global $tabindex; 
    19701974   
    19711975  /* --- MODULES BEGIN --- */ 
     
    19731977   
    19741978  $all_destinations = array(); 
    19751979  $module_hash = array(); 
     1980  $selectHtml=''; 
     1981  if($table){ 
     1982    $selectHtml.='<tr><td colspan=2>'; 
     1983  } 
    19761984 
    1977   $selectHtml = '<tr><td colspan=2>';  
    19781985   
    19791986  //check for module-specific destination functions 
    19801987  foreach ($active_modules as $rawmod => $module) { 
     
    20732080 
    20742081  //close off our row 
    20752082  } 
    2076   $selectHtml .= '</td></tr>'; 
     2083  if($table){ 
     2084    $selectHtml.='</td></tr>'; 
     2085  } 
    20772086   
    20782087  return $selectHtml; 
    20792088}