diff --git a/app/classes/Framadate/Form.php b/app/classes/Framadate/Form.php index 52437e5..f8620de 100644 --- a/app/classes/Framadate/Form.php +++ b/app/classes/Framadate/Form.php @@ -52,6 +52,12 @@ class Form */ public $hidden; + /** + * If true, the author want to customize the URL + * @var boolean + */ + public $use_customized_url; + /** * If true, a password will be needed to access the poll * @var boolean @@ -99,4 +105,4 @@ class Form usort($this->choices, array('Framadate\Choice', 'compare')); } -} \ No newline at end of file +} diff --git a/create_poll.php b/create_poll.php index f90562f..24bf5c1 100644 --- a/create_poll.php +++ b/create_poll.php @@ -56,8 +56,8 @@ if (isset($_GET['type']) && $_GET['type'] == 'date' || $goToStep2 = filter_input(INPUT_POST, GO_TO_STEP_2, FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '/^(date|classic)$/']]); if ($goToStep2) { $title = $inputService->filterTitle($_POST['title']); - $customizeId = isset($_POST['customize_id']) ? $inputService->filterBoolean($_POST['customize_id']) : false; - $id = $customizeId == true ? $inputService->filterId($_POST['id']) : null; + $use_customized_url = isset($_POST['use_customized_url']) ? $inputService->filterBoolean($_POST['use_customized_url']) : false; + $customized_url = $use_customized_url == true ? $inputService->filterId($_POST['customized_url']) : null; $name = $inputService->filterName($_POST['name']); $mail = $config['use_smtp'] == true ? $inputService->filterMail($_POST['mail']) : null; $description = $inputService->filterDescription($_POST['description']); @@ -77,10 +77,11 @@ if ($goToStep2) { $error_on_description = false; $error_on_password = false; $error_on_password_repeat = false; - $error_on_id = false; + $error_on_customized_url = false; $_SESSION['form']->title = $title; - $_SESSION['form']->id = $id; + $_SESSION['form']->id = $customized_url; + $_SESSION['form']->use_customized_url = $use_customized_url; $_SESSION['form']->admin_name = $name; $_SESSION['form']->admin_mail = $mail; $_SESSION['form']->description = $description; @@ -102,12 +103,12 @@ if ($goToStep2) { $error_on_title = true; } - if ($customizeId) { - if ($id === false) { - $error_on_id = true; - } else if ($pollRepository->existsById($id)) { - $error_on_id = true; - $error_on_id_msg = __('Error', 'Poll id already used'); + if ($use_customized_url) { + if ($customized_url === false) { + $error_on_customized_url = true; + } else if ($pollRepository->existsById($customized_url)) { + $error_on_customized_url = true; + $error_on_customized_url_msg = __('Error', 'Poll id already used'); } } @@ -134,7 +135,7 @@ if ($goToStep2) { } } - if ($title && $name && $email_OK && !$error_on_title && !$error_on_id && !$error_on_description && !$error_on_name + if ($title && $name && $email_OK && !$error_on_title && !$error_on_customized_url && !$error_on_description && !$error_on_name && !$error_on_password && !$error_on_password_repeat ) { @@ -172,7 +173,7 @@ $errors = array( 'aria' => '', 'class' => '' ), - 'id' => array( + 'customized_url' => array( 'msg' => '', 'aria' => '', 'class' => '' @@ -215,10 +216,10 @@ if (!empty($_POST[GO_TO_STEP_2])) { $errors['title']['msg'] = __('Error', 'Something is wrong with the format'); } - if ($error_on_id) { - $errors['id']['aria'] = 'aria-describeby="poll_comment_error" '; - $errors['id']['class'] = ' has-error'; - $errors['id']['msg'] = isset($error_on_id_msg) ? $error_on_id_msg : __('Error', 'Something is wrong with the format'); + if ($error_on_customized_url) { + $errors['customized_url']['aria'] = 'aria-describeby="customized_url" '; + $errors['customized_url']['class'] = ' has-error'; + $errors['customized_url']['msg'] = isset($error_on_customized_url_msg) ? $error_on_customized_url_msg : __('Error', 'Something is wrong with the format'); } if ($error_on_description) { @@ -269,7 +270,8 @@ $smarty->assign('goToStep2', GO_TO_STEP_2); $smarty->assign('poll_type', $poll_type); $smarty->assign('poll_title', Utils::fromPostOrDefault('title', $_SESSION['form']->title)); -$smarty->assign('poll_id', Utils::fromPostOrDefault('id', $_SESSION['form']->id)); +$smarty->assign('customized_url', Utils::fromPostOrDefault('customized_url', $_SESSION['form']->id)); +$smarty->assign('use_customized_url', Utils::fromPostOrDefault('use_customized_url', $_SESSION['form']->use_customized_url)); $smarty->assign('poll_description', Utils::fromPostOrDefault('description', $_SESSION['form']->description)); $smarty->assign('poll_name', Utils::fromPostOrDefault('name', $_SESSION['form']->admin_name)); $smarty->assign('poll_mail', Utils::fromPostOrDefault('mail', $_SESSION['form']->admin_mail)); diff --git a/js/app/create_poll.js b/js/app/create_poll.js index 601fd7c..d708726 100644 --- a/js/app/create_poll.js +++ b/js/app/create_poll.js @@ -34,27 +34,13 @@ $(document).ready(function () { }); /** - * Enable/Disable custom id options + * Enable/Disable custom url options */ - var $pollId = $("#poll_id"); - var $customizeId = $("#customize_id"); - - // Init checkbox + input - if (($pollId.val() || $pollId.attr('value') || "").length > 0) { - $customizeId.attr('checked', 'checked'); - $pollId.removeAttr("disabled"); - } - // Listen for checkbox changes - $customizeId.change(function () { + $("#use_customized_url").change(function () { if ($(this).prop("checked")) { - $pollId - .removeAttr("disabled") - .val($pollId.attr("tmp") || $pollId.attr('value')); + $("#customized_url_options").removeClass("hidden"); } else { - $pollId - .attr("disabled", "disabled") - .attr("tmp", $pollId.val()) - .val(""); + $("#customized_url_options").addClass("hidden"); } }); @@ -90,4 +76,4 @@ $(document).ready(function () { document.getElementById("cookie-warning").setAttribute("style", ""); } -}); \ No newline at end of file +}); diff --git a/locale/de.json b/locale/de.json index 9034792..6fd40d8 100644 --- a/locale/de.json +++ b/locale/de.json @@ -241,7 +241,9 @@ "Use a password to restrict access": "Verwende ein Passwort um den Zugriff zu beschänken", "The results are publicly visible": "Die Ergebnisse sind öffentlich Einsehbar", "Poll password": "Password", - "Confirm password": "Passwort bestätigen", + "Password choice": "DE_Choix", + "Password confirmation": "DE_Confirmation", + "Permissions": "DE_Permissions", "Go to step 2": "Weiter zum 2. Schritt" }, "Step 2": { diff --git a/locale/en.json b/locale/en.json index cc49b95..dd96545 100644 --- a/locale/en.json +++ b/locale/en.json @@ -229,7 +229,7 @@ "You are in the poll creation section.": "You are in the poll creation section.", "Required fields cannot be left blank.": "Required fields cannot be left blank.", "Poll title": "Poll title", - "Poll id": "Identifier", + "Poll id": "Poll link", "Poll id rules": "The identifier can contain letters, numbers and dashes \"-\".", "Poll id warning": "By defining an identifier that can facilitate access to the poll for unwanted people. It is recommended to protect it with a password.", "Votes cannot be modified": "Votes cannot be modified", @@ -241,7 +241,9 @@ "Use a password to restrict access": "Use a password to restrict access", "The results are publicly visible": "The results are publicly visible", "Poll password": "Password", - "Confirm password": "Confirmer votre mot de passe", + "Password choice": "Choice", + "Password confirmation": "Confirmation", + "Permissions": "Permissions", "Go to step 2": "Go to step 2" }, "Step 2": { @@ -420,4 +422,4 @@ "Check again": "Check again", "Continue the installation": "Continue the installation" } -} \ No newline at end of file +} diff --git a/locale/es.json b/locale/es.json index 7d1a56e..e51ec5b 100644 --- a/locale/es.json +++ b/locale/es.json @@ -241,7 +241,9 @@ "Use a password to restrict access": "ES_Utiliser un mot de passe pour restreindre l'accès au sondage", "The results are publicly visible": "ES_Les résultats sont visibles sans mot de passe", "Poll password": "ES_Mot de passe", - "Confirm password": "ES_Confirmer votre mot de passe", + "Password choice": "ES_Choix", + "Password confirmation": "ES_Confirmation", + "Permissions": "ES_Permissions", "Go to step 2": "Ir al paso número 2" }, "Step 2": { diff --git a/locale/fr.json b/locale/fr.json index e80c610..d5dae19 100644 --- a/locale/fr.json +++ b/locale/fr.json @@ -229,19 +229,22 @@ "You are in the poll creation section.": "Vous avez choisi de créer un nouveau sondage.", "Required fields cannot be left blank.": "Merci de remplir les champs obligatoires, marqués d'une *.", "Poll title": "Titre du sondage", - "Poll id": "Identifiant", - "Poll id rules": "L'identifiant peut contenir des lettres, des chiffres et des tirets \"-\".", - "Poll id warning": "En définissant un identifiant cela peut faciliter l'accès à ce sondage pour des personnes non désirées. Il est recommandé de le protéger par mot de passe.", + "Poll id": "Lien du sondage", + "Customize the URL": "Personnaliser le lien", + "Poll id rules": "(peut contenir des lettres, des chiffres et des tirets)", + "Poll id warning": "La modification du lien du sondage peut faciliter l'accès à ce sondage pour des personnes non désirées. Il est recommandé de le protéger par mot de passe.", "Votes cannot be modified": "Aucun vote ne peut être modifié", "All voters can modify any vote": "Tous les sondés peuvent modifier tous les votes", "Voters can modify their vote themselves": "Chaque sondé peut modifier son propre vote", - "To receive an email for each new vote": "Recevoir un courriel à chaque participation d'un sondé", + "To receive an email for each new vote": "Recevoir un courriel à chaque participation", "To receive an email for each new comment": "Recevoir un courriel à chaque commentaire", "Only the poll maker can see the poll's results": "Seul le créateur du sondage peut voir les résultats", - "Use a password to restrict access": "Utiliser un mot de passe pour restreindre l'accès au sondage", + "Use a password to restrict access": "Restreindre l'accès au sondage par mot de passe", "The results are publicly visible": "Les résultats sont visibles sans mot de passe", "Poll password": "Mot de passe", - "Confirm password": "Confirmer votre mot de passe ", + "Password choice": "Choix", + "Password confirmation": "Confirmation", + "Permissions": "Permissions", "Go to step 2": "Aller à l'étape 2" }, "Step 2": { @@ -419,4 +422,4 @@ "Check again": "Vérifier à nouveau", "Continue the installation": "Continuer l'installation" } -} \ No newline at end of file +} diff --git a/locale/it.json b/locale/it.json index 5a0cabb..6ae6de4 100644 --- a/locale/it.json +++ b/locale/it.json @@ -241,7 +241,9 @@ "Use a password to restrict access": "Utilizzare una passwor per limitare l'accesso al sondaggio", "The results are publicly visible": "I risultati sono visibili senza password", "Poll password": "Password", - "Confirm password": "Conferma della password", + "Password choice": "IT_Choix", + "Password confirmation": "Conferma della password", + "Permissions": "IT_Permissions", "Go to step 2": "Andare al punto 2" }, "Step 2": { diff --git a/locale/oc.json b/locale/oc.json index b8f5688..7f0033f 100644 --- a/locale/oc.json +++ b/locale/oc.json @@ -241,7 +241,9 @@ "Use a password to restrict access": "OC_Utiliser un mot de passe pour restreindre l'accès au sondage", "The results are publicly visible": "OC_Les résultats sont visibles sans mot de passe", "Poll password": "OC_Mot de passe", - "Confirm password": "OC_Confirmer votre mot de passe ", + "Password choice": "OC_Choix", + "Password confirmation": "OC_Confirmation", + "Permissions": "OC_Permissions", "Go to step 2": "Anar a l'etapa 2" }, "Step 2": { @@ -419,4 +421,4 @@ "Check again": "OC_Vérifier à nouveau", "Continue the installation": "OC_Continuer l'installation" } -} \ No newline at end of file +} diff --git a/tpl/create_poll.tpl b/tpl/create_poll.tpl index 780431e..f773e2e 100644 --- a/tpl/create_poll.tpl +++ b/tpl/create_poll.tpl @@ -17,63 +17,6 @@

-
- - -
- -
-
- {if !empty($errors['title']['msg'])} -
-

- {$errors['title']['msg']} -

-
- {/if} - -
- - -
-
- - - - -
- {__('Step 1', 'Poll id rules')} - {__('Step 1', 'Poll id warning')} -
-
- {if !empty($errors['id']['msg'])} -
-

- {$errors['id']['msg']} -

-
- {/if} - -
- - -
- -
-
- {if !empty($errors['description']['msg'])} -
-

- {$errors['description']['msg']} -

-
- {/if} -
@@ -118,8 +61,143 @@ {/if} +
+ + +
+ +
+
+ {if !empty($errors['title']['msg'])} +
+

+ {$errors['title']['msg']} +

+
+ {/if} + +
+ + +
+ +
+
+ {if !empty($errors['description']['msg'])} +
+

+ {$errors['description']['msg']} +

+
+ {/if} + + {* Poll identifier *} + +
+ + +
+
+ +
+
+
+
+
+ + +
+
+ + {$SERVER_URL} + + +
+ {__('Step 1', 'Poll id warning')} +
+
+ {if !empty($errors['customized_url']['msg'])} +
+

+ {$errors['customized_url']['msg']} +

+
+ {/if} +
+ + {* Password *} +
-
+ + +
+
+ +
+
+ + +
+ +
+ +
-
-
-
- -
-
- -
- - - - - -

-{/block} \ No newline at end of file +{/block}