$criteria->delete(array('id' => $key)); } } } } else if (isset($_POST['id'])) {*/ $criteria->check($_POST['id'], 'w'); $criteria->delete($_POST); $criteria->redirectToList(); // } Html::back(); } else { if (isset($_POST["add_action"])) { $criteria->check($_POST['plugin_typology_typologycriterias_id'], 'w'); $definition = new PluginTypologyTypologyCriteriaDefinition(); $definition->add($_POST); // Mise à jour de l'heure de modification pour le critère $criteria->update(array('id' => $_POST['plugin_typology_typologycriterias_id'], 'date_mod' => $_SESSION['glpi_currenttime'])); Html::back(); } else { if (isset($_POST["delete_action"])) { $definition = new PluginTypologyTypologyCriteriaDefinition(); if (isset($_POST["item"]) && count($_POST["item"])) { foreach ($_POST["item"] as $key => $val) { if ($val == 1) { if ($definition->can($key, 'w')) { $definition->delete(array('id' => $key)); } } } } else {
/** * Do the specific massive actions * * @since version 0.84 * * @param $input array of input datas * * @return an array of results (nbok, nbko, nbnoright counts) **/ function doSpecificMassiveActions($input = array()) { $res = array('ok' => 0, 'ko' => 0, 'noright' => 0); $criteria = new PluginTypologyTypologyCriteria(); $definition = new PluginTypologyTypologyCriteriaDefinition(); switch ($input['action']) { case "Transfert": if ($input['itemtype'] == 'PluginTypologyTypology') { foreach ($input["item"] as $key => $val) { if ($val == 1) { $this->getFromDB($key); $restrict = "`plugin_typology_typologies_id` = '" . $key . "'"; $crits = getAllDatasFromTable("glpi_plugin_typology_typologycriterias", $restrict); if (!empty($crits)) { foreach ($crits as $crit) { $criteria->getFromDB($crit["id"]); $condition = "`plugin_typology_typologycriterias_id` = '" . $crit["id"] . "'"; $defs = getAllDatasFromTable("glpi_plugin_typology_typologycriteriadefinitions", $condition); if (!empty($defs)) { foreach ($defs as $def) { $definition->getFromDB($def["id"]); unset($values); $values["id"] = $def["id"]; $values["entities_id"] = $input['entities_id']; $definition->update($values); } } unset($values); $values["id"] = $crit["id"]; $values["entities_id"] = $input['entities_id']; $criteria->update($values); } } unset($values); $values["id"] = $key; $values["entities_id"] = $input['entities_id']; if ($this->update($values)) { $res['ok']++; } else { $res['ko']++; } } } } break; case "Duplicate": if ($input['itemtype'] == 'PluginTypologyTypology') { foreach ($input["item"] as $key => $val) { if ($val == 1) { $this->getFromDB($key); $restrict = "`plugin_typology_typologies_id` = '" . $key . "'"; $crits = getAllDatasFromTable("glpi_plugin_typology_typologycriterias", $restrict); unset($this->fields["id"]); $this->fields["name"] = addslashes($this->fields["name"] . " Copy"); $this->fields["comment"] = addslashes($this->fields["comment"]); $this->fields["notepad"] = addslashes($this->fields["notepad"]); $newIDtypo = $this->add($this->fields); if ($newIDtypo) { $res['ok']++; } else { $res['ko']++; } if (!empty($crits)) { foreach ($crits as $crit) { $criteria->getFromDB($crit["id"]); $condition = "`plugin_typology_typologycriterias_id` = '" . $crit["id"] . "'"; $defs = getAllDatasFromTable("glpi_plugin_typology_typologycriteriadefinitions", $condition); unset($criteria->fields["id"]); $criteria->fields["name"] = addslashes($criteria->fields["name"]); $criteria->fields["plugin_typology_typologies_id"] = $newIDtypo; $criteria->fields["itemtype"] = addslashes($criteria->fields["itemtype"]); $newIDcrit = $criteria->add($criteria->fields); if (!empty($defs)) { foreach ($defs as $def) { $definition->getFromDB($def["id"]); unset($definition->fields["id"]); $definition->fields["plugin_typology_typologycriterias_id"] = $newIDcrit; $definition->fields["field"] = addslashes($definition->fields["field"]); $definition->fields["action_type"] = addslashes($definition->fields["action_type"]); $definition->fields["value"] = addslashes($definition->fields["value"]); $definition->add($definition->fields); } } } } } } } break; default: return parent::doSpecificMassiveActions($input); } return $res; }