Changeset 14580


Ignore:
Timestamp:
04/30/12 11:44:51 (8 years ago)
Author:
plg
Message:

feature 2626: fix watermark form submission (with the help of rvelices)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/configuration_watermark_process.inc.php

    r14549 r14580  
    130130    || $watermark->opacity != $old_watermark->opacity; 
    131131 
    132   // do we have to regenerate the derivatives? 
    133   $old_enabled = ImageStdParams::get_defined_type_map(); 
    134   // $disabled = @unserialize( @$conf['disabled_derivatives'] ); 
    135   // if ($disabled===false) 
    136   // { 
    137   //   $disabled = array(); 
    138   // } 
    139  
    140132  // save the new watermark configuration 
    141133  ImageStdParams::set_watermark($watermark); 
    142134 
    143   $new_enabled = ImageStdParams::get_defined_type_map(); 
     135  // do we have to regenerate the derivatives (and which types)? 
     136  $types = ImageStdParams::get_defined_type_map(); 
     137  $changed_types = array(); 
    144138   
    145   $changed_types = array(); 
     139  foreach ($types as $type => $params) 
     140  { 
     141    $old_use_watermark = $params->use_watermark; 
     142    ImageStdParams::apply_global($params); 
    146143 
    147   foreach(ImageStdParams::get_all_types() as $type) 
    148   { 
    149     if (isset($old_enabled[$type])) 
     144    if ($params->use_watermark != $old_use_watermark 
     145        or $params->use_watermark and $watermark_changed) 
    150146    { 
    151       $old_params = $old_enabled[$type]; 
    152       // echo '<pre>old '.$type."\n"; print_r($old_params); echo '</pre>'; 
    153       
    154       $new_params = $new_enabled[$type]; 
    155       ImageStdParams::apply_global($new_params); 
    156       // echo '<pre>new '.$type."\n"; print_r($old_params); echo '</pre>'; 
    157        
    158       $same = true; 
    159            
    160       if ($new_params->use_watermark != $old_params->use_watermark 
    161           or $new_params->use_watermark and $watermark_changed) 
    162       { 
    163         $same = false; 
    164       } 
    165  
    166       if (!$same) 
    167       { 
    168         $new_params->last_mod_time = time(); 
    169         $changed_types[] = $type; 
    170       } 
    171       else 
    172       { 
    173         $new_params->last_mod_time = $old_params->last_mod_time; 
    174       } 
    175       $new_enabled[$type] = $new_params; 
     147      $params->last_mod_time = time(); 
     148      $changed_types[] = $type; 
     149      $types[$type] = $params; 
    176150    } 
    177151  } 
    178152 
    179   $enabled_by = array(); // keys ordered by all types 
    180   foreach(ImageStdParams::get_all_types() as $type) 
    181   { 
    182     if (isset($new_enabled[$type])) 
    183     { 
    184       $enabled_by[$type] = $new_enabled[$type]; 
    185     } 
    186   } 
    187   ImageStdParams::set_and_save($enabled_by); 
     153  ImageStdParams::set_and_save($types); 
    188154 
    189155  if (count($changed_types)) 
Note: See TracChangeset for help on using the changeset viewer.