From 817e653519c2cca95833d44f9595793ac58fbeed Mon Sep 17 00:00:00 2001
From: Regis Houssin <regis@dolibarr.fr>
Date: Tue, 25 Sep 2012 18:31:08 +0200
Subject: [PATCH] Fix: add todo for free tag treatment

---
 ...face_20_modPaypal_PaypalWorkflow.class.php | 81 ++++++++++---------
 1 file changed, 44 insertions(+), 37 deletions(-)

diff --git a/htdocs/core/triggers/interface_20_modPaypal_PaypalWorkflow.class.php b/htdocs/core/triggers/interface_20_modPaypal_PaypalWorkflow.class.php
index 3b63eb25c65..b6b74ba8253 100755
--- a/htdocs/core/triggers/interface_20_modPaypal_PaypalWorkflow.class.php
+++ b/htdocs/core/triggers/interface_20_modPaypal_PaypalWorkflow.class.php
@@ -102,47 +102,54 @@ class InterfacePaypalWorkflow
         if ($action == 'PAYPAL_PAYMENT_OK')
         {
         	dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". source=".$object->source." ref=".$object->ref);
-        	
-        	if ($object->source == 'membersubscription')
-        	{
-        		//require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherents.class.php';
-        		
-        		// TODO add subscription treatment
-        	}
-        	else
+
+        	if (! empty($object->source))
         	{
-        		require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
-        		
-        		$soc = new Societe($this->db);
-        		
-        		// Parse element/subelement (ex: project_task)
-        		$element = $path = $filename = $object->source;
-        		if (preg_match('/^([^_]+)_([^_]+)/i',$object->source,$regs))
+        		if ($object->source == 'membersubscription')
         		{
-        			$element = $path = $regs[1];
-        			$filename = $regs[2];
-        		}
-        		// For compatibility
-        		if ($element == 'order') {
-        			$path = $filename = 'commande';
+        			//require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherents.class.php';
+
+        			// TODO add subscription treatment
         		}
-        		if ($element == 'invoice') {
-        			$path = 'compta/facture'; $filename = 'facture';
+        		else
+        		{
+        			require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
+
+        			$soc = new Societe($this->db);
+
+        			// Parse element/subelement (ex: project_task)
+        			$element = $path = $filename = $object->source;
+        			if (preg_match('/^([^_]+)_([^_]+)/i',$object->source,$regs))
+        			{
+        				$element = $path = $regs[1];
+        				$filename = $regs[2];
+        			}
+        			// For compatibility
+        			if ($element == 'order') {
+        				$path = $filename = 'commande';
+        			}
+        			if ($element == 'invoice') {
+        				$path = 'compta/facture'; $filename = 'facture';
+        			}
+
+        			dol_include_once('/'.$path.'/class/'.$filename.'.class.php');
+
+        			$classname = ucfirst($filename);
+        			$obj = new $classname($this->db);
+
+        			$ret = $obj->fetch('',$object->ref);
+        			if ($ret < 0) return -1;
+
+        			// Add payer id
+        			$soc->setValueFrom('ref_int', $object->payerID, 'societe', $obj->socid);
+
+        			// Add transaction id
+        			$obj->setValueFrom('ref_int',$object->resArray["TRANSACTIONID"]);
         		}
-        		
-        		dol_include_once('/'.$path.'/class/'.$filename.'.class.php');
-        		
-        		$classname = ucfirst($filename);
-        		$obj = new $classname($this->db);
-        		
-        		$ret = $obj->fetch('',$object->ref);
-        		if ($ret < 0) return -1;
-        		
-        		// Add payer id
-        		$soc->setValueFrom('ref_int', $object->payerID, 'societe', $obj->socid);
-        		
-        		// Add transaction id
-        		$obj->setValueFrom('ref_int',$object->resArray["TRANSACTIONID"]);
+        	}
+        	else
+        	{
+        		// TODO add free tag treatment
         	}
 
         }
-- 
GitLab