title) || !isset($_SESSION['form']->admin_name) || ($config['use_smtp'] && !isset($_SESSION['form']->admin_mail))) { Utils::print_header ( __('Error', 'Error!') ); bandeau_titre(__('Error', 'Error!')); echo '

' . __('Error', 'You haven\'t filled the first section of the poll creation.') . ' !

' . __('Error', 'Back to the homepage of') . ' ' . '' . NOMAPPLICATION . '.

'; bandeau_pied(); } else { $min_time = time() + 86400; $max_time = time() + (86400 * $config['default_poll_duration']); // Step 4 : Data prepare before insert in DB if (!empty($_POST['confirmation'])) { // Define expiration date $enddate = filter_input(INPUT_POST, 'enddate', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '#^[0-9]{2}/[0-9]{2}/[0-9]{4}$#']]); if (!empty($enddate)) { $registredate = explode('/', $enddate); if (is_array($registredate) && count($registredate) == 3) { $time = mktime(0, 0, 0, $registredate[1], $registredate[0], $registredate[2]); if ($time < $min_time) { $_SESSION['form']->end_date = $min_time; } elseif ($max_time < $time) { $_SESSION['form']->end_date = $max_time; } else { $_SESSION['form']->end_date = $time; } } } if (empty($_SESSION['form']->end_date)) { // By default, expiration date is 6 months after last day $_SESSION['form']->end_date = $max_time; } // Insert poll in database $ids = $pollService->createPoll($_SESSION['form']); $poll_id = $ids[0]; $admin_poll_id = $ids[1]; // Send confirmation by mail if enabled if ($config['use_smtp'] === true) { $message = __('Mail', "This is the message you have to send to the people you want to poll. \nNow, you have to send this message to everyone you want to poll."); $message .= '

'; $message .= Utils::htmlEscape($_SESSION['form']->admin_name) . ' ' . __('Mail', 'hast just created a poll called') . ' : "' . Utils::htmlEscape($_SESSION['form']->title) . '".
'; $message .= __('Mail', 'Thanks for filling the poll at the link above') . ' :

%s'; $message_admin = __('Mail', "This message should NOT be sent to the polled people. It is private for the poll's creator.\n\nYou can now modify it at the link above"); $message_admin .= ' :

%s'; $message = sprintf($message, Utils::getUrlSondage($poll_id)); $message_admin = sprintf($message_admin, Utils::getUrlSondage($admin_poll_id, true)); if ($mailService->isValidEmail($_SESSION['form']->admin_mail)) { $mailService->send($_SESSION['form']->admin_mail, '[' . NOMAPPLICATION . '][' . __('Mail', 'Author\'s message') . '] ' . __('Generic', 'Poll') . ' : ' . Utils::htmlEscape($_SESSION['form']->title), $message_admin); $mailService->send($_SESSION['form']->admin_mail, '[' . NOMAPPLICATION . '][' . __('Mail', 'For sending to the polled users') . '] ' . __('Generic', 'Poll') . ' : ' . Utils::htmlEscape($_SESSION['form']->title), $message); } } // Clean Form data in $_SESSION unset($_SESSION['form']); // Delete old polls $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])); } } } } } } //le format du sondage est DATE $_SESSION['form']->format = 'D'; // 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)')); $_SESSION['form']->sortChoices(); $last_date = $_SESSION['form']->lastChoice()->getName(); $removal_date = $last_date + (86400 * $config['default_poll_duration']); // Summary $summary = ''; $end_date_str = utf8_encode(strftime('%d/%m/%Y', $max_time)); //textual date echo '

'. __('Step 3', 'Confirm the creation of your poll') .'

'. __('Step 3', 'List of your choices').'

'. $summary .'

' . __('Step 3', 'Your poll will be automatically removed after') . ' ' . $config['default_poll_duration'] . ' ' . __('Generic', 'days') . ' ' .__('Step 3', 'after the last date of your poll:') . '
' . __('Step 3', 'You can set a closer removal date for it.') .'

('. __('Date', 'dd/mm/yyyy') .')

'. __('Step 3', 'Once you have confirmed the creation of your poll, you will be automatically redirected on the administration page of your poll.'). '

'; if($config['use_smtp'] == true) { echo '

' . __('Step 3', 'Then, you will receive quickly two emails: one contening the link of your poll for sending it to the voters, the other contening the link to the administration page of your poll.') .'

'; } echo '

'."\n"; bandeau_pied(); // Step 2/4 : Select dates of the poll } else { Utils::print_header(__('Step 2 date', 'Poll dates (2 on 3)')); bandeau_titre(__('Step 2 date', 'Poll dates (2 on 3)')); echo '

'. __('Step 2 date', 'Choose the dates of your poll') .'

'. __('Step 2 date', 'To schedule an event you need to propose at least two choices (two hours for one day or two days).').'

'. __('Step 2 date', 'You can add or remove additionnal days and hours with the buttons') .' '. __('Remove') .' '. __('Add') .'

'. __('Step 2 date', 'For each selected day, you can choose, or not, meeting hours (e.g.: "8h", "8:30", "8h-10h", "evening", etc.)').'

'; // Fields days : 3 by default $nb_days = (isset($_SESSION['totalchoixjour'])) ? count($_SESSION['totalchoixjour']) : 3; for ($i = 0; $i < $nb_days; $i++) { $day_value = isset($_SESSION['totalchoixjour'][$i]) ? strftime('%d/%m/%Y', $_SESSION['totalchoixjour'][$i]) : ''; echo '
('. __('Date', 'dd/mm/yyyy') .')
'."\n"; // Fields hours : 3 by default $moments = isset($_SESSION['horaires' . $i]) ? $_SESSION['horaires' . $i] : []; for ($j = 0; $j < max(count($moments), 3); $j++) { $hour_value = isset($_SESSION['horaires'.$i][$j]) ? $_SESSION['horaires'.$i][$j] : ''; echo '
'."\n"; } echo '
'; } echo '
'."\n"; bandeau_pied(); } }