function plugin_positions_install() { global $DB, $CFG_GLPI; include_once GLPI_ROOT . "/plugins/positions/inc/profile.class.php"; if (!TableExists("glpi_plugin_positions_positions")) { $DB->runFile(GLPI_ROOT . "/plugins/positions/sql/empty-2.0.0.sql"); } //v1.0.0 to V2.0.0 if (TableExists("glpi_plugin_positions_positions_items") && !FieldExists("glpi_plugin_positions_positions_items", "items_id")) { $query = "ALTER TABLE `glpi_plugin_positions_positions` \n ADD `items_id` int(11) NOT NULL default '0' COMMENT 'RELATION to various tables, according to itemtype (id)';"; $result = $DB->query($query); $query = "ALTER TABLE `glpi_plugin_positions_positions` \n ADD `itemtype` varchar(100) collate utf8_unicode_ci NOT NULL COMMENT 'see .class.php file';"; $result = $DB->query($query); $query_ = "SELECT *\n FROM `glpi_plugin_positions_positions_items` "; $result_ = $DB->query($query_); if ($DB->numrows($result_) > 0) { while ($data = $DB->fetch_array($result_)) { $query = "UPDATE `glpi_plugin_positions_positions`\n SET `items_id` = '" . $data["items_id"] . "',\n `itemtype` = '" . $data["itemtype"] . "'\n WHERE `id` = '" . $data["id"] . "';"; $result = $DB->query($query); } } $query = "DROP TABLE `glpi_plugin_positions_positions_items`;"; $result = $DB->query($query); } //v1.0.0 to V2.0.0 if (!TableExists("glpi_plugin_positions_infos")) { $query = "CREATE TABLE `glpi_plugin_positions_infos` (\n `id` int(11) NOT NULL auto_increment,\n `name` varchar(255) collate utf8_unicode_ci default NULL,\n `entities_id` int(11) NOT NULL default '0',\n `is_recursive` tinyint(1) NOT NULL default '0',\n `itemtype` varchar(100) collate utf8_unicode_ci NOT NULL COMMENT 'see .class.php file',\n `fields` text collate utf8_unicode_ci,\n `comment` text collate utf8_unicode_ci,\n `notepad` longtext collate utf8_unicode_ci,\n `date_mod` datetime NULL default NULL,\n `is_active` tinyint(1) NOT NULL DEFAULT '0',\n `is_deleted` tinyint(1) NOT NULL default '0',\n PRIMARY KEY (`id`)\n) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; $result = $DB->query($query); } //to V3.0.0 if (TableExists("glpi_plugin_positions_positions") && FieldExists("glpi_plugin_positions_positions", "documents_id")) { $query = "ALTER TABLE `glpi_plugin_positions_positions` DROP `documents_id`;"; $result = $DB->query($query); } $rep_files_positions = GLPI_PLUGIN_DOC_DIR . "/positions"; if (!is_dir($rep_files_positions)) { mkdir($rep_files_positions); } $rep_files_positions_pics = GLPI_PLUGIN_DOC_DIR . "/positions/pics"; if (!is_dir($rep_files_positions_pics)) { mkdir($rep_files_positions_pics); } PluginPositionsProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); return true; }
Copyright (C) 2003-2011 by the Positions Development Team. https://forge.indepnet.net/projects/positions ------------------------------------------------------------------------- LICENSE This file is part of Positions. Positions 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. Positions 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 Positions. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; Session::checkRight("profile", "r"); $prof = new PluginPositionsProfile(); //Save profile if (isset($_POST['update'])) { $prof->update($_POST); Html::back(); }
function plugin_positions_uninstall() { global $DB; $tables = array("glpi_plugin_positions_positions", "glpi_plugin_positions_positions_items", "glpi_plugin_positions_imageitems", "glpi_plugin_positions_infos", "glpi_plugin_positions_configs"); foreach ($tables as $table) { $DB->query("DROP TABLE IF EXISTS `{$table}`;"); } $rep_files_positions = GLPI_PLUGIN_DOC_DIR . "/positions"; Toolbox::deleteDir($rep_files_positions); $tables_glpi = array("glpi_displaypreferences", "glpi_documents_items", "glpi_bookmarks", "glpi_logs", "glpi_tickets"); foreach ($tables_glpi as $table_glpi) { $DB->query("DELETE FROM `{$table_glpi}` WHERE `itemtype` = 'PluginPositionsPosition' ;"); } //Delete rights associated with the plugin $profileRight = new ProfileRight(); foreach (PluginPositionsProfile::getAllRights() as $right) { $profileRight->deleteByCriteria(array('name' => $right['field'])); } PluginPositionsMenu::removeRightsFromSession(); PluginPositionsProfile::removeRightsFromSession(); return true; }