/** * @since version 0.85 * * @see CommonDBTM::processMassiveActionsForOneItemtype() **/ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) { global $DB; switch ($ma->getAction()) { case 'move_version': $input = $ma->getInput(); if (isset($input['softwareversions_id'])) { foreach ($ids as $id) { if ($item->can($id, UPDATE)) { //Process rules if ($item->update(array('id' => $id, 'softwareversions_id' => $input['softwareversions_id']))) { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK); } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO); $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION)); } } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT); $ma->addMessage($item->getErrorMessage(ERROR_RIGHT)); } } } else { $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO); } return; case 'add': $itemtoadd = new Computer_SoftwareVersion(); if (isset($_POST['peer_softwareversions_id'])) { foreach ($ids as $id) { if ($item->can($id, UPDATE)) { //Process rules if ($itemtoadd->add(array('computers_id' => $id, 'softwareversions_id' => $_POST['peer_softwareversions_id']))) { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK); } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO); $ma->addMessage($itemtoadd->getErrorMessage(ERROR_ON_ACTION)); } } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT); $ma->addMessage($itemtoadd->getErrorMessage(ERROR_RIGHT)); } } } else { $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO); } return; } parent::processMassiveActionsForOneItemtype($ma, $item, $ids); }