Пример #1
0
 static function showGeolocLink($itemtype, $id, $positions_id = 0)
 {
     global $CFG_GLPI;
     if ($itemtype != 'User' && $itemtype != 'PluginResourcesResource') {
         $item = new $itemtype();
         $item->getFromDB($id);
         $documents_id = self::getDocument($item->fields['locations_id']);
         $locations_id = $item->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($ressource->fields['locations_id']);
                                         $positions_id = $data['id'];
                                         $locations_id = $ressource->fields['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($ressource->fields['locations_id']) && $ressource->fields['locations_id'] > 0) {
                                     $documents_id = self::getDocument($ressource->fields['locations_id']);
                                     $positions_id = $data['id'];
                                     $locations_id = $ressource->fields['locations_id'];
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $out = "";
     $Doc = new Document();
     if (isset($documents_id) && $Doc->getFromDB($documents_id)) {
         $out .= "&nbsp;<a href='#' onClick=\"var w = window.open('" . $CFG_GLPI['root_doc'] . "/plugins/positions/front/geoloc.php?positions_id=" . $positions_id . "&amp;download=1&amp;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>&nbsp;";
     }
     return $out;
 }
Пример #2
0
include '../../../inc/includes.php';
if (!isset($_GET["id"])) {
    $_GET["id"] = "";
}
if (isset($_GET["users_id"])) {
    //si plugin ressource active
    $plugin = new Plugin();
    if ($plugin->isActivated("resources")) {
        //recherche de la ressource lie a ce user
        $condition = "`items_id`= '" . $_GET["users_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->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($ressource->fields['locations_id']) && $ressource->fields['locations_id'] > 0) {
                                $id = $data['id'];
                                $locations_id = $ressource->fields['locations_id'];
                                $itemtype = 'User';
                                $menuoff = 1;
                                $download = 1;
                            }
                        }
                    }
                }
            }