Ejemplo n.º 1
0
function plugin_racks_install()
{
    global $DB;
    include_once GLPI_ROOT . "/plugins/racks/inc/profile.class.php";
    $update = false;
    if (!TableExists("glpi_plugin_rack_profiles") && !TableExists("glpi_plugin_racks_profiles")) {
        $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/empty-1.4.1.sql");
    } else {
        if (TableExists("glpi_plugin_rack_content") && !FieldExists("glpi_plugin_rack_content", "first_powersupply")) {
            $update = true;
            $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.0.2.sql");
            $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.1.0.sql");
        } else {
            if (!TableExists("glpi_plugin_racks_profiles")) {
                $update = true;
                $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.1.0.sql");
            }
        }
    }
    //from 1.1 version
    if (TableExists("glpi_plugin_racks_racks") && !FieldExists("glpi_plugin_racks_racks", "otherserial")) {
        $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.2.1.sql");
    }
    if (TableExists("glpi_plugin_racks_racks") && !FieldExists("glpi_plugin_racks_racks", "users_id_tech")) {
        $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.3.0.sql");
    }
    if (!TableExists("glpi_plugin_racks_racktypes")) {
        $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.3.2.sql");
    }
    if (TableExists("glpi_plugin_racks_racktypes") && !FieldExists("glpi_plugin_racks_racktypes", "is_recursive")) {
        $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.4.1.sql");
    }
    if ($update) {
        $query_ = "SELECT *\n            FROM `glpi_plugin_racks_profiles` ";
        $result_ = $DB->query($query_);
        if ($DB->numrows($result_) > 0) {
            while ($data = $DB->fetch_array($result_)) {
                $query = "UPDATE `glpi_plugin_racks_profiles`\n                  SET `profiles_id` = '" . $data["id"] . "'\n                  WHERE `id` = '" . $data["id"] . "';";
                $result = $DB->query($query);
            }
        }
        $query = "ALTER TABLE `glpi_plugin_racks_profiles`\n               DROP `name` ;";
        $result = $DB->query($query);
        Plugin::migrateItemType(array(4450 => 'PluginRacksRack', 4451 => 'PluginRacksOther'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_racks_racks_items", "glpi_plugin_racks_itemspecifications"));
    }
    PluginRacksProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
    return true;
}
Ejemplo n.º 2
0
function plugin_racks_uninstall()
{
    global $DB;
    include_once GLPI_ROOT . "/plugins/racks/inc/profile.class.php";
    include_once GLPI_ROOT . "/plugins/racks/inc/menu.class.php";
    $migration = new Migration("1.6.1");
    $tables = array("glpi_plugin_racks_racks", "glpi_plugin_racks_racks_items", "glpi_plugin_racks_itemspecifications", "glpi_plugin_racks_rackmodels", "glpi_plugin_racks_roomlocations", "glpi_plugin_racks_connections", "glpi_plugin_racks_configs", "glpi_plugin_racks_others", "glpi_plugin_racks_othermodels", "glpi_plugin_racks_racktypes", "glpi_plugin_racks_rackstates");
    foreach ($tables as $table) {
        $migration->dropTable($table);
    }
    //old versions
    $tables = array("glpi_plugin_rack", "glpi_plugin_rack_content", "glpi_plugin_rack_device_spec", "glpi_plugin_rack_profiles", "glpi_plugin_racks_profiles", "glpi_plugin_rack_config", "glpi_dropdown_plugin_rack_room_locations", "glpi_dropdown_plugin_rack_ways", "glpi_plugin_rack_others", "glpi_dropdown_plugin_rack_others_type");
    foreach ($tables as $table) {
        $migration->dropTable($table);
    }
    $tables_glpi = array("glpi_displaypreferences", "glpi_documents_items", "glpi_bookmarks", "glpi_logs", "glpi_items_tickets", "glpi_dropdowntranslations");
    foreach ($tables_glpi as $table_glpi) {
        $DB->query("DELETE FROM `{$table_glpi}` WHERE `itemtype` LIKE 'PluginRacks%';");
    }
    //Delete rights associated with the plugin
    $profileRight = new ProfileRight();
    foreach (PluginRacksProfile::getAllRights() as $right) {
        $profileRight->deleteByCriteria(array('name' => $right['field']));
    }
    PluginRacksProfile::removeRightsFromSession();
    PluginRacksProfile::removeRightsFromDB();
    PluginRacksMenu::removeRightsFromSession();
    return true;
}
Ejemplo n.º 3
0
function plugin_racks_uninstall()
{
    include_once GLPI_ROOT . "/plugins/racks/inc/profile.class.php";
    include_once GLPI_ROOT . "/plugins/racks/inc/menu.class.php";
    $migration = new Migration("1.5.0");
    $tables = array("glpi_plugin_racks_racks", "glpi_plugin_racks_racks_items", "glpi_plugin_racks_itemspecifications", "glpi_plugin_racks_rackmodels", "glpi_plugin_racks_roomlocations", "glpi_plugin_racks_connections", "glpi_plugin_racks_configs", "glpi_plugin_racks_others", "glpi_plugin_racks_othermodels", "glpi_plugin_racks_racktypes", "glpi_plugin_racks_rackstates");
    foreach ($tables as $table) {
        $migration->dropTable($table);
    }
    //old versions
    $tables = array("glpi_plugin_rack", "glpi_plugin_rack_content", "glpi_plugin_rack_device_spec", "glpi_plugin_rack_profiles", "glpi_plugin_racks_profiles", "glpi_plugin_rack_config", "glpi_dropdown_plugin_rack_room_locations", "glpi_dropdown_plugin_rack_ways", "glpi_plugin_rack_others", "glpi_dropdown_plugin_rack_others_type");
    foreach ($tables as $table) {
        $migration->dropTable($table);
    }
    $itemtypes = array("DisplayPreference", "Document_Item", "Bookmark", "Log", "Ticket");
    foreach ($itemtypes as $itemtype) {
        $item = new $itemtype();
        $item->deleteByCriteria(array('itemtype' => 'PluginRacksRack'));
    }
    //Delete rights associated with the plugin
    $profileRight = new ProfileRight();
    foreach (PluginRacksProfile::getAllRights() as $right) {
        $profileRight->deleteByCriteria(array('name' => $right['field']));
    }
    PluginRacksProfile::removeRightsFromSession();
    PluginRacksProfile::removeRightsFromDB();
    PluginRacksMenu::removeRightsFromSession();
    return true;
}