} // ------------------------------- // Update poll info // ------------------------------- if (isset($_POST['update_poll_info'])) { $updated = false; $field = $inputService->filterAllowedValues($_POST['update_poll_info'], ['title', 'admin_mail', 'description', 'rules', 'expiration_date', 'name', 'hidden']); // Update the right poll field if ($field == 'title') { $title = $inputService->filterTitle($_POST['title']); if ($title) { $poll->title = $title; $updated = true; } } elseif ($field == 'admin_mail') { $admin_mail = $inputService->filterMail($_POST['admin_mail']); if ($admin_mail) { $poll->admin_mail = $admin_mail; $updated = true; } } elseif ($field == 'description') { $description = $inputService->filterDescription($_POST['description']); if ($description) { $poll->description = $description; $updated = true; } } elseif ($field == 'rules') { $rules = strip_tags($_POST['rules']); switch ($rules) { case 0: $poll->active = false;
$_SESSION['form'] = new Form(); } // Type de sondage if (isset($_GET['type']) && $_GET['type'] == 'date' || isset($_POST['type']) && $_POST['type'] == 'date') { $poll_type = 'date'; $_SESSION['form']->choix_sondage = $poll_type; } else { $poll_type = 'classic'; $_SESSION['form']->choix_sondage = $poll_type; } // We clean the data $goToStep2 = filter_input(INPUT_POST, GO_TO_STEP_2, FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '/^(date|classic)$/']]); if ($goToStep2) { $title = $inputService->filterTitle($_POST['title']); $name = $inputService->filterName($_POST['name']); $mail = $inputService->filterMail($_POST['mail']); $description = $inputService->filterDescription($_POST['description']); $editable = $inputService->filterEditable($_POST['editable']); $receiveNewVotes = isset($_POST['receiveNewVotes']) ? $inputService->filterBoolean($_POST['receiveNewVotes']) : false; $receiveNewComments = isset($_POST['receiveNewComments']) ? $inputService->filterBoolean($_POST['receiveNewComments']) : false; $hidden = isset($_POST['hidden']) ? $inputService->filterBoolean($_POST['hidden']) : false; // On initialise également les autres variables $error_on_mail = false; $error_on_title = false; $error_on_name = false; $error_on_description = false; $_SESSION['form']->title = $title; $_SESSION['form']->admin_name = $name; $_SESSION['form']->admin_mail = $mail; $_SESSION['form']->description = $description; $_SESSION['form']->editable = $editable;