Changeset 21100


Ignore:
Timestamp:
03/02/13 18:28:58 (6 years ago)
Author:
Eric
Message:

Next version will be 1.1.0 :

  • Compliance with Piwigo 2.5
  • Code refactory : Change config variables to assoc array and $_POST vars control before writing conf in database - Thx to flop25 for his advices ;-)
  • Bug fixed : Unable to restore an history backup file
Location:
extensions/Prune_History
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • extensions/Prune_History/admin/PH_admin.php

    r14854 r21100  
    3535{ 
    3636 
    37   $newconf_PH[0] = $version; 
    38   $newconf_PH[1] = $_POST['PH_AutoPrune']; 
    39   $newconf_PH[2] = $_POST['PH_Range_Value']; 
    40   $newconf_PH[3] = $_POST['PH_Range']; 
     37  $newconf_PH['PHVersion'] = $version; 
     38  $newconf_PH['AUTOPRUNE'] = (isset($_POST['PH_AutoPrune']) ? $_POST['PH_AutoPrune'] : 'false'); 
     39  $newconf_PH['RANGEVALUE'] = (isset($_POST['PH_Range_Value']) ? $_POST['PH_Range_Value'] : '0'); 
     40  $newconf_PH['RANGE'] = (isset($_POST['PH_Range']) ? $_POST['PH_Range'] : '0'); 
    4141 
    4242  $conf['PruneHistory'] = serialize($newconf_PH); 
     
    162162    'PH_VERSION'                 => $version, 
    163163    'PH_DUMP_DOWNLOAD'           => $dump_download, 
    164                 'PH_AUTOPRUNE_TRUE'          => $conf_PH[1]=='true' ? 'checked="checked"' : '' , 
    165                 'PH_AUTOPRUNE_FALSE'         => $conf_PH[1]=='false' ? 'checked="checked"' : '' , 
    166     'PH_RANGE_VALUE'             => $conf_PH[2], 
    167     'PH_RANGE_SELECTED'          => $conf_PH[3], 
     164                'PH_AUTOPRUNE_TRUE'          => $conf_PH['AUTOPRUNE']=='true' ? 'checked="checked"' : '' , 
     165                'PH_AUTOPRUNE_FALSE'         => $conf_PH['AUTOPRUNE']=='false' ? 'checked="checked"' : '' , 
     166    'PH_RANGE_VALUE'             => $conf_PH['RANGEVALUE'], 
     167    'PH_RANGE_SELECTED'          => $conf_PH['RANGE'], 
    168168    'range_list'                 => $range_list, 
    169169    'month_list'                 => $month_list, 
  • extensions/Prune_History/changelog.txt

    r20375 r21100  
    2828 
    29292012-10-05 - 1.0.8 - Bug fixed : Possible MySql error when using "0" value in auto-prune function. 
     30 
     312013-02-28 - 1.1.0 - Compliance with Piwigo 2.5 
     32                   - Code refactory : Change config variables to assoc array and $_POST vars control before writing conf in database - Thx to flop25 for his advices ;-) 
     33                   - Bug fixed : Unable to restore a backup file 
  • extensions/Prune_History/include/functions.inc.php

    r20375 r21100  
    9999  $result = pwg_query($query); 
    100100  $conf_PH = pwg_db_fetch_assoc($result); 
    101      
     101 
    102102  $Newconf_PH = unserialize($conf_PH['value']); 
    103    
    104   $Newconf_PH[0] = $version; 
     103 
     104  $Newconf_PH['PHVersion'] = $version; 
    105105 
    106106  $update_conf = serialize($Newconf_PH); 
     
    228228 
    229229  // Definition of the range to keep 
    230   if (isset($conf_PH[1]) and $conf_PH[1] == 'true' and isset($conf_PH[2]) and $conf_PH[2] <> '0' and isset($conf_PH[3]) and $conf_PH[3] <> '0') 
    231   { 
    232     if ($conf_PH[3] == '1') // Ranged for days 
    233     { 
    234       $limit = mktime(0, 0, 0, date("m") , date("d")-$conf_PH[2], date("Y")); 
     230  if (isset($conf_PH['AUTOPRUNE']) and $conf_PH['AUTOPRUNE'] == 'true' and isset($conf_PH['RANGEVALUE']) and $conf_PH['RANGEVALUE'] <> '0' and isset($conf_PH['RANGE']) and $conf_PH['RANGE'] <> '0') 
     231  { 
     232    if ($conf_PH['RANGE'] == '1') // Ranged for days 
     233    { 
     234      $limit = mktime(0, 0, 0, date("m") , date("d")-$conf_PH['RANGEVALUE'], date("Y")); 
    235235      $limit = date('Y-m-d', $limit); 
    236236    } 
    237     else if ($conf_PH[3] == '2') // Ranged for months 
    238     { 
    239       $limit = mktime(0, 0, 0, date("m")-$conf_PH[2] , date("d"), date("Y")); 
     237    else if ($conf_PH['RANGE'] == '2') // Ranged for months 
     238    { 
     239      $limit = mktime(0, 0, 0, date("m")-$conf_PH['RANGEVALUE'] , date("d"), date("Y")); 
    240240      $limit = date('Y-m-d', $limit); 
    241241    } 
    242     else if  ($conf_PH[3] == '3') // Ranged for years 
    243     { 
    244       $limit = mktime(0, 0, 0, date("m") , date("d"), date("Y")-$conf_PH[2]); 
     242    else if  ($conf_PH['RANGE'] == '3') // Ranged for years 
     243    { 
     244      $limit = mktime(0, 0, 0, date("m") , date("d"), date("Y")-$conf_PH['RANGEVALUE']); 
    245245      $limit = date('Y-m-d', $limit); 
    246246    } 
     
    307307      $insertions .= "DROP TABLE IF EXISTS ".$ListTables[$j].";\n\n"; 
    308308 
    309       $array = mysql_fetch_array($res); 
     309      $array = pwg_db_fetch_row($res); 
    310310      $array[1] .= ";\n\n"; 
    311311      $insertions .= $array[1]; 
    312312 
    313       $req_table = pwg_query('SELECT * FROM '.$ListTables[$j]) or die(mysql_error()); 
    314       $nb_fields = mysql_num_fields($req_table); 
    315       while ($line = mysql_fetch_array($req_table)) 
     313      $req_table = pwg_query('DESCRIBE '.$ListTables[$j].';') or die(my_error()); 
     314      $nb_fields = pwg_db_num_rows($req_table); 
     315      $req_table2 = pwg_query('SELECT * FROM '.$ListTables[$j]) or die(my_error()); 
     316 
     317      while ($line = pwg_db_fetch_row($req_table2)) 
    316318      { 
    317319        $insertions .= 'INSERT INTO '.$ListTables[$j].' VALUES ('; 
     
    375377  // Restore sql backup file - DROP TABLE queries are executed 
    376378  // --------------------------------------------------------- 
    377   UAM_execute_sqlfile( 
     379  PH_execute_sqlfile( 
    378380    $Backup_File, 
    379381    DEFAULT_PREFIX_TABLE, 
  • extensions/Prune_History/main.inc.php

    r18489 r21100  
    3131 
    3232/* Prune automation on user login */ 
    33 if (isset($conf_PH[1]) and $conf_PH[1] == 'true') 
     33if (isset($conf_PH['AUTOPRUNE']) and $conf_PH['AUTOPRUNE'] == 'true') 
    3434{ 
    3535  add_event_handler('login_success', 'history_autoprune' ); 
  • extensions/Prune_History/maintain.inc.php

    r14854 r21100  
    2424  // Default global parameters for Prune History conf 
    2525  // ------------------------------------------------- 
    26   $defaultPH[0] = $version;                                  // Prune History version 
    27   $defaultPH[1] = 'false';                                   // Enable automated prune 
    28   $defaultPH[2] = '0';                                       // Range 
    29   $defaultPH[3] = '0';                                       // Value (Year, month, day) 
    30  
     26  $defaultPH = array( 
     27    'PHVersion'   => $version, // Prune History version 
     28    'AUTOPRUNE'   => 'false', // Enable automated prune 
     29    'RANGEVALUE'  => '0', // Range 
     30    'RANGE'       => '0' // Value (Year, month, day) 
     31  ); 
    3132  // Create Prune History conf if not already exists 
    3233  // ------------------------------------------------ 
     
    5758  PH_Obsolete_Files(); 
    5859 
     60  include_once (PH_PATH.'include/upgradedb.inc.php'); 
     61 
     62/* Check database upgrade */ 
     63/* ********************** */ 
     64  $conf_PH = unserialize($conf['PruneHistory']); 
     65 
     66  if (isset($conf_PH[0])) 
     67  { 
     68    if (version_compare($conf_PH['PHVersion'], '1.1.0') < 0) 
     69    { 
     70    /* upgrade from 1.0 to 1.1 */ 
     71    /* *********************** */ 
     72      upgrade_100_110(); 
     73    } 
     74  } 
     75 
    5976/* Update plugin version number in #_config table */ 
    6077/* and check consistency of #_plugins table       */ 
Note: See TracChangeset for help on using the changeset viewer.