コード例 #1
0
function plugin_manufacturersimports_install()
{
    global $DB;
    include_once GLPI_ROOT . "/plugins/manufacturersimports/inc/profile.class.php";
    include_once GLPI_ROOT . "/plugins/manufacturersimports/inc/config.class.php";
    $migration = new Migration("1.7.0");
    $update = false;
    //Root of SQL files for DB installation or upgrade
    $sql_root = GLPI_ROOT . "/plugins/manufacturersimports/sql/";
    if (!TableExists("glpi_plugin_manufacturersimports_configs")) {
        $DB->runFile($sql_root . "/empty-1.7.0.sql");
    } else {
        if (TableExists("glpi_plugin_suppliertag_config") && !FieldExists("glpi_plugin_suppliertag_config", "FK_entities")) {
            $update = true;
            $DB->runFile($sql_root . "/update-1.1.sql");
            $DB->runFile($sql_root . "/update-1.2.0.sql");
            $DB->runFile($sql_root . "/update-1.3.0.sql");
            $DB->runFile($sql_root . "/update-1.4.1.sql");
            $DB->runFile($sql_root . "/update-1.5.0.sql");
            $DB->runFile($sql_root . "/update-1.7.0.sql");
        } else {
            if (TableExists("glpi_plugin_suppliertag_profiles") && FieldExists("glpi_plugin_suppliertag_profiles", "interface")) {
                $update = true;
                $DB->runFile($sql_root . "/update-1.2.0.sql");
                $DB->runFile($sql_root . "/update-1.3.0.sql");
                $DB->runFile($sql_root . "/update-1.4.1.sql");
                $DB->runFile($sql_root . "/update-1.5.0.sql");
                $DB->runFile($sql_root . "/update-1.7.0.sql");
            } else {
                if (!TableExists("glpi_plugin_manufacturersimports_profiles") && !FieldExists("glpi_plugin_manufacturersimports_configs", "supplier_key")) {
                    $update = true;
                    $DB->runFile($sql_root . "/update-1.3.0.sql");
                    $DB->runFile($sql_root . "/update-1.4.1.sql");
                    $DB->runFile($sql_root . "/update-1.5.0.sql");
                    $DB->runFile($sql_root . "/update-1.7.0.sql");
                } else {
                    if (!FieldExists("glpi_plugin_manufacturersimports_configs", "supplier_key")) {
                        $DB->runFile($sql_root . "/update-1.7.0.sql");
                    }
                }
            }
        }
    }
    $query = "UPDATE `glpi_plugin_manufacturersimports_configs` \n             SET `Supplier_url` = 'http://www.dell.com/support/troubleshooting/us/en/04/Index?c=us&l=en&s=bsd&cs=04&t=system&ServiceTag=' \n             WHERE `name` ='" . PluginManufacturersimportsConfig::DELL . "'";
    $DB->query($query);
    if ($update) {
        foreach ($DB->request('glpi_plugin_manufacturersimports_profiles') as $data) {
            $query = "UPDATE `glpi_plugin_manufacturersimports_profiles`\n                   SET `profiles_id` = '" . $data["id"] . "'\n                   WHERE `id` = '" . $data["id"] . "';";
            $DB->query($query);
        }
        $migration->dropField('glpi_plugin_manufacturersimports_profiles', 'name');
        Plugin::migrateItemType(array(2150 => 'PluginManufacturersimportsModel', 2151 => 'PluginManufacturersimportsConfig'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_manufacturersimports_models", "glpi_plugin_manufacturersimports_logs"));
    }
    //Migrate profiles to the system introduced in 0.85
    PluginManufacturersimportsProfile::initProfile();
    PluginManufacturersimportsProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
    //Drop old profile table : not used anymore
    $migration->dropTable('glpi_plugin_manufacturersimports_profiles');
    return true;
}
コード例 #2
0
ファイル: hook.php プロジェクト: geldarr/hack-space
function plugin_manufacturersimports_install()
{
    global $DB;
    include_once GLPI_ROOT . "/plugins/manufacturersimports/inc/profile.class.php";
    $update = false;
    if (!TableExists("glpi_plugin_suppliertag_profiles") && !TableExists("glpi_plugin_manufacturersimports_profiles")) {
        $DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/empty-1.5.0.sql");
    } else {
        if (TableExists("glpi_plugin_suppliertag_config") && !FieldExists("glpi_plugin_suppliertag_config", "FK_entities")) {
            $update = true;
            $DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.1.sql");
            $DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.2.0.sql");
            $DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.3.0.sql");
            $DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.4.1.sql");
            $DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.5.0.sql");
        } else {
            if (TableExists("glpi_plugin_suppliertag_profiles") && FieldExists("glpi_plugin_suppliertag_profiles", "interface")) {
                $update = true;
                $DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.2.0.sql");
                $DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.3.0.sql");
                $DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.4.1.sql");
                $DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.5.0.sql");
            } else {
                if (!TableExists("glpi_plugin_manufacturersimports_profiles")) {
                    $update = true;
                    $DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.3.0.sql");
                    $DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.4.1.sql");
                    $DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.5.0.sql");
                }
            }
        }
    }
    $query = "UPDATE `glpi_plugin_manufacturersimports_configs` \n            SET `Supplier_url` = 'http://www.dell.com/support/troubleshooting/us/en/04/Index?c=us&l=en&s=bsd&cs=04&t=system&ServiceTag=' \n            WHERE `name` ='Dell'";
    $DB->query($query);
    if ($update) {
        $query_ = "SELECT *\n            FROM `glpi_plugin_manufacturersimports_profiles` ";
        $result_ = $DB->query($query_);
        if ($DB->numrows($result_) > 0) {
            while ($data = $DB->fetch_array($result_)) {
                $query = "UPDATE `glpi_plugin_manufacturersimports_profiles`\n                  SET `profiles_id` = '" . $data["id"] . "'\n                  WHERE `id` = '" . $data["id"] . "';";
                $result = $DB->query($query);
            }
        }
        $query = "ALTER TABLE `glpi_plugin_manufacturersimports_profiles`\n               DROP `name` ;";
        $result = $DB->query($query);
        Plugin::migrateItemType(array(2150 => 'PluginManufacturersimportsModel', 2151 => 'PluginManufacturersimportsConfig'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_manufacturersimports_models", "glpi_plugin_manufacturersimports_logs"));
    }
    PluginManufacturersimportsProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
    return true;
}