diff --git a/adminstuds.php b/adminstuds.php index a9977db3bddfaddedf34cba0803eaaa64a5475fb..5750828a81ed4d31fe84cc3bc55f7c365413d5a8 100644 --- a/adminstuds.php +++ b/adminstuds.php @@ -333,7 +333,7 @@ if (isset($_POST['confirm_delete_poll'])) { // Delete a slot // ------------------------------- -if (!empty($_GET['delete_column'])) { +if (isset($_GET['delete_column'])) { $column = filter_input(INPUT_GET, 'delete_column', FILTER_DEFAULT); $column = Utils::base64url_decode($column); @@ -360,22 +360,32 @@ if (!empty($_GET['delete_column'])) { // Add a slot // ------------------------------- -if (isset($_GET['add_column'])) { +function exit_displaying_add_column($message = null) { + global $smarty, $poll_id, $admin_poll_id, $poll; $smarty->assign('poll_id', $poll_id); $smarty->assign('admin_poll_id', $admin_poll_id); $smarty->assign('format', $poll->format); $smarty->assign('title', __('Generic', 'Poll') . ' - ' . $poll->title); + $smarty->assign('message', $message); $smarty->display('add_column.tpl'); exit; } + +if (isset($_GET['add_column'])) { + exit_displaying_add_column(); +} + if (isset($_POST['confirm_add_column'])) { try { + if (($poll->format === 'D' && empty($_POST['newdate'])) + || ($poll->format === 'A' && empty($_POST['choice']))) { + exit_displaying_add_column(new Message('danger', __('Error', "Can't create an empty column."))); + } if ($poll->format === 'D') { - $newdate = strip_tags($_POST['newdate']); + $date = DateTime::createFromFormat(__('Date', 'datetime_parseformat'), $_POST['newdate'])->setTime(0, 0, 0); + $time = $date->getTimestamp(); $newmoment = str_replace(',', '-', strip_tags($_POST['newmoment'])); - - $ex = explode('/', $newdate); - $adminPollService->addDateSlot($poll_id, mktime(0, 0, 0, $ex[1], $ex[0], $ex[2]), $newmoment); + $adminPollService->addDateSlot($poll_id, $time, $newmoment); } else { $newslot = str_replace(',', '-', strip_tags($_POST['choice'])); $adminPollService->addClassicSlot($poll_id, $newslot); @@ -383,7 +393,7 @@ if (isset($_POST['confirm_add_column'])) { $message = new Message('success', __('adminstuds', 'Choice added')); } catch (MomentAlreadyExistsException $e) { - $message = new Message('danger', __('Error', 'The column already exists')); + exit_displaying_add_column(new Message('danger', __('Error', 'The column already exists'))); } } diff --git a/locale/de.json b/locale/de.json index 59d6834b1ca2803745d8cf9164894105a42f8399..568adadf22bc876229988ca4427176968777795e 100644 --- a/locale/de.json +++ b/locale/de.json @@ -397,7 +397,8 @@ "Passwords do not match": "DE_Les mot de passes ne correspondent pas.", "Poll id already used": "DE_L'identifiant est déjà utilisé", "You can't select more than %d dates": "DE_Vous ne pouvez pas choisir plus de %d dates", - "Can't create the config.php file in '%s'.": "DE_Impossible de créer le fichier config.php dans '%s'." + "Can't create the config.php file in '%s'.": "DE_Impossible de créer le fichier config.php dans '%s'.", + "Can't create an empty column.": "DE_Impossible de créer une colonne vide." }, "Check": { "Installation checking": "DE_Vérifications de l'installation", diff --git a/locale/en.json b/locale/en.json index c6fade5299f08efc6d3853eb12aab2495873f15b..9faeed6e602585e4bacdd6fe89a61ddd378b1076 100644 --- a/locale/en.json +++ b/locale/en.json @@ -398,7 +398,8 @@ "Passwords do not match": "Passwords do not match.", "Poll id already used": "Identifier is already used", "You can't select more than %d dates": "You can't select more than %d dates", - "Can't create the config.php file in '%s'.": "Can't create the config.php file in '%s'." + "Can't create the config.php file in '%s'.": "Can't create the config.php file in '%s'.", + "Can't create an empty column.": "Can't create an empty column." }, "Check": { "Installation checking": "Installation checking", diff --git a/locale/es.json b/locale/es.json index 2b07f84311bc84850cf4a235ca4a18d94cb591a0..8eebe5803882746b9fd05fd9020d0828bca7079d 100644 --- a/locale/es.json +++ b/locale/es.json @@ -397,7 +397,8 @@ "Passwords do not match": "ES_Les mot de passes ne correspondent pas.", "Poll id already used": "ES_L'identifiant est déjà utilisé", "You can't select more than %d dates": "ES_Vous ne pouvez pas choisir plus de %d dates", - "Can't create the config.php file in '%s'.": "ES_Impossible de créer le fichier config.php dans '%s'." + "Can't create the config.php file in '%s'.": "ES_Impossible de créer le fichier config.php dans '%s'.", + "Can't create an empty column.": "ES_Impossible de créer une colonne vide." }, "Check": { "Installation checking": "ES_Vérifications de l'installation", diff --git a/locale/fr.json b/locale/fr.json index 54c503010d28d6882710b41bcf78d258faccad28..9b33af3ccbab8a575195811cd8fe6cba57041ab8 100644 --- a/locale/fr.json +++ b/locale/fr.json @@ -397,7 +397,8 @@ "Passwords do not match": "Les mots de passe ne correspondent pas.", "Poll id already used": "L'identifiant est déjà utilisé", "You can't select more than %d dates": "Vous ne pouvez pas choisir plus de %d dates", - "Can't create the config.php file in '%s'.": "Impossible de créer le fichier config.php dans '%s'." + "Can't create the config.php file in '%s'.": "Impossible de créer le fichier config.php dans '%s'.", + "Can't create an empty column.": "Impossible de créer une colonne vide." }, "Check": { "Installation checking": "Vérifications de l'installation", diff --git a/locale/it.json b/locale/it.json index 1bbebcd692ff68a0828099218e73f5cd0471d9df..06775a5d3bfcc3d58857d77f7049774cd230002b 100644 --- a/locale/it.json +++ b/locale/it.json @@ -397,7 +397,8 @@ "Passwords do not match": "IT_Les mots de passe ne correspondent pas.", "Poll id already used": "IT_L'identifiant est déjà utilisé", "You can't select more than %d dates": "IT_Vous ne pouvez pas choisir plus de %d dates", - "Can't create the config.php file in '%s'.": "IT_Impossible de créer le fichier config.php dans '%s'." + "Can't create the config.php file in '%s'.": "IT_Impossible de créer le fichier config.php dans '%s'.", + "Can't create an empty column.": "IT_Impossible de créer une colonne vide." }, "Check": { "Installation checking": "IT_Vérifications de l'installation", diff --git a/locale/oc.json b/locale/oc.json index ff70a2f533558b9d51b46888b4930be33f732f83..6f4fcd6361aac1c6e052a0b49d04d350809085f3 100644 --- a/locale/oc.json +++ b/locale/oc.json @@ -397,7 +397,8 @@ "Passwords do not match": "OC_Les mots de passe ne correspondent pas.", "Poll id already used": "OC_L'identifiant est déjà utilisé", "You can't select more than %d dates": "OC_Vous ne pouvez pas choisir plus de %d dates", - "Can't create the config.php file in '%s'.": "OC_Impossible de créer le fichier config.php dans '%s'." + "Can't create the config.php file in '%s'.": "OC_Impossible de créer le fichier config.php dans '%s'.", + "Can't create an empty column.": "OC_Impossible de créer une colonne vide." }, "Check": { "Installation checking": "OC_Vérifications de l'installation", diff --git a/tpl/add_column.tpl b/tpl/add_column.tpl index 7cf1bdd2abf250148713a010fac6aacbc2076132..600b53a24e7a33453f4b987e4052c60c37c1a500 100644 --- a/tpl/add_column.tpl +++ b/tpl/add_column.tpl @@ -11,10 +11,14 @@ {/block} {block name=main} + <form action="{poll_url id=$admin_poll_id admin=true}" method="POST"> <div class="alert alert-info text-center"> <h2>{__('adminstuds', 'Column\'s adding')}</h2> + {* Messages *} + {include 'part/messages.tpl'} + {if $format === 'D'} <div class="form-group"> <label for="newdate" class="col-md-4">{__('Generic', 'Day')}</label> diff --git a/tpl/part/messages.tpl b/tpl/part/messages.tpl new file mode 100644 index 0000000000000000000000000000000000000000..2bcb7b9bbdaf84b9ce9bf3f189e3914c294cd94a --- /dev/null +++ b/tpl/part/messages.tpl @@ -0,0 +1,25 @@ +{* Messages *} +<div id="message-container"> + {if !empty($message)} + <div class="alert alert-dismissible alert-{$message->type|html} hidden-print" role="alert"> + <button type="button" class="close" data-dismiss="alert" aria-label="{__('Generic', 'Close')}"><span aria-hidden="true">×</span></button> + {$message->message|html} + {if $message->link != null} + <div class="input-group input-group-sm"> + <span class="input-group-btn"> + <a {if $message->linkTitle != null} title="{$message->linkTitle|escape}" {/if} class="btn btn-default btn-sm" href="{$message->link}"> + {if $message->linkIcon != null}<i class="glyphicon glyphicon-pencil"></i>{if $message->linkTitle != null}<span class="sr-only">{$message->linkTitle|escape}</span>{/if}{/if} + </a> + </span> + <input type="text" aria-hidden="true" value="{$message->link}" class="form-control" readonly="readonly" > + </div> + {if $message->includeTemplate != null} + {$message->includeTemplate} + {/if} + {/if} + </div> + {/if} +</div> +<div id="nameErrorMessage" class="hidden alert alert-dismissible alert-danger hidden-print" role="alert">{__('Error', 'The name is invalid.')}<button type="button" class="close" data-dismiss="alert" aria-label="{__('Generic', 'Close')}"><span aria-hidden="true">×</span></button></div> +<div id="genericErrorTemplate" class="hidden alert alert-dismissible alert-danger hidden-print" role="alert"><span class="contents"></span><button type="button" class="close" data-dismiss="alert" aria-label="{__('Generic', 'Close')}"><span aria-hidden="true">×</span></button></div> +<div id="genericUnclosableSuccessTemplate" class="hidden alert alert-success hidden-print" role="alert"><span class="contents"></span></div> \ No newline at end of file diff --git a/tpl/studs.tpl b/tpl/studs.tpl index fe4fb7f7f58ab3bddf7fb9e7f29d903a7eb675d1..55348686d8c8926386fccab935783cebe90773a7 100644 --- a/tpl/studs.tpl +++ b/tpl/studs.tpl @@ -13,30 +13,8 @@ {* Messages *} - <div id="message-container"> - {if !empty($message)} - <div class="alert alert-dismissible alert-{$message->type|html} hidden-print" role="alert"> - <button type="button" class="close" data-dismiss="alert" aria-label="{__('Generic', 'Close')}"><span aria-hidden="true">×</span></button> - {$message->message|html} - {if $message->link != null} - <div class="input-group input-group-sm"> - <span class="input-group-btn"> - <a {if $message->linkTitle != null} title="{$message->linkTitle|escape}" {/if} class="btn btn-default btn-sm" href="{$message->link}"> - {if $message->linkIcon != null}<i class="glyphicon glyphicon-pencil"></i>{if $message->linkTitle != null}<span class="sr-only">{$message->linkTitle|escape}</span>{/if}{/if} - </a> - </span> - <input type="text" aria-hidden="true" value="{$message->link}" class="form-control" readonly="readonly" > - </div> - {if $message->includeTemplate != null} - {$message->includeTemplate} - {/if} - {/if} - </div> - {/if} - </div> - <div id="nameErrorMessage" class="hidden alert alert-dismissible alert-danger hidden-print" role="alert">{__('Error', 'The name is invalid.')}<button type="button" class="close" data-dismiss="alert" aria-label="{__('Generic', 'Close')}"><span aria-hidden="true">×</span></button></div> - <div id="genericErrorTemplate" class="hidden alert alert-dismissible alert-danger hidden-print" role="alert"><span class="contents"></span><button type="button" class="close" data-dismiss="alert" aria-label="{__('Generic', 'Close')}"><span aria-hidden="true">×</span></button></div> - <div id="genericUnclosableSuccessTemplate" class="hidden alert alert-success hidden-print" role="alert"><span class="contents"></span></div> + {include 'part/messages.tpl'} + {if !$accessGranted && !$resultPubliclyVisible}