Exemplo n.º 1
0
--------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
Session::checkSeveralRightsOr(array("plugin_ocsinventoryng" => READ, "plugin_ocsinventoryng_clean" => READ));
Html::header('OCS Inventory NG', '', "tools", "pluginocsinventoryngmenu", "ocsinventoryng");
if (isset($_SESSION["ocs_import"])) {
    unset($_SESSION["ocs_import"]);
}
if (isset($_SESSION["ocs_link"])) {
    unset($_SESSION["ocs_link"]);
}
if (isset($_SESSION["ocs_update"])) {
    unset($_SESSION["ocs_update"]);
}
if (isset($_POST["plugin_ocsinventoryng_ocsservers_id"])) {
    $_SESSION["plugin_ocsinventoryng_ocsservers_id"] = $_POST["plugin_ocsinventoryng_ocsservers_id"];
} else {
    $_SESSION["plugin_ocsinventoryng_ocsservers_id"] = PluginOcsinventoryngOcsServer::getFirstServer();
}
//PluginOcsinventoryngOcsServer::newOcsMenu($_SESSION["plugin_ocsinventoryng_ocsservers_id"]);
$menu = new PluginOcsinventoryngMenu();
$menu->show();
//load mac constructors in sessionMemory
$_SESSION["OCS"]["count"] = 0;
if (!isset($_SESSION["OCS"]["IpdiscoverMacConstructors"])) {
    $ip = new PluginOcsinventoryngIpdiscoverOcslink();
    $ip->loadMacConstructor();
    $_SESSION["OCS"]["count"] = $_SESSION["OCS"]["count"] + 1;
}
//PluginOcsinventoryngOcsServer::ocsMenu($_SESSION["plugin_ocsinventoryng_ocsservers_id"]);
Html::footer();
Exemplo n.º 2
0
/**
 * @return bool
 */
function plugin_ocsinventoryng_uninstall()
{
    global $DB;
    include_once GLPI_ROOT . "/plugins/ocsinventoryng/inc/profile.class.php";
    include_once GLPI_ROOT . "/plugins/ocsinventoryng/inc/menu.class.php";
    $tables = array("glpi_plugin_ocsinventoryng_ocsservers", "glpi_plugin_ocsinventoryng_ocslinks", "glpi_plugin_ocsinventoryng_ocsadmininfoslinks", "glpi_plugin_ocsinventoryng_profiles", "glpi_plugin_ocsinventoryng_threads", "glpi_plugin_ocsinventoryng_snmpocslinks", "glpi_plugin_ocsinventoryng_ipdiscoverocslinks", "glpi_plugin_ocsinventoryng_servers", "glpi_plugin_ocsinventoryng_configs", "glpi_plugin_ocsinventoryng_notimportedcomputers", "glpi_plugin_ocsinventoryng_details", "glpi_plugin_ocsinventoryng_registrykeys", "glpi_plugin_ocsinventoryng_networkports", "glpi_plugin_ocsinventoryng_networkporttypes", "glpi_plugin_ocsinventoryng_ocsservers_profiles", "glpi_plugin_ocsinventoryng_devicebiosdatas", "glpi_plugin_ocsinventoryng_items_devicebiosdatas");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    $tables_glpi = array("glpi_bookmarks", "glpi_displaypreferences", "glpi_logs");
    foreach ($tables_glpi as $table_glpi) {
        $DB->query("DELETE\r\n                  FROM `" . $table_glpi . "`\r\n                  WHERE `itemtype` IN ('PluginMassocsimportNotimported',\r\n                                       'PluginMassocsimportDetail',\r\n                                       'PluginOcsinventoryngOcsServer',\r\n                                       'PluginOcsinventoryngNotimportedcomputer',\r\n                                       'PluginOcsinventoryngDetail')");
    }
    $tables_ocs = array("ocs_glpi_crontasks", "ocs_glpi_displaypreferences", "ocs_glpi_ocsadmininfoslinks", "ocs_glpi_ocslinks", "ocs_glpi_ocsservers", "ocs_glpi_registrykeys", "ocs_glpi_profiles");
    foreach ($tables_ocs as $table_ocs) {
        $DB->query("DROP TABLE IF EXISTS `{$table_ocs}`;");
    }
    $tables_mass = array("backup_glpi_plugin_massocsimport_configs", "backup_glpi_plugin_massocsimport_details", "backup_glpi_plugin_massocsimport_notimported", "backup_glpi_plugin_massocsimport_servers", "backup_glpi_plugin_massocsimport_threads");
    foreach ($tables_mass as $table_mass) {
        $DB->query("DROP TABLE IF EXISTS `{$table_mass}`;");
    }
    $query = "DELETE\r\n             FROM `glpi_alerts`\r\n             WHERE `itemtype` IN ('PluginMassocsimportNotimported',\r\n                                  'PluginOcsinventoryngNotimportedcomputer')";
    $DB->queryOrDie($query, $DB->error());
    // clean rules
    $rule = new RuleImportEntity();
    foreach ($DB->request("glpi_rules", array('sub_type' => 'RuleImportEntity')) as $data) {
        $rule->delete($data);
    }
    $rule = new RuleImportComputer();
    foreach ($DB->request("glpi_rules", array('sub_type' => 'RuleImportComputer')) as $data) {
        $rule->delete($data);
    }
    $notification = new Notification();
    foreach (getAllDatasFromTable($notification->getTable(), "`itemtype` IN ('PluginMassocsimportNotimported',\r\n                                                 'PluginOcsinventoryngNotimportedcomputer')") as $data) {
        $notification->delete($data);
    }
    $template = new NotificationTemplate();
    foreach (getAllDatasFromTable($template->getTable(), "`itemtype` IN ('PluginMassocsimportNotimported',\r\n                                                 'PluginOcsinventoryngNotimportedcomputer')") as $data) {
        $template->delete($data);
    }
    $cron = new CronTask();
    if ($cron->getFromDBbyName('PluginMassocsimportThread', 'CleanOldThreads')) {
        CronTask::Unregister('massocsimport');
        CronTask::Unregister('CleanOldThreads');
    }
    if ($cron->getFromDBbyName('PluginOcsinventoryngOcsServer', 'ocsng')) {
        CronTask::Unregister('ocsinventoryng');
        CronTask::Unregister('ocsng');
    }
    if ($cron->getFromDBbyName('PluginOcsinventoryngNotimportedcomputer', 'SendAlerts')) {
        CronTask::Unregister('SendAlerts');
    }
    if ($cron->getFromDBbyName('PluginOcsinventoryngOcsServer', 'CleanOldAgents')) {
        CronTask::Unregister('CleanOldAgents');
    }
    //Delete rights associated with the plugin
    $profileRight = new ProfileRight();
    foreach (PluginOcsinventoryngProfile::getAllRights() as $right) {
        $profileRight->deleteByCriteria(array('name' => $right['field']));
    }
    PluginOcsinventoryngMenu::removeRightsFromSession();
    PluginOcsinventoryngProfile::removeRightsFromSession();
    return true;
}