diff --git a/adminstuds.php b/adminstuds.php index bb450be..701940b 100644 --- a/adminstuds.php +++ b/adminstuds.php @@ -153,7 +153,8 @@ if (isset($_POST['update_poll_info'])) { break; } } elseif ($field == 'expiration_date') { - $expiration_date = filter_input(INPUT_POST, 'expiration_date', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '#^[0-9]+[-/][0-9]+[-/][0-9]+#']]); + $expiration_date = filter_input(INPUT_POST, 'expiration_date', FILTER_VALIDATE_REGEXP, + ['options' => ['regexp' => '#^[0-9]{4}-[0-9]{2}-[0-9]{2}$#']]); if ($expiration_date) { $poll->end_date = $expiration_date; $updated = true; @@ -374,7 +375,7 @@ if (!empty($_GET['delete_column'])) { if ($result) { $message = new Message('success', __('adminstuds', 'Column removed')); } else { - $message = new Message('danger', __('Error', 'Failed to delete the column')); + $message = new Message('danger', __('Error', 'Failed to delete column')); } } diff --git a/app/classes/Framadate/Services/AdminPollService.php b/app/classes/Framadate/Services/AdminPollService.php index b4b47d5..4760f8a 100644 --- a/app/classes/Framadate/Services/AdminPollService.php +++ b/app/classes/Framadate/Services/AdminPollService.php @@ -117,6 +117,10 @@ class AdminPollService { $slots = $this->pollService->allSlotsByPollId($poll_id); + if (count($slots) === 1) { + return false; + } + $index = 0; $indexToDelete = -1; $newMoments = []; @@ -155,6 +159,10 @@ class AdminPollService { $slots = $this->pollService->allSlotsByPollId($poll_id); + if (count($slots) === 1) { + return false; + } + $index = 0; $indexToDelete = -1; diff --git a/app/classes/Framadate/Services/InputService.php b/app/classes/Framadate/Services/InputService.php index c7de298..31b3103 100644 --- a/app/classes/Framadate/Services/InputService.php +++ b/app/classes/Framadate/Services/InputService.php @@ -51,8 +51,7 @@ class InputService { } public function filterTitle($title) { - $filtered = filter_var($title, FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => TITLE_REGEX]]); - return $this->returnIfNotBlank($filtered); + return $this->returnIfNotBlank($title); } public function filterName($name) { @@ -66,7 +65,7 @@ class InputService { public function filterDescription($description) { $description = str_replace("\r\n", "\n", $description); - return filter_var($description, FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => DESCRIPTION_REGEX]]); + return $description; } public function filterBoolean($boolean) { @@ -79,8 +78,7 @@ class InputService { public function filterComment($comment) { $comment = str_replace("\r\n", "\n", $comment); - $filtered = filter_var($comment, FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => COMMENT_REGEX]]); - return $this->returnIfNotBlank($filtered); + return $this->returnIfNotBlank($comment); } /** diff --git a/app/inc/constants.php b/app/inc/constants.php index f043099..d1db10a 100644 --- a/app/inc/constants.php +++ b/app/inc/constants.php @@ -24,9 +24,6 @@ const VERSION = '0.9'; const POLL_REGEX = '/^[a-z0-9]+$/i'; const CHOICE_REGEX = '/^[012]$/'; const NAME_REGEX = '/^[áàâäãåçéèêëíìîïñóòôöõúùûüýÿæœa-z0-9_ -]+$/i'; -const TITLE_REGEX = '/^[áàâäãåçéèêëíìîïñóòôöõúùûüýÿæœa-z0-9\\/ &"\'(_)=~#{|`^@}$[\\]\\\\,;:!?.*-]+$/i'; -const DESCRIPTION_REGEX = "/^[áàâäãåçéèêëíìîïñóòôöõúùûüýÿæœa-z0-9\\/ &\"'(_)=~#{|`^@}$[\\]\\\\,;:!?.*\n-]*$/i"; -const COMMENT_REGEX = "/^[áàâäãåçéèêëíìîïñóòôöõúùûüýÿæœa-z0-9\\/ &\"'(_)=~#{|`^@}$[\\]\\\\,;:!?.*\n-]+$/i"; const BOOLEAN_REGEX = '/^(on|off|true|false|1|0)$/i'; const BOOLEAN_TRUE_REGEX = '/^(on|true|1)$/i'; const EDITABLE_CHOICE_REGEX = '/^[0-2]$/'; diff --git a/create_poll.php b/create_poll.php index 8682c74..43c5b4a 100644 --- a/create_poll.php +++ b/create_poll.php @@ -90,7 +90,7 @@ if ($goToStep2) { $error_on_name = true; } - if ($description !== $_POST['description']) { + if ($description === false) { $error_on_description = true; } diff --git a/locale/de.json b/locale/de.json index 597e553..d70c502 100644 --- a/locale/de.json +++ b/locale/de.json @@ -328,6 +328,7 @@ "Update vote failed": "Update vote failed", "Adding vote failed": "Adding vote failed", "Comment failed": "Kommentar gescheitert", - "You can't create a poll with hidden results with the following edition option:": "Sie können nicht eine Umfrage erstellen mit versteckten Ergebnisse mit der folgenden Ausgabe-Option:" + "You can't create a poll with hidden results with the following edition option:": "Sie können nicht eine Umfrage erstellen mit versteckten Ergebnisse mit der folgenden Ausgabe-Option:", + "Failed to delete column": "Fehler beim Spalte löschen" } } diff --git a/locale/en.json b/locale/en.json index 58441e5..bc4d4ed 100644 --- a/locale/en.json +++ b/locale/en.json @@ -328,6 +328,7 @@ "Update vote failed": "Update vote failed", "Adding vote failed": "Adding vote failed", "Comment failed": "Comment failed", - "You can't create a poll with hidden results with the following edition option:": "You can't create a poll with hidden results with the following edition option: " + "You can't create a poll with hidden results with the following edition option:": "You can't create a poll with hidden results with the following edition option: ", + "Failed to delete column": "Failed to delete column" } } diff --git a/locale/es.json b/locale/es.json index ed52eca..357ff31 100644 --- a/locale/es.json +++ b/locale/es.json @@ -328,6 +328,7 @@ "Update vote failed": "ES_Mise à jour du vote échoué", "Adding vote failed": "ES_Ajout d'un vote échoué", "Comment failed": "ES_Commentaire échoué", - "You can't create a poll with hidden results with the following edition option:": "ES_Vous ne pouvez pas créer de sondage avec résulats cachés avec les options d'éditions suivantes : " + "You can't create a poll with hidden results with the following edition option:": "ES_Vous ne pouvez pas créer de sondage avec résulats cachés avec les options d'éditions suivantes : ", + "Failed to delete column": "Error al eliminar la columna" } } diff --git a/locale/fr.json b/locale/fr.json index 32026b8..cc0f5e6 100644 --- a/locale/fr.json +++ b/locale/fr.json @@ -328,6 +328,7 @@ "Update vote failed": "Mise à jour du vote échoué", "Adding vote failed": "Ajout d'un vote échoué", "Comment failed": "Commentaire échoué", - "You can't create a poll with hidden results with the following edition option:": "Vous ne pouvez pas créer de sondage avec résulats cachés avec les options d'éditions suivantes : " + "You can't create a poll with hidden results with the following edition option:": "Vous ne pouvez pas créer de sondage avec résulats cachés avec les options d'éditions suivantes : ", + "Failed to delete column": "Échec de la suppression de colonne" } } diff --git a/locale/it.json b/locale/it.json index 0d90324..19d702c 100644 --- a/locale/it.json +++ b/locale/it.json @@ -328,6 +328,7 @@ "Update vote failed": "IT_Mise à jour du vote échoué", "Adding vote failed": "IT_Ajout d'un vote échoué", "Comment failed": "IT_Commentaire échoué", - "You can't create a poll with hidden results with the following edition option:": "IT_Vous ne pouvez pas créer de sondage avec résulats cachés avec les options d'éditions suivantes : " + "You can't create a poll with hidden results with the following edition option:": "IT_Vous ne pouvez pas créer de sondage avec résulats cachés avec les options d'éditions suivantes : ", + "Failed to delete column": "Impossibile eliminare colonna" } } \ No newline at end of file diff --git a/studs.php b/studs.php index 9448297..9246943 100644 --- a/studs.php +++ b/studs.php @@ -206,7 +206,7 @@ $smarty->assign('poll_id', $poll_id); $smarty->assign('poll', $poll); $smarty->assign('title', __('Generic', 'Poll') . ' - ' . $poll->title); $smarty->assign('expired', strtotime($poll->end_date) < time()); -$smarty->assign('deletion_date', $poll->end_date + PURGE_DELAY * 86400); +$smarty->assign('deletion_date', strtotime($poll->end_date) + PURGE_DELAY * 86400); $smarty->assign('slots', $poll->format === 'D' ? $pollService->splitSlots($slots) : $slots); $smarty->assign('votes', $pollService->splitVotes($votes)); $smarty->assign('best_choices', $pollService->computeBestChoices($votes)); diff --git a/tpl/part/comments.tpl b/tpl/part/comments.tpl index 660041e..c25adf2 100644 --- a/tpl/part/comments.tpl +++ b/tpl/part/comments.tpl @@ -11,7 +11,7 @@ {/if} {$comment->name|html}  - {nl2br($comment->comment|html)} + {$comment->comment|escape|nl2br} {/foreach} {/if}