function doSpecificMassiveActions($input = array()) { $res = array('ok' => 0, 'ko' => 0, 'noright' => 0); $projet_item = new PluginProjetProjet_Item(); switch ($input['action']) { case "Transfert": if ($input['itemtype'] == 'PluginProjetProjet') { foreach ($input["item"] as $key => $val) { if ($val == 1) { $PluginProjetTask = new PluginProjetTask(); $restrict = "`plugin_projet_projets_id` = '" . $key . "'"; $tasks = getAllDatasFromTable("glpi_plugin_projet_tasks"); if (!empty($tasks)) { foreach ($tasks as $task) { $PluginProjetTask->getFromDB($task["id"]); $tasktype = PluginProjetTaskType::transfer($PluginProjetTask->fields["plugin_projet_tasktypes_id"], $input['entities_id']); if ($tasktype > 0) { $values["id"] = $task["id"]; $values["plugin_projet_tasktypes_id"] = $tasktype; $PluginProjetTask->update($values); } $values["id"] = $task["id"]; $values["entities_id"] = $input['entities_id']; $PluginProjetTask->update($values); } } unset($values); $values["id"] = $key; $values["entities_id"] = $input['entities_id']; if ($this->update($values)) { $res['ok']++; } else { $res['ko']++; } } } } break; case "Install": foreach ($input["item"] as $key => $val) { if ($val == 1) { $values = array('plugin_projet_projets_id' => $key, 'items_id' => $input["item_item"], 'itemtype' => $input['typeitem']); if ($projet_item->add($values)) { $res['ok']++; } else { $res['ko']++; } } } break; case "Desinstall": foreach ($input["item"] as $key => $val) { if ($val == 1) { if ($projet_item->deleteItemByProjetAndItem($key, $input['item_item'], $input['typeitem'])) { $res['ok']++; } else { $res['ko']++; } } } break; default: return parent::doSpecificMassiveActions($input); break; } return $res; }
} if (!isset($_GET["plugin_projet_projets_id"])) { $_GET["plugin_projet_projets_id"] = 0; } $task = new PluginProjetTask(); $task_item = new PluginProjetTask_Item(); $task_task = new PluginProjetTask_Task(); //add tasks if (isset($_POST['add'])) { $task->check(-1, 'w', $_POST); $newID = $task->add($_POST); Html::back(); } else { if (isset($_POST["update"])) { $task->check($_POST['id'], 'w'); $task->update($_POST); Html::back(); } else { if (isset($_POST["delete"])) { $task->check($_POST['id'], 'w'); $task->delete($_POST); Html::redirect(Toolbox::getItemTypeFormURL('PluginProjetProjet') . "?id=" . $_POST["plugin_projet_projets_id"]); } else { if (isset($_POST["restore"])) { $task->check($_POST['id'], 'w'); $task->restore($_POST); Html::redirect(Toolbox::getItemTypeFormURL('PluginProjetProjet') . "?id=" . $_POST["plugin_projet_projets_id"]); } else { if (isset($_POST["purge"])) { $task->check($_POST['id'], 'w'); $task->delete($_POST, 1);