static function showGeolocLink($itemtype, $id, $positions_id = 0) { global $CFG_GLPI; if ($itemtype != 'User' && $itemtype != 'PluginResourcesResource') { $position = new PluginPositionsPosition(); $position->getFromDBByQuery("WHERE itemtype ='" . $itemtype . "' AND items_id = " . $id); $documents_id = self::getDocument($position->fields['locations_id']); $locations_id = $position->fields['locations_id']; } else { //si plugin ressource active $plugin = new Plugin(); if ($plugin->isActivated("resources")) { //recherche de la ressource lie a ce user if ($itemtype != 'PluginResourcesResource') { $condition = "`items_id`= '" . $id . "' AND `itemtype` = 'User'"; $infos = getAllDatasFromTable('glpi_plugin_resources_resources_items', $condition); if (!empty($infos)) { foreach ($infos as $info) { $ressource = new PluginResourcesResource(); $ressource->getFromDB($info['plugin_resources_resources_id']); $restrict = "`items_id` = '" . $ressource->getID() . "'\n AND `is_deleted` = '0' \n AND `entities_id` = '" . $ressource->fields['entities_id'] . "'\n AND `itemtype` = 'PluginResourcesResource'"; $datas = getAllDatasFromTable('glpi_plugin_positions_positions', $restrict); if (!empty($datas)) { foreach ($datas as $data) { if (isset($data['id'])) { if (isset($ressource->fields['locations_id']) && $ressource->fields['locations_id'] > 0) { $documents_id = self::getDocument($data['locations_id']); $positions_id = $data['id']; $locations_id = $data['locations_id']; } } } } } } } else { $ressource = new PluginResourcesResource(); if ($ressource->getFromDB($id)) { $restrict = "`items_id` = '" . $ressource->fields['id'] . "'\n AND `is_deleted` = '0' \n AND `entities_id` = '" . $ressource->fields['entities_id'] . "'\n AND `itemtype` = '" . $ressource->getType() . "'"; $datas = getAllDatasFromTable('glpi_plugin_positions_positions', $restrict); if (!empty($datas)) { foreach ($datas as $data) { if (isset($data['id'])) { if (isset($data['locations_id']) && $data['locations_id'] > 0) { $documents_id = self::getDocument($data['locations_id']); $positions_id = $data['id']; $locations_id = $data['locations_id']; } } } } } } } } $out = ""; $Doc = new Document(); if (isset($documents_id) && $Doc->getFromDB($documents_id)) { $out .= " <a href='#' onClick=\"var w = window.open('" . $CFG_GLPI['root_doc'] . "/plugins/positions/front/geoloc.php?positions_id=" . $positions_id . "&download=1&locations_id=" . $locations_id . "' ,'glpipopup', \n 'height=650, width=1400, top=100, left=100, scrollbars=yes' );\n w.focus();\" ><img src='" . $CFG_GLPI["root_doc"] . "/plugins/positions/pics/sm_globe.png'></a> "; } return $out; }