function plugin_vip_install() { global $DB; $migration = new Migration(100); // Création de la table uniquement lors de la première installation if (!TableExists("glpi_plugin_vip_profiles")) { // Table des droits du profil $query = "CREATE TABLE `glpi_plugin_vip_profiles` (\n\t `id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_profiles (id)',\n\t `show_vip_tab` tinyint(1) collate utf8_unicode_ci default NULL,\n\t PRIMARY KEY (`id`)\n\t ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query) or die("Error creating Vip Profiles table" . $DB->error()); $migration->executeMigration(); //creation du premier accès nécessaire lors de l'installation du plugin include_once GLPI_ROOT . "/plugins/vip/inc/profile.class.php"; PluginVipProfile::createAdminAccess($_SESSION['glpiactiveprofile']['id']); } if (!TableExists("glpi_plugin_vip_groups")) { // $query = "CREATE TABLE `glpi_plugin_vip_groups` (\n `id` int(11) NOT NULL default 0 COMMENT 'RELATION to glpi_groups(id)',\n `isvip` tinyint(1) default '0',\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query) or die("Erreur lors de la création de la table des groupes vip " . $DB->error()); $query = "INSERT INTO `glpi_plugin_vip_groups`\n (`id`, `isvip`)\n VALUES ('0', '0')"; $DB->query($query) or die("Erreur lors de l'insertion des valeurs par défaut dans la table des groupes vip " . $DB->error()); } if (!TableExists("glpi_plugin_vip_tickets")) { $query = "CREATE TABLE glpi_plugin_vip_tickets (\n\t\t\t\t id int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_tickets (id)',\n\t\t\t\t isvip tinyint(1) default '0',\n\t\t\t\t PRIMARY KEY (`id`)\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query) or die("Error creating Vip Tickets table"); } $query = "INSERT INTO glpi_plugin_vip_tickets\n\t\t\t\t SELECT id, '0'\n\t\t\t\t\t FROM glpi_tickets\n\t\t ON DUPLICATE KEY\n\t\t\t\t UPDATE isvip = '0'"; $DB->query($query) or die("Error inserting ticket in Vip Tickets table"); $migration->executeMigration(); return true; }
<?php include "../../../inc/includes.php"; Session::checkRight("profile", "r"); $prof = new PluginVipProfile(); if (isset($_POST['update_user_profile'])) { $prof->update($_POST); Html::back(); }