Exemplo n.º 1
0
function plugin_environment_install()
{
    global $DB;
    include_once GLPI_ROOT . "/plugins/environment/inc/profile.class.php";
    $update = false;
    if (TableExists("glpi_plugin_environment_profiles") && FieldExists("glpi_plugin_environment_profiles", "interface")) {
        $update = true;
        $DB->runFile(GLPI_ROOT . "/plugins/environment/sql/update-1.3.0.sql");
        $DB->runFile(GLPI_ROOT . "/plugins/environment/sql/update-1.4.0.sql");
    } else {
        if (TableExists("glpi_plugin_environment_profiles") && FieldExists("glpi_plugin_environment_profiles", "connections")) {
            $update = true;
            $DB->runFile(GLPI_ROOT . "/plugins/environment/sql/update-1.4.0.sql");
        }
    }
    if ($update) {
        //Do One time on 0.78
        $query_ = "SELECT *\n            FROM `glpi_plugin_environment_profiles` ";
        $result_ = $DB->query($query_);
        if ($DB->numrows($result_) > 0) {
            while ($data = $DB->fetch_array($result_)) {
                $query = "UPDATE `glpi_plugin_environment_profiles`\n                  SET `profiles_id` = '" . $data["id"] . "'\n                  WHERE `id` = '" . $data["id"] . "';";
                $result = $DB->query($query);
            }
        }
        $query = "ALTER TABLE `glpi_plugin_environment_profiles`\n               DROP `name` ;";
        $result = $DB->query($query);
    }
    PluginEnvironmentProfile::initProfile();
    PluginEnvironmentProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
    $migration = new Migration("1.8.0");
    $migration->dropTable('glpi_plugin_environment_profiles');
    $_SESSION["glpi_plugin_environment_installed"] = 1;
    return true;
}