Commit 905208c2 authored by Antonin's avatar Antonin
Browse files

Deny the possibility to add an empty slot.

parent d05a1e51
......@@ -359,21 +359,30 @@ if (isset($_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']);
$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);
} else {
......@@ -383,7 +392,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')));
}
}
......
......@@ -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",
......
......@@ -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",
......
......@@ -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",
......
......@@ -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",
......
......@@ -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",
......
......@@ -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",
......
......@@ -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>
......
{* 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">&times;</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">&times;</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">&times;</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
......@@ -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">&times;</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">&times;</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">&times;</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}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment