Explorar el Código

Merge pull request #17962 from atm-lena/12.0_FIX_AddTrigger_MailingDelete

12.0 fix add trigger mailing delete
Laurent Destailleur hace 4 años
padre
commit
96da2a6a37
Se han modificado 1 ficheros con 24 adiciones y 2 borrados
  1. 24 2
      htdocs/comm/mailing/class/mailing.class.php

+ 24 - 2
htdocs/comm/mailing/class/mailing.class.php

@@ -427,8 +427,12 @@ class Mailing extends CommonObject
 	 *  @param	int		$rowid      id du mailing a supprimer
 	 *  @return int         		1 en cas de succes
 	 */
-	public function delete($rowid)
+	public function delete($rowid, $notrigger = 0)
 	{
+		global $user;
+
+		$this->db->begin();
+
 		$sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing";
 		$sql .= " WHERE rowid = ".$rowid;
 
@@ -436,13 +440,31 @@ class Mailing extends CommonObject
 		$resql = $this->db->query($sql);
 		if ($resql)
 		{
-			return $this->delete_targets();
+			$res = $this->delete_targets();
+			if(empty($res)){
+				$this->db->rollback();
+				$this->error = $this->db->lasterror();
+				return -1;
+			}
 		}
 		else
 		{
+			$this->db->rollback();
 			$this->error = $this->db->lasterror();
 			return -1;
 		}
+
+		if(!$notrigger){
+			$result = $this->call_trigger('MAILING_DELETE', $user);
+			if ($result < 0)
+			{
+				$this->db->rollback();
+				return -1;
+			}
+		}
+
+		$this->db->commit();
+		return 1;
 	}
 
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps