function plugin_barcode_install() { global $DB; $migration = new Migration(PLUGIN_BARCODE_VERSION); if (!file_exists(GLPI_PLUGIN_DOC_DIR . "/barcode")) { mkdir(GLPI_PLUGIN_DOC_DIR . "/barcode"); } $migration->renameTable("glpi_plugin_barcode_config", "glpi_plugin_barcode_configs"); if (!TableExists("glpi_plugin_barcode_configs")) { $query = "CREATE TABLE `glpi_plugin_barcode_configs` (\n `id` int(11) NOT NULL auto_increment,\n `type` varchar(20) collate utf8_unicode_ci default NULL,\n PRIMARY KEY (`ID`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query) or die("error creating glpi_plugin_barcode_configs " . $DB->error()); $query = "INSERT INTO `glpi_plugin_barcode_configs` \n (`id`, `type`)\n VALUES\n ('1', 'code128')"; $DB->query($query) or die("error populate glpi_plugin_barcode_configs " . $DB->error()); } $migration->renameTable("glpi_plugin_barcode_config_type", "glpi_plugin_barcode_configs_types"); if (!TableExists("glpi_plugin_barcode_configs_types")) { $query = "CREATE TABLE `glpi_plugin_barcode_configs_types` (\n `id` int(11) NOT NULL auto_increment,\n `type` varchar(20) collate utf8_unicode_ci default NULL,\n `size` varchar(20) collate utf8_unicode_ci default NULL,\n `orientation` varchar(9) collate utf8_unicode_ci default NULL,\n `marginTop` int(11) NULL,\n `marginBottom` int(11) NULL,\n `marginLeft` int(11) NULL,\n `marginRight` int(11) NULL,\n `marginHorizontal` int(11) NULL,\n `marginVertical` int(11) NULL,\n `maxCodeWidth` int(11) NULL,\n `maxCodeHeight` int(11) NULL,\n PRIMARY KEY (`ID`),\n UNIQUE (`type`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; $DB->query($query) or die("error creating glpi_plugin_barcode_configs_types " . $DB->error()); $query = "INSERT INTO `glpi_plugin_barcode_configs_types`\n (`type`, `size`, `orientation`,\n `marginTop`, `marginBottom`, `marginLeft`, `marginRight`,\n `marginHorizontal`, `marginVertical`, `maxCodeWidth`, `maxCodeHeight`)\n VALUES\n ('Code39', 'A4', 'Portrait',\n '30', '30', '30', '30',\n '25', '30', '128', '50'),\n ('code128', 'A4', 'Portrait',\n '30', '30', '30', '30',\n '25', '30', '110', '70'),\n ('ean13', 'A4', 'Portrait',\n '30', '30', '30', '30',\n '25', '30', '110', '70'),\n ('int25', 'A4', 'Portrait',\n '30', '30', '30', '30',\n '25', '30', '110', '70'),\n ('postnet', 'A4', 'Portrait',\n '30', '30', '30', '30',\n '25', '30', '110', '70'),\n ('upca', 'A4', 'Portrait',\n '30', '30', '30', '30',\n '25', '30', '110', '70'),\n ('QRcode', 'A4', 'Portrait',\n '30', '30', '30', '30',\n '25', '30', '110', '100')"; $DB->query($query) or die("error populate glpi_plugin_barcode_configs_types " . $DB->error()); } if (countElementsInTable("glpi_plugin_barcode_configs_types", "`type`='QRcode'") == 0) { $query = "INSERT INTO `glpi_plugin_barcode_configs_types`\n (`type`, `size`, `orientation`,\n `marginTop`, `marginBottom`, `marginLeft`, `marginRight`,\n `marginHorizontal`, `marginVertical`, `maxCodeWidth`, `maxCodeHeight`)\n VALUES\n ('QRcode', 'A4', 'Portrait',\n '30', '30', '30', '30',\n '25', '30', '110', '100')"; $DB->query($query) or die("error populate glpi_plugin_barcode_configs_types " . $DB->error()); } if (!TableExists("glpi_plugin_barcode_profiles")) { $query = "CREATE TABLE `glpi_plugin_barcode_profiles` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `profile` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\n `generate` char(1) COLLATE utf8_unicode_ci DEFAULT NULL,\n `config` char(1) COLLATE utf8_unicode_ci DEFAULT NULL,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; $DB->query($query) or die("error populate glpi_plugin_barcode_profiles " . $DB->error()); } // Give right to current Profile include_once GLPI_ROOT . '/plugins/barcode/inc/profile.class.php'; $prof = new PluginBarcodeProfile(); $prof->add(array('id' => $_SESSION['glpiactiveprofile']['id'], 'profile' => $_SESSION['glpiactiveprofile']['name'], 'generate' => 1, 'config' => 1)); return true; }
Plugin Barcode 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Plugin Barcode. If not, see <http://www.gnu.org/licenses/>. ------------------------------------------------------------------------ @package Plugin Barcode @author David Durieux @co-author @copyright Copyright (c) 2009-2013 Barcode plugin Development team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link https://forge.indepnet.net/projects/barscode @since 2009 ------------------------------------------------------------------------ */ include '../../../inc/includes.php'; Session::checkRight("profile", "r"); // Mainly usefull if not actived Plugin::load('barcode', true); $prof = new PluginBarcodeProfile(); if (isset($_POST["update_user_profile"])) { Session::checkRight("profile", "w"); $prof->update($_POST); Html::back(); }
function plugin_barcode_uninstall() { global $DB; if (TableExists("glpi_plugin_barcode_configs")) { $query = "DROP TABLE `glpi_plugin_barcode_configs`"; $DB->query($query) or die("error deleting glpi_plugin_barcode_configs"); } if (TableExists("glpi_plugin_barcode_configs_types")) { $query = "DROP TABLE `glpi_plugin_barcode_configs_types`"; $DB->query($query) or die("error deleting glpi_plugin_barcode_configs_types"); } if (TableExists("glpi_plugin_barcode_profiles")) { $query = "DROP TABLE `glpi_plugin_barcode_profiles`"; $DB->query($query) or die("error deleting glpi_plugin_barcode_profiles"); } include_once GLPI_ROOT . '/plugins/barcode/inc/profile.class.php'; PluginBarcodeProfile::removeRights(); return true; }