function plugin_ideabox_install() { global $DB; include_once GLPI_ROOT . "/plugins/ideabox/inc/profile.class.php"; $install = false; $update78 = false; $update80 = false; if (!TableExists("glpi_plugin_ideabox_profiles") && !TableExists("glpi_plugin_ideabox_ideaboxes")) { $install = true; $DB->runFile(GLPI_ROOT . "/plugins/ideabox/sql/empty-1.8.0.sql"); } else { if (TableExists("glpi_plugin_ideabox_mailing") && !FieldExists("glpi_plugin_ideabox", "begin_date")) { $update78 = true; $update80 = true; $DB->runFile(GLPI_ROOT . "/plugins/ideabox/sql/update-1.5.sql"); $DB->runFile(GLPI_ROOT . "/plugins/ideabox/sql/update-1.6.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/ideabox/sql/update-1.7.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/ideabox/sql/update-1.7.1.sql"); } else { if (TableExists("glpi_plugin_ideabox_profiles") && FieldExists("glpi_plugin_ideabox_profiles", "interface")) { $update78 = true; $update80 = true; $DB->runFile(GLPI_ROOT . "/plugins/ideabox/sql/update-1.6.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/ideabox/sql/update-1.7.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/ideabox/sql/update-1.7.1.sql"); } else { if (!TableExists("glpi_plugin_ideabox_ideaboxs") && !FieldExists("glpi_plugin_ideabox_profiles", "profiles_id")) { $update78 = true; $update80 = true; $DB->runFile(GLPI_ROOT . "/plugins/ideabox/sql/update-1.7.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/ideabox/sql/update-1.7.1.sql"); } else { if (!TableExists("glpi_plugin_ideabox_ideaboxes")) { $update80 = true; $DB->runFile(GLPI_ROOT . "/plugins/ideabox/sql/update-1.7.1.sql"); } } } } } if ($install || $update78) { //Do One time on 0.78 $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginIdeaboxIdeabox' AND `name` = 'Idea'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n VALUES(NULL, " . $itemtype . ", '','##lang.ideabox.title##',\n '##lang.ideabox.url## : ##ideabox.url##\n ##lang.ideabox.entity## : ##ideabox.entity##\n ##IFideabox.name####lang.ideabox.name## : ##ideabox.name##\n ##ENDIFideabox.name##\n ##IFideabox.comment####lang.ideabox.comment## : ##ideabox.comment##\n ##ENDIFideabox.comment##\n\n ##FOREACHupdates##----------\n ##lang.update.title##:\n ##IFupdate.name####lang.ideabox.name## : ##update.name####ENDIFupdate.name##\n ##IFupdate.comment##\n ##lang.ideabox.comment## : ##update.comment##\n ##ENDIFupdate.comment##\n ----------##ENDFOREACHupdates##\n\n ##lang.comment.title##\n ----------\n ##FOREACHcomments##\n ##IFcomment.name####lang.comment.name## : ##comment.name####ENDIFcomment.name##\n ##IFcomment.author####lang.comment.author## : ##comment.author####ENDIFcomment.author##\n ##IFcomment.datecomment####lang.comment.datecomment## : ##comment.datecomment####ENDIFcomment.datecomment##\n ##IFcomment.comment####lang.comment.comment## : ##comment.comment####ENDIFcomment.comment##\n -------\n ##ENDFOREACHcomments##',\n '<p><strong>##lang.ideabox.url##</strong> : <a href=\"##ideabox.url##\">##ideabox.url##</a><br /><br /><strong>##lang.ideabox.entity##</strong> : ##ideabox.entity##<br /> ##IFideabox.name##<strong>##lang.ideabox.name##</strong> : ##ideabox.name####ENDIFideabox.name##<br /><br /> ##IFideabox.comment##<strong>##lang.ideabox.comment##</strong> : ##ideabox.comment####ENDIFideabox.comment##<br /><br />##FOREACHupdates##----------<br /><strong>##lang.update.title## :</strong><br />##IFupdate.name##<strong>##lang.ideabox.name##</strong> : ##update.name####ENDIFupdate.name##<br />##IFupdate.comment##<br /><strong>##lang.ideabox.comment##</strong> : ##update.comment##<br />##ENDIFupdate.comment##<br />----------##ENDFOREACHupdates##<br /><br /><strong>##lang.comment.title## :</strong><br />----------<br />##FOREACHcomments####IFcomment.name##<strong>##lang.comment.name##</strong> : ##comment.name####ENDIFcomment.name##<br />##IFcomment.author##<strong>##lang.comment.author##</strong> : ##comment.author####ENDIFcomment.author##<br />##IFcomment.datecomment##<strong>##lang.comment.datecomment##</strong> : ##comment.datecomment####ENDIFcomment.datecomment##<br />##IFcomment.comment##<strong>##lang.comment.comment##</strong> : ##comment.comment####ENDIFcomment.comment##<br />----------<br />##ENDFOREACHcomments##</p>');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'New Idea', 0, 'PluginIdeaboxIdeabox', 'new',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Update Idea', 0, 'PluginIdeaboxIdeabox', 'update',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Delete Idea', 0, 'PluginIdeaboxIdeabox', 'delete',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'New Idea Comment', 0, 'PluginIdeaboxIdeabox', 'newcomment',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Update Idea Comment', 0, 'PluginIdeaboxIdeabox', 'updatecomment',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Delete Idea Comment', 0, 'PluginIdeaboxIdeabox', 'deletecomment',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); } if ($update78) { $query_ = "SELECT *\n FROM `glpi_plugin_ideabox_profiles` "; $result_ = $DB->query($query_); if ($DB->numrows($result_) > 0) { while ($data = $DB->fetch_array($result_)) { $query = "UPDATE `glpi_plugin_ideabox_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "';"; $result = $DB->query($query); } } $query = "ALTER TABLE `glpi_plugin_ideabox_profiles`\n DROP `name` ;"; $result = $DB->query($query); Plugin::migrateItemType(array(4900 => 'PluginIdeaboxIdeabox', 4901 => 'PluginIdeaboxIdeabox'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets")); } PluginIdeaboxProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); return true; }
Copyright (C) 2003-2011 by the Ideabox Development Team. https://forge.indepnet.net/projects/ideabox ------------------------------------------------------------------------- LICENSE This file is part of Ideabox. Ideabox 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. Ideabox 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 Ideabox. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; Session::checkRight("profile", "r"); $prof = new PluginIdeaboxProfile(); //Save profile if (isset($_POST['update'])) { $prof->update($_POST); Html::back(); }