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/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"); } 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); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 7da8959fe71..40d71775a08 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -478,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 { 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).")"; 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/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 { 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 14b5a1a40b5..a938fe82922 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1801,6 +1801,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'; @@ -1809,11 +1813,27 @@ 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) { + $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; } } @@ -1825,6 +1845,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'; @@ -1834,11 +1857,27 @@ class Expedition extends CommonObject { $this->statut=2; $this->billed=1; + + // Call trigger + $result=$this->call_trigger('SHIPPING_BILLED',$user); + if ($result < 0) { + $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; } } @@ -1851,6 +1890,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'; @@ -1859,11 +1902,27 @@ class Expedition extends CommonObject { $this->statut=1; $this->billed=0; + + // Call trigger + $result=$this->call_trigger('SHIPPING_REOPEN',$user); + if ($result < 0) { + $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; } } 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)) {