commit
b285ddf62b
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2013-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2013-2015 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) 2018 Frédéric France <frederic.france@netlogic.fr>
|
* Copyright (C) 2018-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
|
||||||
@ -41,14 +41,13 @@ $cancel = GETPOST('cancel', 'alpha');
|
|||||||
$numsondage = '';
|
$numsondage = '';
|
||||||
|
|
||||||
if (GETPOST('id')) {
|
if (GETPOST('id')) {
|
||||||
$numsondage = GETPOST('id', 'alpha');
|
$numsondage = (string) GETPOST('id', 'alpha');
|
||||||
}
|
}
|
||||||
|
|
||||||
$object = new Opensurveysondage($db);
|
$object = new Opensurveysondage($db);
|
||||||
|
|
||||||
$result = $object->fetch(0, $numsondage);
|
$result = $object->fetch(0, $numsondage);
|
||||||
if ($result <= 0)
|
if ($result <= 0) {
|
||||||
{
|
|
||||||
dol_print_error($db, $object->error);
|
dol_print_error($db, $object->error);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -112,17 +111,16 @@ if (empty($reshook))
|
|||||||
|
|
||||||
if (!$error)
|
if (!$error)
|
||||||
{
|
{
|
||||||
$object->title = GETPOST('nouveautitre', 'nohtml');
|
$object->title = (string) GETPOST('nouveautitre', 'alphanohtml');
|
||||||
$object->description = GETPOST('nouveauxcommentaires', 'restricthtml');
|
$object->description = (string) GETPOST('nouveauxcommentaires', 'restricthtml');
|
||||||
$object->mail_admin = GETPOST('nouvelleadresse', 'alpha');
|
$object->mail_admin = (string) GETPOST('nouvelleadresse', 'alpha');
|
||||||
$object->date_fin = $expiredate;
|
$object->date_fin = $expiredate;
|
||||||
$object->allow_comments = GETPOST('cancomment', 'alpha') == 'on' ? 1 : 0;
|
$object->allow_comments = GETPOST('cancomment', 'aZ09') == 'on' ? 1 : 0;
|
||||||
$object->allow_spy = GETPOST('canseeothersvote', 'alpha') == 'on' ? 1 : 0;
|
$object->allow_spy = GETPOST('canseeothersvote', 'aZ09') == 'on' ? 1 : 0;
|
||||||
$object->mailsonde = GETPOST('mailsonde', 'alpha') == 'on' ? true : false;
|
$object->mailsonde = GETPOST('mailsonde', 'aZ09') == 'on' ? true : false;
|
||||||
|
|
||||||
$res = $object->update($user);
|
$res = $object->update($user);
|
||||||
if ($res < 0)
|
if ($res < 0) {
|
||||||
{
|
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
$action = 'edit';
|
$action = 'edit';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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
|
||||||
@ -49,7 +50,6 @@ class Opensurveysondage extends CommonObject
|
|||||||
*/
|
*/
|
||||||
public $picto = 'poll';
|
public $picto = 'poll';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string ID survey
|
* @var string ID survey
|
||||||
*/
|
*/
|
||||||
@ -60,7 +60,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 +82,25 @@ class Opensurveysondage extends CommonObject
|
|||||||
public $title;
|
public $title;
|
||||||
|
|
||||||
public $date_fin = '';
|
public $date_fin = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int status
|
||||||
|
*/
|
||||||
public $status = 1;
|
public $status = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string format of survey
|
||||||
|
*/
|
||||||
public $format;
|
public $format;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int mailsonde
|
||||||
|
*/
|
||||||
public $mailsonde;
|
public $mailsonde;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string subject
|
||||||
|
*/
|
||||||
public $sujet;
|
public $sujet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -133,8 +155,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 +177,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,24 +194,18 @@ 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
|
||||||
if ($error)
|
if ($error) {
|
||||||
{
|
foreach ($this->errors as $errmsg) {
|
||||||
foreach ($this->errors as $errmsg)
|
|
||||||
{
|
|
||||||
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
|
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
|
||||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||||
}
|
}
|
||||||
@ -310,10 +325,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 +373,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 +454,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 +606,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);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user