*    2.0.1 Nothing
 *    2.0.2 config version field 2.0.2
 *    2.1.0 config version field 2.1.0
 **/
if (Session::haveRight('config', UPDATE) && Session::haveRight('profile', UPDATE)) {
    $config = new PluginFusioninventoryConfig();
    if (!TableExists("glpi_plugin_fusioninventory_agents")) {
        PluginFusioninventorySetup::update("1.1.0");
    }
    if (!TableExists("glpi_plugin_fusioninventory_config_discovery")) {
        PluginFusioninventorySetup::update("2.0.0");
    }
    if (!FieldExists("glpi_plugin_fusioninventory_configs", "version")) {
        PluginFusioninventorySetup::update("2.0.2");
    }
    if (FieldExists("glpi_plugin_fusioninventory_configs", "version")) {
        if ($config->getValue('version') == "2.0.2" || $config->getValue('version') == "2.1.0") {
            $DB->query("UPDATE `glpi_plugin_fusioninventory_configs`\n                     SET `version` = '2.1.1'\n                     WHERE `id`=1");
        }
        PluginFusioninventorySetup::update("2.0.2");
        if ($config->getValue('version') == "0") {
            $DB->query("UPDATE `glpi_plugin_fusioninventory_configs`\n                     SET `version` = '2.1.1'\n                     WHERE `id`=1");
        }
    }
    Html::back();
} else {
    Html::header(__('Access denied'), $_SERVER['PHP_SELF'], "plugins", "fusioninventory");
    echo "<div align='center'><br><br><img src=\"" . $CFG_GLPI['root_doc'] . "/pics/warning.png\"\n              alt=\"warning\"><br><br>";
    echo "<b>" . __('Access denied') . "</b></div>";
    Html::footer();
}
Exemplo n.º 2
0
function plugin_fusioninventory_install()
{
    global $DB, $LANG, $CFG_GLPI;
    include_once GLPI_ROOT . "/inc/profile.class.php";
    /**
     *  List of all FusionInventorys versions :
     *    1.0.0
     *    1.1.0 non exists glpi_plugin_fusioninventory_agents (MySQL)
     *    2.0.0 non exists glpi_plugin_fusioninventory_config_discovery (MySQL)
     *    2.0.1 Nothing
     *    2.0.2 config version field 2.0.2
     *    2.1.0 config version field 2.1.0
     *    2.1.1 config version field 2.1.1
     **/
    if (!TableExists("glpi_plugin_tracker_config") && !TableExists("glpi_plugin_fusioninventory_config")) {
        PluginFusioninventorySetup::install("2.2.0");
    } else {
        if (TableExists("glpi_plugin_tracker_config")) {
            //$config = new PluginFusioninventoryConfig;
            if (!TableExists("glpi_plugin_tracker_agents")) {
                PluginFusioninventorySetup::update("1.1.0");
            }
            if (!TableExists("glpi_plugin_tracker_config_discovery")) {
                PluginFusioninventorySetup::update("2.0.0");
            }
            if (!FieldExists("glpi_plugin_tracker_config", "version")) {
                PluginFusioninventorySetup::update("2.0.2");
            }
            if (FieldExists("glpi_plugin_tracker_config", "version")) {
                $query = "SELECT version FROM glpi_plugin_tracker_config LIMIT 1";
                $result = $DB->query($query);
                $data = $DB->fetch_assoc($result);
                if ($data['version'] == "0") {
                    $DB->query("UPDATE `glpi_plugin_tracker_config`\n                        SET `version` = '2.0.2'\n                        WHERE `ID`='1';");
                    $data['version'] = "2.0.2";
                }
                if ($data['version'] == "2.0.2") {
                    $DB->query("UPDATE `glpi_plugin_tracker_config`\n                        SET `version` = '2.1.0'\n                        WHERE `ID`='1';");
                    $data['version'] = "2.1.0";
                }
                if ($data['version'] == "2.1.0") {
                    PluginFusioninventorySetup::update("2.1.1");
                    $DB->query("UPDATE `glpi_plugin_tracker_config` \n                        SET version = '2.1.1'\n                        WHERE ID=1");
                    $data['version'] = "2.1.1";
                }
                if ($data['version'] == "2.1.1") {
                    //PluginFusioninventorySetup::update("2.1.2");
                    $DB->query("UPDATE `glpi_plugin_tracker_config`\n                        SET `version` = '2.1.2'\n                        WHERE `ID`='1';");
                    $data['version'] = "2.1.2";
                }
                if ($data['version'] == "2.1.2") {
                    //PluginFusioninventorySetup::update("2.1.2");
                    $DB->query("UPDATE `glpi_plugin_tracker_config`\n                        SET `version` = '2.1.3'\n                        WHERE `ID`='1';");
                    $data['version'] = "2.1.3";
                }
                if ($data['version'] == "2.1.3") {
                    PluginFusioninventorySetup::update("2.2.0");
                    $DB->query("UPDATE `glpi_plugin_fusioninventory_config`\n                        SET `version` = '2.2.0'\n                        WHERE `ID`='1';");
                }
            }
        } else {
            if (TableExists("glpi_plugin_fusioninventory_config")) {
            }
        }
    }
    return true;
}