diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index 0a3f2c571df62112b8d9eee22f15b7694b2cccb4..188e830be63bc4e32f306793b637dcabe62ea20d 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -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); diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index 506ffecc99e19c21d24c620f93a694109cfedf92..c87526ce5ca389f85e912589e3f37d1840c2890c 100755 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -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,16 +46,10 @@ 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(); }