} } // ------------------------------- // A vote is going to be edited // ------------------------------- if (!empty($_GET['vote'])) { $editingVoteId = filter_input(INPUT_GET, 'vote', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => POLL_REGEX]]); } // ------------------------------- // Something to save (edit or add) // ------------------------------- if (!empty($_POST['save'])) { // Save edition of an old vote $name = $inputService->filterName($_POST['name']); $editedVote = filter_input(INPUT_POST, 'save', FILTER_VALIDATE_INT); $choices = $inputService->filterArray($_POST['choices'], FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => CHOICE_REGEX]]); if (empty($editedVote)) { $message = new Message('danger', __('Error', 'Something is going wrong...')); } if (count($choices) != count($_POST['choices'])) { $message = new Message('danger', __('Error', 'There is a problem with your choices')); } if ($message == null) { // Update vote $result = $pollService->updateVote($poll_id, $editedVote, $name, $choices); if ($result) { $message = new Message('success', __('adminstuds', 'Vote updated')); } else { $message = new Message('danger', __('Error', 'Update vote failed')); } }
$purgeService->purgeOldPolls(); // Redirect to poll administration header('Location:' . Utils::getUrlSondage($admin_poll_id, true)); exit; } else { if (!empty($_POST['days'])) { // Clear previous choices $_SESSION['form']->clearChoices(); for ($i = 0; $i < count($_POST['days']); $i++) { $day = $_POST['days'][$i]; if (!empty($day)) { // Add choice to Form data $time = mktime(0, 0, 0, substr($_POST["days"][$i], 3, 2), substr($_POST["days"][$i], 0, 2), substr($_POST["days"][$i], 6, 4)); $choice = new Choice($time); $_SESSION['form']->addChoice($choice); $schedules = $inputService->filterArray($_POST['horaires' . $i], FILTER_DEFAULT); for ($j = 0; $j < count($schedules); $j++) { if (!empty($schedules[$j])) { $choice->addSlot(strip_tags($schedules[$j])); } } } } } } // Step 3/4 : Confirm poll creation if (!empty($_POST['choixheures']) && !isset($_SESSION['form']->totalchoixjour)) { Utils::print_header(__('Step 3', 'Removal date and confirmation (3 on 3)')); bandeau_titre(__('Step 3', 'Removal date and confirmation (3 on 3)')); $end_date_str = utf8_encode(strftime('%d/%m/%Y', $max_expiry_time)); // textual date