Exemplo n.º 1
0
 Positions 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.

 Positions 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 Positions. If not, see <http://www.gnu.org/licenses/>.
 --------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
$img = new PluginPositionsImageItem();
if (isset($_POST["add"]) && isset($_POST['type'])) {
    $test = explode(";", $_POST['type']);
    if (isset($test[0]) && isset($test[1]) && !empty($test[1])) {
        $_POST['type'] = $test[1];
        $_POST['itemtype'] = $test[0];
        if ($img->canCreate()) {
            if (!empty($_POST["img"])) {
                $img->addItemImage($_POST);
            } else {
                Session::addMessageAfterRedirect(__('No picture uploaded', 'positions'), false, ERROR);
            }
        }
    }
    Html::back();
} else {
Exemplo n.º 2
0
 /**
  * @static function displayMap : permet de récuperer tous les éléments de  la base de données pour pouvoir
  * les afficher sur la carte
  * @param $items
  * @param $params
  */
 static function displayMap($items, $params)
 {
     global $CFG_GLPI, $DB;
     if (isset($params['itemtype']) && is_array($params['itemtype'])) {
         foreach ($items as $classe => $ids) {
             if (!in_array($classe, $params['itemtype'])) {
                 unset($items[$classe]);
             }
         }
     }
     $plugin = new Plugin();
     $objects = array();
     if (!empty($items)) {
         foreach ($items as $classe => $ids) {
             foreach ($ids as $key => $val) {
                 if ($val['locations_id'] == $params['locations_id']) {
                     $itemclass = new $val['itemtype']();
                     if ($itemclass->getFromDB($val['items_id'])) {
                         $val['picture'] = null;
                         $val['img'] = null;
                         $canvas_id = count($objects);
                         $options = array('canvas_id' => $canvas_id, 'name' => self::displayItemTitle($itemclass), 'id' => $val['id'], 'items_id' => $val['items_id'], 'itemtype' => $val['itemtype'], 'width' => $val['width'], 'height' => $val['height'], 'x_coordinates' => $val['x_coordinates'], 'y_coordinates' => $val['y_coordinates'], "hideLabel" => $val['hideLabel'], "hideTooltip" => $val['hideTooltip'], "tooltip" => $val['tooltip'], "color" => $val['color'], "rotate" => $val['rotate'], "outline" => $val['outline'], "outlineWidth" => $val['outlineWidth'], "pattern" => $val['pattern'], "outlineWidth" => $val['outlineWidth'], "labelSize" => $val['labelSize'], "shape" => $val['shape']);
                         if ($plugin->isActivated("resources") && $val['itemtype'] == 'PluginResourcesResource') {
                             $val['picture'] = $itemclass->fields['picture'];
                             $options['img'] = $CFG_GLPI['url_base'] . '/plugins/resources/pics/nobody.png';
                             if (!($val['picture'] == null)) {
                                 $options['img'] = $CFG_GLPI['url_base'] . '/plugins/resources/front/picture.send.php?file=' . $val['picture'];
                             }
                             $objects[$val['id']] = $options;
                         } else {
                             if ($val['itemtype'] == 'Location') {
                                 $options['img'] = $CFG_GLPI['url_base'] . '/plugins/positions/pics/door.png';
                                 $objects[$val['id']] = $options;
                             } else {
                                 if ($val['itemtype'] == 'Netpoint') {
                                     $options['img'] = $CFG_GLPI['url_base'] . '/plugins/positions/pics/socket.png';
                                     $objects[$val['id']] = $options;
                                 } else {
                                     $itemtype = $val['itemtype'] . "Type";
                                     $typefield = getForeignKeyFieldForTable(getTableForItemType($itemtype));
                                     $imgitem = new PluginPositionsImageItem();
                                     if (isset($itemclass->fields[$typefield])) {
                                         $val['img'] = $imgitem->displayItemImage($itemclass->fields[$typefield], $classe);
                                     }
                                     $options['img'] = $CFG_GLPI['url_base'] . '/plugins/positions/pics/nothing.png';
                                     if (!($val['img'] == null)) {
                                         $options['img'] = $CFG_GLPI['url_base'] . '/plugins/positions/front/map.send.php?type=pics&file=' . $val['img'];
                                     }
                                     $objects[$val['id']] = $options;
                                 }
                             }
                         }
                         $canvas_id++;
                     }
                 }
             }
         }
         self::drawCanvas($objects, $params);
     } else {
         // Tests sur les droits
         $eventless = false;
         if (!Session::haveRight('plugin_positions', UPDATE) || isset($params['menuoff']) && $params['menuoff'] == 1) {
             $eventless = true;
         }
         $objects[] = array('canvas_id' => '0', 'name' => '', 'id' => '', 'items_id' => '', 'itemtype' => '', 'width' => 0.5, 'height' => 0.5, 'x_coordinates' => -300, 'y_coordinates' => 80, 'testEvent' => $eventless, 'hideLabel' => true, 'img' => $CFG_GLPI['url_base'] . '/plugins/positions/pics/nothing.png');
         self::drawCanvas($objects, $params);
     }
 }