Ignore:
Timestamp:
04/10/10 17:15:30 (10 years ago)
Author:
Eric
Message:

[NBC_UserAdvManager]

Merged from trunk to branch 2.15

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/NBC_UserAdvManager/branches/2.15/maintain.inc.php

    r5634 r5763  
    8181/* *********************** */ 
    8282  clean_obsolete_files(); 
    83  
    84 /* Check if it's a blank installation */ 
    85 /* ********************************** */ 
     83   
     84  include_once (UAM_PATH.'include/upgradedb.inc.php'); 
     85 
     86/* Check if old version is < 2.15 */ 
     87/* ****************************** */ 
    8688        $query = ' 
    8789SELECT param 
    8890  FROM '.CONFIG_TABLE.' 
    89 WHERE param = "nbc_UserAdvManager_ConfirmMail" 
    90 ;'; 
    91   $count1 = pwg_db_num_rows(pwg_query($query)); 
    92    
    93         $query1 = ' 
    94 SELECT param 
    95   FROM '.CONFIG_TABLE.' 
    96 WHERE param = "nbc_UserAdvManager_ConfirmMail" 
    97 ;'; 
    98   $count2 = pwg_db_num_rows(pwg_query($query1)); 
     91WHERE param = "nbc_UserAdvManager" 
     92;'; 
     93  $count = pwg_db_num_rows(pwg_query($query)); 
    9994 
    10095/* If old params exist an upgrade is needed */ 
    10196/* **************************************** */ 
    102   if ($count1 == 1 or $count2 == 1) 
     97  if ($count == 1) 
    10398  { 
    10499/* Check for upgrade from 2.10 to 2.11 */ 
     
    115110    /* upgrade from branch 2.10 to 2.11 */ 
    116111    /* ******************************** */ 
    117       upgrade_210(); 
     112      upgrade_210_211(); 
    118113    } 
    119114 
     
    125120    /* upgrade from branch 2.11 to 2.12 */ 
    126121    /* ******************************** */ 
    127                 upgrade_211(); 
     122                upgrade_211_212(); 
    128123    } 
    129124 
     
    147142    /* upgrade from branch 2.12 to 2.13 */ 
    148143    /* ******************************** */ 
    149       upgrade_212(); 
     144      upgrade_212_213(); 
    150145    } 
    151146 
     
    157152    /* upgrade from branch 2.13 to 2.14 */ 
    158153    /* ******************************** */ 
    159       upgrade_213(); 
    160     } 
    161    
    162  
    163 /* Check for upgrade from 2.14.1 to 2.14.2 */ 
    164 /* *************************************** */ 
     154      upgrade_213_214(); 
     155    } 
     156     
     157 
     158/* Check for upgrade from 2.14 to 2.15 */ 
     159/* *********************************** */ 
    165160        $query1 = ' 
    166161SELECT param 
     
    179174    if ($count1 == 1 or $count2 == 1) 
    180175    { 
    181     /* upgrade from branch 2.14.1 to 2.14.2 */ 
    182     /* ************************************ */ 
    183       upgrade_214_1(); 
     176    /* upgrade from branch 2.14 to 2.15 */ 
     177    /* ******************************** */ 
     178      upgrade_214_215(); 
    184179    } 
    185180  } 
     181   
     182/* Check for upgrade from 2.15 to 2.xx */ 
     183/* *********************************** */ 
    186184} 
    187185 
     
    217215  pwg_query( $q ); 
    218216} 
    219  
    220  
    221 // +----------------------------------------------------------+ 
    222 // |       Upgrading database from old plugin versions        | 
    223 // +----------------------------------------------------------+ 
    224  
    225 /* upgrade from branch 2.10 to 2.11 */ 
    226 /* ******************************** */ 
    227 function upgrade_210() 
    228 { 
    229         global $conf; 
    230            
    231   $q = ' 
    232 INSERT INTO '.CONFIG_TABLE.' (param, value, comment) 
    233 VALUES ("nbc_UserAdvManager_ConfirmMail","false;5;Hello. 
    234                  
    235 This is a reminder message because you registered on our gallery but you do not validate your registration and your validation key has expired. To still allow you to access to our gallery, your validation period has been reset. You have again 5 days to validate your registration. 
    236  
    237 Note: After this period, your account will be permanently deleted.;false;Hello. 
    238  
    239 This is a reminder message because you registered on our gallery but you do not validate your registration and your validation key will expire. To allow you access to our gallery, you have 2 days to confirm your registration by clicking on the link in the message you should have received when you registered. 
    240  
    241 Note: After this period, your account will be permanently deleted.","Parametres nbc_UserAdvManager - ConfirmMail") 
    242   ;'; 
    243   pwg_query($q); 
    244  
    245   upgrade_211(); 
    246 } 
    247  
    248  
    249 /* upgrade from branch 2.11 to 2.12 */ 
    250 /* ******************************** */ 
    251 function upgrade_211() 
    252 { 
    253         global $conf; 
    254  
    255   $conf_UAM = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); 
    256  
    257   if ((!isset($conf_UAM[14]) and !isset($conf_UAM[15])) and !isset($conf_UAM[16]) and !isset($conf_UAM[17])) 
    258   { 
    259     $upgrade_UAM = $conf_UAM[0].';'.$conf_UAM[1].';'.$conf_UAM[2].';'.$conf_UAM[3].';'.$conf_UAM[4].';'.$conf_UAM[5].';'.$conf_UAM[6].';'.$conf_UAM[7].';'.$conf_UAM[8].';'.$conf_UAM[9].';'.$conf_UAM[10].';'.$conf_UAM[11].';'.$conf_UAM[12].';'.$conf_UAM[13].';false;100;false;false;10;Hello. 
    260          
    261 This is a reminder because a very long time passed since your last visit on our gallery. If you do not want anymore to use your access account, please let us know by replying to this email. Your account will be deleted. 
    262  
    263 On receipt of this message and no new visit within 15 days, we would be obliged to automatically delete your account. 
    264  
    265 Best regards, 
    266  
    267 The admin of the gallery.'; 
    268                  
    269                 $query = ' 
    270 UPDATE '.CONFIG_TABLE.' 
    271 SET value="'.$upgrade_UAM.'" 
    272 WHERE param="nbc_UserAdvManager" 
    273 LIMIT 1 
    274 ;'; 
    275                 pwg_query($query); 
    276   } 
    277    
    278         $q = " 
    279 CREATE TABLE IF NOT EXISTS ".USER_LASTVISIT_TABLE." ( 
    280   user_id SMALLINT(5) NOT NULL DEFAULT '0', 
    281   lastvisit DATETIME NULL DEFAULT NULL, 
    282   reminder ENUM('true','false') NULL, 
    283 PRIMARY KEY (`user_id`) 
    284   ) 
    285 ;"; 
    286   pwg_query($q); 
    287  
    288   upgrade_212(); 
    289 } 
    290  
    291  
    292 /* upgrade from branch 2.12 to 2.13 */ 
    293 /* ******************************** */ 
    294 function upgrade_212() 
    295 { 
    296 /* Create missing table */ 
    297   $query = " 
    298 ALTER TABLE ".USER_CONFIRM_MAIL_TABLE." 
    299 ADD reminder ENUM('true', 'false') NULL DEFAULT NULL 
    300 ;"; 
    301    
    302   pwg_query($query); 
    303  
    304 /* Upgrade plugin configuration */ 
    305         global $conf; 
    306  
    307   $conf_UAM = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); 
    308  
    309   if ((!isset($conf_UAM[20]))) 
    310   { 
    311     $upgrade_UAM = $conf_UAM[0].';'.$conf_UAM[1].';'.$conf_UAM[2].';'.$conf_UAM[3].';'.$conf_UAM[4].';'.$conf_UAM[5].';'.$conf_UAM[6].';'.$conf_UAM[7].';'.$conf_UAM[8].';'.$conf_UAM[9].';'.$conf_UAM[10].';'.$conf_UAM[11].';'.$conf_UAM[12].';'.$conf_UAM[13].';'.$conf_UAM[14].';'.$conf_UAM[15].';'.$conf_UAM[16].';'.$conf_UAM[17].';'.$conf_UAM[18].';'.$conf_UAM[19].';false'; 
    312                  
    313                 $query = ' 
    314 UPDATE '.CONFIG_TABLE.' 
    315 SET value="'.$upgrade_UAM.'" 
    316 WHERE param="nbc_UserAdvManager" 
    317 LIMIT 1 
    318 ;'; 
    319                 pwg_query($query); 
    320      
    321     upgrade_213(); 
    322   } 
    323 } 
    324  
    325  
    326 /* upgrade from branch 2.13 to 2.14 */ 
    327 /* ******************************** */ 
    328 function upgrade_213() 
    329 { 
    330         global $conf; 
    331    
    332   $conf_UAM = explode(';', $conf['nbc_UserAdvManager']); 
    333  
    334   $upgrade_UAM = array($conf_UAM[0],$conf_UAM[1],$conf_UAM[2],$conf_UAM[3],$conf_UAM[4],$conf_UAM[5],$conf_UAM[6],$conf_UAM[7],$conf_UAM[8],$conf_UAM[9],$conf_UAM[10],$conf_UAM[11],$conf_UAM[12],$conf_UAM[13],$conf_UAM[14],$conf_UAM[15],$conf_UAM[16],$conf_UAM[17],$conf_UAM[18],$conf_UAM[19],$conf_UAM[20],'false'); 
    335  
    336   $query = ' 
    337 UPDATE '.CONFIG_TABLE.' 
    338   SET value = "'.addslashes(serialize($upgrade_UAM)).'" 
    339   WHERE param = "nbc_UserAdvManager" 
    340 ;'; 
    341   pwg_query($query); 
    342    
    343   if (unserialize($conf['nbc_UserAdvManager_ConfirmMail']) === false) 
    344   { 
    345     $data = explode(';', $conf['nbc_UserAdvManager_ConfirmMail']); 
    346  
    347     $query = ' 
    348 UPDATE '.CONFIG_TABLE.' 
    349   SET value = "'.addslashes(serialize($data)).'" 
    350   WHERE param = "nbc_UserAdvManager_ConfirmMail" 
    351 ;'; 
    352     pwg_query($query); 
    353      
    354     upgrade_214_1(); 
    355   } 
    356 } 
    357  
    358 function upgrade_214_1() 
    359 { 
    360   global $conf; 
    361  
    362 /* Changing parameter name */ 
    363   $q = ' 
    364 UPDATE '.CONFIG_TABLE.' 
    365 SET param = "UserAdvManager" 
    366 WHERE param = "nbc_UserAdvManager" 
    367 ;'; 
    368   pwg_query($q); 
    369    
    370   $q = ' 
    371 UPDATE '.CONFIG_TABLE.' 
    372 SET param = "UserAdvManager_ConfirmMail" 
    373 WHERE param = "nbc_UserAdvManager_ConfirmMail" 
    374 ;'; 
    375   pwg_query($q); 
    376  
    377 /* Upgrading ConfirmMail options */ 
    378   $query = ' 
    379 SELECT value 
    380   FROM '.CONFIG_TABLE.' 
    381 WHERE param = "UserAdvManager_ConfirmMail" 
    382 ;'; 
    383  
    384   $result = pwg_query($query); 
    385   $conf_UAM_ConfirmMail = pwg_db_fetch_assoc($result); 
    386      
    387   $conf_ConfirmMail = unserialize($conf_UAM_ConfirmMail['value']); 
    388    
    389   $conf_ConfirmMail[5] ='Thank you to have confirmed your email address and your registration on the gallery. Have fun !'; 
    390   $conf_ConfirmMail[6] ='Your activation key is incorrect or expired or you have already validated your account, please contact the webmaster to fix this problem.'; 
    391    
    392   $update_conf = serialize($conf_ConfirmMail); 
    393      
    394   $query = ' 
    395       UPDATE '.CONFIG_TABLE.' 
    396                         SET value="'.addslashes($update_conf).'" 
    397                         WHERE param="UserAdvManager_ConfirmMail" 
    398                         LIMIT 1 
    399                 ;'; 
    400  
    401                 pwg_query($query); 
    402 } 
    403217?> 
Note: See TracChangeset for help on using the changeset viewer.