title) || empty($form->admin_name) || (($config['use_smtp']) ? empty($form->admin_mail) : false)) { $smarty->assign('title', __('Error', 'Error!')); $smarty->assign('error', __('Error', 'You haven\'t filled the first section of the poll creation.')); $smarty->display('error.tpl'); exit; } // The poll format is other (A) if we are in this file if (!isset($form->format)) { $form->format = 'A'; } // If we come from another format, we need to clear choices if (isset($form->format) && $form->format !== 'A') { $form->format = 'A'; $form->clearChoices(); } // Step 4 : Data prepare before insert in DB if (isset($_POST['confirmation'])) { // Define expiration date $expiration_date = $inputService->validateDate($_POST['expiration_date'], $pollService->minExpiryDate(), $pollService->maxExpiryDate()); $form->end_date = $expiration_date->getTimestamp(); // Insert poll in database $ids = $pollService->createPoll($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::htmlMailEscape($form->admin_name) . ' ' . __('Mail', 'hast just created a poll called') . ' : "' . Utils::htmlMailEscape($form->title) . '".
'; $message .= sprintf(__('Mail', 'Thanks for filling the poll at the link above') . ' :

%1$s', Utils::getUrlSondage($poll_id)); $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 .= sprintf(' :

%1$s', Utils::getUrlSondage($admin_poll_id, true)); if ($mailService->isValidEmail($form->admin_mail)) { $mailService->send($form->admin_mail, '[' . NOMAPPLICATION . '][' . __('Mail', 'Author\'s message') . '] ' . __('Generic', 'Poll') . ': ' . Utils::htmlEscape($form->title), $message_admin); $mailService->send($form->admin_mail, '[' . NOMAPPLICATION . '][' . __('Mail', 'For sending to the polled users') . '] ' . __('Generic', 'Poll') . ': ' . Utils::htmlEscape($form->title), $message); } } // Clean Form data in $_SESSION unset($_SESSION['form']); // Delete old polls $purgeService->purgeOldPolls(); // creation message $sessionService->set("Framadate", "messagePollCreated", TRUE); // Redirect to poll administration header('Location:' . Utils::getUrlSondage($admin_poll_id, true)); exit; } // Step 3/4 : Confirm poll creation and choose a removal date else if (isset($_POST['fin_sondage_autre'])) { // Store choices in $_SESSION if (isset($_POST['choices'])) { $form->clearChoices(); foreach ($_POST['choices'] as $c) { if (!empty($c)) { $c = strip_tags($c); $choice = new Choice($c); $form->addChoice($choice); } } } // Expiration date is initialised with config parameter. Value will be modified in step 4 if user has defined an other date $form->end_date = $pollService->maxExpiryDate()->format('Y-m-d H:i:s'); // Summary $summary = '
    '; foreach ($form->getChoices() as $i=>$choice) { preg_match_all('/\[!\[(.*?)\]\((.*?)\)\]\((.*?)\)/', $choice->getName(), $md_a_img); // Markdown [![alt](src)](href) preg_match_all('/!\[(.*?)\]\((.*?)\)/', $choice->getName(), $md_img); // Markdown ![alt](src) preg_match_all('/\[(.*?)\]\((.*?)\)/', $choice->getName(), $md_a); // Markdown [text](href) if (isset($md_a_img[2][0]) && $md_a_img[2][0] !== '' && isset($md_a_img[3][0]) && $md_a_img[3][0] !== '') { // [![alt](src)](href) $li_subject_text = (isset($md_a_img[1][0]) && $md_a_img[1][0] !== '') ? stripslashes($md_a_img[1][0]) : __('Generic', 'Choice') . ' ' . ($i + 1); $li_subject_html = '' . $li_subject_text . ''; } elseif (isset($md_img[2][0]) && $md_img[2][0] !== '') { // ![alt](src) $li_subject_text = (isset($md_img[1][0]) && $md_img[1][0] !== '') ? stripslashes($md_img[1][0]) : __('Generic', 'Choice') . ' ' . ($i + 1); $li_subject_html = '' . $li_subject_text . ''; } elseif (isset($md_a[2][0]) && $md_a[2][0] !== '') { // [text](href) $li_subject_text = (isset($md_a[1][0]) && $md_a[1][0] !== '') ? stripslashes($md_a[1][0]) : __('Generic', 'Choice') . ' ' . ($i + 1); $li_subject_html = '' . $li_subject_text . ''; } else { // text only $li_subject_text = stripslashes($choice->getName()); $li_subject_html = $li_subject_text; } $summary .= '
  1. ' . $li_subject_html . '
  2. ' . "\n"; } $summary .= '
'; $end_date_str = utf8_encode(strftime($date_format['txt_date'], $pollService->maxExpiryDate()->getTimestamp())); //textual date $_SESSION['form'] = serialize($form); $smarty->assign('title', __('Step 3', 'Removal date and confirmation (3 on 3)')); $smarty->assign('summary', $summary); $smarty->assign('end_date_str', $end_date_str); $smarty->assign('default_poll_duration', $config['default_poll_duration']); $smarty->assign('use_smtp', $config['use_smtp']); $smarty->display('create_classic_poll_step3.tpl'); // Step 2/4 : Select choices of the poll } else { Utils::print_header(__('Step 2 classic', 'Poll subjects (2 on 3)')); bandeau_titre(__('Step 2 classic', 'Poll subjects (2 on 3)')); echo '
'; echo '

' . __('Step 2 classic', 'To make a generic poll you need to propose at least two choices between differents subjects.') . '

' . __('Step 2 classic', 'You can add or remove additional choices with the buttons') . ' ' . __('Generic', 'Remove') . ' ' . __('Generic', 'Add') . '

'; if ($config['user_can_add_img_or_link']) { echo '

' . __('Step 2 classic', 'It\'s possible to propose links or images by using') . ' ' . __('Step 2 classic', 'the Markdown syntax') . '.

'; } echo '
' . "\n"; // Fields choices : 5 by default $choices = $form->getChoices(); $nb_choices = max(count($choices), 5); for ($i = 0; $i < $nb_choices; $i++) { $choice = isset($choices[$i]) ? $choices[$i] : new Choice(); echo '
'; if ($config['user_can_add_img_or_link']) { echo ' '; } echo '
' . "\n"; } echo '
' . __('Generic', 'Back') . '
' . "\n"; bandeau_pied(); }