From 0448a76df560faf65a3c7e3b3bca0fa82388ad4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 13 Nov 2020 21:13:00 +0100 Subject: [PATCH 1/5] doxygen --- .../class/opensurveysondage.class.php | 70 +++++++++++-------- 1 file changed, 42 insertions(+), 28 deletions(-) diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index f8f6cb0f885..4b8ac089591 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2014 Marcos García + * Copyright (C) 2020 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -60,7 +61,14 @@ class Opensurveysondage extends CommonObject */ public $description; + /** + * @var string email admin + */ public $mail_admin; + + /** + * @var admin name + */ public $nom_admin; /** @@ -75,10 +83,21 @@ class Opensurveysondage extends CommonObject public $title; public $date_fin = ''; + + /** + * @var int status + */ public $status = 1; public $format; + + /** + * @var int mailsonde + */ public $mailsonde; + /** + * @var string subject + */ public $sujet; /** @@ -133,8 +152,7 @@ class Opensurveysondage extends CommonObject $this->cleanParameters(); // Check parameters - if (!$this->date_fin > 0) - { + if (!$this->date_fin > 0) { $this->error = 'BadValueForEndDate'; dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); return -1; @@ -156,10 +174,10 @@ class Opensurveysondage extends CommonObject $sql .= ") VALUES ("; $sql .= "'".$this->db->escape($this->id_sondage)."',"; $sql .= " ".(empty($this->description) ? 'NULL' : "'".$this->db->escape($this->description)."'").","; - $sql .= " ".$user->id.","; + $sql .= " ".(int) $user->id.","; $sql .= " '".$this->db->escape($this->title)."',"; $sql .= " '".$this->db->idate($this->date_fin)."',"; - $sql .= " ".$this->status.","; + $sql .= " ".(int) $this->status.","; $sql .= " '".$this->db->escape($this->format)."',"; $sql .= " ".$this->db->escape($this->mailsonde).","; $sql .= " ".$this->db->escape($this->allow_comments).","; @@ -173,17 +191,13 @@ class Opensurveysondage extends CommonObject $resql = $this->db->query($sql); if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (!$error) - { - if (!$notrigger) - { - global $langs, $conf; + if (!$error && !$notrigger) + global $langs, $conf; - // Call trigger - $result = $this->call_trigger('OPENSURVEY_CREATE', $user); - if ($result < 0) $error++; - // End call triggers - } + // Call trigger + $result = $this->call_trigger('OPENSURVEY_CREATE', $user); + if ($result < 0) $error++; + // End call triggers } // Commit or rollback @@ -310,10 +324,12 @@ class Opensurveysondage extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); + } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('OPENSURVEY_MODIFY', $user); if ($result < 0) $error++; @@ -356,15 +372,11 @@ class Opensurveysondage extends CommonObject $this->db->begin(); - if (!$error) - { - if (!$notrigger) - { - // Call trigger - $result = $this->call_trigger('OPENSURVEY_DELETE', $user); - if ($result < 0) $error++; - // End call triggers - } + if (!$error && !$notrigger) { + // Call trigger + $result = $this->call_trigger('OPENSURVEY_DELETE', $user); + if ($result < 0) $error++; + // End call triggers } if (!$error) @@ -441,7 +453,9 @@ class Opensurveysondage extends CommonObject } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } $linkstart = ''; @@ -591,7 +605,7 @@ class Opensurveysondage extends CommonObject $this->mail_admin = trim($this->mail_admin); $this->nom_admin = trim($this->nom_admin); $this->title = trim($this->title); - $this->status = trim($this->status); + $this->status = (int) $this->status; $this->format = trim($this->format); $this->mailsonde = ($this->mailsonde ? 1 : 0); $this->allow_comments = ($this->allow_comments ? 1 : 0); From fd14ce4ea47df324c0f4ab2314b91085c03761ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 13 Nov 2020 21:16:58 +0100 Subject: [PATCH 2/5] Update opensurveysondage.class.php --- htdocs/opensurvey/class/opensurveysondage.class.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index 4b8ac089591..27179a20ac3 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -50,7 +50,6 @@ class Opensurveysondage extends CommonObject */ public $picto = 'poll'; - /** * @var string ID survey */ @@ -88,6 +87,10 @@ class Opensurveysondage extends CommonObject * @var int status */ public $status = 1; + + /** + * @var string format of survey + */ public $format; /** @@ -201,10 +204,8 @@ class Opensurveysondage extends CommonObject } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } From 894f1e8215857bcb5dedab0118dad6707538b278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 13 Nov 2020 21:20:17 +0100 Subject: [PATCH 3/5] Update card.php --- htdocs/opensurvey/card.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index 96bcd2af739..92d0f7a3eb5 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -1,7 +1,7 @@ * Copyright (C) 2014 Marcos García - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2020 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -41,14 +41,13 @@ $cancel = GETPOST('cancel', 'alpha'); $numsondage = ''; if (GETPOST('id')) { - $numsondage = GETPOST('id', 'alpha'); + $numsondage = (string) GETPOST('id', 'alpha'); } $object = new Opensurveysondage($db); $result = $object->fetch(0, $numsondage); -if ($result <= 0) -{ +if ($result <= 0) { dol_print_error($db, $object->error); exit; } @@ -112,17 +111,16 @@ if (empty($reshook)) if (!$error) { - $object->title = GETPOST('nouveautitre', 'nohtml'); - $object->description = GETPOST('nouveauxcommentaires', 'restricthtml'); - $object->mail_admin = GETPOST('nouvelleadresse', 'alpha'); + $object->title = (string) GETPOST('nouveautitre', 'nohtml'); + $object->description = (string) GETPOST('nouveauxcommentaires', 'restricthtml'); + $object->mail_admin = (string) GETPOST('nouvelleadresse', 'alpha'); $object->date_fin = $expiredate; $object->allow_comments = GETPOST('cancomment', 'alpha') == 'on' ? 1 : 0; $object->allow_spy = GETPOST('canseeothersvote', 'alpha') == 'on' ? 1 : 0; $object->mailsonde = GETPOST('mailsonde', 'alpha') == 'on' ? true : false; $res = $object->update($user); - if ($res < 0) - { + if ($res < 0) { setEventMessages($object->error, $object->errors, 'errors'); $action = 'edit'; } From 10bdb1f787f39a1d061155e9dfb3284c29fa3304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 13 Nov 2020 21:21:48 +0100 Subject: [PATCH 4/5] Update opensurveysondage.class.php --- htdocs/opensurvey/class/opensurveysondage.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index 27179a20ac3..595270b78ad 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -194,7 +194,7 @@ class Opensurveysondage extends CommonObject $resql = $this->db->query($sql); if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (!$error && !$notrigger) + if (!$error && !$notrigger) { global $langs, $conf; // Call trigger From 34beb995f23b1103c34f789e67b35e592ec408c1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 14 Nov 2020 00:51:01 +0100 Subject: [PATCH 5/5] Update card.php --- htdocs/opensurvey/card.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index 92d0f7a3eb5..393914f95ba 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -111,13 +111,13 @@ if (empty($reshook)) if (!$error) { - $object->title = (string) GETPOST('nouveautitre', 'nohtml'); + $object->title = (string) GETPOST('nouveautitre', 'alphanohtml'); $object->description = (string) GETPOST('nouveauxcommentaires', 'restricthtml'); $object->mail_admin = (string) GETPOST('nouvelleadresse', 'alpha'); $object->date_fin = $expiredate; - $object->allow_comments = GETPOST('cancomment', 'alpha') == 'on' ? 1 : 0; - $object->allow_spy = GETPOST('canseeothersvote', 'alpha') == 'on' ? 1 : 0; - $object->mailsonde = GETPOST('mailsonde', 'alpha') == 'on' ? true : false; + $object->allow_comments = GETPOST('cancomment', 'aZ09') == 'on' ? 1 : 0; + $object->allow_spy = GETPOST('canseeothersvote', 'aZ09') == 'on' ? 1 : 0; + $object->mailsonde = GETPOST('mailsonde', 'aZ09') == 'on' ? true : false; $res = $object->update($user); if ($res < 0) {