Пример #1
0
 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>&nbsp;" . $LANG['plugin_fusioninventory']["functionalities"][73] . "&nbsp;</th>";
     echo "<th>&nbsp;" . $LANG['plugin_fusioninventory']["functionalities"][74] . "&nbsp;</th>";
     echo "<th>&nbsp;" . $LANG['plugin_fusioninventory']["functionalities"][75] . "&nbsp;</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>';
     }
 }
Пример #3
0
/**
 * 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);
        }
    }
}