Limiting the voting time of the survey

This commit is contained in:
Marcos García de La Fuente 2014-01-05 21:54:12 +01:00
parent aa25d2cb81
commit ff7e4e49f3
2 changed files with 24 additions and 2 deletions

View File

@ -66,3 +66,4 @@ ErrorOpenSurveyOneChoice=Enter at least one choice
ErrorOpenSurveyDateFormat=Date must be have the format DD/MM/YYYY ErrorOpenSurveyDateFormat=Date must be have the format DD/MM/YYYY
ErrorInsertingComment=There was an error while inserting your comment ErrorInsertingComment=There was an error while inserting your comment
MoreChoices=Enter more choices for the voters MoreChoices=Enter more choices for the voters
SurveyExpiredInfo=The voting time of this poll has expired.

View File

@ -45,6 +45,9 @@ if ($result <= 0) dol_print_error('','Failed to get survey id '.$numsondage);
$nblignes=count($object->fetch_lines()); $nblignes=count($object->fetch_lines());
//If the survey has not yet finished, then it can be modified
$canbemodified = ($object->date_fin > dol_now());
/* /*
* Actions * Actions
@ -57,6 +60,8 @@ $listofvoters=explode(',',$_SESSION["savevoter"]);
// Add comment // Add comment
if (GETPOST('ajoutcomment')) if (GETPOST('ajoutcomment'))
{ {
if (!$canbemodified) accessforbidden();
$error=0; $error=0;
if (! GETPOST('comment')) if (! GETPOST('comment'))
@ -82,8 +87,10 @@ if (GETPOST('ajoutcomment'))
} }
// Add vote // Add vote
if (isset($_POST["boutonp"]) || isset($_POST["boutonp_x"])) if (isset($_POST["boutonp"]))
{ {
if (!$canbemodified) accessforbidden();
//Si le nom est bien entré //Si le nom est bien entré
if (GETPOST('nom')) if (GETPOST('nom'))
{ {
@ -191,6 +198,8 @@ if ($testmodifier)
} }
} }
if (!$canbemodified) accessforbidden();
$idtomodify=$_POST["idtomodify".$modifier]; $idtomodify=$_POST["idtomodify".$modifier];
$sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_user_studs"; $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_user_studs";
$sql.= " SET reponses = '".$db->escape($nouveauchoix)."'"; $sql.= " SET reponses = '".$db->escape($nouveauchoix)."'";
@ -205,6 +214,8 @@ if ($testmodifier)
$idcomment=GETPOST('deletecomment','int'); $idcomment=GETPOST('deletecomment','int');
if ($idcomment) if ($idcomment)
{ {
if (!$canbemodified) accessforbidden();
$resql = $object->deleteComment($idcomment); $resql = $object->deleteComment($idcomment);
} }
@ -251,6 +262,16 @@ if ($object->commentaires)
print '</div>'."\n"; print '</div>'."\n";
//The survey has expired, users can't vote or do any action
if (!$canbemodified) {
print '<div style="text-align: center"><p>'.$langs->trans('SurveyExpiredInfo').'</p></div>';
llxFooterSurvey();
$db->close();
die;
}
print '<form name="formulaire" action="studs.php?sondage='.$numsondage.'"'.'#bas" method="POST">'."\n"; print '<form name="formulaire" action="studs.php?sondage='.$numsondage.'"'.'#bas" method="POST">'."\n";
print '<input type="hidden" name="sondage" value="' . $numsondage . '"/>'; print '<input type="hidden" name="sondage" value="' . $numsondage . '"/>';