From 3f9053170edf132f7febae0df600ce629683ecab Mon Sep 17 00:00:00 2001 From: Can Arslan <138895927+mc2rcanarslan@users.noreply.github.com> Date: Tue, 19 Dec 2023 09:08:14 -0700 Subject: [PATCH 01/14] FIX: removed duplicate code removed duplicate code (with line 407) --- htdocs/core/actions_sendmails.inc.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 6fbe2440fb3..ebc6d5fe3ae 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -411,7 +411,6 @@ if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPO $object->email_tocc = $sendtocc; $object->email_tobcc = $sendtobcc; $object->email_subject = $subject; - $object->email_msgid = $mailfile->msgid; // Call of triggers (you should have set $triggersendname to execute trigger. $trigger_name is deprecated) if (!empty($triggersendname) || !empty($trigger_name)) { From e9de2f6bbb4d01498ed2f3ca0253edefafe25e04 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 18 Dec 2023 04:49:22 +0100 Subject: [PATCH 02/14] Fix Update PSWebServiceLibrary to fix deprecated function call libxml_disable_entity_loader() # Fix PSWebServiceLibrary.class.php: PhanDeprecatedFunctionInternal: Call to deprecated function \libxml_disable_entity_loader() See https://github.com/Dolibarr/dolibarr/actions/runs/7242938198/job/19729044021#step:5:32 --- COPYRIGHT | 1 + .../class/PSWebServiceLibrary.class.php | 288 ++++++++++++------ .../dolistore/class/PS_WS_LIB-LICENSE.md | 53 ++++ htdocs/admin/dolistore/class/README.md | 12 + 4 files changed, 263 insertions(+), 91 deletions(-) create mode 100644 htdocs/admin/dolistore/class/PS_WS_LIB-LICENSE.md create mode 100644 htdocs/admin/dolistore/class/README.md diff --git a/COPYRIGHT b/COPYRIGHT index 0bb5937497d..fc50ab2093e 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -38,6 +38,7 @@ PHP-Iban 4.1.1 LGPL-3+ Yes PHP-Imap 2.7.2 MIT License Yes Library to use IMAP with OAuth PHPoAuthLib 0.8.2 MIT License Yes Library to provide oauth1 and oauth2 to different service PHPPrintIPP 1.3 GPL-2+ Yes Library to send print IPP requests +PrestaShop-WS-Lib 94feb5f OSL-3.0 No Library providing API client for Prestashop. PSR/Logs 1.0 MIT License Yes Library for logs (used by DebugBar) PSR/simple-cache ? MIT License Yes Library for cache (used by PHPSpreadSheet) Restler 3.1.1 LGPL-3+ Yes Library to develop REST Web services (+ swagger-ui js lib into dir explorer) diff --git a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php index 80da9f12971..316e1533c86 100644 --- a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php +++ b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php @@ -1,6 +1,6 @@ -* @copyright 2007-2013 PrestaShop SA -* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA +* @author PrestaShop SA +* @copyright 2007-2022 PrestaShop SA +* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA * PrestaShop Webservice Library * @package PrestaShopWebservice */ @@ -31,10 +31,11 @@ */ class PrestaShopWebservice { + /** @var string Shop URL */ protected $url; - /** @var string Authentification key */ + /** @var string Authentication key */ protected $key; /** @var boolean is debug activated */ @@ -43,36 +44,40 @@ class PrestaShopWebservice /** @var string PS version */ protected $version; - /** @var string compatible min version of PrestaShop Webservice */ - const PSCOMPATIBLEVERSIONMIN = '1.4.0.0'; - /** @var string compatible max version of PrestaShop Webservice */ - const PSCOMPATIBLEVERSIONMAX = '1.7.99.99'; - + /** @var string Minimal version of PrestaShop to use with this library */ + const psCompatibleVersionsMin = '1.4.0.0'; + /** @var string Maximal version of PrestaShop to use with this library */ + const psCompatibleVersionsMax = '8.1.1'; /** * PrestaShopWebservice constructor. Throw an exception when CURL is not installed/activated * * getMessage(); + * echo 'Error : '.$ex->getMessage(); * } * ?> * + * * @param string $url Root URL for the shop - * @param string $key Authentification key + * @param string $key Authentication key * @param mixed $debug Debug mode Activated (true) or deactivated (false) + * + * @throws PrestaShopWebserviceException if curl is not loaded */ - public function __construct($url, $key, $debug = true) + function __construct($url, $key, $debug = true) { if (!extension_loaded('curl')) { - throw new PrestaShopWebserviceException('Please activate the PHP extension \'curl\' to allow use of PrestaShop webservice library'); + throw new PrestaShopWebserviceException( + 'Please activate the PHP extension \'curl\' to allow use of PrestaShop webservice library' + ); } $this->url = $url; $this->key = $key; @@ -82,51 +87,92 @@ class PrestaShopWebservice /** * Take the status code and throw an exception if the server didn't return 200 or 201 code + *

Unique parameter must take :

+ * 'status_code' => Status code of an HTTP return
+ * 'response' => CURL response + *

+ * + * @param array $request Response elements of CURL request * - * @param int $status_code Status code of an HTTP return * @return void + * @throws PrestaShopWebserviceException if HTTP status code is not 200 or 201 */ - protected function checkStatusCode($status_code) + protected function checkStatusCode($request) { - $error_label = 'This call to PrestaShop Web Services failed and returned an HTTP status of %d. That means: %s.'; - switch ($status_code) { + switch ($request['status_code']) { case 200: case 201: break; case 204: - throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'No content')); + $error_message = 'No content'; + break; case 400: - throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'Bad Request')); + $error_message = 'Bad Request'; + break; case 401: - throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'Unauthorized')); + $error_message = 'Unauthorized'; + break; case 404: - throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'Not Found')); + $error_message = 'Not Found'; + break; case 405: - throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'Method Not Allowed')); + $error_message = 'Method Not Allowed'; + break; case 500: - throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'Internal Server Error')); + $error_message = 'Internal Server Error'; + break; default: - throw new PrestaShopWebserviceException('This call to PrestaShop Web Services returned an unexpected HTTP status of:'.$status_code); + throw new PrestaShopWebserviceException( + 'This call to PrestaShop Web Services returned an unexpected HTTP status of:' . $request['status_code'] + ); + } + + if (!empty($error_message)) { + $response = $this->parseXML($request['response']); + $errors = $response->children()->children(); + if ($errors && count($errors) > 0) { + foreach ($errors as $error) { + $error_message.= ' - (Code ' . $error->code . '): ' . $error->message; + } + } + $error_label = 'This call to PrestaShop Web Services failed and returned an HTTP status of %d. That means: %s.'; + throw new PrestaShopWebserviceException(sprintf($error_label, $request['status_code'], $error_message)); } } /** - * Handles a CURL request to PrestaShop Webservice. Can throw exception. - * - * @param string $url Resource name - * @param mixed $curl_params CURL parameters (sent to curl_set_opt) - * @return array status_code, response + * Provides default parameters for the curl connection(s) + * @return array Default parameters for curl connection(s) */ - public function executeRequest($url, $curl_params = array()) + protected function getCurlDefaultParams() { $defaultParams = array( CURLOPT_HEADER => true, CURLOPT_RETURNTRANSFER => true, CURLINFO_HEADER_OUT => true, CURLOPT_HTTPAUTH => CURLAUTH_BASIC, - CURLOPT_USERPWD => $this->key.':', - CURLOPT_HTTPHEADER => array('Expect:') + CURLOPT_USERPWD => $this->key . ':', + CURLOPT_HTTPHEADER => array('Expect:'), + //CURLOPT_SSL_VERIFYPEER => false, // reminder, in dev environment sometimes self-signed certificates are used + //CURLOPT_CAINFO => "PATH2CAINFO", // ssl certificate chain checking + //CURLOPT_CAPATH => "PATH2CAPATH", ); + return $defaultParams; + } + + /** + * Handles a CURL request to PrestaShop Webservice. Can throw exception. + * + * @param string $url Resource name + * @param mixed $curl_params CURL parameters (sent to curl_set_opt) + * + * @return array status_code, response, header + * + * @throws PrestaShopWebserviceException + */ + protected function executeRequest($url, $curl_params = array()) + { + $defaultParams = $this->getCurlDefaultParams(); dol_syslog("curl_init url=".$url); $session = curl_init($url); @@ -151,7 +197,7 @@ class PrestaShopWebservice $index = strpos($response, "\r\n\r\n"); if ($index === false && $curl_params[CURLOPT_CUSTOMREQUEST] != 'HEAD') { - throw new PrestaShopWebserviceException('Bad HTTP response'); + throw new PrestaShopWebserviceException('Bad HTTP response ' . $response . curl_error($session)); } $header = substr($response, 0, $index); @@ -170,10 +216,13 @@ class PrestaShopWebservice if (array_key_exists('PSWS-Version', $headerArray)) { $this->version = $headerArray['PSWS-Version']; - if (version_compare(PrestaShopWebservice::PSCOMPATIBLEVERSIONMIN, $headerArray['PSWS-Version']) == 1 || - version_compare(PrestaShopWebservice::PSCOMPATIBLEVERSIONMAX, $headerArray['PSWS-Version']) == -1 + if ( + version_compare(PrestaShopWebservice::psCompatibleVersionsMin, $headerArray['PSWS-Version']) == 1 || + version_compare(PrestaShopWebservice::psCompatibleVersionsMax, $headerArray['PSWS-Version']) == -1 ) { - throw new PrestaShopWebserviceException('This library is not compatible with this version of PrestaShop. Please upgrade/downgrade this library'); + throw new PrestaShopWebserviceException( + 'This library is not compatible with this version of PrestaShop. Please upgrade/downgrade this library' + ); } } @@ -183,7 +232,7 @@ class PrestaShopWebservice } $status_code = curl_getinfo($session, CURLINFO_HTTP_CODE); if ($status_code === 0) { - throw new PrestaShopWebserviceException('CURL Error: '.curl_error($session)); + throw new PrestaShopWebserviceException('CURL Error: ' . curl_error($session)); } curl_close($session); if ($this->debug) { @@ -200,19 +249,27 @@ class PrestaShopWebservice /** * Output debug info * - * @param string $title Title - * @param string $content Content - * @return void + * @param string $title Title + * @param string $content Content + * @return void */ public function printDebug($title, $content) { - echo '
'.dol_escape_htmltag($title).'
'.dol_escape_htmltag($content).'
'; + if (php_sapi_name() == 'cli') { + echo $title . PHP_EOL . $content; + } else { + echo '
' + . $title + . '
'
+				. htmlentities($content)
+				. '
'; + } } /** * Return version * - * @return string Version + * @return string Version */ public function getVersion() { @@ -222,9 +279,9 @@ class PrestaShopWebservice /** * Load XML from string. Can throw exception * - * @param string $response String from a CURL response - * @return SimpleXMLElement|boolean status_code, response + * @param string $response String from a CURL response * + * @return SimpleXMLElement status_code, response * @throws PrestaShopWebserviceException */ protected function parseXML($response) @@ -232,16 +289,11 @@ class PrestaShopWebservice if ($response != '') { libxml_clear_errors(); libxml_use_internal_errors(true); - libxml_disable_entity_loader(true); // Avoid load of external entities (security problem). Required only if LIBXML_VERSION < 20900 - - if (!function_exists('simplexml_load_string')) { - throw new PrestaShopWebserviceException('Method simplexml_load_string not available. Your PHP does not support xml.'); - } - $xml = simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET); + $xml = simplexml_load_string(trim($response), 'SimpleXMLElement', LIBXML_NOCDATA); if (libxml_get_errors()) { $msg = var_export(libxml_get_errors(), true); libxml_clear_errors(); - throw new PrestaShopWebserviceException('HTTP XML response is not parsable: '.$msg); + throw new PrestaShopWebserviceException('HTTP XML response is not parsable: ' . $msg); } return $xml; } else { @@ -256,62 +308,62 @@ class PrestaShopWebservice * 'postXml' => Full XML string to add resource

* Examples are given in the tutorial

* - * @param array $options Options - * @return SimpleXMLElement|boolean status_code, response + * @param array $options * + * @return SimpleXMLElement status_code, response * @throws PrestaShopWebserviceException */ public function add($options) { $xml = ''; - $url = ''; if (isset($options['resource'], $options['postXml']) || isset($options['url'], $options['postXml'])) { - $url = (isset($options['resource']) ? $this->url.'/api/'.$options['resource'] : $options['url']); + $url = (isset($options['resource']) ? $this->url . '/api/' . $options['resource'] : $options['url']); $xml = $options['postXml']; if (isset($options['id_shop'])) { - $url .= '&id_shop='.$options['id_shop']; + $url .= '&id_shop=' . $options['id_shop']; } if (isset($options['id_group_shop'])) { - $url .= '&id_group_shop='.$options['id_group_shop']; + $url .= '&id_group_shop=' . $options['id_group_shop']; } } else { throw new PrestaShopWebserviceException('Bad parameters given'); } $request = $this->executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => $xml)); - $this->checkStatusCode($request['status_code']); + $this->checkStatusCode($request); return $this->parseXML($request['response']); } /** * Retrieve (GET) a resource *

Unique parameter must take :

- * 'url' => Full URL for a GET request of Webservice (ex: http://mystore.com/api/customers/1/)
+ * 'url' => Full URL for a GET request of Webservice (ex: https://mystore.com/api/customers/1/)
* OR
* 'resource' => Resource name,
* 'id' => ID of a resource you want to get

*

* * get(array('resource' => 'orders', 'id' => 1)); - * // Here in $xml, a SimpleXMLElement object you can parse + * // Here in $xml, a SimpleXMLElement object you can parse * foreach ($xml->children()->children() as $attName => $attValue) - * echo $attName.' = '.$attValue.'
'; + * echo $attName.' = '.$attValue.'
'; * } * catch (PrestaShopWebserviceException $ex) * { - * echo 'Error : '.$ex->getMessage(); + * echo 'Error : '.$ex->getMessage(); * } * ?> *
- * @param array $options Array representing resource to get. - * @return SimpleXMLElement|boolean status_code, response * + * @param array $options Array representing resource to get. + * + * @return SimpleXMLElement status_code, response * @throws PrestaShopWebserviceException */ public function get($options) @@ -319,15 +371,13 @@ class PrestaShopWebservice if (isset($options['url'])) { $url = $options['url']; } elseif (isset($options['resource'])) { - $url = $this->url.'/api/'.$options['resource']; + $url = $this->url . '/api/' . $options['resource']; $url_params = array(); if (isset($options['id'])) { - $url .= '/'.$options['id']; + $url .= '/' . $options['id']; } - // @CHANGE LDR - //$params = array('filter', 'display', 'sort', 'limit', 'id_shop', 'id_group_shop'); - $params = array('filter', 'display', 'sort', 'limit', 'id_shop', 'id_group_shop', 'date'); + $params = array('filter', 'display', 'sort', 'limit', 'id_shop', 'id_group_shop', 'schema', 'language', 'date', 'price'); foreach ($params as $p) { foreach ($options as $k => $o) { if (strpos($k, $p) !== false) { @@ -336,23 +386,25 @@ class PrestaShopWebservice } } if (count($url_params) > 0) { - $url .= '?'.http_build_query($url_params); + $url .= '?' . http_build_query($url_params); } } else { - throw new PrestaShopWebserviceException('Bad parameters given '); + throw new PrestaShopWebserviceException('Bad parameters given'); } $request = $this->executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'GET')); - $this->checkStatusCode($request['status_code']); // check the response validity + + $this->checkStatusCode($request);// check the response validity + return $this->parseXML($request['response']); } /** * Head method (HEAD) a resource * - * @param array $options Array representing resource for head request. - * @return SimpleXMLElement status_code, response + * @param array $options Array representing resource for head request. * + * @return SimpleXMLElement status_code, response * @throws PrestaShopWebserviceException */ public function head($options) @@ -360,10 +412,10 @@ class PrestaShopWebservice if (isset($options['url'])) { $url = $options['url']; } elseif (isset($options['resource'])) { - $url = $this->url.'/api/'.$options['resource']; + $url = $this->url . '/api/' . $options['resource']; $url_params = array(); if (isset($options['id'])) { - $url .= '/'.$options['id']; + $url .= '/' . $options['id']; } $params = array('filter', 'display', 'sort', 'limit'); @@ -375,15 +427,16 @@ class PrestaShopWebservice } } if (count($url_params) > 0) { - $url .= '?'.http_build_query($url_params); + $url .= '?' . http_build_query($url_params); } } else { throw new PrestaShopWebserviceException('Bad parameters given'); } $request = $this->executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'HEAD', CURLOPT_NOBODY => true)); - $this->checkStatusCode($request['status_code']); // check the response validity + $this->checkStatusCode($request);// check the response validity return $request['header']; } + /** * Edit (PUT) a resource *

Unique parameter must take :

@@ -392,9 +445,9 @@ class PrestaShopWebservice * 'putXml' => Modified XML string of a resource

* Examples are given in the tutorial

* - * @param array $options Array representing resource to edit. - * @return SimpleXMLElement|boolean status_code, response + * @param array $options Array representing resource to edit. * + * @return SimpleXMLElement * @throws PrestaShopWebserviceException */ public function edit($options) @@ -403,22 +456,75 @@ class PrestaShopWebservice if (isset($options['url'])) { $url = $options['url']; } elseif ((isset($options['resource'], $options['id']) || isset($options['url'])) && $options['putXml']) { - $url = (isset($options['url']) ? $options['url'] : $this->url.'/api/'.$options['resource'].'/'.$options['id']); + $url = (isset($options['url']) ? $options['url'] : + $this->url . '/api/' . $options['resource'] . '/' . $options['id']); $xml = $options['putXml']; if (isset($options['id_shop'])) { - $url .= '&id_shop='.$options['id_shop']; + $url .= '&id_shop=' . $options['id_shop']; } if (isset($options['id_group_shop'])) { - $url .= '&id_group_shop='.$options['id_group_shop']; + $url .= '&id_group_shop=' . $options['id_group_shop']; } } else { throw new PrestaShopWebserviceException('Bad parameters given'); } $request = $this->executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'PUT', CURLOPT_POSTFIELDS => $xml)); - $this->checkStatusCode($request['status_code']); // check the response validity + $this->checkStatusCode($request);// check the response validity return $this->parseXML($request['response']); } + + /** + * Delete (DELETE) a resource. + * Unique parameter must take :

+ * 'resource' => Resource name
+ * 'id' => ID or array which contains IDs of a resource(s) you want to delete

+ * + * delete(array('resource' => 'orders', 'id' => 1)); + * // Following code will not be executed if an exception is thrown. + * echo 'Successfully deleted.'; + * } + * catch (PrestaShopWebserviceException $ex) + * { + * echo 'Error : '.$ex->getMessage(); + * } + * ?> + * + * + * @param array $options Array representing resource to delete. + * + * @return bool + * @throws PrestaShopWebserviceException + */ + public function delete($options) + { + if (isset($options['url'])) { + $url = $options['url']; + } elseif (isset($options['resource']) && isset($options['id'])) { + $url = (is_array($options['id'])) + ? $this->url . '/api/' . $options['resource'] . '/?id=[' . implode(',', $options['id']) . ']' + : $this->url . '/api/' . $options['resource'] . '/' . $options['id']; + } else { + throw new PrestaShopWebserviceException('Bad parameters given'); + } + + if (isset($options['id_shop'])) { + $url .= '&id_shop=' . $options['id_shop']; + } + if (isset($options['id_group_shop'])) { + $url .= '&id_group_shop=' . $options['id_group_shop']; + } + + $request = $this->executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'DELETE')); + $this->checkStatusCode($request);// check the response validity + return true; + } + } /** diff --git a/htdocs/admin/dolistore/class/PS_WS_LIB-LICENSE.md b/htdocs/admin/dolistore/class/PS_WS_LIB-LICENSE.md new file mode 100644 index 00000000000..0dbd9d23112 --- /dev/null +++ b/htdocs/admin/dolistore/class/PS_WS_LIB-LICENSE.md @@ -0,0 +1,53 @@ +# Open Software License v. 3.0 (OSL-3.0) + +This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: + +Licensed under the Open Software License version 3.0 + +1) **Grant of Copyright License.** Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: + +a) to reproduce the Original Work in copies, either alone or as part of a collective work; + +b) to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; + +c) to distribute or communicate copies of the Original Work and Derivative Works to the public, _with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License_; + +d) to perform the Original Work publicly; and + +e) to display the Original Work publicly. + +2) **Grant** of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. + +3) **Grant** of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. + +4) **Exclusions From License Grant.** Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2\. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. + +5) **External Deployment.** The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). + +6) **Attribution Rights.** You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. + +7) **Warranty of Provenance and Disclaimer of Warranty.** Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. + +8) **Limitation of Liability.** Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. + +9) **Acceptance and Termination.** If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). + +10) **Termination for Patent Action.** This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. + +11) **Jurisdiction, Venue and Governing Law.** Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. + +12) **Attorneys' Fees.** In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. + +13) **Miscellaneous.** If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. + +14) **Definition of "You" in This License.** "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +15) **Right to Use.** You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. + +16) **Modification of This License.** This License is Copyright (c) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. + +[A brief explanation of this license is available][0]. + + +[0]: http://rosenlaw.com/OSL3.0-explained.htm + diff --git a/htdocs/admin/dolistore/class/README.md b/htdocs/admin/dolistore/class/README.md new file mode 100644 index 00000000000..b0f57af00e7 --- /dev/null +++ b/htdocs/admin/dolistore/class/README.md @@ -0,0 +1,12 @@ +# PrestaShop-webservice-lib + +Source updated from: + +https://github.com/PrestaShop/PrestaShop-webservice-lib/blob/master/PSWebServiceLibrary.php + +## Compatibility analysis + +https://www.gnu.org/licenses/license-list.html#OSL + + + From 77f6606b1b5f853acef431705c8bd1f4bf8ef469 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 18 Dec 2023 05:05:15 +0100 Subject: [PATCH 03/14] Fix Dolibar PHP-CS requirements --- .../dolistore/class/PSWebServiceLibrary.class.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php index 316e1533c86..9ed9333079c 100644 --- a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php +++ b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php @@ -45,9 +45,9 @@ class PrestaShopWebservice protected $version; /** @var string Minimal version of PrestaShop to use with this library */ - const psCompatibleVersionsMin = '1.4.0.0'; + const PS_COMPATIBLE_VERSIONS_MIN = '1.4.0.0'; /** @var string Maximal version of PrestaShop to use with this library */ - const psCompatibleVersionsMax = '8.1.1'; + const PS_COMPATIBLE_VERSIONS_MAX = '8.1.1'; /** * PrestaShopWebservice constructor. Throw an exception when CURL is not installed/activated @@ -72,7 +72,7 @@ class PrestaShopWebservice * * @throws PrestaShopWebserviceException if curl is not loaded */ - function __construct($url, $key, $debug = true) + public function __construct($url, $key, $debug = true) { if (!extension_loaded('curl')) { throw new PrestaShopWebserviceException( @@ -217,8 +217,8 @@ class PrestaShopWebservice if (array_key_exists('PSWS-Version', $headerArray)) { $this->version = $headerArray['PSWS-Version']; if ( - version_compare(PrestaShopWebservice::psCompatibleVersionsMin, $headerArray['PSWS-Version']) == 1 || - version_compare(PrestaShopWebservice::psCompatibleVersionsMax, $headerArray['PSWS-Version']) == -1 + version_compare(PrestaShopWebservice::PS_COMPATIBLE_VERSIONS_MIN, $headerArray['PSWS-Version']) == 1 || + version_compare(PrestaShopWebservice::PS_COMPATIBLE_VERSIONS_MAX, $headerArray['PSWS-Version']) == -1 ) { throw new PrestaShopWebserviceException( 'This library is not compatible with this version of PrestaShop. Please upgrade/downgrade this library' @@ -308,7 +308,7 @@ class PrestaShopWebservice * 'postXml' => Full XML string to add resource

* Examples are given in the tutorial

* - * @param array $options + * @param array $options Options * * @return SimpleXMLElement status_code, response * @throws PrestaShopWebserviceException @@ -352,7 +352,7 @@ class PrestaShopWebservice * $xml = $ws->get(array('resource' => 'orders', 'id' => 1)); * // Here in $xml, a SimpleXMLElement object you can parse * foreach ($xml->children()->children() as $attName => $attValue) - * echo $attName.' = '.$attValue.'
'; + * echo $attName.' = '.$attValue.'
'; * } * catch (PrestaShopWebserviceException $ex) * { @@ -524,7 +524,6 @@ class PrestaShopWebservice $this->checkStatusCode($request);// check the response validity return true; } - } /** From e99825723536ffedf9e5c58f8c9efa1ce0d9170b Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Dec 2023 19:53:44 +0100 Subject: [PATCH 04/14] libxml - reintroduce security measure not in the official PS WebServiceLib --- .../admin/dolistore/class/PSWebServiceLibrary.class.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php index 9ed9333079c..49850bb1d2b 100644 --- a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php +++ b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php @@ -289,7 +289,13 @@ class PrestaShopWebservice if ($response != '') { libxml_clear_errors(); libxml_use_internal_errors(true); - $xml = simplexml_load_string(trim($response), 'SimpleXMLElement', LIBXML_NOCDATA); + if (LIBXML_VERSION < 20900) { + // Avoid load of external entities (security problem). + // Required only if LIBXML_VERSION < 20900 + libxml_disable_entity_loader(true); + } + + $xml = simplexml_load_string(trim($response), 'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET); if (libxml_get_errors()) { $msg = var_export(libxml_get_errors(), true); libxml_clear_errors(); From 8a556a8cb5545efce7306633dc5490ff8bd1eedd Mon Sep 17 00:00:00 2001 From: LauraDiaz Date: Wed, 20 Dec 2023 09:30:08 +0100 Subject: [PATCH 05/14] Update card.php --- htdocs/user/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 78e4e5e0ac4..700dd744382 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -481,7 +481,7 @@ if (empty($reshook)) { $object->thm = GETPOST("thm", 'alphanohtml') != '' ? GETPOST("thm", 'alphanohtml') : ''; $object->thm = price2num($object->thm); $object->tjm = GETPOST("tjm", 'alphanohtml') != '' ? GETPOST("tjm", 'alphanohtml') : ''; - $object->thm = price2num($object->thm); + $object->tjm = price2num($object->tjm); $object->salary = GETPOST("salary", 'alphanohtml') != '' ? GETPOST("salary", 'alphanohtml') : ''; $object->salary = price2num($object->salary); $object->salaryextra = GETPOST("salaryextra", 'alphanohtml') != '' ? GETPOST("salaryextra", 'alphanohtml') : ''; From 5e4a4da130cbf077fd4470c305765b5e4cd10086 Mon Sep 17 00:00:00 2001 From: Hystepik Date: Wed, 20 Dec 2023 14:22:45 +0100 Subject: [PATCH 06/14] Fix some php codce smell --- htdocs/accountancy/admin/accountmodel.php | 2 +- htdocs/accountancy/admin/categories_list.php | 2 +- htdocs/accountancy/admin/journals_list.php | 2 +- htdocs/accountancy/class/accountancyexport.class.php | 6 +++--- htdocs/accountancy/class/bookkeeping.class.php | 2 +- htdocs/adherents/class/adherent.class.php | 4 ++-- htdocs/admin/dict.php | 2 +- htdocs/admin/mails_templates.php | 2 +- htdocs/admin/website.php | 2 +- htdocs/blockedlog/class/blockedlog.class.php | 6 +++--- htdocs/bom/class/bom.class.php | 6 +++--- htdocs/categories/class/categorie.class.php | 2 +- htdocs/comm/action/class/actioncomm.class.php | 6 +++--- htdocs/comm/action/class/api_agendaevents.class.php | 2 +- htdocs/comm/action/class/ical.class.php | 2 +- htdocs/comm/action/index.php | 4 ++-- htdocs/comm/propal/class/propal.class.php | 12 ++++++------ htdocs/commande/class/commande.class.php | 12 ++++++------ 18 files changed, 38 insertions(+), 38 deletions(-) diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index 5a2b7aa5e21..456b1503ca7 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -740,7 +740,7 @@ $db->close(); * @param string $context 'add'=Output field for the "add form", 'edit'=Output field for the "edit form", 'hide'=Output field for the "add form" but we dont want it to be rendered * @return void */ -function fieldListAccountModel($fieldlist, $obj = '', $tabname = '', $context = '') +function fieldListAccountModel($fieldlist, $obj = null, $tabname = '', $context = '') { global $langs, $db; global $form; diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index 35126c5d464..66f411c8cca 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -958,7 +958,7 @@ $db->close(); * @param string $context 'add'=Output field for the "add form", 'edit'=Output field for the "edit form", 'hide'=Output field for the "add form" but we dont want it to be rendered * @return void */ -function fieldListAccountingCategories($fieldlist, $obj = '', $tabname = '', $context = '') +function fieldListAccountingCategories($fieldlist, $obj = null, $tabname = '', $context = '') { global $conf, $langs, $db; global $form, $mysoc; diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index 02158f7536a..c1ad8bdb0c5 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -691,7 +691,7 @@ $db->close(); * @param string $context 'add'=Output field for the "add form", 'edit'=Output field for the "edit form", 'hide'=Output field for the "add form" but we dont want it to be rendered * @return void */ -function fieldListJournal($fieldlist, $obj = '', $tabname = '', $context = '') +function fieldListJournal($fieldlist, $obj = null, $tabname = '', $context = '') { global $conf, $langs, $db; global $form, $mysoc; diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 737573ef21e..7573dbee9f4 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -829,7 +829,7 @@ class AccountancyExport * @param array $objectLines data * @param resource $exportFile [=null] File resource to export or print if null * @param array $archiveFileList [=array()] Archive file list : array of ['path', 'name'] - * @param bool $withAttachment [=0] Not add files or 1 to have attached in an archive + * @param int $withAttachment [=0] Not add files or 1 to have attached in an archive * @return array Archive file list : array of ['path', 'name'] */ public function exportQuadratus($objectLines, $exportFile = null, $archiveFileList = array(), $withAttachment = 0) @@ -1309,7 +1309,7 @@ class AccountancyExport * @param array $objectLines data * @param resource $exportFile [=null] File resource to export or print if null * @param array $archiveFileList [=array()] Archive file list : array of ['path', 'name'] - * @param bool $withAttachment [=0] Not add files or 1 to have attached in an archive + * @param int $withAttachment [=0] Not add files or 1 to have attached in an archive * @return array Archive file list : array of ['path', 'name'] */ public function exportFEC($objectLines, $exportFile = null, $archiveFileList = array(), $withAttachment = 0) @@ -1520,7 +1520,7 @@ class AccountancyExport * @param array $objectLines data * @param resource $exportFile [=null] File resource to export or print if null * @param array $archiveFileList [=array()] Archive file list : array of ['path', 'name'] - * @param bool $withAttachment [=0] Not add files or 1 to have attached in an archive + * @param int $withAttachment [=0] Not add files or 1 to have attached in an archive * @return array Archive file list : array of ['path', 'name'] */ public function exportFEC2($objectLines, $exportFile = null, $archiveFileList = array(), $withAttachment = 0) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index ffda82c2174..9de46b09d39 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -2124,7 +2124,7 @@ class BookKeeping extends CommonObject * @param array $event Event options * @param int $select_in Value is a aa.rowid (0 default) or aa.account_number (1) * @param int $select_out Set value returned by select 0=rowid (default), 1=account_number - * @param int $aabase Set accounting_account base class to display empty=all or from 1 to 8 will display only account beginning by this number + * @param string $aabase Set accounting_account base class to display empty=all or from 1 to 8 will display only account beginning by this number * @return string String with HTML select */ public function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 154b886ae0e..dee2b122ae7 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1361,7 +1361,7 @@ class Adherent extends CommonObject * @param bool $fetch_subscriptions To load member subscriptions * @return int >0 if OK, 0 if not found, <0 if KO */ - public function fetch($rowid, $ref = '', $fk_soc = '', $ref_ext = '', $fetch_optionals = true, $fetch_subscriptions = true) + public function fetch($rowid, $ref = '', $fk_soc = 0, $ref_ext = '', $fetch_optionals = true, $fetch_subscriptions = true) { global $langs; @@ -1679,7 +1679,7 @@ class Adherent extends CommonObject * @param string $num_chq Numero cheque (if Id bank account provided) * @param string $emetteur_nom Name of cheque writer * @param string $emetteur_banque Name of bank of cheque - * @param string $autocreatethirdparty Auto create new thirdparty if member not yet linked to a thirdparty and we request an option that generate invoice. + * @param int $autocreatethirdparty Auto create new thirdparty if member not yet linked to a thirdparty and we request an option that generate invoice. * @param string $ext_payment_id External id of payment (for example Stripe charge id) * @param string $ext_payment_site Name of external paymentmode (for example 'stripe') * @return int Return integer <0 if KO, >0 if OK diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index d1fbb458549..6a6ee16dbcb 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -2540,7 +2540,7 @@ $db->close(); * @param string $context 'add'=Output field for the "add form", 'edit'=Output field for the "edit form", 'hide'=Output field for the "add form" but we dont want it to be rendered * @return string '' or value of entity into table */ -function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') +function fieldList($fieldlist, $obj = null, $tabname = '', $context = '') { global $conf, $langs, $db, $mysoc; global $form; diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index f658d456f8d..cabbe69c319 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -1354,7 +1354,7 @@ $db->close(); * @param string $context 'add'=Output field for the "add form", 'edit'=Output field for the "edit form", 'hide'=Output field for the "add form" but we dont want it to be rendered * @return void */ -function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') +function fieldList($fieldlist, $obj = null, $tabname = '', $context = '') { global $langs, $user, $db; global $form; diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php index 44a394ebe8f..3a6d4639fbb 100644 --- a/htdocs/admin/website.php +++ b/htdocs/admin/website.php @@ -681,7 +681,7 @@ $db->close(); * @param string $context 'add'=Output field for the "add form", 'edit'=Output field for the "edit form", 'hide'=Output field for the "add form" but we dont want it to be rendered * @return void */ -function fieldListWebsites($fieldlist, $obj = '', $tabname = '', $context = '') +function fieldListWebsites($fieldlist, $obj = null, $tabname = '', $context = '') { global $conf, $langs, $db; global $form; diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index a69c839f369..e5279635b2a 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -797,7 +797,7 @@ class BlockedLog * Encode data * * @param string $data Data to serialize - * @param string $mode 0=serialize, 1=json_encode + * @param int $mode 0=serialize, 1=json_encode * @return string Value serialized, an object (stdClass) */ public function dolEncodeBlockedData($data, $mode = 0) @@ -817,7 +817,7 @@ class BlockedLog * Decode data * * @param string $data Data to unserialize - * @param string $mode 0=unserialize, 1=json_decode + * @param int $mode 0=unserialize, 1=json_decode * @return object Value unserialized, an object (stdClass) */ public function dolDecodeBlockedData($data, $mode = 0) @@ -852,7 +852,7 @@ class BlockedLog * Create blocked log in database. * * @param User $user Object user that create - * @param int $forcesignature Force signature (for example '0000000000' when we disabled the module) + * @param string $forcesignature Force signature (for example '0000000000' when we disabled the module) * @return int Return integer <0 if KO, >0 if OK */ public function create($user, $forcesignature = '') diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 9c89778d555..108de19475a 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -602,7 +602,7 @@ class BOM extends CommonObject * @param int $fk_default_workstation Default workstation * @return int Return integer <0 if KO, Id of created object if OK */ - public function addLine($fk_product, $qty, $qty_frozen = 0, $disable_stock_change = 0, $efficiency = 1.0, $position = -1, $fk_bom_child = null, $import_key = null, $fk_unit = '', $array_options = 0, $fk_default_workstation = null) + public function addLine($fk_product, $qty, $qty_frozen = 0, $disable_stock_change = 0, $efficiency = 1.0, $position = -1, $fk_bom_child = null, $import_key = null, $fk_unit = '', $array_options = array(), $fk_default_workstation = null) { global $mysoc, $conf, $langs, $user; @@ -710,7 +710,7 @@ class BOM extends CommonObject * @param int $fk_default_workstation Default workstation * @return int Return integer <0 if KO, Id of updated BOM-Line if OK */ - public function updateLine($rowid, $qty, $qty_frozen = 0, $disable_stock_change = 0, $efficiency = 1.0, $position = -1, $import_key = null, $fk_unit = 0, $array_options = 0, $fk_default_workstation = null) + public function updateLine($rowid, $qty, $qty_frozen = 0, $disable_stock_change = 0, $efficiency = 1.0, $position = -1, $import_key = null, $fk_unit = 0, $array_options = array(), $fk_default_workstation = null) { global $mysoc, $conf, $langs, $user; @@ -1594,7 +1594,7 @@ class BOM extends CommonObject * @param int $level Protection against infinite loop * @return void */ - public function getParentBomTreeRecursive(&$TParentBom, $bom_id = '', $level = 1) + public function getParentBomTreeRecursive(&$TParentBom, $bom_id = 0, $level = 1) { // Protection against infinite loop diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 3a57d245956..f7008dad5eb 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1385,7 +1385,7 @@ class Categorie extends CommonObject * @param string $sep Separator * @param string $url Url ('', 'none' or 'urltouse') * @param int $nocolor 0 - * @param string $addpicto Add picto into link + * @param int $addpicto Add picto into link * @return array */ public function print_all_ways($sep = '>>', $url = '', $nocolor = 0, $addpicto = 0) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 8f13709a1e0..7ebd0a3413c 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -784,7 +784,7 @@ class ActionComm extends CommonObject * @param string $ref Ref of action to get * @param string $ref_ext Ref ext to get * @param string $email_msgid Email msgid - * @param string $loadresources 1=Load also resources + * @param int $loadresources 1=Load also resources * @return int Return integer <0 if KO, >0 if OK */ public function fetch($id, $ref = '', $ref_ext = '', $email_msgid = '', $loadresources = 1) @@ -1328,7 +1328,7 @@ class ActionComm extends CommonObject * @param string $filter Other filter * @param string $sortfield Sort on this field * @param string $sortorder ASC or DESC - * @param string $limit Limit number of answers + * @param int $limit Limit number of answers * @return ActionComm[]|string Error string if KO, array with actions if OK */ public function getActions($socid = 0, $fk_element = 0, $elementtype = '', $filter = '', $sortfield = 'a.datep', $sortorder = 'DESC', $limit = 0) @@ -1542,7 +1542,7 @@ class ActionComm extends CommonObject * @param int $percent Percent * @param int $mode 0=Long label, 1=Short label, 2=Picto+Short label, 3=Picto, 4=Picto+Short label, 5=Short label+Picto, 6=Picto+Long label, 7=Very short label+Picto * @param int $hidenastatus 1=Show nothing if status is "Not applicable" - * @param int $datestart Date start of event + * @param int|string $datestart Date start of event * @return string Label */ public function LibStatut($percent, $mode, $hidenastatus = 0, $datestart = '') diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 5c86aa9f6b5..50fb1882aaf 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -103,7 +103,7 @@ class AgendaEvents extends DolibarrApi * @param string $properties Restrict the data returned to theses properties. Ignored if empty. Comma separated list of properties names * @return array Array of Agenda Events objects */ - public function index($sortfield = "t.id", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '', $properties = '') + public function index($sortfield = "t.id", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = '', $sqlfilters = '', $properties = '') { global $db, $conf; diff --git a/htdocs/comm/action/class/ical.class.php b/htdocs/comm/action/class/ical.class.php index bace864360e..d7b60f5e5ef 100644 --- a/htdocs/comm/action/class/ical.class.php +++ b/htdocs/comm/action/class/ical.class.php @@ -109,7 +109,7 @@ class ICal * * @param string $uri Url * @param string $usecachefile Full path of a cache file to use a cache file - * @param string $delaycache Delay in seconds for cache (by default 3600 secondes) + * @param int $delaycache Delay in seconds for cache (by default 3600 secondes) * @return array|string */ public function parse($uri, $usecachefile = '', $delaycache = 3600) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index f008b84dfad..87835c9b36f 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1743,8 +1743,8 @@ $db->close(); * @param string $newparam Parameters on current URL * @param int $showinfo Add extended information (used by day and week view) * @param int $minheight Minimum height for each event. 60px by default. - * @param string $nonew 0=Add "new entry button", 1=No "new entry button", -1=Only "new entry button" - * @param string $bookcalcalendarsarray Used for Bookcal module array of calendar of bookcal + * @param int $nonew 0=Add "new entry button", 1=No "new entry button", -1=Only "new entry button" + * @param array $bookcalcalendarsarray Used for Bookcal module array of calendar of bookcal * @return void */ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam = '', $showinfo = 0, $minheight = 60, $nonew = 0, $bookcalcalendarsarray = array()) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index d470fc8bc52..c5e9175a2af 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -577,8 +577,8 @@ class Propal extends CommonObject * @param int $fk_fournprice Id supplier price * @param int $pa_ht Buying price without tax * @param string $label ??? - * @param int $date_start Start date of the line - * @param int $date_end End date of the line + * @param int|string $date_start Start date of the line + * @param int|string $date_end End date of the line * @param array $array_options extrafields array * @param string $fk_unit Code of the unit to use. Null to use the default one * @param string $origin Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be 'orderdet', 'propaldet'..., else 'order','propal,'.... @@ -589,7 +589,7 @@ class Propal extends CommonObject * @return int >0 if OK, <0 if KO * @see add_product() */ - public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $fk_product = 0, $remise_percent = 0.0, $price_base_type = 'HT', $pu_ttc = 0.0, $info_bits = 0, $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $date_start = '', $date_end = '', $array_options = 0, $fk_unit = null, $origin = '', $origin_id = 0, $pu_ht_devise = 0, $fk_remise_except = 0, $noupdateafterinsertline = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $fk_product = 0, $remise_percent = 0.0, $price_base_type = 'HT', $pu_ttc = 0.0, $info_bits = 0, $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $date_start = '', $date_end = '', $array_options = array(), $fk_unit = null, $origin = '', $origin_id = 0, $pu_ht_devise = 0, $fk_remise_except = 0, $noupdateafterinsertline = 0) { global $mysoc, $conf, $langs; @@ -827,8 +827,8 @@ class Propal extends CommonObject * @param int $pa_ht Price (without tax) of product when it was bought * @param string $label ??? * @param int $type 0/1=Product/service - * @param int $date_start Start date of the line - * @param int $date_end End date of the line + * @param int|string $date_start Start date of the line + * @param int|string $date_end End date of the line * @param array $array_options extrafields array * @param string $fk_unit Code of the unit to use. Null to use the default one * @param double $pu_ht_devise Unit price in currency @@ -836,7 +836,7 @@ class Propal extends CommonObject * @param integer $rang line rank * @return int 0 if OK, <0 if KO */ - public function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $desc = '', $price_base_type = 'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $type = 0, $date_start = '', $date_end = '', $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $rang = 0) + public function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $desc = '', $price_base_type = 'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $type = 0, $date_start = '', $date_end = '', $array_options = array(), $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $rang = 0) { global $mysoc, $langs; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 5ec0a3374d1..76701e51ca7 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1483,8 +1483,8 @@ class Commande extends CommonOrder * @param int $fk_remise_except Id remise * @param string $price_base_type HT or TTC * @param float $pu_ttc Prix unitaire TTC - * @param int $date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) - * @param int $date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) + * @param int|string $date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) + * @param int|string $date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) * @param int $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used. * @param int $rang Position of line * @param int $special_code Special code (also used by externals modules!) @@ -1508,7 +1508,7 @@ class Commande extends CommonOrder * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit) * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) */ - public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $info_bits = 0, $fk_remise_except = 0, $price_base_type = 'HT', $pu_ttc = 0, $date_start = '', $date_end = '', $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = 0, $fk_unit = null, $origin = '', $origin_id = 0, $pu_ht_devise = 0, $ref_ext = '', $noupdateafterinsertline = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $info_bits = 0, $fk_remise_except = 0, $price_base_type = 'HT', $pu_ttc = 0, $date_start = '', $date_end = '', $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = array(), $fk_unit = null, $origin = '', $origin_id = 0, $pu_ht_devise = 0, $ref_ext = '', $noupdateafterinsertline = 0) { global $mysoc, $conf, $langs, $user; @@ -1755,8 +1755,8 @@ class Commande extends CommonOrder * @param int $idproduct Product Id * @param float $qty Quantity * @param float $remise_percent Product discount relative - * @param int $date_start Start date of the line - * @param int $date_end End date of the line + * @param int|string $date_start Start date of the line + * @param int|string $date_end End date of the line * @return void * * TODO Remplacer les appels a cette fonction par generation objet Ligne @@ -2728,7 +2728,7 @@ class Commande extends CommonOrder * @param string $sortorder Sort order * @return int|array -1 if KO, array with result if OK */ - public function liste_array($shortlist = 0, $draft = 0, $excluser = '', $socid = 0, $limit = 0, $offset = 0, $sortfield = 'c.date_commande', $sortorder = 'DESC') + public function liste_array($shortlist = 0, $draft = 0, $excluser = null, $socid = 0, $limit = 0, $offset = 0, $sortfield = 'c.date_commande', $sortorder = 'DESC') { // phpcs:enable global $user; From d08f91e4cbfca3a0f2d570451dd7453f834e2b9e Mon Sep 17 00:00:00 2001 From: Hystepik Date: Thu, 21 Dec 2023 13:43:19 +0100 Subject: [PATCH 07/14] Fix some phpstan warnings --- htdocs/commande/class/commande.class.php | 6 +++--- htdocs/compta/bank/class/account.class.php | 4 ++-- .../compta/facture/class/facture-rec.class.php | 8 ++++---- htdocs/compta/facture/class/facture.class.php | 18 +++++++++--------- .../cheque/class/remisecheque.class.php | 2 +- .../compta/paiement/class/paiement.class.php | 2 +- .../prelevement/class/bonprelevement.class.php | 2 +- htdocs/contrat/class/contrat.class.php | 8 ++++---- htdocs/core/class/comment.class.php | 2 +- htdocs/core/class/commondocgenerator.class.php | 4 ++-- htdocs/core/class/commonobject.class.php | 4 ++-- htdocs/core/class/discount.class.php | 2 +- htdocs/core/class/doleditor.class.php | 4 ++-- 13 files changed, 33 insertions(+), 33 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 5ec0a3374d1..815c776ad26 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3092,8 +3092,8 @@ class Commande extends CommonOrder * @param float $txlocaltax2 Local tax 2 rate * @param string $price_base_type HT or TTC * @param int $info_bits Miscellaneous informations on line - * @param int $date_start Start date of the line - * @param int $date_end End date of the line + * @param int|string $date_start Start date of the line + * @param int|string $date_end End date of the line * @param int $type Type of line (0=product, 1=service) * @param int $fk_parent_line Id of parent line (0 in most cases, used by modules adding sublevels into lines). * @param int $skip_update_total Keep fields total_xxx to 0 (used for special lines by some modules) @@ -3109,7 +3109,7 @@ class Commande extends CommonOrder * @param integer $rang line rank * @return int Return integer < 0 if KO, > 0 if OK */ - public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $price_base_type = 'HT', $info_bits = 0, $date_start = '', $date_end = '', $type = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $ref_ext = '', $rang = 0) + public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $price_base_type = 'HT', $info_bits = 0, $date_start = '', $date_end = '', $type = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = array(), $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $ref_ext = '', $rang = 0) { global $conf, $mysoc, $langs, $user; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index c6ad77c7475..bdeed68f0b0 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -491,7 +491,7 @@ class Account extends CommonObject * @param string $type To search using type * @return array|int Array of links array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> ) or -1 on error */ - public function get_url($fk_bank = '', $url_id = '', $type = '') + public function get_url($fk_bank = 0, $url_id = 0, $type = '') { // phpcs:enable $lines = array(); @@ -1258,7 +1258,7 @@ class Account extends CommonObject * Return current sold * * @param int $option 1=Exclude future operation date (this is to exclude input made in advance and have real account sold) - * @param int $date_end Date until we want to get bank account sold + * @param int|string $date_end Date until we want to get bank account sold * @param string $field dateo or datev * @return int current sold (value date <= today) */ diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 1410c86b0dd..9a0127134fa 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -873,7 +873,7 @@ class FactureRec extends CommonInvoice * @param int $fk_parent_line Id of parent line * @return int Return integer <0 if KO, Id of line if OK */ - public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $date_start_fill = 0, $date_end_fill = 0, $fk_fournprice = null, $pa_ht = 0, $fk_parent_line = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = 0, $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $date_start_fill = 0, $date_end_fill = 0, $fk_fournprice = null, $pa_ht = 0, $fk_parent_line = 0) { global $mysoc; @@ -1080,7 +1080,7 @@ class FactureRec extends CommonInvoice * @param int $fk_parent_line Id of parent line * @return int Return integer <0 if KO, Id of line if OK */ - public function updateline($rowid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $date_start_fill = 0, $date_end_fill = 0, $fk_fournprice = null, $pa_ht = 0, $fk_parent_line = 0) + public function updateline($rowid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = 0, $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $date_start_fill = 0, $date_end_fill = 0, $fk_fournprice = null, $pa_ht = 0, $fk_parent_line = 0) { global $mysoc; @@ -1447,7 +1447,7 @@ class FactureRec extends CommonInvoice * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = '', $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1) { global $langs, $hookmanager; @@ -2172,7 +2172,7 @@ class FactureLigneRec extends CommonInvoiceLine * @param int $notrigger Disable triggers * @return int Return integer <0 if KO, >0 if OK */ - public function delete(User $user, $notrigger = false) + public function delete(User $user, $notrigger = 0) { $error = 0; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index b277db0da53..dad469a8eea 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2113,7 +2113,7 @@ class Facture extends CommonInvoice * @param bool $fetch_situation Load also the previous and next situation invoice into $tab_previous_situation_invoice and $tab_next_situation_invoice * @return int >0 if OK, <0 if KO, 0 if not found */ - public function fetch($rowid, $ref = '', $ref_ext = '', $notused = '', $fetch_situation = false) + public function fetch($rowid, $ref = '', $ref_ext = '', $notused = 0, $fetch_situation = false) { if (empty($rowid) && empty($ref) && empty($ref_ext)) { return -1; @@ -3747,8 +3747,8 @@ class Facture extends CommonInvoice * @param double $txlocaltax2 Local tax 2 rate (deprecated, use instead txtva with code inside) * @param int $fk_product Id of predefined product/service * @param double $remise_percent Percent of discount on line - * @param int $date_start Date start of service - * @param int $date_end Date end of service + * @param int|string $date_start Date start of service + * @param int|string $date_end Date end of service * @param int $ventil Code of dispatching into accountancy * @param int $info_bits Bits of type of lines * @param int $fk_remise_except Id discount used @@ -3785,7 +3785,7 @@ class Facture extends CommonInvoice $date_end = '', $ventil = 0, $info_bits = 0, - $fk_remise_except = '', + $fk_remise_except = 0, $price_base_type = 'HT', $pu_ttc = 0, $type = 0, @@ -3797,7 +3797,7 @@ class Facture extends CommonInvoice $fk_fournprice = null, $pa_ht = 0, $label = '', - $array_options = 0, + $array_options = array(), $situation_percent = 100, $fk_prev_id = 0, $fk_unit = null, @@ -4068,7 +4068,7 @@ class Facture extends CommonInvoice * @param integer $rang rank of line * @return int Return integer < 0 if KO, > 0 if OK */ - public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $situation_percent = 100, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $ref_ext = '', $rang = 0) + public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = array(), $situation_percent = 100, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $ref_ext = '', $rang = 0) { global $conf, $user; // Deprecation warning @@ -4709,7 +4709,7 @@ class Facture extends CommonInvoice * @param string $sortorder Sort order * @return array|int -1 if KO, array with result if OK */ - public function liste_array($shortlist = 0, $draft = 0, $excluser = '', $socid = 0, $limit = 0, $offset = 0, $sortfield = 'f.datef,f.rowid', $sortorder = 'DESC') + public function liste_array($shortlist = 0, $draft = 0, $excluser = null, $socid = 0, $limit = 0, $offset = 0, $sortfield = 'f.datef,f.rowid', $sortorder = 'DESC') { // phpcs:enable global $conf, $user; @@ -5581,7 +5581,7 @@ class Facture extends CommonInvoice * @param string $dateYmd date limit of retained warranty in Y m d format * @return int >0 if OK, <0 if KO */ - public function setRetainedWarrantyDateLimit($timestamp, $dateYmd = false) + public function setRetainedWarrantyDateLimit($timestamp, $dateYmd = '') { if (!$timestamp && $dateYmd) { $timestamp = $this->db->jdate($dateYmd); @@ -6449,7 +6449,7 @@ class FactureLigne extends CommonInvoiceLine * @param int $notrigger Disable triggers * @return int Return integer <0 if KO, >0 if OK */ - public function update($user = '', $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $user, $conf; diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 562d9da587f..7eba56434fe 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -291,7 +291,7 @@ class RemiseCheque extends CommonObject * @param User $user User that delete * @return int */ - public function delete($user = '') + public function delete($user = null) { global $conf; diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index ffb3f5083b8..64335484aa1 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -178,7 +178,7 @@ class Paiement extends CommonObject * @param int $fk_bank Id of bank line associated to payment * @return int Return integer <0 if KO, 0 if not found, >0 if OK */ - public function fetch($id, $ref = '', $fk_bank = '') + public function fetch($id, $ref = '', $fk_bank = 0) { $sql = 'SELECT p.rowid, p.ref, p.ref_ext, p.datep as dp, p.amount, p.statut, p.ext_payment_id, p.ext_payment_site, p.fk_bank, p.multicurrency_amount,'; $sql .= ' c.code as type_code, c.libelle as type_label,'; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 6ec256df84f..48b82d45d8a 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -954,7 +954,7 @@ class BonPrelevement extends CommonObject * @param string $type 'direct-debit' or 'bank-transfer' * @param int $did ID of an existing payment request. If $did is defined, we use the existing payment request. * @param int $fk_bank_account Bank account ID the receipt is generated for. Will use the ID into the setup of module Direct Debit or Credit Transfer if 0. - * @param int $sourcetype 'invoice' or 'salary' + * @param string $sourcetype 'invoice' or 'salary' * @return int Return integer <0 if KO, No of invoice included into file if OK */ public function create($banque = 0, $agence = 0, $mode = 'real', $format = 'ALL', $executiondate = '', $notrigger = 0, $type = 'direct-debit', $did = 0, $fk_bank_account = 0, $sourcetype = 'invoice') diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index d524c6973a1..ac760bd8ecc 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1474,10 +1474,10 @@ class Contrat extends CommonObject * @param int $pa_ht Buying price HT * @param array $array_options extrafields array * @param string $fk_unit Code of the unit to use. Null to use the default one - * @param string $rang Position + * @param int $rang Position * @return int Return integer <0 if KO, >0 if OK */ - public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type = 'HT', $pu_ttc = 0.0, $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = 0, $fk_unit = null, $rang = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type = 'HT', $pu_ttc = 0.0, $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = array(), $fk_unit = null, $rang = 0) { global $user, $langs, $conf, $mysoc; $error = 0; @@ -1706,10 +1706,10 @@ class Contrat extends CommonObject * @param int $pa_ht Buying price HT * @param array $array_options extrafields array * @param string $fk_unit Code of the unit to use. Null to use the default one - * @param string $rang Position + * @param int $rang Position * @return int Return integer <0 if KO, >0 if OK */ - public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx = 0.0, $localtax2tx = 0.0, $date_start_real = '', $date_end_real = '', $price_base_type = 'HT', $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = 0, $fk_unit = null, $rang = 0) + public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx = 0.0, $localtax2tx = 0.0, $date_start_real = '', $date_end_real = '', $price_base_type = 'HT', $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = array(), $fk_unit = null, $rang = 0) { global $user, $conf, $langs, $mysoc; diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php index 3bae32d81e3..491c84f2a11 100644 --- a/htdocs/core/class/comment.class.php +++ b/htdocs/core/class/comment.class.php @@ -177,7 +177,7 @@ class Comment extends CommonObject * Load object in memory from database * * @param int $id Id object - * @param int $ref ref object + * @param string $ref ref object * @return int Return integer <0 if KO, 0 if not found, >0 if OK */ public function fetch($id, $ref = '') diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index e211cd631d0..9b6c0b4bf75 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -825,7 +825,7 @@ abstract class CommonDocGenerator * * @param Expedition $object Main object to use as data source * @param Translate $outputlangs Lang object to use for output - * @param array $array_key Name of the key for return array + * @param string $array_key Name of the key for return array * @return array Array of substitution */ public function get_substitutionarray_shipment($object, $outputlangs, $array_key = 'object') @@ -1189,7 +1189,7 @@ abstract class CommonDocGenerator * @param bool $insertAfterTarget insert before or after target column ? * @return int new rank on success and -1 on error */ - public function insertNewColumnDef($newColKey, $defArray, $targetCol = false, $insertAfterTarget = false) + public function insertNewColumnDef($newColKey, $defArray, $targetCol = '', $insertAfterTarget = false) { // prepare wanted rank $rank = -1; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 4ab1a0577ff..8628d98ab2e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4342,7 +4342,7 @@ abstract class CommonObject * @return int >0 if OK, <0 if KO * @see add_object_linked(), updateObjectLinked(), fetchObjectLinked() */ - public function deleteObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $rowid = '', $f_user = null, $notrigger = 0) + public function deleteObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $rowid = 0, $f_user = null, $notrigger = 0) { global $user; $deletesource = false; @@ -8490,7 +8490,7 @@ abstract class CommonObject * @param string $display_type "card" for form display, "line" for document line display (extrafields on propal line, order line, etc...) * @return string String with html content to show */ - public function showOptionals($extrafields, $mode = 'view', $params = null, $keysuffix = '', $keyprefix = '', $onetrtd = 0, $display_type = 'card') + public function showOptionals($extrafields, $mode = 'view', $params = null, $keysuffix = '', $keyprefix = '', $onetrtd = '', $display_type = 'card') { global $db, $conf, $langs, $action, $form, $hookmanager; diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index f92ce30e087..07e3ffe8d94 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -532,7 +532,7 @@ class DiscountAbsolute * @param int $multicurrency Return multicurrency_amount instead of amount * @return int Return integer <0 if KO, amount otherwise */ - public function getAvailableDiscounts($company = '', $user = '', $filter = '', $maxvalue = 0, $discount_type = 0, $multicurrency = 0) + public function getAvailableDiscounts($company = null, $user = null, $filter = '', $maxvalue = 0, $discount_type = 0, $multicurrency = 0) { global $conf; diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 4a9d216bca2..6e7e59f21f0 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -54,7 +54,7 @@ class DolEditor * * @param string $htmlname HTML name of WYSIWIG field * @param string $content Content of WYSIWIG field - * @param int $width Width in pixel of edit area (auto by default) + * @param int|string $width Width in pixel of edit area (auto by default) * @param int $height Height in pixel of edit area (200px by default) * @param string $toolbarname Name of bar set to use ('Full', 'dolibarr_notes[_encoded]', 'dolibarr_details[_encoded]'=the less featured, 'dolibarr_mailings[_encoded]', 'dolibarr_readonly'). * @param string $toolbarlocation Deprecated. Not used @@ -67,7 +67,7 @@ class DolEditor * @param int $readonly 0=Read/Edit, 1=Read only * @param array $poscursor Array for initial cursor position array('x'=>x, 'y'=>y) */ - public function __construct($htmlname, $content, $width = '', $height = 200, $toolbarname = 'Basic', $toolbarlocation = 'In', $toolbarstartexpanded = false, $uselocalbrowser = 1, $okforextendededitor = true, $rows = 0, $cols = 0, $readonly = 0, $poscursor = array()) + public function __construct($htmlname, $content, $width = '', $height = 200, $toolbarname = 'Basic', $toolbarlocation = 'In', $toolbarstartexpanded = false, $uselocalbrowser = 1, $okforextendededitor = true, $rows = 0, $cols = '', $readonly = 0, $poscursor = array()) { global $conf; From c8031a6f4f9d33f259d690e16cac4a894a2400e3 Mon Sep 17 00:00:00 2001 From: Hystepik Date: Thu, 21 Dec 2023 14:30:28 +0100 Subject: [PATCH 08/14] Fix #27190 Set inventory to draft and label --- htdocs/product/inventory/card.php | 8 +++++++- htdocs/product/inventory/class/inventory.class.php | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 6760d4c2841..79bbf393938 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -262,6 +262,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $formconfirm = ''; + + // Confirmation of action xxxx + if ($action == 'setdraft') { + $text = $langs->trans('ConfirmSetToDraft', $object->ref); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetToDraft'), $text, 'confirm_setdraft', '', 0, 1, 220); + } // Confirmation to delete if ($action == 'delete') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteInventory'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1); @@ -403,7 +409,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Back to draft if ($object->status == $object::STATUS_VALIDATED) { if ($permissiontoadd) { - print ''.$langs->trans("SetToDraft").''; + print ''.$langs->trans("SetToDraft").''; } } // Back to validate diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 06db36dda41..29c1ffb9024 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -100,7 +100,7 @@ class Inventory extends CommonObject 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',), 'ref' => array('type'=>'varchar(64)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>'Reference of object', 'css'=>'maxwidth150'), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), - 'title' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>25, 'css'=>'minwidth300', 'csslist'=>'tdoverflowmax150'), + 'title' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>25, 'css'=>'minwidth300', 'csslist'=>'tdoverflowmax150', 'alwayseditable'=>1), 'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Warehouse', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'index'=>1, 'help'=>'InventoryForASpecificWarehouse', 'picto'=>'stock', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax150'), 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'get_name_url_params' => '0::0:-1:0::1', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'InventoryForASpecificProduct', 'picto'=>'product', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax150'), 'categories_product' => array('type'=>'chkbxlst:categorie:label:rowid::type=0:0:', 'label'=>'OrProductsWithCategories', 'visible'=>3, 'enabled'=>1, 'position'=>33, 'help'=>'', 'picto'=>'category', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx'), From 29da3406fff459e21b62ca74084928fdf92943df Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Thu, 21 Dec 2023 16:03:00 +0100 Subject: [PATCH 09/14] NEW create action log entry for deleting project --- .../interface_50_modAgenda_ActionsAuto.class.php | 11 +++++++++++ htdocs/langs/en_US/agenda.lang | 2 ++ 2 files changed, 13 insertions(+) diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 7c11e252f4b..b4cd2d2ce53 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -7,6 +7,7 @@ * Copyright (C) 2015 Bahfir Abbes * Copyright (C) 2022 Ferran Marcet * Copyright (C) 2023 William Mead + * Copyright (C) 2023 Christian Foellmann * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1253,6 +1254,16 @@ class InterfaceActionsAuto extends DolibarrTriggers // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; + } elseif ($action == 'PROJECT_DELETE') { + // Load translation files required by the page + $langs->loadLangs(array("agenda", "other", "projects")); + + if (empty($object->actionmsg2)) { + $object->actionmsg2 = $langs->transnoentities("ProjectDeletedInDolibarr", $object->ref); + } + $object->actionmsg = $langs->transnoentities("ProjectDeletedInDolibarr", $object->ref); + + $object->sendtoid = 0; } elseif ($action == 'PROJECT_CLOSE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "projects")); diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index 42c56174c46..ac4cb92c0d6 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -89,6 +89,8 @@ ShippingSentByEMail=Shipment %s sent by email ShippingValidated= Shipment %s validated InterventionSentByEMail=Intervention %s sent by email ProjectSentByEMail=Project %s sent by email +ProjectDeletedInDolibarr=Project %s deleted +ProjectClosedInDolibarr=Project %s closed ProposalDeleted=Proposal deleted OrderDeleted=Order deleted InvoiceDeleted=Invoice deleted From c72644cd8472721d46507b5378e28461742d60d0 Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Thu, 21 Dec 2023 17:44:48 +0100 Subject: [PATCH 10/14] QUAL respect DISABLEDRAFT on project edit --- htdocs/projet/card.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index c7b875427cd..1d2b8416878 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2023 Charlene Benke + * Copyright (C) 2023 Christian Foellmann * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -977,7 +978,11 @@ if ($action == 'create' && $user->hasRight('projet', 'creer')) { // Status print ''.$langs->trans("Status").''; print ''; From e7071dd8c43a881831124f2155e33a769c2cb892 Mon Sep 17 00:00:00 2001 From: vmaury Date: Thu, 21 Dec 2023 19:17:39 +0100 Subject: [PATCH 11/14] Fix #27203 avoid ugly messages --- htdocs/core/lib/functions.lib.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a1cb88fa60e..26fef322e06 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -9022,7 +9022,8 @@ function setEventMessage($mesgs, $style = 'mesgs', $noduplicate = 0) { //dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING); This is not deprecated, it is used by setEventMessages function if (!is_array($mesgs)) { - // If mesgs is a string + $mesgs = trim((string)$mesgs); + // If mesgs is a not an empty string if ($mesgs) { if (!empty($noduplicate) && isset($_SESSION['dol_events'][$style]) && in_array($mesgs, $_SESSION['dol_events'][$style])) { return; @@ -9032,6 +9033,7 @@ function setEventMessage($mesgs, $style = 'mesgs', $noduplicate = 0) } else { // If mesgs is an array foreach ($mesgs as $mesg) { + $mesg = trim((string)$mesg); if ($mesg) { if (!empty($noduplicate) && isset($_SESSION['dol_events'][$style]) && in_array($mesg, $_SESSION['dol_events'][$style])) { return; From b5d4b53597766a85d163294cd258c4bacda561c1 Mon Sep 17 00:00:00 2001 From: vmaury Date: Thu, 21 Dec 2023 19:23:12 +0100 Subject: [PATCH 12/14] Fix #27203 avoid ugly messages --- htdocs/core/lib/functions.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 26fef322e06..510c22a0af9 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -9022,7 +9022,7 @@ function setEventMessage($mesgs, $style = 'mesgs', $noduplicate = 0) { //dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING); This is not deprecated, it is used by setEventMessages function if (!is_array($mesgs)) { - $mesgs = trim((string)$mesgs); + $mesgs = trim((string) $mesgs); // If mesgs is a not an empty string if ($mesgs) { if (!empty($noduplicate) && isset($_SESSION['dol_events'][$style]) && in_array($mesgs, $_SESSION['dol_events'][$style])) { @@ -9033,7 +9033,7 @@ function setEventMessage($mesgs, $style = 'mesgs', $noduplicate = 0) } else { // If mesgs is an array foreach ($mesgs as $mesg) { - $mesg = trim((string)$mesg); + $mesg = trim((string) $mesg); if ($mesg) { if (!empty($noduplicate) && isset($_SESSION['dol_events'][$style]) && in_array($mesg, $_SESSION['dol_events'][$style])) { return; From dc74eaa3fc5dce1022bf2357429b2aab32fc2110 Mon Sep 17 00:00:00 2001 From: vmaury Date: Thu, 21 Dec 2023 19:26:30 +0100 Subject: [PATCH 13/14] Fix #27203 avoid ugly messages --- 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 510c22a0af9..d4c586202e8 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -9023,7 +9023,7 @@ function setEventMessage($mesgs, $style = 'mesgs', $noduplicate = 0) //dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING); This is not deprecated, it is used by setEventMessages function if (!is_array($mesgs)) { $mesgs = trim((string) $mesgs); - // If mesgs is a not an empty string + // If mesgs is a not an empty string if ($mesgs) { if (!empty($noduplicate) && isset($_SESSION['dol_events'][$style]) && in_array($mesgs, $_SESSION['dol_events'][$style])) { return; From 46572116abaa34d8273de59f409070b5a6343f9a Mon Sep 17 00:00:00 2001 From: Hystepik Date: Fri, 22 Dec 2023 10:02:08 +0100 Subject: [PATCH 14/14] change question set to draft --- htdocs/langs/en_US/products.lang | 1 + htdocs/product/inventory/card.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index dc7a05d3822..898ce266443 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -437,3 +437,4 @@ ModifyValueExtrafields = Modify value of an extrafield OrProductsWithCategories=Or products with tags/categories WarningTransferBatchStockMouvToGlobal = If you want to deserialize this product, all its serialized stock will be transformed into global stock WarningConvertFromBatchToSerial=If you currently have a quantity higher or equal to 2 for the product, switching to this choice means you will still have a product with different objects of the same batch (while you want a unique serial number). The duplicate will remain until an inventory or a manual stock movement to fix this is done. +ConfirmSetToDraftInventory=Are you sure you want to go back to Draft status?
The quantities currently set in the inventory will be reset. diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 79bbf393938..e7b152556bd 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -265,7 +265,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Confirmation of action xxxx if ($action == 'setdraft') { - $text = $langs->trans('ConfirmSetToDraft', $object->ref); + $text = $langs->trans('ConfirmSetToDraftInventory', $object->ref); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetToDraft'), $text, 'confirm_setdraft', '', 0, 1, 220); } // Confirmation to delete