Esempio n. 1
0
 function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     if ($item->getType() == 'Profile') {
         return PluginPositionsPosition::getTypeName();
     }
     return '';
 }
Esempio n. 2
0
function plugin_init_racks()
{
    global $PLUGIN_HOOKS, $CFG_GLPI;
    $PLUGIN_HOOKS['csrf_compliant']['racks'] = true;
    $PLUGIN_HOOKS['change_profile']['racks'] = array('PluginRacksProfile', 'changeProfile');
    if (class_exists('PluginRacksRack')) {
        // only if plugin activated
        $PLUGIN_HOOKS['pre_item_purge']['racks'] = array('Profile' => array('PluginRacksProfile', 'purgeProfiles'));
    }
    Plugin::registerClass('PluginRacksRack', array('document_types' => true, 'unicity_types' => true, 'linkgroup_tech_types' => true, 'linkuser_tech_types' => true, 'infocom_types' => true));
    Plugin::registerClass('PluginRacksProfile', array('addtabon' => 'Profile'));
    if (class_exists('PluginAppliancesAppliance')) {
        PluginAppliancesAppliance::registerType('PluginRacksRack');
    }
    if (class_exists('PluginManufacturersimportsConfig')) {
        PluginManufacturersimportsConfig::registerType('PluginRacksRack');
    }
    if (class_exists('PluginTreeviewConfig')) {
        PluginTreeviewConfig::registerType('PluginRacksRack');
        $PLUGIN_HOOKS['treeview']['PluginRacksRack'] = '../racks/pics/racks.png';
    }
    if (class_exists('PluginPositionsPosition')) {
        PluginPositionsPosition::registerType('PluginRacksRack');
    }
    if (Session::getLoginUserID()) {
        // Display a menu entry ?
        if (plugin_racks_haveRight("racks", "r")) {
            $PLUGIN_HOOKS['menu_entry']['racks'] = 'front/rack.php';
            $PLUGIN_HOOKS['submenu_entry']['racks']['search'] = 'front/rack.php';
            $PLUGIN_HOOKS['submenu_entry']['racks']['add'] = 'front/setup.templates.php?add=1';
        }
        if (plugin_racks_haveRight("model", "r")) {
            $PLUGIN_HOOKS['submenu_entry']['racks']['template'] = 'front/setup.templates.php?add=0';
            $PLUGIN_HOOKS['submenu_entry']['racks']["<img  src='" . $CFG_GLPI["root_doc"] . "/pics/menu_showall.png' title=\"" . __('Equipments models specifications', 'racks') . "\" alt=\"" . __('Equipments models specifications', 'racks') . "\">"] = 'front/itemspecification.php';
        }
        if (plugin_racks_haveRight("racks", "r")) {
            $PLUGIN_HOOKS['submenu_entry']['racks']['config'] = 'front/config.form.php';
            $PLUGIN_HOOKS['use_massive_action']['racks'] = 1;
        }
        // Config page
        if (plugin_racks_haveRight("racks", "w") || Session::haveRight("config", "w")) {
            $PLUGIN_HOOKS['config_page']['racks'] = 'front/config.form.php';
        }
        // Add specific files to add to the header : javascript or css
        //$PLUGIN_HOOKS['add_javascript']['example']="example.js";
        $PLUGIN_HOOKS['add_css']['racks'] = "racks.css";
        $PLUGIN_HOOKS['post_init']['racks'] = 'plugin_racks_postinit';
        $PLUGIN_HOOKS['reports']['racks'] = array('front/report.php' => __("Report - Bays management", "racks"));
    }
}
Esempio n. 3
0
 static function getMenuContent()
 {
     global $CFG_GLPI;
     $menu = array();
     $menu['title'] = self::getMenuName();
     $menu['page'] = "/plugins/positions/front/map.form.php";
     $menu['links']['search'] = PluginPositionsPosition::getSearchURL(false);
     $menu['options']['positions']['links']['search'] = PluginPositionsPosition::getSearchURL(false);
     $menu['options']['positions']['links']['config'] = '/plugins/positions/front/config.form.php';
     $menu['options']['positions']['links']["<img  src='" . $CFG_GLPI["root_doc"] . "/pics/menu_showall.png' title='" . __('Map view', 'positions') . "' alt='" . __('Map view', 'positions') . "'>"] = '/plugins/positions/front/map.form.php';
     //$menu['options']['config']['links']['search'] = PluginPositionsPosition::getSearchURL(false);
     $menu['options']['config']['links']['config'] = '/plugins/positions/front/config.form.php';
     $menu['options']['info']['links']['search'] = '/plugins/positions/front/info.php';
     $menu['options']['info']['links']["<img  src='" . $CFG_GLPI["root_doc"] . "/pics/menu_showall.png' title='" . __('Map view', 'positions') . "' alt='" . __('Map view', 'positions') . "'>"] = '/plugins/positions/front/map.form.php';
     $menu['options']['info']['links']['config'] = '/plugins/positions/front/config.form.php';
     if (PluginPositionsPosition::canCreate()) {
         $menu['links']['add'] = PluginPositionsPosition::getFormURL(false);
         $menu['options']['positions']['links']['add'] = PluginPositionsPosition::getFormURL(false);
         $menu['options']['info']['links']['add'] = '/plugins/positions/front/info.form.php';
     }
     return $menu;
 }
Esempio n. 4
0
LICENSE
		
This file is part of Positions.

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';
$plugin = new Plugin();
if ($plugin->isActivated("positions")) {
    Html::header(PluginPositionsPosition::getTypeName(), '', "plugins", "positions");
    PluginPositionsPosition::showConfigForm();
    Html::footer();
} else {
    Html::header(__('Setup'), '', "config", "plugins");
    echo "<div align='center'><br><br>";
    echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/warning.png\" alt='warning'><br><br>";
    echo "<b>" . __('Please activate the plugin', 'positions') . "</b></div>";
    Html::footer();
}
Esempio n. 5
0
        $_POST["locations_id"] = $_GET["locations_id"];
    }
    if (!isset($_POST["download"])) {
        $_POST["download"] = $_GET["download"];
    }
    $types = PluginPositionsPosition::getTypes();
    if (!isset($_POST["itemtype"])) {
        $_POST["itemtype"] = $types;
    }
    $locations_id = $_POST["locations_id"];
    $id = $_GET["positions_id"];
    $itemtype = $_POST['itemtype'];
    $menuoff = 1;
    $download = $_POST['download'];
}
$plugin = new Plugin();
if (isset($_GET['from_treeview']) && $plugin->isActivated("treeview")) {
    Html::header(PluginPositionsPosition::getTypeName(), '', "plugins", "positions");
} else {
    Html::popHeader(PluginPositionsPosition::getTypeName(), $_SERVER['PHP_SELF']);
}
if (isset($locations_id) && !empty($locations_id)) {
    $target = $_SERVER['PHP_SELF'] . "?id=" . $id;
    $options = array('id' => $id, 'locations_id' => $locations_id, 'itemtype' => $itemtype, 'target' => $target, 'menuoff' => $menuoff, 'download' => $download);
    PluginPositionsPosition::showMap($options);
} else {
    echo "<div class='center'><br><br>";
    echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/warning.png' alt='warning'><br><br>";
    echo "<span class='b'>" . __('The selected object is not located on a map', 'positions') . "</span></div>";
}
Html::popFooter();
Esempio n. 6
0
function plugin_positions_MassiveActionsProcess($data)
{
    $pos = new PluginPositionsPosition();
    $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
    switch ($data['action']) {
        case "plugin_positions_add_item":
            $i = 0;
            foreach ($data["item"] as $key => $val) {
                if ($val == 1) {
                    $entity = $_SESSION["glpiactive_entity"];
                    $item = new $data['itemtype']();
                    $values = array('items_id' => $key, 'itemtype' => $data['itemtype'], 'entities_id' => $entity, 'x_coordinates' => $i, 'massiveaction' => 1);
                    $restrict = "`items_id` = '" . $values["items_id"] . "'\n                     AND `itemtype` = '" . $values["itemtype"] . "'";
                    if (countElementsInTable("glpi_plugin_positions_positions", $restrict) == 0) {
                        $pos->check(-1, 'w', $values);
                        if ($pos->add($values)) {
                            $res['ok']++;
                            $i = $i + 35;
                        } else {
                            $res['ko']++;
                        }
                    } else {
                        $res['ko']++;
                    }
                }
            }
            break;
        case "plugin_positions_del_item":
            foreach ($data["item"] as $key => $val) {
                if ($val == 1) {
                    $restrict = "`items_id` = '" . $key . "'\n                     AND `itemtype` = '" . $data["itemtype"] . "'";
                    $items = getAllDatasFromTable("glpi_plugin_positions_positions", $restrict);
                    if (!empty($items)) {
                        foreach ($items as $item) {
                            $values = array('id' => $item["id"], 'delete' => 'delete');
                        }
                        $pos->check($values['id'], 'w');
                        if ($pos->delete($values, 1)) {
                            $res['ok']++;
                        } else {
                            $res['ko']++;
                        }
                    } else {
                        $res['ko']++;
                    }
                }
            }
            break;
    }
    return $res;
}
Esempio n. 7
0
function plugin_init_resources()
{
    global $PLUGIN_HOOKS, $CFG_GLPI;
    $PLUGIN_HOOKS['csrf_compliant']['resources'] = true;
    $PLUGIN_HOOKS['change_profile']['resources'] = array('PluginResourcesProfile', 'changeProfile');
    $PLUGIN_HOOKS['assign_to_ticket']['resources'] = true;
    if (Session::getLoginUserID()) {
        $noupdate = false;
        if (isset($_SESSION['glpiactiveprofile']['interface']) && $_SESSION['glpiactiveprofile']['interface'] != 'central') {
            $noupdate = true;
        }
        Plugin::registerClass('PluginResourcesResource', array('linkuser_types' => true, 'document_types' => true, 'ticket_types' => true, 'helpdesk_visible_types' => true, 'notificationtemplates_types' => true, 'unicity_types' => true, 'massiveaction_nodelete_types' => $noupdate, 'massiveaction_noupdate_types' => $noupdate));
        Plugin::registerClass('PluginResourcesDirectory', array('massiveaction_nodelete_types' => true, 'massiveaction_noupdate_types' => true));
        Plugin::registerClass('PluginResourcesRecap', array('massiveaction_nodelete_types' => true, 'massiveaction_noupdate_types' => true));
        Plugin::registerClass('PluginResourcesTaskPlanning', array('planning_types' => true));
        Plugin::registerClass('PluginResourcesRuleChecklistCollection', array('rulecollections_types' => true));
        Plugin::registerClass('PluginResourcesRuleContracttypeCollection', array('rulecollections_types' => true));
        Plugin::registerClass('PluginResourcesProfile', array('addtabon' => 'Profile'));
        Plugin::registerClass('PluginResourcesEmployment', array('massiveaction_nodelete_types' => true));
        if (class_exists('PluginPositionsPosition')) {
            PluginPositionsPosition::registerType('PluginResourcesResource');
            //$PLUGIN_HOOKS['plugin_positions']['PluginResourcesResource']='plugin_resources_positions_pics';
        }
        if (class_exists('PluginBehaviorsCommon')) {
            PluginBehaviorsCommon::addCloneType('PluginResourcesRuleChecklist', 'PluginBehaviorsRule');
            PluginBehaviorsCommon::addCloneType('PluginResourcesRuleContracttype', 'PluginBehaviorsRule');
        }
        if (class_exists('PluginTreeviewConfig')) {
            PluginTreeviewConfig::registerType('PluginResourcesResource');
            $PLUGIN_HOOKS['treeview']['PluginResourcesResource'] = '../resources/pics/miniresources.png';
            $PLUGIN_HOOKS['treeview_params']['resources'] = array('PluginResourcesResource', 'showResourceTreeview');
        }
        if (plugin_resources_haveRight("resources", "r") || plugin_resources_haveRight("employer", "w")) {
            $PLUGIN_HOOKS['menu_entry']['resources'] = 'front/menu.php';
            $PLUGIN_HOOKS['helpdesk_menu_entry']['resources'] = '/front/menu.php';
            $PLUGIN_HOOKS['submenu_entry']['resources']['search'] = 'front/resource.php';
            $PLUGIN_HOOKS['redirect_page']['resources'] = "front/resource.form.php";
            $PLUGIN_HOOKS['submenu_entry']['resources']["<img src='" . $CFG_GLPI["root_doc"] . "/plugins/resources/pics/directory18.png' title='" . __('Directory', 'resources') . "' alt='" . __('Directory', 'resources') . "'>"] = 'front/directory.php';
        }
        if (plugin_resources_haveRight("resting", "w")) {
            $PLUGIN_HOOKS['submenu_entry']['resources']["<img src='" . $CFG_GLPI["root_doc"] . "/plugins/resources/pics/restinglist18.png' title='" . __('List of non contract periods', 'resources') . "' alt='" . __('List of non contract periods', 'resources') . "'>"] = 'front/resourceresting.php';
        }
        if (plugin_resources_haveRight("holiday", "w")) {
            $PLUGIN_HOOKS['submenu_entry']['resources']["<img src='" . $CFG_GLPI["root_doc"] . "/plugins/resources/pics/holidaylist18.png' title='" . __('List of forced holidays', 'resources') . "' alt='" . __('List of forced holidays', 'resources') . "'>"] = 'front/resourceholiday.php';
        }
        if (plugin_resources_haveRight("employment", "r")) {
            $PLUGIN_HOOKS['submenu_entry']['resources']["<img src='" . $CFG_GLPI["root_doc"] . "/plugins/resources/pics/employmentlist18.png' title='" . __('Employment management', 'resources') . "' alt='" . __('Employment management', 'resources') . "'>"] = 'front/employment.php';
            $PLUGIN_HOOKS['submenu_entry']['resources']["<img src='" . $CFG_GLPI["root_doc"] . "/plugins/resources/pics/recap18.png' title='" . __('List Employments / Resources', 'resources') . "' alt='" . __('List Employments / Resources', 'resources') . "'>"] = 'front/recap.php';
        }
        if (plugin_resources_haveRight("budget", "r")) {
            $PLUGIN_HOOKS['submenu_entry']['resources']["<img src='" . $CFG_GLPI["root_doc"] . "/plugins/resources/pics/budgetlist18.png' title='" . __('Budget management', 'resources') . "' alt='" . __('Budget management', 'resources') . "'>"] = 'front/budget.php';
        }
        if (plugin_resources_haveRight("resources", "w")) {
            $PLUGIN_HOOKS['submenu_entry']['resources']['add'] = 'front/wizard.form.php';
            $PLUGIN_HOOKS['submenu_entry']['resources']['template'] = 'front/setup.templates.php?add=0';
            if (plugin_resources_haveRight("task", "r")) {
                $PLUGIN_HOOKS['submenu_entry']['resources']["<img  src='" . $CFG_GLPI["root_doc"] . "/pics/menu_showall.png' title='" . __('Tasks list', 'resources') . "' alt='" . __('Tasks list', 'resources') . "'>"] = 'front/task.php';
            }
            if (plugin_resources_haveRight("checklist", "r")) {
                $PLUGIN_HOOKS['submenu_entry']['resources']["<img  src='" . $CFG_GLPI["root_doc"] . "/pics/reservation-3.png' title='" . _n('Checklist', 'Checklists', 2, 'resources') . "' alt='" . _n('Checklist', 'Checklists', 2, 'resources') . "'>"] = 'front/checklistconfig.php';
            }
            if (plugin_resources_haveRight("checklist", "r")) {
                $PLUGIN_HOOKS['submenu_entry']['resources']['options']['checklist']['title'] = __('Checklists', 'resources');
                $PLUGIN_HOOKS['submenu_entry']['resources']['options']['checklist']['page'] = '/plugins/resources/front/checklistconfig.php';
                $PLUGIN_HOOKS['submenu_entry']['resources']['options']['checklist']['links']['search'] = '/plugins/resources/front/checklistconfig.php';
            }
            if (plugin_resources_haveRight("checklist", "w")) {
                $PLUGIN_HOOKS['submenu_entry']['resources']['options']['checklist']['links']['add'] = '/plugins/resources/front/checklistconfig.form.php?new=1';
            }
            if (plugin_resources_haveRight("employment", "r")) {
                $PLUGIN_HOOKS['submenu_entry']['resources']['options']['employment']['title'] = __('Employments', 'resources');
                $PLUGIN_HOOKS['submenu_entry']['resources']['options']['employment']['page'] = '/plugins/resources/front/employment.php';
                $PLUGIN_HOOKS['submenu_entry']['resources']['options']['employment']['links']['search'] = '/plugins/resources/front/employment.php';
            }
            if (plugin_resources_haveRight("employment", "w")) {
                $PLUGIN_HOOKS['submenu_entry']['resources']['options']['employment']['links']['add'] = '/plugins/resources/front/employment.form.php';
            }
            if (plugin_resources_haveRight("budget", "r")) {
                $PLUGIN_HOOKS['submenu_entry']['resources']['options']['budget']['title'] = _n('Budget', 'Budgets', 2);
                $PLUGIN_HOOKS['submenu_entry']['resources']['options']['budget']['page'] = '/plugins/resources/front/budget.php';
                $PLUGIN_HOOKS['submenu_entry']['resources']['options']['budget']['links']['search'] = '/plugins/resources/front/budget.php';
            }
            if (plugin_resources_haveRight("budget", "w")) {
                $PLUGIN_HOOKS['submenu_entry']['resources']['options']['budget']['links']['add'] = '/plugins/resources/front/budget.form.php';
            }
            if (Session::haveRight("config", "w")) {
                $PLUGIN_HOOKS['submenu_entry']['resources']['options']['checklist']['links']['config'] = '/plugins/resources/front/config.form.php';
            }
            $PLUGIN_HOOKS['use_massive_action']['resources'] = 1;
        }
        // Add specific files to add to the header : javascript or css
        $PLUGIN_HOOKS['add_javascript']['resources'] = "resources.js";
        $PLUGIN_HOOKS['add_css']['resources'] = "resources.css";
        //TODO : Check
        $PLUGIN_HOOKS['plugin_pdf']['PluginResourcesResource'] = 'PluginResourcesResourcePDF';
        //Clean Plugin on Profile delete
        if (class_exists('PluginResourcesResource_Item')) {
            // only if plugin activated
            $PLUGIN_HOOKS['pre_item_purge']['resources'] = array('Profile' => array('PluginResourcesProfile', 'purgeProfiles'));
            $PLUGIN_HOOKS['plugin_datainjection_populate']['resources'] = 'plugin_datainjection_populate_resources';
        }
        //planning action
        $PLUGIN_HOOKS['planning_populate']['resources'] = array('PluginResourcesTaskPlanning', 'populatePlanning');
        $PLUGIN_HOOKS['display_planning']['resources'] = array('PluginResourcesTaskPlanning', 'displayPlanningItem');
        $PLUGIN_HOOKS['migratetypes']['resources'] = 'plugin_datainjection_migratetypes_resources';
        // Config page
        if (Session::haveRight("config", "w")) {
            $PLUGIN_HOOKS['submenu_entry']['resources']['config'] = 'front/config.form.php';
            $PLUGIN_HOOKS['config_page']['resources'] = 'front/config.form.php';
        }
    }
    // End init, when all types are registered
    $PLUGIN_HOOKS['post_init']['resources'] = 'plugin_resources_postinit';
}
Esempio n. 8
0
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';
if (!isset($_GET["file"])) {
    $_GET["file"] = "";
    $image = $_GET['img'];
} else {
    $image = $_GET['file'];
}
$items_id = $_GET['items_id'];
$name = $_GET['name'];
$itemtype = $_GET['itemtype'];
$idpos = $_GET['id'];
$pos = new PluginPositionsPosition();
if ($itemtype == 'Location') {
    PluginPositionsPosition::showGeolocLocation($itemtype, $items_id);
} else {
    $detail = new PluginPositionsInfo();
    $restrict = "`is_active` = 1 ";
    $pos->getFromDB($idpos);
    $restrict = "`is_active` = '1' AND `is_deleted` = '0'";
    $restrict .= getEntitiesRestrictRequest(" AND ", "glpi_plugin_positions_infos", '', '', $pos->maybeRecursive());
    $infos = getAllDatasFromTable('glpi_plugin_positions_infos', $restrict);
    $item = new $itemtype();
    $item->getFromDB($items_id);
    PluginPositionsPosition::showOverlay($items_id, $image, $item, $infos);
}
Esempio n. 9
0
 function showConfigForm()
 {
     global $DB, $CFG_GLPI;
     echo "<form method='post' action='./imageitem.form.php' name='imageitemform'>";
     echo "<table class='tab_cadre_fixe' cellpadding='5'>";
     echo "<tr>";
     echo "<th colspan='5'>";
     echo __('Setup') . " : </th>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'><th colspan='5'>";
     _e('Add pictures to use with plugin', 'positions');
     echo "</th></tr>";
     echo "<tr class='tab_bg_1'><td colspan='2'>";
     echo "<span class='upload' id='container'>";
     echo "<img src='../pics/select.png' id='pickfiles' \n            title=\"" . __('Select pictures to upload (gif, jpg, png)', 'positions') . "\">&nbsp;";
     _e('Select pictures to upload (gif, jpg, png)', 'positions');
     echo "</td><td>";
     echo "<span class='upload' id='filelist'></span>";
     echo "<img src='../pics/upload.png' id='uploadfiles' \n            title=\"" . __('upload pictures to the server', 'positions') . "\">&nbsp;";
     echo __('Then', 'positions') . "&nbsp;";
     _e('upload pictures to the server', 'positions');
     echo "</td><td colspan='2'>";
     echo "<a href='" . $_SERVER['PHP_SELF'] . "'><img src='../pics/refresh.png' \n            title=\"" . __s('refresh this form', 'positions') . "\"></a>&nbsp;";
     echo __('Then', 'positions') . "&nbsp;";
     _e('refresh this form', 'positions');
     echo "</span>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><th colspan='5'>";
     _e('Associate images with types of equipment', 'positions');
     echo "</th></tr>";
     echo "<tr class='tab_bg_1'><td>";
     $types = PluginPositionsPosition::getTypes();
     self::showAllItems("type", 0, 0, $_SESSION["glpiactive_entity"], $types, -1, 'showType');
     echo "</td><td>";
     Html::showToolTip(nl2br(__('Types of materials should be created so that the association can exist', 'positions')));
     echo "<input type='hidden' name='_glpi_csrf_token' value=''>";
     echo "</td><td>";
     self::showUploadedFilesDropdown("img");
     echo "</td><td>";
     echo "<div id=\"imageitemPreview\"></div>";
     echo "</td><td>";
     echo "<div align='center'><input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit' ></div></td></tr>";
     echo "</table>";
     Html::closeForm();
     $query = "SELECT * \n                FROM `" . $this->getTable() . "` \n                ORDER BY `itemtype`,`type` ASC;";
     $i = 0;
     if ($result = $DB->query($query)) {
         $number = $DB->numrows($result);
         if ($number != 0) {
             echo "<form method='post' name='massiveaction_form' id='massiveaction_form' action='" . "./imageitem.form.php'>";
             echo "<div id='liste'>";
             echo "<table class='tab_cadre_fixe' cellpadding='5'>";
             $colspan = 4;
             if ($number > 1) {
                 $colspan = 8;
             }
             echo "<tr class='tab_bg_2'><th colspan='{$colspan}'>";
             _e('List of associations', 'positions');
             echo "</th></tr>";
             echo "<tr>";
             echo "<th class='left'>" . __('Equipment', 'positions') . "</th>";
             echo "<th class='left'>" . __('Equipment type', 'positions') . "</th>";
             echo "<th class='left'>" . __('Picture', 'positions') . "</th><th></th>";
             if ($number > 1) {
                 echo "<th class='left'>" . __('Equipment', 'positions') . "</th>";
                 echo "<th class='left'>" . __('Equipment type', 'positions') . "</th>";
                 echo "<th class='left'>" . __('Picture', 'positions') . "</th><th></th>";
             }
             echo "</tr>";
             while ($ligne = $DB->fetch_assoc($result)) {
                 $ID = $ligne["id"];
                 if ($i % 2 == 0 && $number > 1) {
                     echo "<tr class='tab_bg_1'>";
                 }
                 if ($number == 1) {
                     echo "<tr class='tab_bg_1'>";
                 }
                 if (!($item = getItemForItemtype($ligne["itemtype"]))) {
                     continue;
                 }
                 //$item = new $ligne["itemtype"]();
                 echo "<td>" . $item->getTypeName() . "</td>";
                 $class = $ligne["itemtype"] . "Type";
                 $typeclass = new $class();
                 $typeclass->getFromDB($ligne["type"]);
                 $name = $ligne["type"];
                 if (isset($typeclass->fields["name"])) {
                     $name = $typeclass->fields["name"];
                 }
                 echo "<td>" . $name . "</td>";
                 echo "<td>";
                 if (!empty($ligne["img"])) {
                     $ext = pathinfo($ligne["img"], PATHINFO_EXTENSION);
                     echo "<object data='" . $CFG_GLPI['root_doc'] . "/plugins/positions/front/map.send.php?file=" . $ligne["img"] . "&type=pics' type='image/{$ext}'>\n                      <param name='src' value='" . $CFG_GLPI['root_doc'] . "/plugins/positions/front/map.send.php?file=" . $ligne["img"] . "&type=pics'>\n                     </object> ";
                 } else {
                     _e('No associated picture', 'positions');
                 }
                 echo "</td>";
                 echo "<td>";
                 echo "<input type='hidden' name='id' value='{$ID}'>";
                 echo "<input type='checkbox' name='item[{$ID}]' value='1'>";
                 echo "</td>";
                 $i++;
                 if ($i == $number && $number % 2 != 0 && $number > 1) {
                     echo "<td>&nbsp;</td>";
                     echo "<td>&nbsp;</td>";
                     echo "<td>&nbsp;</td>";
                     echo "<td>&nbsp;</td>";
                     echo "</tr>";
                 }
             }
             echo "<tr class='tab_bg_1'>";
             if ($number > 1) {
                 echo "<td colspan='8' class='center'>";
             } else {
                 echo "<td colspan='4' class='center'>";
             }
             echo "<a onclick= \"if (markCheckboxes ('massiveaction_form')) return false;\" \n                  href='#'>" . __('Check all') . "</a>";
             echo " - <a onclick= \"if ( unMarkCheckboxes ('massiveaction_form') ) return false;\" \n                  href='#'>" . __('Uncheck all') . "</a> ";
             echo "<input type='submit' name='delete' value=\"" . _sx('button', 'Delete permanently') . "\" class='submit'>";
             echo "</td></tr>";
             echo "</table>";
             echo "</div>";
             Html::closeForm();
         }
     }
 }
Esempio n. 10
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';
if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
    //from central
    Html::header(PluginPositionsPosition::getTypeName(), '', "plugins", "positions");
} else {
    //from helpdesk
    Html::helpHeader(PluginPositionsPosition::getTypeName());
}
if (!isset($_POST["locations_id"])) {
    $_POST["locations_id"] = 0;
}
PluginPositionsPosition::showLocationForm($_POST["locations_id"]);
if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
    Html::footer();
} else {
    Html::helpFooter();
}
Esempio n. 11
0
This file is part of Positions.

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';
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
switch ($_POST['action']) {
    case 'setConfig':
        if (isset($_POST['config']) && !empty($_POST['config'])) {
            $positions = new PluginPositionsPosition();
            $input = json_decode(stripslashes($_POST['config']), true);
            $input['name'] = $input['label'];
            $input['x_coordinates'] = $input['x'];
            $input['y_coordinates'] = $input['y'];
            $positions->update($input);
        }
        break;
}
Esempio n. 12
0
https://forge.indepnet.net/projects/positions
-------------------------------------------------------------------------

LICENSE
		
This file is part of Positions.

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';
Html::header(PluginPositionsPosition::getTypeName(), '', "plugins", "positions");
$pos = new PluginPositionsPosition();
if ($pos->canView() || Session::haveRight("config", "w")) {
    Search::show("PluginPositionsPosition");
} else {
    Html::displayRightError();
}
Html::footer();
Esempio n. 13
0
 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 .= "&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;
 }
Esempio n. 14
0
function plugin_positions_postinit()
{
    global $CFG_GLPI, $PLUGIN_HOOKS;
    $plugin = 'positions';
    foreach (array('add_css', 'add_javascript') as $type) {
        if (isset($PLUGIN_HOOKS[$type][$plugin])) {
            foreach ($PLUGIN_HOOKS[$type][$plugin] as $data) {
                if (!empty($PLUGIN_HOOKS[$type])) {
                    foreach ($PLUGIN_HOOKS[$type] as $key => $plugins_data) {
                        if (is_array($plugins_data) && $key != $plugin) {
                            foreach ($plugins_data as $key2 => $values) {
                                if ($values == $data) {
                                    unset($PLUGIN_HOOKS[$type][$key][$key2]);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    $PLUGIN_HOOKS['item_purge']['positions'] = array();
    foreach (PluginPositionsPosition::getTypes(true) as $type) {
        $PLUGIN_HOOKS['item_purge']['positions'][$type] = array('PluginPositionsPosition', 'purgePositions');
        CommonGLPI::registerStandardTab($type, 'PluginPositionsPosition');
    }
}
Esempio n. 15
0
 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';
if (!isset($_GET["id"])) {
    $_GET["id"] = "";
}
if (!isset($_GET["withtemplate"])) {
    $_GET["withtemplate"] = "";
}
$pos = new PluginPositionsPosition();
if (isset($_POST["add"])) {
    $test = explode(";", $_POST['items_id']);
    if (isset($test[0]) && isset($test[1]) && !empty($test[1])) {
        $_POST['items_id'] = $test[1];
        $_POST['itemtype'] = $test[0];
        $pos->check(-1, CREATE, $_POST);
        $pos->add($_POST);
    } else {
        $pos->check(-1, CREATE, $_POST);
        $pos->add($_POST);
    }
} else {
    if (isset($_POST["additem"])) {
        $pos->check(-1, UPDATE, $_POST);
        $pos->add($_POST);
Esempio n. 16
0
 function showForm($ID, $options = array())
 {
     if (!Session::haveRight("profile", "r")) {
         return false;
     }
     $prof = new Profile();
     if ($ID) {
         $this->getFromDBByProfile($ID);
         $prof->getFromDB($ID);
     }
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_2'>";
     echo "<th colspan='4'>" . sprintf(__('%1$s - %2$s'), __('Rights management', 'positions'), $prof->fields["name"]) . "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . PluginPositionsPosition::getTypeName() . ":</td><td>";
     if ($prof->fields['interface'] != 'helpdesk') {
         Profile::dropdownNoneReadWrite("positions", $this->fields["positions"], 1, 1, 1);
     } else {
         Profile::dropdownNoneReadWrite("positions", $this->fields["positions"], 1, 1, 0);
     }
     echo "</td>";
     echo "<td></td>";
     echo "</tr>";
     echo "<input type='hidden' name='id' value=" . $this->fields["id"] . ">";
     $options['candel'] = false;
     $this->showFormButtons($options);
 }
Esempio n. 17
0
 /**
  * Display a dropdown which contains all the available itemtypes
  *
  * @param ID the field widget item id
  * @param value the selected value
  *
  * @return nothing
  **/
 function showItemtype($ID, $value = 0)
 {
     global $CFG_GLPI;
     //Criteria already added : only display the selected itemtype
     if ($ID > 0) {
         $item = new $this->fields['itemtype']();
         echo $item->getTypeName();
         echo "<input type='hidden' name='itemtype' value='" . $this->fields['itemtype'] . "'";
     } else {
         $possible_types = PluginPositionsPosition::getTypes();
         $restrict = "`is_active` = '1' AND `is_deleted` = '0'";
         $restrict .= getEntitiesRestrictRequest(" AND ", "glpi_plugin_positions_infos", '', '', $this->maybeRecursive());
         $types = getAllDatasFromTable('glpi_plugin_positions_infos', $restrict);
         if (!empty($types)) {
             foreach ($types as $type) {
                 foreach ($possible_types as $key => $val) {
                     if ($type["itemtype"] == $val) {
                         unset($possible_types[$key]);
                     }
                 }
             }
         }
         //Add criteria : display dropdown
         $options[0] = Dropdown::EMPTY_VALUE;
         foreach ($possible_types as $itemtype) {
             if (class_exists($itemtype)) {
                 $item = new $itemtype();
                 if ($item->can(-1, READ)) {
                     $options[$itemtype] = $item->getTypeName($itemtype);
                 }
             }
         }
         asort($options);
         $rand = Dropdown::showFromArray('itemtype', $options);
         $params = array('itemtype' => '__VALUE__', 'id' => $ID);
         Ajax::updateItemOnSelectEvent("dropdown_itemtype{$rand}", "span_fields", $CFG_GLPI["root_doc"] . "/plugins/positions/ajax/dropdownInfoFields.php", $params);
     }
 }
Esempio n. 18
0
 /**
  * Permet l'affichage dynamique des ressources avec info bulle
  *
  * @static
  * @param array ($myname,$value,$entity_restrict)
  */
 static function dropdown($options = array())
 {
     global $DB, $CFG_GLPI;
     // Default values
     $p['name'] = 'plugin_resources_resources_id';
     $p['value'] = '';
     $p['all'] = 0;
     $p['on_change'] = '';
     $p['comments'] = 1;
     $p['entity'] = -1;
     $p['entity_sons'] = false;
     $p['used'] = array();
     $p['toupdate'] = '';
     $p['rand'] = mt_rand();
     $p['plugin_resources_contracttypes_id'] = 0;
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $p[$key] = $val;
         }
     }
     if (!($p['entity'] < 0) && $p['entity_sons']) {
         if (is_array($p['entity'])) {
             echo "entity_sons options is not available with array of entity";
         } else {
             $p['entity'] = getSonsOf('glpi_entities', $p['entity']);
         }
     }
     // Make a select box with all glpi users
     $use_ajax = false;
     if ($CFG_GLPI["use_ajax"]) {
         $res = self::getSqlSearchResult(true, $p['entity'], $p['value'], $p['used'], '', $p['plugin_resources_contracttypes_id']);
         $nb = $res ? $DB->result($res, 0, "cpt") : 0;
         if ($nb > $CFG_GLPI["ajax_limit_count"]) {
             $use_ajax = true;
         }
     }
     $user = self::getResourceName($p['value'], 2);
     $default_display = "<select id='dropdown_" . $p['name'] . $p['rand'] . "' name='" . $p['name'] . "'>";
     $default_display .= "<option value='" . $p['value'] . "'>";
     $default_display .= Toolbox::substr($user["name"], 0, $_SESSION["glpidropdown_chars_limit"]);
     $default_display .= "</option></select>";
     //$view_users = (Session::haveRight("user", "r"));
     $params = array('searchText' => '__VALUE__', 'value' => $p['value'], 'myname' => $p['name'], 'all' => $p['all'], 'comment' => $p['comments'], 'rand' => $p['rand'], 'on_change' => $p['on_change'], 'entity_restrict' => $p['entity'], 'used' => $p['used'], 'update_item' => $p['toupdate'], 'plugin_resources_contracttypes_id' => $p['plugin_resources_contracttypes_id']);
     $default = "";
     if (!empty($p['value']) && $p['value'] > 0) {
         $default = $default_display;
     } else {
         $default = "<select name='" . $p['name'] . "' id='dropdown_" . $p['name'] . $p['rand'] . "'>";
         if ($p['all']) {
             $default .= "<option value='0'>[ " . __('All') . " ]</option></select>";
         } else {
             $default .= "<option value='0'>" . Dropdown::EMPTY_VALUE . "</option></select>\n";
         }
     }
     Ajax::dropdown($use_ajax, "/plugins/resources/ajax/dropdownResources.php", $params, $default, $p['rand']);
     if (class_exists('PluginPositionsPosition')) {
         PluginPositionsPosition::showGeolocLink('PluginResourcesResource', $params["value"]);
     }
     // Display comment
     if ($p['comments']) {
         if (empty($user["link"])) {
             $user["link"] = $CFG_GLPI['root_doc'] . "/plugins/resources/front/resource.php";
         }
         Html::showToolTip($user["comment"], array('contentid' => "comment_" . $p['name'] . $p['rand'], 'link' => $user["link"], 'linkid' => "comment_link_" . $p["name"] . $p['rand']));
     }
     return $p['rand'];
 }
Esempio n. 19
0
    $newID = $info->add($_POST);
    Html::back();
} else {
    if (isset($_POST["update"])) {
        $info->check($_POST['id'], 'w');
        $info->update($_POST);
        Html::back();
    } else {
        if (isset($_POST["delete"])) {
            $info->check($_POST['id'], 'w');
            $info->delete($_POST);
            $info->redirectToList();
        } else {
            if (isset($_POST["restore"])) {
                $info->check($_POST['id'], 'w');
                $info->restore($_POST);
                $info->redirectToList();
            } else {
                if (isset($_POST["purge"])) {
                    $info->check($_POST['id'], 'w');
                    $info->delete($_POST, 1);
                    $info->redirectToList();
                } else {
                    Html::header(PluginPositionsPosition::getTypeName(), '', "plugins", "positions", "info");
                    $info->showForm($_GET["id"]);
                    Html::footer();
                }
            }
        }
    }
}
Esempio n. 20
0
    if (!$doc->getFromDB($_GET['docid'])) {
        Html::displayErrorAndDie(__('Unknown file'), true);
    }
    if (!file_exists(GLPI_DOC_DIR . "/" . $doc->fields['filepath'])) {
        Html::displayErrorAndDie(__('File not found'), true);
        // Not found
    }
    if ($doc->fields['sha1sum'] && $doc->fields['sha1sum'] != sha1_file(GLPI_DOC_DIR . "/" . $doc->fields['filepath'])) {
        Html::displayErrorAndDie(__('File is altered (bad checksum)'), true);
        // Doc alterated
    } else {
        $doc->send();
    }
} else {
    if (isset($_GET["file"]) && isset($_GET["type"])) {
        PluginPositionsPosition::sendFile(GLPI_PLUGIN_DOC_DIR . "/positions/" . $_GET["type"] . "/" . $_GET["file"], $_GET["file"], $_GET["type"]);
    } else {
        if (isset($_GET["file"])) {
            // for other file
            $splitter = explode("/", $_GET["file"]);
            if (count($splitter) == 2) {
                $send = false;
                if ($splitter[0] == "_dumps" && Session::haveRight("backup", "w")) {
                    $send = true;
                }
                if ($send && file_exists(GLPI_DOC_DIR . "/" . $_GET["file"])) {
                    Toolbox::sendFile(GLPI_DOC_DIR . "/" . $_GET["file"], $splitter[1]);
                } else {
                    Html::displayErrorAndDie(__('Unauthorized access to this file'), true);
                }
            } else {
Esempio n. 21
0
Positions plugin for GLPI
Copyright (C) 2003-2011 by the Positions Development Team.

https://forge.indepnet.net/projects/positions
-------------------------------------------------------------------------

LICENSE
		
This file is part of Positions.

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';
if (isset($_POST['valid']) && (isset($_POST['locations_id']) || isset($_POST['locations_idParent']))) {
    $options = PluginPositionsPosition::cropPicture($_POST);
    Html::header(PluginPositionsPosition::getTypeName(), '', "tools", "pluginpositionsmenu", "positions");
    PluginPositionsPosition::showFormResCreateLocation($options);
    Html::footer();
}
Esempio n. 22
0
    $_POST["locations_id"] = $_GET["locations_id"];
}
if (isset($_POST["affich"]) && !isset($_POST["itemtype"])) {
    $_POST["itemtype"] = "0";
}
$types = PluginPositionsPosition::getTypes();
if (!isset($_POST["itemtype"])) {
    $_POST["itemtype"] = $types;
}
if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
    //from central
    Html::header(PluginPositionsPosition::getTypeName(), '', "tools", "pluginpositionsmenu", "positions");
} else {
    //from helpdesk
    Html::helpHeader(PluginPositionsPosition::getTypeName());
}
$pos = new PluginPositionsPosition();
if ($pos->canView() || Session::haveRight("config", UPDATE)) {
    if (!$_POST["locations_id"]) {
        PluginPositionsPosition::showLocationForm($_POST["locations_id"]);
        Html::displayErrorAndDie(__('No location selected', 'positions'), false, ERROR);
    } else {
        $options = array('id' => 0, 'locations_id' => $_POST["locations_id"], 'itemtype' => $_POST['itemtype'], 'target' => $_SERVER['PHP_SELF'] . "?locations_id=" . $_POST["locations_id"]);
        PluginPositionsPosition::showMap($options);
    }
}
if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
    Html::footer();
} else {
    Html::helpFooter();
}
Esempio n. 23
0
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 {
    if (isset($_POST["delete"])) {
        $img->getFromDB($_POST["id"], -1);
        foreach ($_POST["item"] as $key => $val) {
            if ($val == 1) {
                $img->delete(array('id' => $key));
            }
        }
        Html::back();
    } else {
        Html::header(PluginPositionsPosition::getTypeName(), '', "tools", "pluginpositionsmenu", "config");
        $img->showConfigForm();
        Html::footer();
    }
}
Esempio n. 24
0
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';
if (!isset($_GET["id"])) {
    $_GET["id"] = "";
}
if (!isset($_GET["withtemplate"])) {
    $_GET["withtemplate"] = "";
}
$pos = new PluginPositionsPosition();
if (isset($_POST["add"])) {
    $test = explode(";", $_POST['items_id']);
    if (isset($test[0]) && isset($test[1]) && !empty($test[1])) {
        $_POST['items_id'] = $test[1];
        $_POST['itemtype'] = $test[0];
        $pos->check(-1, 'w', $_POST);
        $pos->add($_POST);
    } else {
        $pos->check(-1, 'w', $_POST);
        $pos->add($_POST);
    }
} else {
    if (isset($_POST["additem"])) {
        $pos->check(-1, 'w', $_POST);
        $pos->add($_POST);