From ff7e4e49f3a517c1662f8986c1adfdffed99c601 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 5 Jan 2014 21:54:12 +0100 Subject: [PATCH] Limiting the voting time of the survey --- htdocs/langs/en_US/opensurvey.lang | 3 ++- htdocs/opensurvey/public/studs.php | 23 ++++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/opensurvey.lang b/htdocs/langs/en_US/opensurvey.lang index ce6987f4bac..d598a385f00 100644 --- a/htdocs/langs/en_US/opensurvey.lang +++ b/htdocs/langs/en_US/opensurvey.lang @@ -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 \ No newline at end of file +MoreChoices=Enter more choices for the voters +SurveyExpiredInfo=The voting time of this poll has expired. \ No newline at end of file diff --git a/htdocs/opensurvey/public/studs.php b/htdocs/opensurvey/public/studs.php index 6042aafd37b..9eac7face2c 100644 --- a/htdocs/opensurvey/public/studs.php +++ b/htdocs/opensurvey/public/studs.php @@ -45,6 +45,9 @@ if ($result <= 0) dol_print_error('','Failed to get survey id '.$numsondage); $nblignes=count($object->fetch_lines()); +//If the survey has not yet finished, then it can be modified +$canbemodified = ($object->date_fin > dol_now()); + /* * Actions @@ -57,6 +60,8 @@ $listofvoters=explode(',',$_SESSION["savevoter"]); // Add comment if (GETPOST('ajoutcomment')) { + if (!$canbemodified) accessforbidden(); + $error=0; if (! GETPOST('comment')) @@ -82,8 +87,10 @@ if (GETPOST('ajoutcomment')) } // 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')) { @@ -190,6 +197,8 @@ if ($testmodifier) $nouveauchoix.="0"; } } + + if (!$canbemodified) accessforbidden(); $idtomodify=$_POST["idtomodify".$modifier]; $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_user_studs"; @@ -205,6 +214,8 @@ if ($testmodifier) $idcomment=GETPOST('deletecomment','int'); if ($idcomment) { + if (!$canbemodified) accessforbidden(); + $resql = $object->deleteComment($idcomment); } @@ -251,6 +262,16 @@ if ($object->commentaires) print ''."\n"; +//The survey has expired, users can't vote or do any action +if (!$canbemodified) { + + print '

'.$langs->trans('SurveyExpiredInfo').'

'; + llxFooterSurvey(); + + $db->close(); + die; +} + print '
'."\n"; print '';