function plugin_shellcommands_install() { global $DB; include_once GLPI_ROOT . "/plugins/shellcommands/inc/profile.class.php"; $update = false; if (!TableExists("glpi_plugin_cmd_profiles") && !TableExists("glpi_plugin_shellcommands_shellcommands")) { $DB->runFile(GLPI_ROOT . "/plugins/shellcommands/sql/empty-1.3.0.sql"); } else { if (TableExists("glpi_plugin_cmd_profiles") && !TableExists("glpi_plugin_cmd_path")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/shellcommands/sql/update-1.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/shellcommands/sql/update-1.2.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/shellcommands/sql/update-1.3.0.sql"); } else { if (TableExists("glpi_plugin_cmd_profiles") && FieldExists("glpi_plugin_cmd_profiles", "interface")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/shellcommands/sql/update-1.2.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/shellcommands/sql/update-1.3.0.sql"); } else { if (!TableExists("glpi_plugin_shellcommands_shellcommands")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/shellcommands/sql/update-1.3.0.sql"); } } } } if ($update) { $query_ = "SELECT *\n FROM `glpi_plugin_shellcommands_profiles` "; $result_ = $DB->query($query_); if ($DB->numrows($result_) > 0) { while ($data = $DB->fetch_array($result_)) { $query = "UPDATE `glpi_plugin_shellcommands_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "';"; $result = $DB->query($query); } } $query = "ALTER TABLE `glpi_plugin_shellcommands_profiles`\n DROP `name` ;"; $result = $DB->query($query); } PluginShellcommandsProfile::createfirstAccess($_SESSION['glpiactiveprofile']['id']); return true; }
function plugin_shellcommands_uninstall() { global $DB; $tables = array("glpi_plugin_shellcommands_shellcommands", "glpi_plugin_shellcommands_shellcommands_items", "glpi_plugin_shellcommands_commandgroups", "glpi_plugin_shellcommands_commandgroups_items", "glpi_plugin_shellcommands_profiles", "glpi_plugin_shellcommands_shellcommandpaths"); foreach ($tables as $table) { $DB->query("DROP TABLE IF EXISTS `{$table}`;"); } //old versions $tables = array("glpi_plugin_cmd", "glpi_plugin_cmd_device", "glpi_plugin_cmd_setup", "glpi_plugin_cmd_profiles", "glpi_plugin_cmd_path"); foreach ($tables as $table) { $DB->query("DROP TABLE IF EXISTS `{$table}`;"); } $tables_glpi = array("glpi_displaypreferences", "glpi_bookmarks"); foreach ($tables_glpi as $table_glpi) { $DB->query("DELETE FROM `{$table_glpi}` WHERE `itemtype` = 'PluginShellcommandsShellcommand';"); } include_once GLPI_ROOT . "/plugins/shellcommands/inc/profile.class.php"; PluginShellcommandsProfile::removeRightsFromSession(); PluginShellcommandsProfile::removeRightsFromDB(); return true; }
Copyright (C) 2003-2011 by the Shellcommands Development Team. https://forge.indepnet.net/projects/shellcommands ------------------------------------------------------------------------- LICENSE This file is part of Shellcommands. Shellcommands is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Shellcommands is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with shellcommands. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; Session::checkRight("profile", "r"); $prof = new PluginShellcommandsProfile(); //Save profile if (isset($_POST['update'])) { $prof->update($_POST); Html::back(); }