Skip to content

Commit

Permalink
Limiting the voting time of the survey
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosgdf committed Jan 5, 2014
1 parent aa25d2c commit ff7e4e4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
3 changes: 2 additions & 1 deletion htdocs/langs/en_US/opensurvey.lang
Expand Up @@ -65,4 +65,5 @@ ErrorOpenSurveyFillFirstSection=You haven't filled the first section of the poll
ErrorOpenSurveyOneChoice=Enter at least one choice
ErrorOpenSurveyDateFormat=Date must be have the format DD/MM/YYYY
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.
23 changes: 22 additions & 1 deletion htdocs/opensurvey/public/studs.php
Expand Up @@ -45,6 +45,9 @@

$nblignes=count($object->fetch_lines());

//If the survey has not yet finished, then it can be modified
$canbemodified = ($object->date_fin > dol_now());


/*
* Actions
Expand All @@ -57,6 +60,8 @@
// Add comment
if (GETPOST('ajoutcomment'))
{
if (!$canbemodified) accessforbidden();

$error=0;

if (! GETPOST('comment'))
Expand All @@ -82,8 +87,10 @@
}

// Add vote
if (isset($_POST["boutonp"]) || isset($_POST["boutonp_x"]))
if (isset($_POST["boutonp"]))
{
if (!$canbemodified) accessforbidden();

//Si le nom est bien entré
if (GETPOST('nom'))
{
Expand Down Expand Up @@ -190,6 +197,8 @@
$nouveauchoix.="0";
}
}

if (!$canbemodified) accessforbidden();

$idtomodify=$_POST["idtomodify".$modifier];
$sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_user_studs";
Expand All @@ -205,6 +214,8 @@
$idcomment=GETPOST('deletecomment','int');
if ($idcomment)
{
if (!$canbemodified) accessforbidden();

$resql = $object->deleteComment($idcomment);
}

Expand Down Expand Up @@ -251,6 +262,16 @@

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 '<input type="hidden" name="sondage" value="' . $numsondage . '"/>';

Expand Down

0 comments on commit ff7e4e4

Please sign in to comment.