function showForm($p_target, $p_itemtype, $p_items_id) { global $DB, $LANG, $SEARCH_OPTION; echo "<div width='50%'>"; $lockable_fields = PluginFusioninventoryLockable::getLockableFields('', $p_itemtype); $locked = PluginFusioninventoryLock::getLockFields($p_itemtype, $p_items_id); if (count($locked)) { foreach ($locked as $key => $val) { if (!in_array($val, $lockable_fields)) { unset($locked[$key]); } } } else { $locked = array(); } include_once GLPI_ROOT . '/plugins/fusioninventory/inc_constants/mapping.fields.constant.php'; $CommonItem = new CommonItem(); $CommonItem->getFromDB($p_itemtype, $p_items_id); echo "<form method='post' action=\"{$p_target}\">"; echo "<input type='hidden' name='ID' value='{$p_items_id}'>"; echo "<input type='hidden' name='type' value='{$p_itemtype}'>"; echo "<table class='tab_cadre'>"; echo "<tr><th> " . $LANG['plugin_fusioninventory']["functionalities"][73] . " </th>"; echo "<th> " . $LANG['plugin_fusioninventory']["functionalities"][74] . " </th>"; echo "<th> " . $LANG['plugin_fusioninventory']["functionalities"][75] . " </th></tr>"; foreach ($lockable_fields as $key => $val) { if (in_array($val, $locked)) { $checked = 'checked'; } else { $checked = ''; } echo "<tr class='tab_bg_1'><td>" . $FUSIONINVENTORY_MAPPING_FIELDS[$val] . "</td>\n <td>" . $CommonItem->getField($val) . "</td><td align='center'><input type='checkbox' name='lockfield_fusioninventory[" . $val . "]' {$checked}></td></tr>"; } echo "<tr class='tab_bg_2'><td align='center' colspan='3'>\n <input class='submit' type='submit' name='unlock_field_fusioninventory'\n value='" . $LANG['buttons'][7] . "'></td></tr>"; echo "</table>"; echo "</form>"; echo "</div>"; }
/** * Get multiple lockable select * *@param $p_itemtype Table name. *TODO: check rights * *@return nothing **/ static function getLockableSelect($p_itemtype) { global $DB, $LINK_ID_TABLE; $tableId = array_search($p_itemtype, $LINK_ID_TABLE); if ($tableId != 0) { $lockable_fields = PluginFusioninventoryLockable::getLockableFields('', $tableId); include GLPI_ROOT . "/plugins/fusioninventory/inc_constants/mapping.fields.constant.php"; echo '<SELECT NAME="columnLockable[]" MULTIPLE SIZE="15">'; if (count($lockable_fields)) { foreach ($lockable_fields as $key => $val) { echo "<OPTION value='{$val}'>{$FUSIONINVENTORY_MAPPING_FIELDS[$val]}</OPTION>\n"; } } echo '</SELECT>'; } }
foreach ($_POST as $key => $val) { if (is_int($key)) { $input = array(); $input['ID'] = $key; $input['days'] = $val; $pficsnmph->update($input); } } break; } if (isset($config1)) { $config1->update($_POST); } glpi_header($_SERVER['HTTP_REFERER']); } else { if (isset($_POST['Clean_history'])) { $history = new PluginFusioninventorySnmphistory(); $history->CleanHistory(""); glpi_header($_SERVER['HTTP_REFERER']); } else { if (isset($_POST['plugin_fusioninventory_lockable_add']) or isset($_POST['plugin_fusioninventory_lockable_delete'])) { PluginFusioninventoryLockable::setLockableForm($_POST); glpi_header($_SERVER['HTTP_REFERER']); } } } $config = new PluginFusioninventoryConfig(); $config->showTabs('1', '', $_SESSION['glpi_tab']); echo "<div id='tabcontent'></div>"; echo "<script type='text/javascript'>loadDefaultTab();</script>"; commonFooter();
$config_modules->showForm($_POST['target'], '1'); $history = new PluginFusioninventorySnmphistory(); $history->showForm($_POST['target'], '1'); $ptLockable = new PluginFusioninventoryLockable(); $ptLockable->showForm($_POST['target']); break; case 2: $config_modules = new PluginFusioninventoryConfigModules(); $config_modules->showForm($_POST['target'], '1'); break; case 7: // Historique $history = new PluginFusioninventoryConfigSNMPHistory(); $history->showForm($_POST['target']); break; case 8: // lockables $ptLockable = new PluginFusioninventoryLockable(); $ptLockable->showForm($_POST['target']); break; default: if (!displayPluginAction(COMPUTER_TYPE, $_POST["ID"], $_POST['glpi_tab'], $_POST["withtemplate"])) { $config = new PluginFusioninventoryConfig(); $config->showForm($_POST['target'], '1'); } break; } } else { echo $LANG['common'][83] . "<br/>"; } ajaxFooter();
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. GLPI 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 GLPI; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------- */ // ---------------------------------------------------------------------- // Original Author of file: MAZZONI Vincent // Purpose of file: // ---------------------------------------------------------------------- // Direct access to file if (strstr($_SERVER['PHP_SELF'], "lockable.lockables.php")) { define('GLPI_ROOT', '../../..'); include GLPI_ROOT . "/inc/includes.php"; header("Content-Type: text/html; charset=UTF-8"); header_nocache(); } if (!defined('GLPI_ROOT')) { die("Can not acces directly to this file"); } if (isset($_POST["tableSelect"])) { PluginFusioninventoryLockable::getLockableSelect($_POST["tableSelect"]); }
/** * Hook after updates * * @param $parm * @return nothing * **/ function plugin_item_update_fusioninventory($parm) { if (isset($_SESSION["glpiID"]) and $_SESSION["glpiID"] != '') { // manual task $plugin = new Plugin(); if ($plugin->isActivated('fusioninventory')) { // lock fields which have been updated $type = $parm['type']; $ID = $parm['ID']; $fieldsToLock = $parm['updates']; $lockables = PluginFusioninventoryLockable::getLockableFields('', $type); $fieldsToLock = array_intersect($fieldsToLock, $lockables); // do not lock unlockable fields PluginFusioninventoryLock::addLocks($type, $ID, $fieldsToLock); } } }