Ejemplo n.º 1
0
<?php

include '../../../inc/includes.php';
Session::checkLoginUser();
if (empty($_REQUEST["id"])) {
    $_REQUEST["id"] = "";
}
$form = new PluginFormcreatorForm();
if (isset($_POST["add"])) {
    $form->check(-1, 'w', $_POST);
    $newID = $form->add($_POST);
    $newTarget = $form->createDefaultTarget($newID);
    $newSection = $form->createDefaultSection($newID, $newTarget);
    Html::redirect($CFG_GLPI["root_doc"] . "/plugins/formcreator/front/form.form.php?id=" . $newID);
} else {
    if (isset($_POST["delete"])) {
        $form->check($_POST["id"], 'd');
        $form->delete($_POST);
        $formID = $_POST["id"];
        //suppresion question
        $question = new PluginFormcreatorQuestion();
        $listQuestion = $question->find("plugin_formcreator_forms_id = '{$formID}'");
        foreach ($listQuestion as $question_id => $values) {
            $question->delete($values);
        }
        //suppresion section
        $section = new PluginFormcreatorSection();
        $listSection = $section->find("plugin_formcreator_forms_id = '{$formID}'");
        foreach ($listSection as $section_id => $values) {
            $section->delete($values);
        }