Show
Ignore:
Timestamp:
04/23/11 10:51:53 (2 years ago)
Author:
patdenice
Message:

Create a function to save upload form settings.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/admin/batch_manager_global.php

    r10553 r10589  
    434434  if (!empty($update_fields)) 
    435435  { 
    436     // Update configuration 
     436    // Update upload configuration 
    437437    $updates = array(); 
    438438    foreach ($update_fields as $field) 
    439439    { 
    440       if (is_bool($upload_form_config[$field]['default'])) 
    441       { 
    442         $value = isset($_POST[$field]); 
    443  
    444         $updates[] = array( 
    445           'param' => 'upload_form_'.$field, 
    446           'value' => boolean_to_string($value) 
    447           ); 
    448       } 
    449       else 
    450       { 
    451         $value = null; 
    452         if (!empty($_POST[$field])) 
    453         { 
    454           $value = $_POST[$field]; 
    455         } 
    456  
    457         if (preg_match($upload_form_config[$field]['pattern'], $value) 
    458           and $value >= $upload_form_config[$field]['min'] 
    459           and $value <= $upload_form_config[$field]['max']) 
    460         { 
    461           $conf['upload_form_'.$field] = $value; 
    462            $updates[] = array( 
    463             'param' => 'upload_form_'.$field, 
    464             'value' => $value 
    465             ); 
    466         } 
    467         else 
    468         { 
    469           $updates = null; 
    470           break; 
    471         } 
    472       } 
     440      $value = !empty($_POST[$field]) ? $_POST[$field] : null; 
    473441      $form_values[$field] = $value; 
    474     } 
    475     if (!empty($updates)) 
    476     { 
    477       mass_updates( 
    478         CONFIG_TABLE, 
    479         array( 
    480           'primary' => array('param'), 
    481           'update' => array('value') 
    482           ), 
    483         $updates 
    484         ); 
    485     } 
     442      $updates[$field] = $value; 
     443    } 
     444    save_upload_form_config($updates); 
    486445    $template->delete_compiled_templates(); 
    487446  }