/**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     $itemtype = $item->getType();
     switch ($ma->getAction()) {
         case "manage_locks":
             if ($itemtype == "NetworkEquipment" || $itemtype == "Printer" || $itemtype == "Computer") {
                 foreach ($ids as $key) {
                     if (isset($_POST["lockfield_fusioninventory"]) && count($_POST["lockfield_fusioninventory"])) {
                         $tab = PluginFusioninventoryLock::exportChecksToArray($_POST["lockfield_fusioninventory"]);
                         //lock current item
                         if (PluginFusioninventoryLock::setLockArray($_POST['type'], $key, $tab, $_POST['actionlock'])) {
                             //set action massive ok for this item
                             $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                         } else {
                             // KO
                             $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                         }
                     }
                 }
             }
             break;
     }
 }
  @package   FusionInventory
  @author    Vincent Mazzoni
  @co-author
  @copyright Copyright (c) 2010-2014 FusionInventory team
  @license   AGPL License 3.0 or (at your option) any later version
             http://www.gnu.org/licenses/agpl-3.0-standalone.html
  @link      http://www.fusioninventory.org/
  @link      http://forge.fusioninventory.org/projects/fusioninventory-for-glpi/
  @since     2010

  ------------------------------------------------------------------------
*/
include "../../../inc/includes.php";
Session::checkLoginUser();
if (isset($_POST["unlock_field_fusioninventory"])) {
    $typeright = strtolower($_POST['type']);
    if ($typeright == "networkequipment") {
        $typeright = "networking";
    }
    if (Session::haveRight($typeright, UPDATE)) {
        if (isset($_POST["lockfield_fusioninventory"]) && count($_POST["lockfield_fusioninventory"])) {
            $tab = PluginFusioninventoryLock::exportChecksToArray($_POST["lockfield_fusioninventory"]);
            PluginFusioninventoryLock::setLockArray($_POST['type'], $_POST["id"], $tab);
        } else {
            PluginFusioninventoryLock::setLockArray($_POST['type'], $_POST["id"], array());
        }
    }
    Html::back();
}
Html::footer();
示例#3
0
function plugin_fusioninventory_MassiveActionsProcess($data)
{
    global $LANG;
    switch ($data['action']) {
        case "plugin_fusioninventory_get_model":
            if ($data['device_type'] == NETWORKING_TYPE) {
                foreach ($data['item'] as $key => $val) {
                    if ($val == 1) {
                        $PluginFusioninventoryModelInfos = new PluginFusioninventoryModelInfos();
                        $PluginFusioninventoryModelInfos->getrightmodel($key, NETWORKING_TYPE);
                    }
                }
            } else {
                if ($data['device_type'] == PRINTER_TYPE) {
                    foreach ($data['item'] as $key => $val) {
                        if ($val == 1) {
                            $PluginFusioninventoryModelInfos = new PluginFusioninventoryModelInfos();
                            $PluginFusioninventoryModelInfos->getrightmodel($key, PRINTER_TYPE);
                        }
                    }
                }
            }
            break;
        case "plugin_fusioninventory_assign_model":
            if ($data['device_type'] == NETWORKING_TYPE) {
                foreach ($data['item'] as $key => $val) {
                    if ($val == 1) {
                        PluginFusioninventoryMassiveaction::assign($key, NETWORKING_TYPE, "model", $data["snmp_model"]);
                    }
                }
            } else {
                if ($data['device_type'] == PRINTER_TYPE) {
                    foreach ($data['item'] as $key => $val) {
                        if ($val == 1) {
                            PluginFusioninventoryMassiveaction::assign($key, PRINTER_TYPE, "model", $data["snmp_model"]);
                        }
                    }
                }
            }
            break;
        case "plugin_fusioninventory_assign_auth":
            if ($data['device_type'] == NETWORKING_TYPE) {
                foreach ($data['item'] as $key => $val) {
                    if ($val == 1) {
                        PluginFusioninventoryMassiveaction::assign($key, NETWORKING_TYPE, "auth", $data["FK_snmp_connection"]);
                    }
                }
            } else {
                if ($data['device_type'] == PRINTER_TYPE) {
                    foreach ($data['item'] as $key => $val) {
                        if ($val == 1) {
                            PluginFusioninventoryMassiveaction::assign($key, PRINTER_TYPE, "auth", $data["FK_snmp_connection"]);
                        }
                    }
                }
            }
            break;
        case "plugin_fusioninventory_manage_locks":
            if ($data['device_type'] == NETWORKING_TYPE or $data['device_type'] == PRINTER_TYPE) {
                foreach ($data['item'] as $key => $val) {
                    if ($val == 1) {
                        if (isset($data["lockfield_fusioninventory"]) && count($data["lockfield_fusioninventory"])) {
                            $tab = PluginFusioninventoryLock::exportChecksToArray($data["lockfield_fusioninventory"]);
                            PluginFusioninventoryLock::setLockArray($data['type'], $key, $tab);
                        } else {
                            PluginFusioninventoryLock::setLockArray($data['type'], $key, array());
                        }
                    }
                }
            }
            break;
        case "plugin_fusioninventory_discovery_import":
            if (PluginFusioninventory::haveRight("unknowndevices", "w")) {
                $Import = 0;
                $NoImport = 0;
                foreach ($data['item'] as $key => $val) {
                    if ($val == 1) {
                        list($Import, $NoImport) = PluginFusioninventoryDiscovery::import($key, $Import, $NoImport);
                    }
                }
                addMessageAfterRedirect($LANG['plugin_fusioninventory']["discovery"][5] . " : " . $Import);
                addMessageAfterRedirect($LANG['plugin_fusioninventory']["discovery"][9] . " : " . $NoImport);
            }
            break;
    }
}