Beispiel #1
0
/**
 * Add a poll
 *
 * @return	void
 */
function ajouter_sondage()
{
    global $db, $user;
    require_once DOL_DOCUMENT_ROOT . '/opensurvey/class/opensurveysondage.class.php';
    $sondage = dol_survey_random(16);
    $allow_comments = empty($_SESSION['allow_comments']) ? 0 : 1;
    $allow_spy = empty($_SESSION['allow_spy']) ? 0 : 1;
    // Insert survey
    $opensurveysondage = new Opensurveysondage($db);
    $opensurveysondage->id_sondage = $sondage;
    $opensurveysondage->commentaires = $_SESSION['commentaires'];
    $opensurveysondage->mail_admin = $_SESSION['adresse'];
    $opensurveysondage->nom_admin = $_SESSION['nom'];
    $opensurveysondage->titre = $_SESSION['titre'];
    $opensurveysondage->date_fin = $_SESSION['champdatefin'];
    $opensurveysondage->format = $_SESSION['formatsondage'];
    $opensurveysondage->mailsonde = $_SESSION['mailsonde'];
    $opensurveysondage->allow_comments = $allow_comments;
    $opensurveysondage->allow_spy = $allow_spy;
    $opensurveysondage->sujet = $_SESSION['toutchoix'];
    $res = $opensurveysondage->create($user);
    if ($res < 0) {
        dol_print_error($db);
    }
    unset($_SESSION["titre"]);
    unset($_SESSION["nom"]);
    unset($_SESSION["adresse"]);
    unset($_SESSION["commentaires"]);
    unset($_SESSION["mailsonde"]);
    unset($_SESSION['allow_comments']);
    unset($_SESSION['allow_spy']);
    unset($_SESSION['toutchoix']);
    unset($_SESSION['totalchoixjour']);
    unset($_SESSION['champdatefin']);
    $urlback = dol_buildpath('/opensurvey/card.php', 1) . '?id=' . $sondage;
    header("Location: " . $urlback);
    exit;
}