This commit is contained in:
Frédéric FRANCE 2020-11-13 21:13:00 +01:00 committed by GitHub
parent 1f69f4ed5d
commit 0448a76df5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2013-2014 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2013-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2020 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -60,7 +61,14 @@ class Opensurveysondage extends CommonObject
*/ */
public $description; public $description;
/**
* @var string email admin
*/
public $mail_admin; public $mail_admin;
/**
* @var admin name
*/
public $nom_admin; public $nom_admin;
/** /**
@ -75,10 +83,21 @@ class Opensurveysondage extends CommonObject
public $title; public $title;
public $date_fin = ''; public $date_fin = '';
/**
* @var int status
*/
public $status = 1; public $status = 1;
public $format; public $format;
/**
* @var int mailsonde
*/
public $mailsonde; public $mailsonde;
/**
* @var string subject
*/
public $sujet; public $sujet;
/** /**
@ -133,8 +152,7 @@ class Opensurveysondage extends CommonObject
$this->cleanParameters(); $this->cleanParameters();
// Check parameters // Check parameters
if (!$this->date_fin > 0) if (!$this->date_fin > 0) {
{
$this->error = 'BadValueForEndDate'; $this->error = 'BadValueForEndDate';
dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
return -1; return -1;
@ -156,10 +174,10 @@ class Opensurveysondage extends CommonObject
$sql .= ") VALUES ("; $sql .= ") VALUES (";
$sql .= "'".$this->db->escape($this->id_sondage)."',"; $sql .= "'".$this->db->escape($this->id_sondage)."',";
$sql .= " ".(empty($this->description) ? 'NULL' : "'".$this->db->escape($this->description)."'").","; $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->escape($this->title)."',";
$sql .= " '".$this->db->idate($this->date_fin)."',"; $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->format)."',";
$sql .= " ".$this->db->escape($this->mailsonde).","; $sql .= " ".$this->db->escape($this->mailsonde).",";
$sql .= " ".$this->db->escape($this->allow_comments).","; $sql .= " ".$this->db->escape($this->allow_comments).",";
@ -173,17 +191,13 @@ class Opensurveysondage extends CommonObject
$resql = $this->db->query($sql); $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) if (!$error && !$notrigger)
{ global $langs, $conf;
if (!$notrigger)
{
global $langs, $conf;
// Call trigger // Call trigger
$result = $this->call_trigger('OPENSURVEY_CREATE', $user); $result = $this->call_trigger('OPENSURVEY_CREATE', $user);
if ($result < 0) $error++; if ($result < 0) $error++;
// End call triggers // End call triggers
}
} }
// Commit or rollback // Commit or rollback
@ -310,10 +324,12 @@ class Opensurveysondage extends CommonObject
dol_syslog(get_class($this)."::update", LOG_DEBUG); dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql); $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 // Call trigger
$result = $this->call_trigger('OPENSURVEY_MODIFY', $user); $result = $this->call_trigger('OPENSURVEY_MODIFY', $user);
if ($result < 0) $error++; if ($result < 0) $error++;
@ -356,15 +372,11 @@ class Opensurveysondage extends CommonObject
$this->db->begin(); $this->db->begin();
if (!$error) if (!$error && !$notrigger) {
{ // Call trigger
if (!$notrigger) $result = $this->call_trigger('OPENSURVEY_DELETE', $user);
{ if ($result < 0) $error++;
// Call trigger // End call triggers
$result = $this->call_trigger('OPENSURVEY_DELETE', $user);
if ($result < 0) $error++;
// End call triggers
}
} }
if (!$error) if (!$error)
@ -441,7 +453,9 @@ class Opensurveysondage extends CommonObject
} }
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } else {
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
}
$linkstart = '<a href="'.$url.'"'; $linkstart = '<a href="'.$url.'"';
$linkstart .= $linkclose.'>'; $linkstart .= $linkclose.'>';
@ -591,7 +605,7 @@ class Opensurveysondage extends CommonObject
$this->mail_admin = trim($this->mail_admin); $this->mail_admin = trim($this->mail_admin);
$this->nom_admin = trim($this->nom_admin); $this->nom_admin = trim($this->nom_admin);
$this->title = trim($this->title); $this->title = trim($this->title);
$this->status = trim($this->status); $this->status = (int) $this->status;
$this->format = trim($this->format); $this->format = trim($this->format);
$this->mailsonde = ($this->mailsonde ? 1 : 0); $this->mailsonde = ($this->mailsonde ? 1 : 0);
$this->allow_comments = ($this->allow_comments ? 1 : 0); $this->allow_comments = ($this->allow_comments ? 1 : 0);