diff --git a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql index 044d97fd4e4..f1b29472d06 100644 --- a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql +++ b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql @@ -384,3 +384,5 @@ ALTER TABLE llx_prelevement_demande ADD COLUMN fk_salary INTEGER NULL AFTER fk_f ALTER TABLE llx_user ADD COLUMN birth_place varchar(64); +ALTER TABLE llx_opensurvey_user_studs ADD COLUMN date_creation datetime NOT NULL; +ALTER TABLE llx_opensurvey_comments ADD COLUMN date_creation datetime NOT NULL; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_opensurvey_comments-opensurvey.sql b/htdocs/install/mysql/tables/llx_opensurvey_comments-opensurvey.sql index 52d938b7c47..a615e0f9cb7 100644 --- a/htdocs/install/mysql/tables/llx_opensurvey_comments-opensurvey.sql +++ b/htdocs/install/mysql/tables/llx_opensurvey_comments-opensurvey.sql @@ -21,5 +21,6 @@ CREATE TABLE llx_opensurvey_comments ( comment text NOT NULL, tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, usercomment text + date_creation datetime NOT NULL, ) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_opensurvey_user_studs-opensurvey.sql b/htdocs/install/mysql/tables/llx_opensurvey_user_studs-opensurvey.sql index 03ad9b35ec5..d0d1c2a06b8 100644 --- a/htdocs/install/mysql/tables/llx_opensurvey_user_studs-opensurvey.sql +++ b/htdocs/install/mysql/tables/llx_opensurvey_user_studs-opensurvey.sql @@ -21,4 +21,5 @@ CREATE TABLE llx_opensurvey_user_studs ( id_sondage VARCHAR(16) NOT NULL, reponses VARCHAR(100) NOT NULL, -- Not used for 'F' surveys tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP + date_creation datetime NOT NULL, ) ENGINE=innodb; diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index b7fadbdb60d..4d67c9a3a95 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -576,8 +576,9 @@ class Opensurveysondage extends CommonObject */ public function addComment($comment, $comment_user, $user_ip = '') { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_comments (id_sondage, comment, usercomment, ip)"; - $sql .= " VALUES ('".$this->db->escape($this->id_sondage)."','".$this->db->escape($comment)."','".$this->db->escape($comment_user)."'".($user_ip ? ",'".$this->db->escape($user_ip)."'" : '').")"; + $now = dol_now(); + $sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_comments (id_sondage, comment, usercomment, date_creation, ip)"; + $sql .= " VALUES ('".$this->db->escape($this->id_sondage)."','".$this->db->escape($comment)."','".$this->db->escape($comment_user)."','".$this->db->idate($now)."'".($user_ip ? ",'".$this->db->escape($user_ip)."'" : '').")"; $resql = $this->db->query($sql); if (!$resql) { diff --git a/htdocs/public/opensurvey/studs.php b/htdocs/public/opensurvey/studs.php index 30ed4cc8bbb..de2f6b1e3aa 100644 --- a/htdocs/public/opensurvey/studs.php +++ b/htdocs/public/opensurvey/studs.php @@ -108,7 +108,7 @@ if (GETPOST('ajoutcomment', 'alpha')) { $sql = "SELECT COUNT(id_comment) as nb_comments"; $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_comments"; $sql .= " WHERE ip = '".$db->escape($user_ip)."'"; - //$sql .= " AND date_creation > '".$db->idate($minmonthpost)."'"; + $sql .= " AND date_creation > '".$db->idate($minmonthpost)."'"; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -164,7 +164,7 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) { // bo $sql = "SELECT COUNT(id_users) as nb_records"; $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; $sql .= " WHERE ip = '".$db->escape($user_ip)."'"; - //$sql .= " AND date_creation > '".$db->idate($minmonthpost)."'"; + $sql .= " AND date_creation > '".$db->idate($minmonthpost)."'"; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -198,8 +198,9 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) { // bo setEventMessages($langs->trans("AlreadyTooMuchPostOnThisIPAdress"), null, 'errors'); $error++; } else { - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'opensurvey_user_studs (nom, id_sondage, reponses, ip)'; - $sql .= " VALUES ('".$db->escape($nom)."', '".$db->escape($numsondage)."','".$db->escape($nouveauchoix)."', '".$db->escape($user_ip)."')"; + $now = dol_now(); + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'opensurvey_user_studs (nom, id_sondage, reponses, ip, date_creation)'; + $sql .= " VALUES ('".$db->escape($nom)."', '".$db->escape($numsondage)."','".$db->escape($nouveauchoix)."', '".$db->escape($user_ip)."', '".$db->idate($now)."')"; $resql = $db->query($sql); if ($resql) {