function plugin_domains_install() { global $DB; include_once GLPI_ROOT . "/plugins/domains/inc/profile.class.php"; $install = false; $update78 = false; $update80 = false; if (!TableExists("glpi_plugin_domain") && !TableExists("glpi_plugin_domains_domains")) { $install = true; $DB->runFile(GLPI_ROOT . "/plugins/domains/sql/empty-1.4.0.sql"); } else { if (TableExists("glpi_plugin_domain") && !FieldExists("glpi_plugin_domain", "recursive")) { $update78 = true; $update80 = true; $DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.2.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.2.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.3.0.sql"); } else { if (TableExists("glpi_plugin_domain_profiles") && FieldExists("glpi_plugin_domain_profiles", "interface")) { $update78 = true; $update80 = true; $DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.2.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.2.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.3.0.sql"); } else { if (TableExists("glpi_plugin_domain") && !FieldExists("glpi_plugin_domain", "helpdesk_visible")) { $update78 = true; $update80 = true; $DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.2.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.3.0.sql"); } else { if (!TableExists("glpi_plugin_domains_domains")) { $update78 = true; $update80 = true; $DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.3.0.sql"); } } } } } //from 1.3 version if (TableExists("glpi_plugin_domains_domains") && !FieldExists("glpi_plugin_domains_domains", "users_id_tech")) { $DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.5.0.sql"); } if ($install || $update78) { //Do One time on 0.78 $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginDomainsDomain' AND `name` = 'Alert Domains'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n VALUES(NULL, " . $itemtype . ", '','##domain.action## : ##domain.entity##',\n '##lang.domain.entity## :##domain.entity##\n ##FOREACHdomains##\n ##lang.domain.name## : ##domain.name## - ##lang.domain.dateexpiration## : ##domain.dateexpiration##\n ##ENDFOREACHdomains##',\n '<p>##lang.domain.entity## :##domain.entity##<br /> <br />\n ##FOREACHdomains##<br />\n ##lang.domain.name## : ##domain.name## - ##lang.domain.dateexpiration## : ##domain.dateexpiration##<br /> \n ##ENDFOREACHdomains##</p>');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Alert Expired Domains', 0, 'PluginDomainsDomain', 'ExpiredDomains',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Alert Domains Which Expire', 0, 'PluginDomainsDomain', 'DomainsWhichExpire',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); } if ($update78) { $query_ = "SELECT *\n FROM `glpi_plugin_domains_profiles` "; $result_ = $DB->query($query_); if ($DB->numrows($result_) > 0) { while ($data = $DB->fetch_array($result_)) { $query = "UPDATE `glpi_plugin_domains_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "';"; $result = $DB->query($query); } } $query = "ALTER TABLE `glpi_plugin_domains_profiles`\n DROP `name` ;"; $result = $DB->query($query); Plugin::migrateItemType(array(4400 => 'PluginDomainsDomain'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_domains_domains_items")); Plugin::migrateItemType(array(1200 => "PluginAppliancesAppliance", 1300 => "PluginWebapplicationsWebapplication"), array("glpi_plugin_domains_domains_items")); } CronTask::Register('PluginDomainsDomain', 'DomainsAlert', DAY_TIMESTAMP); PluginDomainsProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); return true; }
Copyright (C) 2003-2011 by the Domains Development Team. https://forge.indepnet.net/projects/domains ------------------------------------------------------------------------- LICENSE This file is part of Domains. Domains 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. Domains 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 Domains. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; Session::checkRight("profile", "r"); $prof = new PluginDomainsProfile(); //Save profile if (isset($_POST['update'])) { $prof->update($_POST); Html::back(); }