function upgrade_210_211()
{
    global $conf;
    $q = '
INSERT INTO ' . CONFIG_TABLE . ' (param, value, comment)
VALUES ("nbc_UserAdvManager_ConfirmMail","false;5;Hello.
		
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.

Note: After this period, your account will be permanently deleted.;false;Hello.

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.

Note: After this period, your account will be permanently deleted.","Parametres nbc_UserAdvManager - ConfirmMail")
  ;';
    pwg_query($q);
    upgrade_211_212();
}
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\\_%\'');
}