Skip to content
Snippets Groups Projects
Commit 8a69cdd4 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix: delete of survey

parent 5c1b3d86
Branches
Tags
No related merge requests found
......@@ -337,7 +337,7 @@ class Opensurveysondage extends CommonObject
*
* @param User $user User that deletes
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @param string $numsondageadmin Num sondage to delete
* @param string $numsondageadmin Num sondage admin to delete
* @return int <0 if KO, >0 if OK
*/
function delete($user, $notrigger, $numsondageadmin)
......@@ -345,6 +345,8 @@ class Opensurveysondage extends CommonObject
global $conf, $langs;
$error=0;
$numsondage=substr($numsondageadmin, 0, 16);
$this->db->begin();
if (! $error)
......@@ -366,10 +368,10 @@ class Opensurveysondage extends CommonObject
if (! $error)
{
$sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_comments WHERE id_sondage_admin = '".$numsondageadmin."'";
$sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_comments WHERE id_sondage = '".$numsondage."'";
dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
$sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_user_studs WHERE id_sondage_admin = '".$numsondageadmin."'";
$sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_user_studs WHERE id_sondage = '".$numsondage."'";
dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
......
......@@ -27,6 +27,7 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
$action=GETPOST('action');
$id=GETPOST('id');
$numsondage=substr($id, 0, 16);
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="p.titre";
......@@ -45,15 +46,9 @@ if ($action == 'delete_confirm')
{
$db->begin();
$sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_comments WHERE id_sondage_admin = '".$id."'";
dol_syslog("Delete poll sql=".$sql, LOG_DEBUG);
$resql=$db->query($sql);
$sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_user_studs WHERE id_sondage_admin = '".$id."'";
dol_syslog("Delete poll sql=".$sql, LOG_DEBUG);
$resql=$db->query($sql);
$sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_sondage WHERE id_sondage_admin = '".$id."'";
dol_syslog("Delete poll sql=".$sql, LOG_DEBUG);
$resql=$db->query($sql);
$object=new Opensurveysondage($db);
$result=$object->delete($user,'',$numsondageadmin);
$db->commit();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment