Ignore:
Timestamp:
Sep 22, 2012, 5:39:31 PM (12 years ago)
Author:
Eric
Message:

r17807 to r18159 merged from trunk to branch 2.40 - Thx to flop25 for his really appreciated and usefull help ;-)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/UserAdvManager/branches/2.40/include/upgradedb.inc.php

    r14730 r18160  
    137137  // Create missing table
    138138  // --------------------
    139   $query = "
    140 ALTER TABLE ".USER_CONFIRM_MAIL_TABLE."
    141 ADD reminder ENUM('true', 'false') NULL DEFAULT NULL
    142 ;";
     139  $query = '
     140ALTER TABLE '.USER_CONFIRM_MAIL_TABLE.'
     141ADD reminder ENUM("true", "false") NULL DEFAULT NULL
     142;';
    143143 
    144144  pwg_query($query);
     
    623623  conf_update_param('UserAdvManager', pwg_db_real_escape_string($update_conf));
    624624}
     625
     626
     627/* upgrade from 2.40.x to 2.40.6 */
     628/* ***************************** */
     629function upgrade_2400_2406()
     630{
     631  global $conf;
     632  $conf_UAM = unserialize($conf['UserAdvManager']);
     633 
     634  // Piwigo's native tables modifications for validation status - Add UAM_validated column
     635  // -------------------------------------------------------------------------------------
     636  $query = '
     637SHOW COLUMNS FROM '.USERS_TABLE.'
     638LIKE "UAM_validated"
     639;';
     640 
     641  $result = pwg_query($query);
     642
     643  if(!pwg_db_fetch_row($result))
     644  {
     645    $q = '
     646ALTER TABLE '.USERS_TABLE.'
     647ADD UAM_validated enum("true","false")
     648;';
     649    pwg_query($q);
     650  }
     651
     652  // Fill UAM_validated column with correct information for registered and validated  users
     653  // --------------------------------------------------------------------------------------
     654               
     655                // It goes for everybody registered in the gallery except for Guest and AC users (16 and 18)
     656  $query = '
     657SELECT DISTINCT u.id AS id, u.username AS username
     658FROM '.USERS_TABLE.' AS u
     659                INNER JOIN '.USER_INFOS_TABLE.' AS ui
     660                                ON u.id = ui.user_id
     661                LEFT JOIN '.USER_GROUP_TABLE.' AS ug
     662                                ON u.id = ug.user_id
     663WHERE u.id != 2
     664                AND u.username != \'16\'
     665                AND u.username != \'18\'';
     666
     667                if ($conf_UAM[3] <> '-1' and $conf_UAM[4] == '-1')
     668                {
     669                                $query.= '
     670AND ug.group_id = '.$conf_UAM[3];
     671                }
     672                if ($conf_UAM[3] == '-1' and $conf_UAM[4] <> '-1')
     673                {
     674                                $query.= '
     675AND ui.status = \''.$conf_UAM[4]."'";
     676                }
     677                if ($conf_UAM[3] <> '-1' and $conf_UAM[4] <> '-1')
     678                {
     679                                $query.= '
     680AND ug.group_id = '.$conf_UAM[3];
     681                }
     682                $query.= ';';
     683
     684                $result = pwg_query($query);
     685
     686                while($row = mysql_fetch_array($result))
     687                {
     688                                $query = '
     689UPDATE '.USERS_TABLE.'
     690SET UAM_validated=true
     691WHERE id = '.$row['id'].'
     692;';
     693                                pwg_query($query);
     694                }
     695
     696                // It goes to Webmaster too
     697                $query = '
     698UPDATE '.USERS_TABLE.'
     699SET UAM_validated=true
     700WHERE id = 1
     701;';
     702                pwg_query($query);
     703}
    625704?>
Note: See TracChangeset for help on using the changeset viewer.