function plugin_typology_install() { global $DB; include_once GLPI_ROOT . "/plugins/typology/inc/profile.class.php"; if (!TableExists("glpi_plugin_typology_typologies")) { // table sql creation $DB->runFile(GLPI_ROOT . "/plugins/typology/sql/empty-1.0.0.sql"); $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginTypologyTypology' AND `name` = 'Alert no validated typology'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n VALUES(NULL, " . $itemtype . ", '','##typology.action## : ##typology.entity##',\n '##FOREACHitems##\n ##lang.typology.name## : ##typology.name##\n ##lang.typology.itemtype## : ##typology.itemtype##\n ##lang.typology.items_id## : ##typology.items_id##\n ##lang.typology.itemlocation## : ##typology.itemlocation##\n ##lang.typology.itemuser## : ##typology.itemuser##\n ##lang.typology.error## : ##typology.error##\n ##ENDFOREACHitems##',\n '<table class=\"tab_cadre\" border=\"1\" cellspacing=\"2\" cellpadding=\"3\">\n <tbody>\n <tr>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.typology.name##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.typology.itemtype##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.typology.items_id##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.typology.itemlocation##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.typology.itemuser##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.typology.error##</span></td>\n </tr>\n ##FOREACHtypologyitems##\n <tr>\n <td><a href=\"##typology.url##\" target=\"_blank\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##typology.name##</span></a></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##typology.itemtype##</span></td>\n <td><a href=\"##typology.itemurl##\" target=\"_blank\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##typology.items_id##</span></a></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##typology.itemlocation##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##typology.itemuser##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##typology.error##</span></td>\n </tr>\n ##ENDFOREACHtypologyitems##\n </tbody>\n </table>');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Alert no validated typology', 0, 'PluginTypologyTypology', 'AlertNotValidatedTypology',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); } if (TableExists("glpi_plugin_typology_typologycriterias")) { $query = "UPDATE `glpi_plugin_typology_typologycriterias`\n SET `itemtype`='IPAddress'\n WHERE `itemtype`='NetworkPort'"; $result = $DB->query($query); $query = "UPDATE `glpi_plugin_typology_typologycriteriadefinitions`\n SET `field`='name;glpi_ipaddresses;itemlink'\n WHERE `field` LIKE '%glpi_networkports%'"; $result = $DB->query($query); } CronTask::Register('PluginTypologyTypology', 'UpdateTypology', DAY_TIMESTAMP); CronTask::Register('PluginTypologyTypology', 'NotValidated', DAY_TIMESTAMP); PluginTypologyProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); return true; }