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') . "\"> "; _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') . "\"> "; echo __('Then', 'positions') . " "; _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> "; echo __('Then', 'positions') . " "; _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> </td>"; echo "<td> </td>"; echo "<td> </td>"; echo "<td> </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(); } } }
/** * 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); } }
function plugin_positions_MassiveActionsDisplay($options = array()) { if (in_array($options['itemtype'], PluginPositionsPosition::getTypes(true))) { echo "<input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"" . __('Post') . "\" >"; } return ""; }
$download = 1; } } } } } } } } else { if (!isset($_POST["locations_id"])) { $_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']); }
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'); } }