From 32a0f4c530ecd7224c99ac283803fd3065aa2790 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 20 May 2016 20:03:29 +0200 Subject: [PATCH 01/10] Add trigger into expedition class --- htdocs/expedition/class/expedition.class.php | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 6d3f7b05966..fd2d7ff1777 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1806,6 +1806,14 @@ class Expedition extends CommonObject { // TODO: Add option/checkbox to set order billed if 100% of order is shipped $this->statut=2; + + // Call trigger + $result=$this->call_trigger('SHIPPING_CLOSED',$user); + if ($result < 0) { + return -1; + } + // End call triggers + return 1; } else @@ -1831,6 +1839,15 @@ class Expedition extends CommonObject { $this->statut=2; $this->billed=1; + + // Call trigger + $result=$this->call_trigger('SHIPPING_BILLED',$user); + if ($result < 0) { + return -1; + } + // End call triggers + + return 1; } else @@ -1856,6 +1873,13 @@ class Expedition extends CommonObject { $this->statut=1; $this->billed=0; + + // Call trigger + $result=$this->call_trigger('SHIPPING_REOPENED',$user); + if ($result < 0) { + return -1; + } + return 1; } else From 82d6f4c8080dec3cdb04f2dcef959776fd4bd4fc Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 20 May 2016 20:09:30 +0200 Subject: [PATCH 02/10] add trigger on set draft order --- htdocs/commande/class/commande.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index a2788ba9808..30b06a351d2 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -464,6 +464,12 @@ class Commande extends CommonOrder } } + if (!$error) { + // Call trigger + $result=$this->call_trigger('ORDER_SETDRAFT',$user); + if ($result < 0) $error++; + } + if (!$error) { $this->statut=self::STATUS_DRAFT; From acdf781202054005f70634f8624561eb595c40e9 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 20 May 2016 20:12:23 +0200 Subject: [PATCH 03/10] change tirrger name to harmonised --- htdocs/expedition/class/expedition.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index fd2d7ff1777..b9aaa01b667 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1875,7 +1875,7 @@ class Expedition extends CommonObject $this->billed=0; // Call trigger - $result=$this->call_trigger('SHIPPING_REOPENED',$user); + $result=$this->call_trigger('SHIPPING_REOPEN',$user); if ($result < 0) { return -1; } From 4e707af0fd371387ae2acf72b51cf8acb63e5638 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Mon, 23 May 2016 09:16:47 +0200 Subject: [PATCH 04/10] Add demo information and transsaction management --- .../interface_90_all_Demo.class.php-NORUN | 4 ++ htdocs/expedition/class/expedition.class.php | 47 ++++++++++++++++--- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN b/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN index f25a99f3b59..717ef6585f5 100644 --- a/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN +++ b/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN @@ -119,6 +119,7 @@ class InterfaceDemo extends DolibarrTriggers case 'ORDER_CANCEL': case 'ORDER_SENTBYMAIL': case 'ORDER_CLASSIFY_BILLED': + case 'ORDER_SETDRAFT': case 'LINEORDER_INSERT': case 'LINEORDER_UPDATE': case 'LINEORDER_DELETE': @@ -258,6 +259,9 @@ class InterfaceDemo extends DolibarrTriggers case 'SHIPPING_MODIFY': case 'SHIPPING_VALIDATE': case 'SHIPPING_SENTBYMAIL': + case 'SHIPPING_BILLED': + case 'SHIPPING_CLOSED': + case 'SHIPPING_REOPEN': case 'SHIPPING_DELETE': dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); break; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index b9aaa01b667..b2f5d4bde40 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1798,6 +1798,10 @@ class Expedition extends CommonObject function setClosed() { + $error=0; + + $this->db->begin(); + $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2'; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; @@ -1810,15 +1814,23 @@ class Expedition extends CommonObject // Call trigger $result=$this->call_trigger('SHIPPING_CLOSED',$user); if ($result < 0) { - return -1; + $error++; } - // End call triggers + } else { + $error++; + $this->errors[]=$this->db->lasterror; + } + + if (empty($error)) { + $this->db->commit(); return 1; } else { + $this->db->rollback(); dol_print_error($this->db); + return -1; } } @@ -1830,6 +1842,9 @@ class Expedition extends CommonObject */ function set_billed() { + $error=0; + + $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2, billed=1'; // TODO Update only billed $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; @@ -1843,16 +1858,23 @@ class Expedition extends CommonObject // Call trigger $result=$this->call_trigger('SHIPPING_BILLED',$user); if ($result < 0) { - return -1; + $error++; } - // End call triggers - + } else { + $error++; + $this->errors[]=$this->db->lasterror; + } + + if (empty($error)) { + $this->db->commit(); return 1; } else { + $this->db->rollback(); dol_print_error($this->db); + return -1; } } @@ -1865,6 +1887,10 @@ class Expedition extends CommonObject function reOpen() { + $error=0; + + $this->db->begin(); + $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=1'; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; @@ -1877,14 +1903,23 @@ class Expedition extends CommonObject // Call trigger $result=$this->call_trigger('SHIPPING_REOPEN',$user); if ($result < 0) { - return -1; + $error++; } + } else { + $error++; + $this->errors[]=$this->db->lasterror; + } + + if (empty($error)) { + $this->db->commit(); return 1; } else { + $this->db->rollback(); dol_print_error($this->db); + return -1; } } From 37d366478ff5dbcd4b134ba300bb0ba8944b9e4a Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Mon, 23 May 2016 14:18:29 +0200 Subject: [PATCH 05/10] change trigger position --- htdocs/commande/class/commande.class.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index f89d7d5d5a2..44f14bb09e5 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -464,12 +464,6 @@ class Commande extends CommonOrder } } - if (!$error) { - // Call trigger - $result=$this->call_trigger('ORDER_SETDRAFT',$user); - if ($result < 0) $error++; - } - if (!$error) { $this->statut=self::STATUS_DRAFT; @@ -484,9 +478,20 @@ class Commande extends CommonOrder } } - $this->statut=self::STATUS_DRAFT; - $this->db->commit(); - return 1; + if (!$error) { + // Call trigger + $result=$this->call_trigger('ORDER_SETDRAFT',$user); + if ($result < 0) $error++; + } + + if (!$error) { + $this->statut=self::STATUS_DRAFT; + $this->db->commit(); + return 1; + }else { + $this->db->rollback(); + return -1; + } } else { From 22d6d9497e64de587851ccb58775ce9bdf8e057f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 29 May 2016 11:20:12 +0200 Subject: [PATCH 06/10] Fix ambiguous test on ldap return of getAttributes --- htdocs/adherents/ldap.php | 4 ++-- htdocs/contact/ldap.php | 4 ++-- htdocs/core/class/ldap.class.php | 6 +++--- htdocs/user/group/ldap.php | 2 +- htdocs/user/ldap.php | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/adherents/ldap.php b/htdocs/adherents/ldap.php index 4d9a779d579..a5f61a45642 100644 --- a/htdocs/adherents/ldap.php +++ b/htdocs/adherents/ldap.php @@ -191,12 +191,12 @@ if ($result > 0) } else { - $records=$ldap->getAttribute($dn,$search); + $records = $ldap->getAttribute($dn,$search); //print_r($records); // Affichage arbre - if (count($records) && $records != false && (! isset($records['count']) || $records['count'] > 0)) + if ((! is_numeric($records) || $records != 0) && (! isset($records['count']) || $records['count'] > 0)) { if (! is_array($records)) { diff --git a/htdocs/contact/ldap.php b/htdocs/contact/ldap.php index a626c57b6af..af8fccfd7b9 100644 --- a/htdocs/contact/ldap.php +++ b/htdocs/contact/ldap.php @@ -170,12 +170,12 @@ if ($result > 0) $info=$object->_load_ldap_info(); $dn=$object->_load_ldap_dn($info,1); $search = "(".$object->_load_ldap_dn($info,2).")"; - $records=$ldap->getAttribute($dn,$search); + $records = $ldap->getAttribute($dn,$search); //var_dump($records); // Affichage arbre - if (count($records) && $records != false && (! isset($records['count']) || $records['count'] > 0)) + if ((! is_numeric($records) || $records != 0) && (! isset($records['count']) || $records['count'] > 0)) { if (! is_array($records)) { diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 8ea3221c648..f3845734ec5 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -823,7 +823,7 @@ class Ldap * * @param string $dn DN entry key * @param string $filter Filter - * @return int|false|array <0 or false if KO, array if OK + * @return int|array <0 or false if KO, array if OK */ function getAttribute($dn,$filter) { @@ -848,7 +848,7 @@ class Ldap { $this->ldapErrorCode = -1; $this->ldapErrorText = "Couldn't find entry"; - return false; // Couldn't find entry... + return 0; // Couldn't find entry... } // Get values @@ -856,7 +856,7 @@ class Ldap { $this->ldapErrorCode = ldap_errno($this->connection); $this->ldapErrorText = ldap_error($this->connection); - return false; // No matching attributes + return 0; // No matching attributes } // Return an array containing the attributes. diff --git a/htdocs/user/group/ldap.php b/htdocs/user/group/ldap.php index 199041551c5..bf39a128137 100644 --- a/htdocs/user/group/ldap.php +++ b/htdocs/user/group/ldap.php @@ -177,7 +177,7 @@ if ($result > 0) //var_dump($records); // Affichage arbre - if (count($records) && $records != false && (! isset($records['count']) || $records['count'] > 0)) + if ((! is_numeric($records) || $records != 0) && (! isset($records['count']) || $records['count'] > 0)) { if (! is_array($records)) { diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php index e8a6a8fc1c9..1da5911861c 100644 --- a/htdocs/user/ldap.php +++ b/htdocs/user/ldap.php @@ -181,12 +181,12 @@ if ($result > 0) $info=$object->_load_ldap_info(); $dn=$object->_load_ldap_dn($info,1); $search = "(".$object->_load_ldap_dn($info,2).")"; - $records=$ldap->getAttribute($dn,$search); + $records = $ldap->getAttribute($dn,$search); //print_r($records); // Affichage arbre - if (count($records) && $records != false && (! isset($records['count']) || $records['count'] > 0)) + if ((! is_numeric($records) || $records != 0) && (! isset($records['count']) || $records['count'] > 0)) { if (! is_array($records)) { From 0c6e8b626a50e77b45fbc8c72645eaec915cb733 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 29 May 2016 11:20:27 +0200 Subject: [PATCH 07/10] Fix var not initialized --- htdocs/compta/facture/class/facture-rec.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 13c10a5da0c..3a19605ee5b 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -761,6 +761,8 @@ class FactureRec extends CommonInvoice $nownotime=dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); $prodids = array(); + $num_prods = 0; + $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; $sql.= " WHERE entity IN (".getEntity('product', 1).")"; From 0b6bda910b6679a5af5713fb48a8a50a2c355e3e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 29 May 2016 11:23:32 +0200 Subject: [PATCH 08/10] Removed scrutinizer warning --- htdocs/admin/modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 2dff436ffe6..1151ef4abb9 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -605,7 +605,7 @@ if ($mode != 'marketplace') else $text.=$langs->trans("No"); $text.='
'.$langs->trans("AddMenus").': '; - if (isset($objMod->menu) && is_array($objMod->menu) && $objMod->menu) + if (isset($objMod->menu) && is_array($objMod->menu) && ! empty($objMod->menu)) { $text.=$langs->trans("Yes"); } From d8c6ae0b1729a41797adb50b5f8817bf932c6351 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 29 May 2016 11:26:05 +0200 Subject: [PATCH 09/10] Removed warnings --- htdocs/api/admin/explorer.php | 1 - htdocs/api/class/api_generic.class.php | 2 -- htdocs/api/index.php | 1 - 3 files changed, 4 deletions(-) diff --git a/htdocs/api/admin/explorer.php b/htdocs/api/admin/explorer.php index 262b3f69476..53ff102e89b 100644 --- a/htdocs/api/admin/explorer.php +++ b/htdocs/api/admin/explorer.php @@ -43,7 +43,6 @@ if (empty($conf->global->MAIN_MODULE_API)) exit; } -use \Luracast\Restler\Defaults; $api = new DolibarrApi($db); diff --git a/htdocs/api/class/api_generic.class.php b/htdocs/api/class/api_generic.class.php index 038621b6235..9a630a9da47 100644 --- a/htdocs/api/class/api_generic.class.php +++ b/htdocs/api/class/api_generic.class.php @@ -15,9 +15,7 @@ * along with this program. If not, see . */ -use Luracast\Restler\Restler; use Luracast\Restler\RestException; -use Luracast\Restler\Defaults; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/api/class/api.class.php'; diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 2fbad04ecbb..660c90d3476 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -55,7 +55,6 @@ if (empty($conf->global->MAIN_MODULE_API)) exit; } -use \Luracast\Restler\Defaults; $api = new DolibarrApi($db); From 889ff16906013991b9560140e9677132815f84ae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 29 May 2016 11:56:19 +0200 Subject: [PATCH 10/10] FIX #5239 --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d4f1a38fbbb..fb162927f03 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2778,7 +2778,7 @@ function dol_print_error($db='',$error='',$errors=null) if (empty($msg)) continue; if ($_SERVER['DOCUMENT_ROOT']) // Mode web { - $out.="".$langs->trans("Message").": ".$msg."
\n" ; + $out.="".$langs->trans("Message").": ".dol_escape_htmltag($msg)."
\n" ; } else // Mode CLI {