function upgrade_214_215()
{
    global $conf;
    // Changing parameter name
    // -----------------------
    $q = '
UPDATE ' . CONFIG_TABLE . '
SET param = "UserAdvManager"
WHERE param = "nbc_UserAdvManager"
;';
    pwg_query($q);
    $q = '
UPDATE ' . CONFIG_TABLE . '
SET param = "UserAdvManager_ConfirmMail"
WHERE param = "nbc_UserAdvManager_ConfirmMail"
;';
    pwg_query($q);
    // Upgrading ConfirmMail options
    // -----------------------------
    $query = '
SELECT value
  FROM ' . CONFIG_TABLE . '
WHERE param = "UserAdvManager_ConfirmMail"
;';
    $result = pwg_query($query);
    $conf_UAM_ConfirmMail = pwg_db_fetch_assoc($result);
    $conf_ConfirmMail = unserialize($conf_UAM_ConfirmMail['value']);
    $conf_ConfirmMail[5] = 'Thank you to have confirmed your email address and your registration on the gallery. Have fun !';
    $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.';
    $update_conf = serialize($conf_ConfirmMail);
    conf_update_param('UserAdvManager_ConfirmMail', pwg_db_real_escape_string($update_conf));
    upgrade_2153_2154();
}
function plugin_activate($id, $version, &$errors)
{
    global $conf;
    /* Cleaning obsolete files */
    /* *********************** */
    clean_obsolete_files();
    include_once UAM_PATH . 'include/upgradedb.inc.php';
    /* Check if old version is < 2.15 */
    /* ****************************** */
    $query = '
SELECT param
  FROM ' . CONFIG_TABLE . '
WHERE param = "nbc_UserAdvManager"
;';
    $count1 = pwg_db_num_rows(pwg_query($query));
    $query = '
SELECT *
  FROM ' . CONFIG_TABLE . '
WHERE param = "nbc_UserAdvManager_ConfirmMail"
;';
    $count2 = pwg_db_num_rows(pwg_query($query));
    /* If old params exist an upgrade is needed */
    /* **************************************** */
    if ($count1 == 1) {
        /* Check for upgrade from 2.10 to 2.11 */
        /* *********************************** */
        if ($count1 == 1 and $count2 == 0) {
            /* upgrade from branch 2.10 to 2.11 */
            /* ******************************** */
            upgrade_210_211();
        }
        /* Check for upgrade from 2.11 to 2.12 */
        /* *********************************** */
        if (!table_exist(USER_LASTVISIT_TABLE)) {
            /* upgrade from branch 2.11 to 2.12 */
            /* ******************************** */
            upgrade_211_212();
        }
        /* Check for upgrade from 2.12 to 2.13 */
        /* *********************************** */
        $fields = pwg_query('SHOW COLUMNS FROM ' . USER_CONFIRM_MAIL_TABLE . ';');
        $nb_fields = pwg_db_num_rows($fields);
        if ($nb_fields < 6) {
            /* upgrade from branch 2.12 to 2.13 */
            /* ******************************** */
            upgrade_212_213();
        }
        /* Serializing conf parameters - Available since 2.14.0 */
        /* **************************************************** */
        if (unserialize($conf['nbc_UserAdvManager']) === false) {
            /* upgrade from branch 2.13 to 2.14 */
            /* ******************************** */
            upgrade_213_214();
        }
        /* upgrade from branch 2.14 to 2.15 */
        /* ******************************** */
        upgrade_214_215();
    }
    /* Old version is > 2.15 */
    /* ********************* */
    $query = '
SELECT param
  FROM ' . CONFIG_TABLE . '
WHERE param = "UserAdvManager_Redir"
;';
    $count = pwg_db_num_rows(pwg_query($query));
    if ($count == 0) {
        upgrade_2153_2154();
    }
    /* Check for upgrade from 2.15 to 2.16 */
    /* *********************************** */
    $query = '
SELECT param
  FROM ' . CONFIG_TABLE . '
WHERE param = "UserAdvManager_Version"
;';
    $count = pwg_db_num_rows(pwg_query($query));
    if ($count == 0) {
        /* upgrade from branch 2.15 to 2.16 */
        /* ******************************** */
        upgrade_215_2160();
    }
    /* Check database upgrade since version 2.16.0 */
    /* ******************************************* */
    if (isset($conf['UserAdvManager_Version'])) {
        if (version_compare($conf['UserAdvManager_Version'], '2.20.0') < 0) {
            /* upgrade from branch 2.16 to 2.20 */
            /* ******************************** */
            upgrade_216_220();
        }
        if (version_compare($conf['UserAdvManager_Version'], '2.20.4') < 0) {
            /* upgrade from version 2.20.3 to 2.20.4 */
            /* ************************************* */
            upgrade_2203_2204();
        }
        if (version_compare($conf['UserAdvManager_Version'], '2.20.7') < 0) {
            /* upgrade from version 2.20.4 to 2.20.7 */
            /* ************************************* */
            upgrade_2204_2207();
        }
        if (version_compare($conf['UserAdvManager_Version'], '2.20.8') < 0) {
            /* upgrade from version 2.20.7 to 2.20.8 */
            /* ************************************* */
            upgrade_2207_2208();
        }
        if (version_compare($conf['UserAdvManager_Version'], '2.30.0') < 0) {
            /* upgrade from version 2.20.8 to 2.30.0 */
            /* ************************************* */
            upgrade_2208_2300();
        }
        if (version_compare($conf['UserAdvManager_Version'], '2.30.2') < 0) {
            /* upgrade from version 2.30.x to 2.30.2 */
            /* ************************************* */
            upgrade_2300_2302();
        }
        if (version_compare($conf['UserAdvManager_Version'], '2.40.0') < 0) {
            /* upgrade from version 2.30.x to 2.40.0 */
            /* ************************************* */
            upgrade_2300_2400();
        }
        if (version_compare($conf['UserAdvManager_Version'], '2.41.0') < 0) {
            /* upgrade from version 2.40.x to 2.41.0 */
            /* ************************************* */
            upgrade_2400_2410();
        }
        if (version_compare($conf['UserAdvManager_Version'], '2.50.0') < 0) {
            /* upgrade from version 2.41.x to 2.50.0 */
            /* ************************************* */
            upgrade_2410_2500();
        }
        if (version_compare($conf['UserAdvManager_Version'], '2.50.11') < 0) {
            /* upgrade from version 2.50.x to 2.50.11 */
            /* ************************************** */
            upgrade_2500_25011();
        }
        if (version_compare($conf['UserAdvManager_Version'], '2.51.0') < 0) {
            /* upgrade from version 2.50.x to 2.51.0 */
            /* ************************************* */
            upgrade_2500_2510();
        }
        if (version_compare($conf['UserAdvManager_Version'], '2.70.3') < 0) {
            /* upgrade from version 2.51.0 to 2.70.3 */
            /* ************************************* */
            upgrade_2510_2703();
        }
    }
    // Update plugin version number in #_config table and check consistency of #_plugins table
    // ---------------------------------------------------------------------------------------
    UAM_version_update();
    load_conf_from_db('param like \'UserAdvManager\\_%\'');
}