From d5afff4388a61e3b0856304f6490790d7fc2e0bc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 12 Apr 2015 11:42:49 +0200 Subject: [PATCH] Fix warnings when submitting a vote for a survey --- htdocs/opensurvey/card.php | 2 +- htdocs/opensurvey/results.php | 2 +- htdocs/opensurvey/wizard/create_survey.php | 7 ++++--- .../public => public/opensurvey}/index.html | 0 .../{opensurvey/public => public/opensurvey}/studs.php | 10 ++++++---- 5 files changed, 12 insertions(+), 9 deletions(-) rename htdocs/{opensurvey/public => public/opensurvey}/index.html (100%) rename htdocs/{opensurvey/public => public/opensurvey}/studs.php (99%) diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index 70e1b49ad48..cf4034308ef 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -309,7 +309,7 @@ $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($ $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current -$url=$urlwithouturlroot.dol_buildpath('/opensurvey/public/studs.php',1).'?sondage='.$object->id_sondage; +$url=$urlwithouturlroot.dol_buildpath('/public/opensurvey/studs.php',1).'?sondage='.$object->id_sondage; $urllink=''.$url.''; print $urllink; diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index 226bc0c0465..63242cb341c 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -480,7 +480,7 @@ $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($ $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current -$url=$urlwithouturlroot.dol_buildpath('/opensurvey/public/studs.php',1).'?sondage='.$numsondage; +$url=$urlwithouturlroot.dol_buildpath('/public/opensurvey/studs.php',1).'?sondage='.$numsondage; $urlvcal=''.$url.''; print $urlvcal; diff --git a/htdocs/opensurvey/wizard/create_survey.php b/htdocs/opensurvey/wizard/create_survey.php index cacc0ad8155..ec2568c3858 100644 --- a/htdocs/opensurvey/wizard/create_survey.php +++ b/htdocs/opensurvey/wizard/create_survey.php @@ -79,7 +79,7 @@ if (GETPOST("creation_sondage_date") || GETPOST("creation_sondage_autre")) $testdate = false; $champdatefin = dol_mktime(0,0,0,GETPOST('champdatefinmonth'),GETPOST('champdatefinday'),GETPOST('champdatefinyear')); - if (GETPOST('champdatefin') && ($champdatefin > 0)) // A date was provided + if ($champdatefin && ($champdatefin > 0)) // A date was provided { // Expire date is not before today if ($champdatefin >= dol_now()) @@ -90,16 +90,17 @@ if (GETPOST("creation_sondage_date") || GETPOST("creation_sondage_autre")) else { $testdate = true; + $_SESSION['champdatefin'] = dol_print_date($champdatefin,'dayrfc'); //$testdate = false; //$_SESSION['champdatefin'] = dol_print_date($champdatefin,'dayrfc'); - //setEventMessage($langs->trans('ExpiredDate'),'errors'); + setEventMessage($langs->trans('ExpiredDate'),'warnings'); } } if (! $testdate) { setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("ExpireDate")), 'errors'); } - + if ($titre && $testdate) { if (! empty($creation_sondage_date)) diff --git a/htdocs/opensurvey/public/index.html b/htdocs/public/opensurvey/index.html similarity index 100% rename from htdocs/opensurvey/public/index.html rename to htdocs/public/opensurvey/index.html diff --git a/htdocs/opensurvey/public/studs.php b/htdocs/public/opensurvey/studs.php similarity index 99% rename from htdocs/opensurvey/public/studs.php rename to htdocs/public/opensurvey/studs.php index 1b39391b67c..f7c0e31ef43 100644 --- a/htdocs/opensurvey/public/studs.php +++ b/htdocs/public/opensurvey/studs.php @@ -17,7 +17,7 @@ */ /** - * \file htdocs/opensurvey/public/studs.php + * \file htdocs/public/opensurvey/studs.php * \ingroup opensurvey * \brief Page to list surveys */ @@ -111,12 +111,14 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // bout } $nom=substr(GETPOST("nom"),0,64); - + // Check if vote already exists $sql = 'SELECT id_users, nom as name'; - $sql.= ' FROM '.MAIN_DB_PREFIX."opensurvey_user_studs'; - $sql.= ' WHERE id_sondage='".$db->escape($numsondage)."' AND nom = '".$db->escape($nom)."' ORDER BY id_users"; + $sql.= ' FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs'; + $sql.= " WHERE id_sondage='".$db->escape($numsondage)."' AND nom = '".$db->escape($nom)."' ORDER BY id_users"; $resql = $db->query($sql); + if (! $resql) dol_print_error($db); + $num_rows = $db->num_rows($resql); if ($num_rows > 0) {