/** * @since version 0.85 * * @see CommonDBTM::processMassiveActionsForOneItemtype() **/ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) { $group_item = new PluginFusioninventoryDeployGroup_Staticdata(); switch ($ma->getAction()) { case 'add': $input = $ma->getInput(); foreach ($ids as $key) { if ($item->can($key, UPDATE)) { if (!countElementsInTable($group_item->getTable(), "`plugin_fusioninventory_deploygroups_id`='" . $_POST['id'] . "'\n AND `itemtype`='Computer'\n AND `items_id`='{$key}'")) { $group_item->add(array('plugin_fusioninventory_deploygroups_id' => $_POST['id'], 'itemtype' => 'Computer', 'items_id' => $key)); $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK); } else { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO); } } else { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT); $ma->addMessage($item->getErrorMessage(ERROR_RIGHT)); } } return; case 'deleteitem': foreach ($ids as $key) { $group_item->deleteByCriteria(array('items_id' => $key, 'itemtype' => 'Computer', 'plugin_fusioninventory_deploygroups_id' => $_POST['id'])); } } }
/** * @since version 0.85 * * @see CommonDBTM::processMassiveActionsForOneItemtype() **/ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) { global $DB; switch ($ma->getAction()) { case 'add_to_static_group': if ($item->getType() == 'Computer') { $group_item = new PluginFusioninventoryDeployGroup_Staticdata(); foreach ($ids as $id) { //if ($group_item->can($id, UPDATE)) { if (!countElementsInTable($group_item->getTable(), "`plugin_fusioninventory_deploygroups_id`='" . $_POST['plugin_fusioninventory_deploygroups_id'] . "'\n AND `itemtype`='Computer'\n AND `items_id`='{$id}'")) { $values = array('plugin_fusioninventory_deploygroups_id' => $_POST['plugin_fusioninventory_deploygroups_id'], 'itemtype' => 'Computer', 'items_id' => $id); $group_item->add($values); $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK); } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO); } //} else { // $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT); // $ma->addMessage($item->getErrorMessage(ERROR_RIGHT)); //} } } parent::processMassiveActionsForOneItemtype($ma, $item, $ids); } }