Пример #1
0
function showLocationUpdateForm()
{
    global $DB, $CFG_GLPI;
    if (TableExists("glpi_dropdown_locations") && FieldExists("glpi_dropdown_locations", "parentID", false) || TableExists("glpi_locations") && FieldExists("glpi_locations", "locations_id", false)) {
        updateTreeDropdown();
        return true;
    }
    if (!isset($_POST['root'])) {
        $_POST['root'] = '';
    }
    if (!isset($_POST['car_sep'])) {
        $_POST['car_sep'] = '';
    }
    if (!TableExists("glpi_dropdown_locations_new")) {
        $query = " CREATE TABLE `glpi_dropdown_locations_new` (\n                  `ID` INT NOT NULL auto_increment,\n                  `name` VARCHAR(255) NOT NULL ,\n                  `parentID` INT NOT NULL ,\n                  `comments` TEXT NULL ,\n                 PRIMARY KEY (`ID`),\n                 UNIQUE KEY (`name`,`parentID`),\n                 KEY(`parentID`)) TYPE=MyISAM";
        $DB->queryOrDie($query, "LOCATION");
    }
    if (!isset($_POST["validate_location"])) {
        echo "<div class='center'>";
        echo "<h4>" . __('Locations update') . "</h4>";
        echo "<p>" . __('The new structure is hierarchical') . "</p>";
        echo "<p>" . __('Provide a delimiter in order to automate the new hierarchy generation.') . "<br>";
        echo __('You can also specify a root location which will include all the generated locations.');
        echo "</p>";
        echo "<form action='" . $CFG_GLPI["root_doc"] . "/install/update.php' method='post'>";
        echo "<p>" . __('Delimiter') . "&nbsp;" . "<input type='text' name='car_sep' value='" . $_POST['car_sep'] . "'></p>";
        echo "<p>" . __('Root location') . '&nbsp;' . "<input type='text' name='root' value='" . $_POST['root'] . "'></p>";
        echo "<input type='submit' class='submit' name='new_location' value=\"" . _sx('button', 'Post') . "\">";
        echo "<input type='hidden' name='from_update' value='from_update'>";
        Html::closeForm();
        echo "</div>";
    }
    if (isset($_POST["new_location"])) {
        location_create_new($_POST['car_sep'], $_POST['root']);
        echo "<h4>" . __('Actual locations') . " : </h4>";
        display_old_locations();
        echo "<h4>" . __('New hierarchy') . " : </h4>";
        display_new_locations();
        echo "<p>" . __("This is the new hierarchy. If it's complete approve it.") . "</p>";
        echo "<div class='center'>";
        echo "<form action='" . $CFG_GLPI["root_doc"] . "/install/update.php' method='post'>";
        echo "<input type='submit' class='submit' name='validate_location' value=\"" . _sx('button', 'Post') . "\">";
        echo "<input type='hidden' name='from_update' value='from_update'>";
        echo "</div>";
        Html::closeForm();
    } else {
        if (isset($_POST["validate_location"])) {
            validate_new_location();
            updateTreeDropdown();
            return true;
        } else {
            display_old_locations();
        }
    }
    exit;
}
Пример #2
0
function showLocationUpdateForm()
{
    global $DB, $LANG, $CFG_GLPI;
    if (TableExists("glpi_dropdown_locations") && FieldExists("glpi_dropdown_locations", "parentID") || TableExists("glpi_locations") && FieldExists("glpi_locations", "locations_id")) {
        updateTreeDropdown();
        return true;
    }
    if (!isset($_POST['root'])) {
        $_POST['root'] = '';
    }
    if (!isset($_POST['car_sep'])) {
        $_POST['car_sep'] = '';
    }
    if (!TableExists("glpi_dropdown_locations_new")) {
        $query = " CREATE TABLE `glpi_dropdown_locations_new` (\n                  `ID` INT NOT NULL auto_increment,\n                  `name` VARCHAR(255) NOT NULL ,\n                  `parentID` INT NOT NULL ,\n                  `comments` TEXT NULL ,\n                 PRIMARY KEY (`ID`),\n                 UNIQUE KEY (`name`,`parentID`),\n                 KEY(`parentID`)) TYPE=MyISAM";
        $DB->query($query) or die("LOCATION " . $DB->error());
    }
    if (!isset($_POST["validate_location"])) {
        echo "<div class='center'>";
        echo "<h4>" . $LANG['update'][130] . "</h4>";
        echo "<p>" . $LANG['update'][131] . "</p>";
        echo "<p>" . $LANG['update'][132] . "<br>" . $LANG['update'][133] . "</p>";
        echo "<form action='" . $CFG_GLPI["root_doc"] . "/install/update.php' method='post'>";
        echo "<p>" . $LANG['update'][134] . ": " . "<input type='text' name='car_sep' value='" . $_POST['car_sep'] . "'></p>";
        echo "<p>" . $LANG['update'][135] . ": " . "<input type='text' name='root' value='" . $_POST['root'] . "'></p>";
        echo "<input type='submit' class='submit' name='new_location' value=\"" . $LANG['buttons'][2] . "\">";
        echo "<input type='hidden' name='from_update' value='from_update'>";
        echo "</form>";
        echo "</div>";
    }
    if (isset($_POST["new_location"])) {
        location_create_new($_POST['car_sep'], $_POST['root']);
        echo "<h4>" . $LANG['update'][138] . " : </h4>";
        display_old_locations();
        echo "<h4>" . $LANG['update'][137] . " : </h4>";
        display_new_locations();
        echo "<p>" . $LANG['update'][136] . "</p>";
        echo "<form action='" . $CFG_GLPI["root_doc"] . "/install/update.php' method='post'>";
        echo "<input type='submit' class='submit' name='validate_location' value='" . $LANG['buttons'][2] . "'>";
        echo "<input type='hidden' name='from_update' value='from_update'>";
        echo "</form>";
    } else {
        if (isset($_POST["validate_location"])) {
            validate_new_location();
            updateTreeDropdown();
            return true;
        } else {
            display_old_locations();
        }
    }
    exit;
}