diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index e0a7d71b9b6..8046f932357 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -37,7 +37,7 @@ jobs: tools: phpstan, cs2pr extensions: calendar, json, imagick, gd, zip, mbstring, intl, opcache, imap, mysql, pgsql, sqlite3, ldap, xml, mcrypt # ??? - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: node-version: 14.x registry-url: 'https://registry.npmjs.org' diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 345048e8955..cffcb6ffcd9 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -21,7 +21,7 @@ jobs: run: |- [ -r requirements.txt ] || [ -r pyproject.toml ] || touch requirements.txt # Install python and pre-commit tool - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: cache: pip python-version: '3.11' @@ -62,7 +62,7 @@ jobs: }} # Upload result log files of precommit into the Artifact shared store - name: Provide log as artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: ${{ always() }} with: name: precommit-logs diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a3220cc9d85..6fefa14ed25 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,6 @@ repos: - id: trailing-whitespace exclude_types: [markdown] - id: end-of-file-fixer - types: [yaml] - id: check-merge-conflict - id: check-executables-have-shebangs - id: check-shebang-scripts-are-executable @@ -49,8 +48,10 @@ repos: hooks: - id: php-cbf files: \.(php)$ - args: [-p] + args: [--standard=dev/setup/codesniffer/ruleset.xml -p] - id: php-cs + files: \.(php)$ + args: [--standard=dev/setup/codesniffer/ruleset.xml -p] - id: php-lint # Prettier (format code, only for non common files) @@ -75,7 +76,7 @@ repos: - css - yaml - # Check format of yam files + # Check format of yaml files - repo: https://github.com/adrienverge/yamllint.git rev: v1.32.0 hooks: diff --git a/COPYRIGHT b/COPYRIGHT index e35a544e3d0..e6525d5ccb2 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -42,7 +42,7 @@ PrestaShop-WS-Lib 94feb5f OSL-3.0 No 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) -Sabre 4.0.2 BSD Yes DAV support +Sabre 4.6.0 BSD Yes DAV support Swift Mailer 5.4.2-DEV MIT License Yes Comprehensive mailing tools for PHP Symfony/var-dumper ??? MIT License Yes Library to make var dump (used by DebugBar) Stripe 10.7.0 MIT Licence Yes Library for Stripe module diff --git a/ChangeLog b/ChangeLog index 7766fc58f58..5a045136113 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,26 @@ English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 19.0.0 compared to 18.0.0 ***** + +For users: +---------- +NEW: Compatibility with PHP 8.3 +... + +For developers or integrators: +------------------------------ +... + +WARNING: +-------- + +The following changes may create regressions for some external modules, but were necessary to make Dolibarr better: +* More class properties (with old name in french) are now deprecated in favor of the property name in english. +* Some API HTTP return code were moved from 401 to 403 to better follow REST specification. + + + ***** ChangeLog for 19.0.0 compared to 18.0.0 ***** For users: diff --git a/SECURITY.md b/SECURITY.md index f004cea7c86..a10c1eb15b7 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -48,12 +48,16 @@ Reports are processed around once a month. ONLY vulnerabilities discovered, when the following setup on test platform is used, are "valid": -* The version to analyze must be the last version available in the "develop" branch or in the last stable "vX.Y" released version. Reports on vulnerabilities already fixed (so already reported) in the develop branch will not be validated. +* The version to analyze must be the last version available in the "develop" branch. Reports on vulnerabilities already fixed (so already reported) in the develop branch will not be validated. * $dolibarr_main_prod must be set to 1 in conf.php * $dolibarr_nocsrfcheck must be kept to the value 0 in conf.php (this is the default value) * $dolibarr_main_force_https must be set to something else than 0. -* The constant MAIN_SECURITY_CSRF_WITH_TOKEN must be set to 3 in the backoffice menu Home - Setup - Other (this protection should be set to 3 soon by default). CSRF attacks are accepted but - double check that you have set MAIN_SECURITY_CSRF_WITH_TOKEN to value 3. +* Some constant must be set in the backoffice menu Home - Setup - Other + - MAIN_SECURITY_CSRF_WITH_TOKEN must be set to 3 + - MAIN_RESTRICTHTML_ONLY_VALID_HTML = 1 + - MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 1 + - MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 1 + CSRF attacks and HTML injections are accepted but double check this setup that is experimental setup that already fix a lot of case and soon enabled by default. * ONLY security reports on modules provided by default and with the "stable" status are valid (troubles in "experimental", "development" or external modules are not valid vulnerabilities). * The root of web server must link to htdocs and the documents directory must be outside of the web server root (this is the default when using the default installer but may differs with external installer). * The web server setup must be done so that only the documents directory is in write mode. The root directory called htdocs must be read-only. @@ -87,12 +91,10 @@ Scope is the web application (backoffice) and the APIs. * Logout and other instances of low-severity Cross-Site Request Forgery * Reports from automated web vulnerability scanners (Acunetix, Vega, etc.) that have not been validated * Reports on features on modules flagged as "deprecated", "experimental" or "development" if the module needs to be enabled for that (this is not the case on production). -* Software or libraries versions or private IP disclosure when logged-in user is admin -* Stack traces or path disclosure when logged-in user is admin +* Software or libraries versions, private IP disclosure, Stack traces or path disclosure when logged-in user is admin. * Any vulnerabilities due to a configuration different than the one defined in chapter "Scope for qualified vulnerabilities". * Vulnerabilities affecting outdated browsers or platforms, or vulnerabilities inside browsers themself. * Brute force attacks on login page, password forgotten page or any public pages (/public/*) are not qualified if the recommended fail2ban rules were not installed. * SSL/TLS best practices -* Denial of Service attacks * Invalid or missing SPF (Sender Policy Framework) records (Incomplete or missing SPF/DKIM/DMARC) * Physical or social engineering attempts or issues that require physical access to a victim’s computer/device diff --git a/build/composer/README b/build/composer/README index e6846f2f09b..5d39336a337 100644 --- a/build/composer/README +++ b/build/composer/README @@ -1,19 +1,40 @@ +--- HOW TO USE COMPOSER + +* Switch to the minimal version of PHP + + update-alternatives --config php + * To list packages -composer show -i + cd htdocs/includes/diroflib + composer install + composer show -i -* To test upgrade of a lib with composer: + +* To upgrade a lib with composer using the composer.json of the library only: Remove entry in composer.lock -Edit composer.json to change version to "x.y.z" -composer -v update --root-reqs --no-dev --no-autoloader --dry-run ccampbell/chromephp -* To upgrade a lib with composer: + cd htdocs/includes/diroflib + rm composer.lock + +Edit composer.json to change version to "x.y.z" + + composer -v update --root-reqs --no-dev --ignore-platform-reqs + composer -v update --root-reqs --no-dev --ignore-platform-reqs [--no-autoloader] [--dry-run] ccampbell/chromephp + + +* To upgrade a lib with composer using the composer.json of Dolibarr: Remove entry in composer.lock + + cd / + mv composer.json.disabled composer.json + rm composer.lock + Edit composer.json to change version to "x.y.z" -composer -v update --root-reqs --no-dev --no-autoloader ccampbell/chromephp - + composer -v update --root-reqs --no-dev --ignore-platform-reqs + composer -v update --root-reqs --no-dev --ignore-platform-reqs [--no-autoloader] [--dry-run] ccampbell/chromephp diff --git a/composer.json.disabled b/composer.json.disabled index d3a6ededce4..359470e627a 100644 --- a/composer.json.disabled +++ b/composer.json.disabled @@ -33,16 +33,9 @@ "tecnickcom/tcpdf" : "6.3.2", "nnnick/chartjs" : "^3.7.1", "stripe/stripe-php" : "10.7.0", - "maximebf/debugbar" : "1.18.2", - "symfony/var-dumper" : ">=3.2" + "maximebf/debugbar" : "1.18.2" }, "require-dev" : { - "php-parallel-lint/php-parallel-lint" : "^0", - "php-parallel-lint/php-console-highlighter" : "^0", - "phpunit/phpunit" : "^4", - "squizlabs/php_codesniffer" : "^2", - "phpunit/phpunit-selenium" : "^2", - "rector/rector" : "^0.16.0" }, "suggest" : { "ext-mysqlnd" : "To use with MySQL or MariaDB", @@ -50,7 +43,7 @@ "ext-pgsql" : "To use with PostgreSQL", "ext-gd" : "Image manipulation (Required but maybe built-in PHP)", "ext-imagick" : "Generation of thumbs from PDF", - "ext-mcrypt" : "(Required but maybe built-in PHP)", + "ext-intl" : "Intl", "ext-openssl" : "Secure connections (Emails, SOAP\u2026)", "ext-mbstring" : "Handle non UTF-8 characters", "ext-soap" : "Native SOAP", diff --git a/dev/setup/README.md b/dev/setup/README.md new file mode 100644 index 00000000000..5bc8fc08a99 --- /dev/null +++ b/dev/setup/README.md @@ -0,0 +1,10 @@ +# Setting up for Dolibarr development + +Check out the +[online documentation](https://wiki.dolibarr.org/index.php?title=Environment_and_development_tools) +for recommendations (to be updated). + +If anything, install `pre-commit` - it will help run the tools to format and +make some basic verifications on your submission before committing and pushing +to github for a PR. See [a quick start guide](./pre-commit/README.md) in this +Dolibarr repository. diff --git a/dev/setup/pre-commit/README.md b/dev/setup/pre-commit/README.md new file mode 100644 index 00000000000..d0124e23b16 --- /dev/null +++ b/dev/setup/pre-commit/README.md @@ -0,0 +1,85 @@ +## 'pre-commit' ("replaces" precommit) + +### Introduction + +[`pre-commit`](https://pre-commit.org) is a framework for managing and +maintaining multi-language pre-commit hooks. + +"pre-commit hooks" integrate with `git` and are run when you perform a +`git commit` for instance. + +Historically there was `precommit` for Dolibarr which you can find in this +directory. That script runs `phplint`, `phpcs` and `phpcbf` upon commit. + +`pre-commit` is not specific to Dolibarr and is deployed on many projects - +mostly Python projects, but it is applicable to most (or *all*) code and +documentation development. + +You can find documentation at https://pre-commit.com/ . + +Now you can use `pre-commit` which uses the configuration found at the root of +the project: `pre-commit-config.yaml`. + +### How to + +1. Install `pre-commit`.\ + If you do not have python installed, install + [python](https://www.python.org) first.\ + If you do not have + [`pip`](https://pypi.org/project/pip), install that as well.\\ + + Then you can install pre-commit: `python -m pip install pre-commit`. + +1. In you local git clone of the project, run `pre-commit install`. That will + add the hooks. + +### Tips + +After installing `pre-commit` onto your local git clone, pre-commit will run +on every commit. + +When it finds some issue, the git commit will be aborted, so you can fix it, +or verify it. + +The tools run by `pre-commit` may modify your code: format PHP code +(`phpcbf`), fix line endings, end of files, etc. + +They may also alert about potential issues: syntax errors, spelling errors, +code quality, an execute bit that was (not) set in the git repository, etc. + +One way to use it is this: + +```bash +cd PROJECT_DIR +pre-commit install # Only needed once +# Repeat until success. +git commit -a -m "My message" +# `pre-commit` is run and reports +# Check the results, make fixes, and re-commit (=repeat above line). +``` + +In some cases you may want to commit despite the changes.\ +You can just add +`--no-verify` to your git command: + +```bash +git commit -a -m "My message" --no-verify +``` + +If you want to skip certain checks for whatever reason, you can set the SKIP +environment variable: + +```bash +SKIP=no-commit-to-branch git commit -a -m "My message" + +or + +export SKIP=no-commit-to-branch # In your .bashrc or session. +``` + +There is much more you can do with pre-commit, check out its +[documentation](https://pre-commit.com). + +Now your commit is less likely to fail in the Continuous Intagration (CI) run +on github.\ +CI also runs pre-commit to help maintain code quality. diff --git a/dev/tools/codespell/addCodespellIgnores.sh b/dev/tools/codespell/addCodespellIgnores.sh index 476c5ba287e..0b73c4c16b2 100755 --- a/dev/tools/codespell/addCodespellIgnores.sh +++ b/dev/tools/codespell/addCodespellIgnores.sh @@ -11,10 +11,22 @@ # ```shell # echo > dev/tools/codespell/codespell-lines-ignore.txt # ``` -# and then execute this script +# and then execute this script. # # author: https://github.com/mdeweerd +# +# :warning: +# +# This script only works properly if codespell is install for your CLI. +# As the configuration is in pyproject.toml, you also need tomli. +# +# ```shell +# python -m pip install codespell tomli +# # or +# pip install codespell tomli +# ``` + codespell_ignore_file=dev/tools/codespell/codespell-lines-ignore.txt if [ -z "${0##*.sh}" ] ; then # Suppose running from inside script diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index cc43fc0d4d7..b914ef5f769 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -1,7 +1,7 @@ - * Copyright (C) 2013-2023 Alexandre Spangaro - * Copyright (C) 2016-2018 Laurent Destailleur +/* Copyright (C) 2013-2016 Olivier Geffroy + * Copyright (C) 2013-2024 Alexandre Spangaro + * Copyright (C) 2016-2018 Laurent Destailleur * * 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 @@ -226,7 +226,9 @@ if (empty($reshook)) { $form = new Form($db); $formaccounting = new FormAccounting($db); -llxHeader('', $langs->trans("ListAccounts")); +$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration'; + +llxHeader('', $langs->trans("ListAccounts"), $help_url); if ($action == 'delete') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('DeleteAccount'), $langs->trans('ConfirmDeleteAccount'), 'confirm_delete', '', 0, 1); diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index a37ffc6bd78..13c6b991d5e 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -8,7 +8,7 @@ * Copyright (C) 2011 Remy Younes * Copyright (C) 2012-2015 Marcos García * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2011-2016 Alexandre Spangaro + * Copyright (C) 2011-2024 Alexandre Spangaro * Copyright (C) 2015 Ferran Marcet * Copyright (C) 2016 Raphaël Doursenaud * @@ -401,7 +401,9 @@ if ($action == 'disable_favorite') { $form = new Form($db); $formadmin = new FormAdmin($db); -llxHeader(); +$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration'; + +llxHeader('', $langs->trans("Pcg_version"), $help_url); $titre = $langs->trans($tablib[$id]); $linkback = ''; diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 8f34d85d4da..125261bdd8f 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2020 Alexandre Spangaro + * Copyright (C) 2013-2024 Alexandre Spangaro * Copyright (C) 2014 Florian Henry * * This program is free software; you can redistribute it and/or modify @@ -215,7 +215,7 @@ $accountsystem->fetch(getDolGlobalInt('CHARTOFACCOUNTS')); $title = $langs->trans('AccountAccounting')." - ".$langs->trans('Card'); -$help_url = 'EN:Category:Accounting'; +$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration'; llxHeader('', $title, $help_url); diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php index bd196fb710a..fbf21b04f56 100644 --- a/htdocs/accountancy/admin/categories.php +++ b/htdocs/accountancy/admin/categories.php @@ -1,6 +1,6 @@ - * Copyright (C) 2017-2022 Alexandre Spangaro + * Copyright (C) 2017-2024 Alexandre Spangaro * Copyright (C) 2022 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify @@ -113,7 +113,10 @@ if ($action == 'delete') { $form = new Form($db); $formaccounting = new FormAccounting($db); -llxHeader('', $langs->trans('AccountingCategory')); +$title= $langs->trans('AccountingCategory'); +$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration'; + +llxHeader('', $title, $help_url); $linkback = ''.$langs->trans("BackToList").''; $titlepicto = 'setup'; diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index 48d12ca8370..2b246b9851a 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2011-2021 Alexandre Spangaro +/* Copyright (C) 2004-2023 Laurent Destailleur + * Copyright (C) 2011-2024 Alexandre Spangaro * * 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 @@ -414,7 +414,9 @@ if ($action == 'disable_favorite') { $form = new Form($db); $formadmin = new FormAdmin($db); -llxHeader('', $langs->trans('DictionaryAccountancyCategory')); +$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration'; + +llxHeader('', $langs->trans('DictionaryAccountancyCategory'), $help_url); $titre = $langs->trans($tablib[$id]); $linkback = ''; diff --git a/htdocs/accountancy/admin/closure.php b/htdocs/accountancy/admin/closure.php index faf5360c984..1979b666051 100644 --- a/htdocs/accountancy/admin/closure.php +++ b/htdocs/accountancy/admin/closure.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2019-2024 Alexandre Spangaro * * 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 @@ -101,7 +101,11 @@ if ($action == 'update') { $form = new Form($db); $formaccounting = new FormAccounting($db); -llxHeader(); +$title = $langs->trans('Closure'); + +$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration'; + +llxHeader('', $title, $help_url); $linkback = ''; print load_fiche_titre($langs->trans('MenuClosureAccounts'), $linkback, 'title_accountancy'); diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index 48e4181b8e5..3eace908373 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2023 Alexandre Spangaro + * Copyright (C) 2013-2024 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2014 Marcos García * Copyright (C) 2014 Juanjo Menent @@ -198,7 +198,9 @@ if ($action == 'setACCOUNTING_ACCOUNT_SUPPLIER_USE_AUXILIARY_ON_DEPOSIT') { $form = new Form($db); $formaccounting = new FormAccounting($db); -llxHeader(); +$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration'; + +llxHeader('', $langs->trans('MenuDefaultAccounts'), $help_url); $linkback = ''; print load_fiche_titre($langs->trans('MenuDefaultAccounts'), $linkback, 'title_accountancy'); diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index 70dd216b7c9..902b184a48c 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2022 Alexandre Spangaro + * Copyright (C) 2013-2024 Alexandre Spangaro * Copyright (C) 2014 Florian Henry * Copyright (C) 2014 Marcos García * Copyright (C) 2014 Juanjo Menent @@ -134,9 +134,9 @@ if ($action == 'update') { $form = new Form($db); +$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration'; $title = $langs->trans('ExportOptions'); -llxHeader('', $title); - +llxHeader('', $title, $help_url); $linkback = ''; // $linkback = '' . $langs->trans("BackToModuleList") . ''; diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index 4cbb6045d74..cb142948096 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2013-2024 Alexandre Spangaro * * 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 @@ -87,7 +87,7 @@ $fiscalyearstatic = new Fiscalyear($db); $title = $langs->trans('AccountingPeriods'); -$help_url = "EN:Module_Double_Entry_Accounting"; +$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration'; llxHeader('', $title, $help_url); diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index 914bc34ccb6..477fac08eee 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2018 Frédéric France +/* Copyright (C) 2014-2024 Alexandre Spangaro + * Copyright (C) 2018-2024 Frédéric France * * 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 @@ -109,7 +109,7 @@ if ($action == 'confirm_delete' && $confirm == "yes") { $object->date_start = $date_start; $object->date_end = $date_end; $object->label = GETPOST('label', 'alpha'); - $object->status = GETPOST('status', 'int'); + $object->status = GETPOSTINT('status'); $object->datec = dol_now(); if (empty($object->date_start) && empty($object->date_end)) { @@ -152,7 +152,7 @@ if ($action == 'confirm_delete' && $confirm == "yes") { $object->date_start = GETPOST("fiscalyear") ? $date_start : ''; $object->date_end = GETPOST("fiscalyearend") ? $date_end : ''; $object->label = GETPOST('label', 'alpha'); - $object->status = GETPOST('status', 'int'); + $object->status = GETPOSTINT('status'); $result = $object->update($user); @@ -181,7 +181,7 @@ if ($action == 'create') { $title = $langs->trans("NewFiscalYear"); } -$help_url = "EN:Module_Double_Entry_Accounting"; +$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration'; llxHeader('', $title, $help_url); diff --git a/htdocs/accountancy/admin/fiscalyear_info.php b/htdocs/accountancy/admin/fiscalyear_info.php index 918a5b22db1..39754c0345d 100644 --- a/htdocs/accountancy/admin/fiscalyear_info.php +++ b/htdocs/accountancy/admin/fiscalyear_info.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2014-2024 Alexandre Spangaro * * 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 @@ -45,7 +45,7 @@ $id = GETPOST('id', 'int'); $title = $langs->trans("Fiscalyear")." - ".$langs->trans("Info"); -$help_url = "EN:Module_Double_Entry_Accounting"; +$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration'; llxHeader('', $title, $help_url); diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index acff0845286..636026e526c 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -1,13 +1,13 @@ - * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2023 Alexandre Spangaro - * Copyright (C) 2014-2015 Ari Elbaz (elarifr) - * Copyright (C) 2014 Marcos García - * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2017 Laurent Destailleur - * Copyright (C) 2021 Ferran Marcet +/* Copyright (C) 2013-2014 Olivier Geffroy + * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2013-2024 Alexandre Spangaro + * Copyright (C) 2014-2015 Ari Elbaz (elarifr) + * Copyright (C) 2014 Marcos García + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2017 Laurent Destailleur + * Copyright (C) 2021 Ferran Marcet * * 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 @@ -275,8 +275,8 @@ if ($action == 'setenablevatreversecharge') { $form = new Form($db); $title = $langs->trans('ConfigAccountingExpert'); - -llxHeader('', $title); +$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration'; +llxHeader('', $title, $help_url); $linkback = ''; diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index 7150297c6c3..ec08d2c6d8c 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2017-2024 Alexandre Spangaro * * 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 @@ -351,7 +351,9 @@ if ($action == $acts[1]) { $form = new Form($db); $formadmin = new FormAdmin($db); -llxHeader(); +$title = $langs->trans('AccountingJournals'); +$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration'; +llxHeader('', $title, $help_url); $titre = $langs->trans("DictionarySetup"); $linkback = ''; @@ -367,7 +369,6 @@ print load_fiche_titre($titre, $linkback, $titlepicto); if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); } -//var_dump($elementList); /* * Show a dictionary diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index ca5516547ec..903375f5920 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -1,10 +1,10 @@ - * Copyright (C) 2013-2022 Alexandre Spangaro - * Copyright (C) 2014 Florian Henry - * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015 Ari Elbaz (elarifr) - * Copyright (C) 2021 Gauthier VERDOL +/* Copyright (C) 2013-2014 Olivier Geffroy + * Copyright (C) 2013-2024 Alexandre Spangaro + * Copyright (C) 2014 Florian Henry + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2015 Ari Elbaz (elarifr) + * Copyright (C) 2021 Gauthier VERDOL * * 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 @@ -296,14 +296,14 @@ $aacompta_prodsell_export = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_EXPORT $title = $langs->trans("ProductsBinding"); -$helpurl = ''; +$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration'; $paramsCat = ''; foreach ($searchCategoryProductList as $searchCategoryProduct) { $paramsCat .= "&search_category_product_list[]=".urlencode($searchCategoryProduct); } -llxHeader('', $title, $helpurl, '', 0, 0, array(), array(), $paramsCat, ''); +llxHeader('', $title, $help_url, '', 0, 0, array(), array(), $paramsCat, ''); $pcgverid = getDolGlobalString('CHARTOFACCOUNTS'); $pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version'); diff --git a/htdocs/accountancy/admin/subaccount.php b/htdocs/accountancy/admin/subaccount.php index 69c2f458786..fb9a61e36d0 100644 --- a/htdocs/accountancy/admin/subaccount.php +++ b/htdocs/accountancy/admin/subaccount.php @@ -1,7 +1,7 @@ - * Copyright (C) 2013-2020 Alexandre Spangaro - * Copyright (C) 2016-2018 Laurent Destailleur +/* Copyright (C) 2013-2016 Olivier Geffroy + * Copyright (C) 2013-2024 Alexandre Spangaro + * Copyright (C) 2016-2018 Laurent Destailleur * * 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 @@ -126,7 +126,7 @@ $form = new Form($db); // Page Header -$help_url = 'EN:Module_Double_Entry_Accounting#Setup'; +$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration'; $title = $langs->trans('ChartOfIndividualAccountsOfSubsidiaryLedger'); llxHeader('', $title, $help_url); diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 94016d559c7..779a7942990 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -1,7 +1,7 @@ * Copyright (C) 2016 Florian Henry - * Copyright (C) 2016-2023 Alexandre Spangaro + * Copyright (C) 2016-2024 Alexandre Spangaro * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -248,7 +248,9 @@ if ($type == 'sub') { $title_page = $langs->trans("AccountBalance"); } -llxHeader('', $title_page); +$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double'; + +llxHeader('', $title_page, $help_url); if ($action != 'export_csv') { diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 842059eadb0..0e4abdaebd4 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2017 Florian Henry - * Copyright (C) 2013-2022 Alexandre Spangaro + * Copyright (C) 2013-2024 Alexandre Spangaro * Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2018-2020 Frédéric France * @@ -334,8 +334,8 @@ $form = new Form($db); $formaccounting = new FormAccounting($db); $title = $langs->trans("CreateMvts"); - -llxHeader('', $title); +$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double'; +llxHeader('', $title, $help_url); // Confirmation to delete the command if ($action == 'delete') { @@ -663,7 +663,7 @@ if ($action == 'create') { if (!empty($object->linesmvt[0])) { $tmpline = $object->linesmvt[0]; if (!empty($tmpline->numero_compte)) { - $line = new BookKeepingLine(); + $line = new BookKeepingLine($db); $object->linesmvt[] = $line; } } diff --git a/htdocs/accountancy/bookkeeping/export.php b/htdocs/accountancy/bookkeeping/export.php index 0d4b02386e1..f92c3aee5f0 100644 --- a/htdocs/accountancy/bookkeeping/export.php +++ b/htdocs/accountancy/bookkeeping/export.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2016 Florian Henry - * Copyright (C) 2013-2023 Alexandre Spangaro + * Copyright (C) 2013-2024 Alexandre Spangaro * Copyright (C) 2022 Lionel Vessiller * Copyright (C) 2016-2017 Laurent Destailleur * Copyright (C) 2018-2021 Frédéric France @@ -708,8 +708,9 @@ $arrayofselected = is_array($toselect) ? $toselect : array(); // Output page // -------------------------------------------------------------------- +$help_url ='EN:Module_Double_Entry_Accounting#Exports|FR:Module_Comptabilité_en_Partie_Double#Exports'; -llxHeader('', $title_page); +llxHeader('', $title_page, $help_url); $formconfirm = ''; @@ -1086,7 +1087,7 @@ if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print "\n"; -$line = new BookKeepingLine(); +$line = new BookKeepingLine($db); // Loop on record // -------------------------------------------------------------------- diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 7a10c5d96d6..be1c5a34fcd 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2016 Florian Henry - * Copyright (C) 2013-2023 Alexandre Spangaro + * Copyright (C) 2013-2024 Alexandre Spangaro * Copyright (C) 2022 Lionel Vessiller * Copyright (C) 2016-2017 Laurent Destailleur * Copyright (C) 2018-2021 Frédéric France @@ -711,8 +711,8 @@ $arrayofselected = is_array($toselect) ? $toselect : array(); // Output page // -------------------------------------------------------------------- - -llxHeader('', $title_page); +$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double'; +llxHeader('', $title_page, $help_url); $formconfirm = ''; @@ -1037,7 +1037,7 @@ if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print "\n"; -$line = new BookKeepingLine(); +$line = new BookKeepingLine($db); // Loop on record // -------------------------------------------------------------------- diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 51b37ce6651..e49424b71db 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -2,7 +2,7 @@ /* Copyright (C) 2016 Neil Orley * Copyright (C) 2013-2016 Olivier Geffroy * Copyright (C) 2013-2020 Florian Henry - * Copyright (C) 2013-2023 Alexandre Spangaro + * Copyright (C) 2013-2024 Alexandre Spangaro * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -559,8 +559,8 @@ if ($type == 'sub') { $title_page .= $langs->trans("Bookkeeping"); } $title_page .= ')'; - -llxHeader('', $title_page); +$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double'; +llxHeader('', $title_page, $help_url); // List $nbtotalofrecords = ''; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index a479ce52bc2..554f4390510 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -26,6 +26,7 @@ // Class require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; @@ -986,7 +987,7 @@ class BookKeeping extends CommonObject $i = 0; while (($obj = $this->db->fetch_object($resql)) && (empty($limit) || $i < min($limit, $num))) { - $line = new BookKeepingLine(); + $line = new BookKeepingLine($this->db); $line->id = $obj->rowid; @@ -1140,7 +1141,7 @@ class BookKeeping extends CommonObject $i = 0; while (($obj = $this->db->fetch_object($resql)) && (empty($limit) || $i < min($limit, $num))) { - $line = new BookKeepingLine(); + $line = new BookKeepingLine($this->db); $line->id = $obj->rowid; @@ -1275,7 +1276,7 @@ class BookKeeping extends CommonObject $i = 0; while (($obj = $this->db->fetch_object($resql)) && (empty($limit) || $i < min($limit, $num))) { - $line = new BookKeepingLine(); + $line = new BookKeepingLine($this->db); $line->numero_compte = $obj->numero_compte; //$line->label_compte = $obj->label_compte; @@ -1881,7 +1882,7 @@ class BookKeeping extends CommonObject $result = $this->db->query($sql); if ($result) { while ($obj = $this->db->fetch_object($result)) { - $line = new BookKeepingLine(); + $line = new BookKeepingLine($this->db); $line->id = $obj->rowid; @@ -1951,7 +1952,7 @@ class BookKeeping extends CommonObject $num = $this->db->num_rows($resql); while ($obj = $this->db->fetch_object($resql)) { - $line = new BookKeepingLine(); + $line = new BookKeepingLine($this->db); $line->id = $obj->rowid; @@ -2976,7 +2977,7 @@ class BookKeeping extends CommonObject /** * Class BookKeepingLine */ -class BookKeepingLine +class BookKeepingLine extends CommonObjectLine { /** * @var int ID diff --git a/htdocs/accountancy/closure/index.php b/htdocs/accountancy/closure/index.php index 085c8a65e80..772d1672542 100644 --- a/htdocs/accountancy/closure/index.php +++ b/htdocs/accountancy/closure/index.php @@ -161,7 +161,7 @@ $formaccounting = new FormAccounting($db); $title = $langs->trans('Closure'); -$help_url ='EN:Module_Double_Entry_Accounting'; +$help_url ='EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Cl.C3.B4ture_annuelle'; llxHeader('', $title, $help_url); diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index 4d29a60f1d9..3102b023015 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -1,7 +1,7 @@ - * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2021 Alexandre Spangaro +/* Copyright (C) 2013-2014 Olivier Geffroy + * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2013-2024 Alexandre Spangaro * * 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 @@ -84,8 +84,9 @@ if ($action == 'ventil' && $user->hasRight('accounting', 'bind', 'write')) { /* * View */ +$help_url ='EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Liaisons_comptables'; -llxHeader("", $langs->trans('FicheVentilation')); +llxHeader("", $langs->trans('FicheVentilation'), $help_url); if ($cancel == $langs->trans("Cancel")) { $action = ''; diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 3a9eced377c..018f222daf8 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -299,8 +299,9 @@ if ($action == 'validatehistory') { /* * View */ +$help_url ='EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Liaisons_comptables'; -llxHeader('', $langs->trans("CustomersVentilation")); +llxHeader('', $langs->trans("CustomersVentilation"), $help_url); $textprevyear = ''.img_previous().''; $textnextyear = ' '.img_next().''; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 4929b45ac67..2a08eb3986c 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -175,7 +175,9 @@ if (GETPOST('sortfield') == 'f.datef, f.ref, fd.rowid') { $form = new Form($db); $formother = new FormOther($db); -llxHeader('', $langs->trans("CustomersVentilation").' - '.$langs->trans("Dispatched")); +$help_url ='EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Liaisons_comptables'; + +llxHeader('', $langs->trans("CustomersVentilation").' - '.$langs->trans("Dispatched"), $help_url); print ' + "; + return $out; + } + + + /** * Return templates of email with type = $type_template or type = 'all'. * This search into table c_email_templates. Used by the get_form function. diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index b8f788d70ff..60b71ca95d9 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -522,6 +522,15 @@ class FormOther if (!empty($user->socid)) { $sql_usr .= " AND u.fk_soc = ".((int) $user->socid); } + if (!empty($conf->global->USER_HIDE_NONEMPLOYEE_IN_COMBOBOX)) { + $sql_usr .= " AND u.employee <> 0"; + } + if (!empty($conf->global->USER_HIDE_EXTERNAL_IN_COMBOBOX)) { + $sql_usr .= " AND u.fk_soc IS NULL"; + } + if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX)) { + $sql_usr .= " AND u.statut <> 0"; + } //Add hook to filter on user (for example on usergroup define in custom modules) if (!empty($reshook)) { diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 16f301493f4..b76c8e50fc9 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -887,6 +887,11 @@ class FormSetupItem $selected = (empty($this->fieldValue) ? '' : $this->fieldValue); $out.= $this->form->select_produits($selected, $this->confKey, '', 0, 0, 1, 2, '', 0, array(), 0, '1', 0, $this->cssClass, 0, '', null, 1); } + } elseif ($this->type == 'selectBankAccount') { + if (isModEnabled("bank")) { + $selected = (empty($this->fieldValue) ? '' : $this->fieldValue); + $out.= $this->form->select_comptes($selected, $this->confKey, 0, '', 0, '', 0, '', 1); + } } else { $out.= $this->generateInputFieldText(); } @@ -1175,6 +1180,16 @@ class FormSetupItem } elseif ($resprod < 0) { $this->setErrors($product->errors); } + } elseif ($this->type == 'selectBankAccount') { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + + $bankaccount = new Account($this->db); + $resbank = $bankaccount->fetch($this->fieldValue); + if ($resbank > 0) { + $out.= $bankaccount->label; + } elseif ($resbank < 0) { + $this->setErrors($bankaccount->errors); + } } else { $out.= $this->fieldValue; } @@ -1427,4 +1442,15 @@ class FormSetupItem $this->type = 'selectUser'; return $this; } + + /** + * Set type of input as a simple title. No data to store + * + * @return self + */ + public function setAsSelectBankAccount() + { + $this->type = 'selectBankAccount'; + return $this; + } } diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 0d4c358e3ec..13af895a1b0 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -937,7 +937,7 @@ class FormTicket $arraycodenotparent[] = ""; $stringtoprint = ''.$langs->trans("GroupOfTicket").' '; - $stringtoprint .= ''; $stringtoprint .= ''; $sql = "SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, "; @@ -997,7 +997,7 @@ class FormTicket $levelid = 1; // The first combobox while ($levelid <= $use_multilevel) { // Loop to take the child of the combo $tabscript = array(); - $stringtoprint .= ''; $stringtoprint .= ''; $sql = "SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ctcjoin.code as codefather"; diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 6362783f6ce..ef048be0508 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2021 Regis Houssin * Copyright (C) 2006-2021 Laurent Destailleur + * Copyright (C) 2024 William Mead * * 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 @@ -44,12 +45,12 @@ class Ldap public $errors = array(); /** - * Tableau des serveurs (IP addresses ou nom d'hotes) + * @var array Servers (IP addresses or hostnames) */ public $server = array(); /** - * Current connected server + * @var string Current connected server */ public $connectedServer; @@ -59,51 +60,62 @@ class Ldap public $serverPort; /** - * Base DN (e.g. "dc=foo,dc=com") + * @var string Base DN (e.g. "dc=foo,dc=com") */ + public $dn; /** - * type de serveur, actuellement OpenLdap et Active Directory + * @var string Server type: OpenLDAP or Active Directory */ + public $serverType; /** - * Version du protocole ldap + * @var string LDAP protocol version */ + public $ldapProtocolVersion; /** - * Server DN + * @var string Server DN */ + public $domain; + /** + * @var string Server FQDN + */ public $domainFQDN; /** - * @var int bind + * @var bool LDAP bind */ public $bind; /** - * User administrateur Ldap + * @var string LDAP administrator user * Active Directory does not allow anonymous connections */ public $searchUser; /** - * Administraot Password + * @var string LDAP administrator password * Active Directory does not allow anonymous connections */ public $searchPassword; + /** - * Users DN + * @var string Users DN */ public $people; + /** - * Groups DN + * @var string Groups DN */ public $groups; + /** - * @var string|null Error code provided by the LDAP server + * @var int|null Error code provided by the LDAP server */ public $ldapErrorCode; + /** * @var string|null Error text message */ @@ -113,10 +125,12 @@ class Ldap * @var string */ public $filter; + /** * @var string */ public $filtergroup; + /** * @var string */ @@ -168,56 +182,91 @@ class Ldap public $badpwdtime; /** - * @var string ladpUserDN + * @var string LDAP user DN */ public $ldapUserDN; - //Fetch user + /** + * @var string Fetched username + */ public $name; + + /** + * @var string Fetched user first name + */ public $firstname; + + /** + * @var string Fetched user login + */ public $login; + + /** + * @var string Fetched user phone number + */ public $phone; + + /** + * @var string Fetched user fax number + */ public $fax; + + /** + * @var string Fetched user email + */ public $mail; + + /** + * @var string Fetched user mobile number + */ public $mobile; + /** + * @var array UserAccountControl Flags + */ public $uacf; + + /** + * @var int Password last set time + */ public $pwdlastset; - public $ldapcharset = 'UTF-8'; // LDAP should be UTF-8 encoded - + /** + * @var string LDAP charset. + * LDAP should be UTF-8 encoded + */ + public $ldapcharset = 'UTF-8'; /** - * The internal LDAP connection handle + * @var bool|resource The internal LDAP connection handle */ public $connection; + /** - * Result of any connections etc. + * @var bool|resource Result of any connections or search. */ public $result; /** - * No Ldap synchronization + * @var int No LDAP synchronization */ const SYNCHRO_NONE = 0; /** - * Dolibarr to Ldap synchronization + * @var int Dolibarr to LDAP synchronization */ const SYNCHRO_DOLIBARR_TO_LDAP = 1; /** - * Ldap to Dolibarr synchronization + * @var int LDAP to Dolibarr synchronization */ const SYNCHRO_LDAP_TO_DOLIBARR = 2; - /** * Constructor */ public function __construct() { - global $conf; // Server if (getDolGlobalString('LDAP_SERVER_HOST')) { @@ -260,17 +309,16 @@ class Ldap * Use this->server, this->serverPort, this->ldapProtocolVersion, this->serverType, this->searchUser, this->searchPassword * After return, this->connection and $this->bind are defined * - * @return int Return integer <0 if KO, 1 if bind anonymous, 2 if bind auth + * @return int if KO: <0 || if bind anonymous: 1 || if bind auth: 2 */ public function connect_bind() { // phpcs:enable - global $conf; global $dolibarr_main_auth_ldap_debug; $connected = 0; - $this->bind = 0; - $this->error = 0; + $this->bind = false; + $this->error = ''; $this->connectedServer = ''; $ldapdebug = ((empty($dolibarr_main_auth_ldap_debug) || $dolibarr_main_auth_ldap_debug == "false") ? false : true); @@ -290,7 +338,7 @@ class Ldap if (!function_exists("ldap_connect")) { $this->error = 'LDAPFunctionsNotAvailableOnPHP'; dol_syslog(get_class($this)."::connect_bind ".$this->error, LOG_WARNING); - $return = -1; + return -1; } if (empty($this->error)) { @@ -303,9 +351,9 @@ class Ldap continue; } - if ($this->serverPing($host, $this->serverPort) === true) { + if ($this->serverPing($host, $this->serverPort)) { if ($ldapdebug) { - dol_syslog(get_class($this)."::connect_bind serverPing true, we try ldap_connect to ".$host); + dol_syslog(get_class($this)."::connect_bind serverPing true, we try ldap_connect to ".$host, LOG_DEBUG); } $this->connection = ldap_connect($host, $this->serverPort); } else { @@ -313,10 +361,13 @@ class Ldap // With host = ldaps://server, the serverPing to ssl://server sometimes fails, even if the ldap_connect succeed, so // we test this case and continue in such a case even if serverPing fails. if ($ldapdebug) { - dol_syslog(get_class($this)."::connect_bind serverPing false, we try ldap_connect to ".$host); + dol_syslog(get_class($this)."::connect_bind serverPing false, we try ldap_connect to ".$host, LOG_DEBUG); } $this->connection = ldap_connect($host, $this->serverPort); } else { + if ($ldapdebug) { + dol_syslog(get_class($this)."::connect_bind serverPing false, no ldap_connect ".$host, LOG_DEBUG); + } continue; } } @@ -344,8 +395,7 @@ class Ldap // Execute the ldap_set_option here (after connect and before bind) $this->setVersion(); - ldap_set_option($this->connection, LDAP_OPT_SIZELIMIT, 0); // no limit here. should return true. - + $this->setSizeLimit(); if ($this->serverType == "activedirectory") { $result = $this->setReferrals(); @@ -396,15 +446,13 @@ class Ldap } if ($connected) { - $return = $connected; - dol_syslog(get_class($this)."::connect_bind return=".$return, LOG_DEBUG); + dol_syslog(get_class($this)."::connect_bind ".$connected, LOG_DEBUG); + return $connected; } else { $this->error = 'Failed to connect to LDAP'.($this->error ? ': '.$this->error : ''); - $return = -1; - dol_syslog(get_class($this)."::connect_bind return=".$return.' - '.$this->error, LOG_WARNING); + dol_syslog(get_class($this)."::connect_bind ".$this->error, LOG_WARNING); + return -1; } - - return $return; } /** @@ -481,50 +529,57 @@ class Ldap /** - * Verification de la version du serveur ldap. + * Verify LDAP server version * - * @return string version + * @return int version */ public function getVersion() { - $version = 0; - $version = @ldap_get_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, $version); + @ldap_get_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, $version); return $version; } /** - * Change ldap protocol version to use. + * Set LDAP protocol version. + * LDAP_OPT_PROTOCOL_VERSION is a constant equal to 3 * - * @return boolean version + * @return boolean if set LDAP option OK: true, if KO: false */ public function setVersion() { - // LDAP_OPT_PROTOCOL_VERSION est une constante qui vaut 17 - $ldapsetversion = ldap_set_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, $this->ldapProtocolVersion); - return $ldapsetversion; + return ldap_set_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, $this->ldapProtocolVersion); } /** - * changement du referrals. + * Set LDAP size limit. * - * @return boolean referrals + * @return boolean if set LDAP option OK: true, if KO: false + */ + public function setSizeLimit() + { + return ldap_set_option($this->connection, LDAP_OPT_SIZELIMIT, 0); + } + + /** + * Set LDAP referrals. + * LDAP_OPT_REFERRALS is a constant equal to ? + * + * @return boolean if set LDAP option OK: true, if KO: false */ public function setReferrals() { - // LDAP_OPT_REFERRALS est une constante qui vaut ? - $ldapreferrals = ldap_set_option($this->connection, LDAP_OPT_REFERRALS, 0); - return $ldapreferrals; + return ldap_set_option($this->connection, LDAP_OPT_REFERRALS, 0); } /** - * Add a LDAP entry - * Ldap object connect and bind must have been done + * Add an LDAP entry + * LDAP object connect and bind must have been done * * @param string $dn DN entry key * @param array $info Attributes array * @param User $user Object user that create - * @return int Return integer <0 if KO, >0 if OK + * @return int if KO: <0 || if OK: >0 */ public function add($dn, $info, $user) { @@ -566,13 +621,13 @@ class Ldap } /** - * Modify a LDAP entry - * Ldap object connect and bind must have been done + * Modify an LDAP entry + * LDAP object connect and bind must have been done * * @param string $dn DN entry key * @param array $info Attributes array * @param User $user Object user that modify - * @return int Return integer <0 if KO, >0 if OK + * @return int if KO: <0 || if OK: >0 */ public function modify($dn, $info, $user) { @@ -622,15 +677,15 @@ class Ldap } /** - * Rename a LDAP entry - * Ldap object connect and bind must have been done + * Rename an LDAP entry + * LDAP object connect and bind must have been done * * @param string $dn Old DN entry key (uid=qqq,ou=xxx,dc=aaa,dc=bbb) (before update) * @param string $newrdn New RDN entry key (uid=qqq) * @param string $newparent New parent (ou=xxx,dc=aaa,dc=bbb) * @param User $user Object user that modify * @param bool $deleteoldrdn If true the old RDN value(s) is removed, else the old RDN value(s) is retained as non-distinguished values of the entry. - * @return int Return integer <0 if KO, >0 if OK + * @return int if KO: <0 || if OK: >0 */ public function rename($dn, $newrdn, $newparent, $user, $deleteoldrdn = true) { @@ -665,8 +720,8 @@ class Ldap } /** - * Modify a LDAP entry (to use if dn != olddn) - * Ldap object connect and bind must have been done + * Modify an LDAP entry (to use if dn != olddn) + * LDAP object connect and bind must have been done * * @param string $dn DN entry key * @param array $info Attributes array @@ -674,7 +729,7 @@ class Ldap * @param string $olddn Old DN entry key (before update) * @param string $newrdn New RDN entry key (uid=qqq) (for ldap_rename) * @param string $newparent New parent (ou=xxx,dc=aaa,dc=bbb) (for ldap_rename) - * @return int Return integer <0 if KO, >0 if OK + * @return int if KO: <0 || if OK: >0 */ public function update($dn, $info, $user, $olddn, $newrdn = '', $newparent = '') { @@ -720,11 +775,11 @@ class Ldap /** - * Delete a LDAP entry - * Ldap object connect and bind must have been done + * Delete an LDAP entry + * LDAP object connect and bind must have been done * * @param string $dn DN entry key - * @return int Return integer <0 if KO, >0 if OK + * @return int if KO: <0 || if OK: >0 */ public function delete($dn) { @@ -753,7 +808,7 @@ class Ldap // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Build a LDAP message + * Build an LDAP message * * @param string $dn DN entry key * @param array $info Attributes array @@ -790,29 +845,32 @@ class Ldap } /** - * Dump a LDAP message to ldapinput.in file + * Dump an LDAP message to ldapinput.in file * * @param string $dn DN entry key * @param array $info Attributes array - * @return int Return integer <0 if KO, >0 if OK + * @return int if KO: <0 || if OK: >0 */ public function dump($dn, $info) { global $conf; - + $ldapDirTemp = $conf->ldap->dir_temp; // Create content $content = $this->dump_content($dn, $info); - //Create file - $result = dol_mkdir($conf->ldap->dir_temp); - - $outputfile = $conf->ldap->dir_temp.'/ldapinput.in'; - $fp = fopen($outputfile, "w"); - if ($fp) { - fputs($fp, $content); - fclose($fp); - dolChmod($outputfile); - return 1; + //Create directory & file + $result = dol_mkdir($ldapDirTemp); + if ($result != 0) { + $outputfile = $ldapDirTemp.'/ldapinput.in'; + $fp = fopen($outputfile, "w"); + if ($fp) { + fputs($fp, $content); + fclose($fp); + dolChmod($outputfile); + return 1; + } else { + return -1; + } } else { return -1; } @@ -821,10 +879,10 @@ class Ldap /** * Ping a server before ldap_connect for avoid waiting * - * @param string $host Server host or address - * @param int $port Server port (default 389) - * @param int $timeout Timeout in second (default 1s) - * @return boolean true or false + * @param string $host Server host or address + * @param int $port Server port (default 389) + * @param int $timeout Timeout in second (default 1s) + * @return boolean true or false */ public function serverPing($host, $port = 389, $timeout = 1) { @@ -865,13 +923,13 @@ class Ldap // Attribute methods ----------------------------------------------------- /** - * Add a LDAP attribute in entry - * Ldap object connect and bind must have been done + * Add an LDAP attribute in entry + * LDAP object connect and bind must have been done * * @param string $dn DN entry key * @param array $info Attributes array * @param User $user Object user that create - * @return int Return integer <0 if KO, >0 if OK + * @return int if KO: <0 || if OK: >0 */ public function addAttribute($dn, $info, $user) { @@ -911,13 +969,13 @@ class Ldap } /** - * Update a LDAP attribute in entry - * Ldap object connect and bind must have been done + * Update an LDAP attribute in entry + * LDAP object connect and bind must have been done * * @param string $dn DN entry key * @param array $info Attributes array * @param User $user Object user that create - * @return int Return integer <0 if KO, >0 if OK + * @return int if KO: <0 || if OK: >0 */ public function updateAttribute($dn, $info, $user) { @@ -957,13 +1015,13 @@ class Ldap } /** - * Delete a LDAP attribute in entry - * Ldap object connect and bind must have been done + * Delete an LDAP attribute in entry + * LDAP object connect and bind must have been done * * @param string $dn DN entry key * @param array $info Attributes array * @param User $user Object user that create - * @return int Return integer <0 if KO, >0 if OK + * @return int if KO: <0 || if OK: >0 */ public function deleteAttribute($dn, $info, $user) { @@ -1007,7 +1065,7 @@ class Ldap * * @param string $dn DN entry key * @param string $filter Filter - * @return int|array Return integer <0 or false if KO, array if OK + * @return int|array if KO: <=0 || if OK: array */ public function getAttribute($dn, $filter) { @@ -1046,9 +1104,9 @@ class Ldap /** * Returns an array containing values for an attribute and for first record matching filterrecord * - * @param string $filterrecord Record - * @param string $attribute Attributes - * @return array|boolean + * @param string $filterrecord Record + * @param string $attribute Attributes + * @return array|boolean */ public function getAttributeValues($filterrecord, $attribute) { @@ -1082,16 +1140,16 @@ class Ldap } /** - * Returns an array containing a details or list of LDAP record(s). - * ldapsearch -LLLx -hlocalhost -Dcn=admin,dc=parinux,dc=org -w password -b "ou=adherents,ou=people,dc=parinux,dc=org" userPassword + * Returns an array containing a details or list of LDAP record(s). + * ldapsearch -LLLx -hlocalhost -Dcn=admin,dc=parinux,dc=org -w password -b "ou=adherents,ou=people,dc=parinux,dc=org" userPassword * * @param string $search Value of field to search, '*' for all. Not used if $activefilter is set. * @param string $userDn DN (Ex: ou=adherents,ou=people,dc=parinux,dc=org) * @param string $useridentifier Name of key field (Ex: uid). - * @param array $attributeArray Array of fields required. Note this array must also contains field $useridentifier (Ex: sn,userPassword) + * @param array $attributeArray Array of fields required. Note this array must also contain field $useridentifier (Ex: sn,userPassword) * @param int $activefilter '1' or 'user'=use field this->filter as filter instead of parameter $search, 'group'=use field this->filtergroup as filter, 'member'=use field this->filtermember as filter * @param array $attributeAsArray Array of fields wanted as an array not a string - * @return array|int Array of [id_record][ldap_field]=value + * @return array|int if KO: <0 || if OK: array of [id_record][ldap_field]=value */ public function getRecords($search, $userDn, $useridentifier, $attributeArray, $activefilter = 0, $attributeAsArray = array()) { @@ -1179,7 +1237,7 @@ class Ldap } /** - * Converts a little-endian hex-number to one, that 'hexdec' can convert + * Converts a little-endian hex-number to one, that 'hexdec' can convert * Required by Active Directory * * @param string $hex Hex value @@ -1196,11 +1254,11 @@ class Ldap /** - * Recupere le SID de l'utilisateur + * Gets LDAP user SID. * Required by Active Directory * - * @param string $ldapUser Login de l'utilisateur - * @return string Sid + * @param string $ldapUser User login + * @return int|string if SID OK: SID string, if KO: -1 */ public function getObjectSid($ldapUser) { @@ -1241,13 +1299,13 @@ class Ldap return $SIDText; } else { $this->error = ldap_errno($this->connection)." ".ldap_error($this->connection); - return '?'; + return -1; } } /** * Returns the textual SID - * Indispensable pour Active Directory + * Required by Active Directory * * @param string $binsid Binary SID * @return string Textual SID @@ -1267,15 +1325,17 @@ class Ldap /** - * Fonction de recherche avec filtre - * this->connection doit etre defini donc la methode bind ou bindauth doit avoir deja ete appelee - * Ne pas utiliser pour recherche d'une liste donnee de proprietes - * car conflict majuscule-minuscule. A n'utiliser que pour les pages - * 'Fiche LDAP' qui affiche champ lisibles par default. + * Search method with filter + * this->connection must be defined. The bind or bindauth methods must already have been called. + * Do not use for search of a given properties list because of upper-lower case conflict. + * Only use for pages. + * 'Fiche LDAP' shows readable fields by default. + * @see bind + * @see bindauth * - * @param string $checkDn DN de recherche (Ex: ou=users,cn=my-domain,cn=com) - * @param string $filter Search filter (ex: (sn=nom_personne) ) - * @return array|int Array with answers (key lowercased - value) + * @param string $checkDn Search DN (Ex: ou=users,cn=my-domain,cn=com) + * @param string $filter Search filter (ex: (sn=name_person) ) + * @return array|int Array with answers (lowercase key - value) */ public function search($checkDn, $filter) { @@ -1303,12 +1363,12 @@ class Ldap /** - * Load all attribute of a LDAP user + * Load all attributes of an LDAP user * - * @param User|string $user Not used. - * @param string $filter Filter for search. Must start with &. - * Examples: &(objectClass=inetOrgPerson) &(objectClass=user)(objectCategory=person) &(isMemberOf=cn=Sales,ou=Groups,dc=opencsi,dc=com) - * @return int >0 if OK, <0 if KO + * @param User|string $user Not used. + * @param string $filter Filter for search. Must start with &. + * Examples: &(objectClass=inetOrgPerson) &(objectClass=user)(objectCategory=person) &(isMemberOf=cn=Sales,ou=Groups,dc=opencsi,dc=com) + * @return int if KO: <0 || if OK: > 0 */ public function fetch($user, $filter) { @@ -1363,14 +1423,14 @@ class Ldap $this->uacf = $this->parseUACF($this->convToOutputCharset($result[0]["useraccountcontrol"][0], $this->ldapcharset)); if (isset($result[0]["pwdlastset"][0])) { // If expiration on password exists - $this->pwdlastset = ($result[0]["pwdlastset"][0] != 0) ? $this->convert_time($this->convToOutputCharset($result[0]["pwdlastset"][0], $this->ldapcharset)) : 0; + $this->pwdlastset = ($result[0]["pwdlastset"][0] != 0) ? $this->convertTime($this->convToOutputCharset($result[0]["pwdlastset"][0], $this->ldapcharset)) : 0; } else { $this->pwdlastset = -1; } if (!$this->name && !$this->login) { $this->pwdlastset = -1; } - $this->badpwdtime = $this->convert_time($this->convToOutputCharset($result[0]["badpasswordtime"][0], $this->ldapcharset)); + $this->badpwdtime = $this->convertTime($this->convToOutputCharset($result[0]["badpasswordtime"][0], $this->ldapcharset)); // FQDN domain $domain = str_replace('dc=', '', $this->domain); @@ -1390,7 +1450,7 @@ class Ldap // helper methods /** - * Returns the correct user identifier to use, based on the ldap server type + * Returns the correct user identifier to use, based on the LDAP server type * * @return string Login */ @@ -1404,7 +1464,7 @@ class Ldap } /** - * UserAccountControl Flgs to more human understandable form... + * UserAccountControl Flags to more human understandable form... * * @param string $uacf UACF * @return array @@ -1482,16 +1542,14 @@ class Ldap return $retval; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Convertit le temps ActiveDirectory en Unix timestamp + * Converts ActiveDirectory time to Unix timestamp * * @param string $value AD time to convert * @return integer Unix timestamp */ - public function convert_time($value) + public function convertTime($value) { - // phpcs:enable $dateLargeInt = $value; // nano secondes depuis 1601 !!!! $secsAfterADEpoch = $dateLargeInt / (10000000); // secondes depuis le 1 jan 1601 $ADToUnixConvertor = ((1970 - 1601) * 365.242190) * 86400; // UNIX start date - AD start date * jours * secondes @@ -1503,9 +1561,9 @@ class Ldap /** * Convert a string into output/memory charset * - * @param string $str String to convert + * @param string $str String to convert * @param string $pagecodefrom Page code of src string - * @return string Converted string + * @return string Converted string */ private function convToOutputCharset($str, $pagecodefrom = 'UTF-8') { @@ -1522,9 +1580,9 @@ class Ldap /** * Convert a string from output/memory charset * - * @param string $str String to convert + * @param string $str String to convert * @param string $pagecodeto Page code for result string - * @return string Converted string + * @return string Converted string */ public function convFromOutputCharset($str, $pagecodeto = 'UTF-8') { @@ -1547,7 +1605,6 @@ class Ldap */ public function getNextGroupGid($keygroup = 'LDAP_KEY_GROUPS') { - global $conf; if (empty($keygroup)) { $keygroup = 'LDAP_KEY_GROUPS'; diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index fae891e07ec..1c686a9a7fb 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -1270,7 +1270,11 @@ class mysqliDoli extends mysqli public function __construct($host, $user, $pass, $name, $port = 0, $socket = "") { $flags = 0; - parent::init(); + if (PHP_VERSION_ID >= 80100) { + parent::__construct(); + } else { + parent::init(); + } if (strpos($host, 'ssl://') === 0) { $host = substr($host, 6); parent::options(MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, false); diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 190bef849e9..a2f98a6ba4b 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -1339,17 +1339,17 @@ jQuery(document).ready(function() { }); + /* - * Hacky fix for a bug in select2 with jQuery 3.6.0's new nested-focus "protection" + * Hacky fix for a bug in select2 with jQuery 3.6.4's new nested-focus "protection" + * This fix needs to click a second time when clicking into a combo with ajax (see Test4d and Test5a in test_forms.php * see: https://github.com/select2/select2/issues/5993 * see: https://github.com/jquery/jquery/issues/4382 * * TODO: Recheck with the select2 GH issue and remove once this is fixed on their side */ - - $(document).on('select2:open', (e) => { console.log("Execute the focus (click on combo or use space when on component"); const target = $(e.target); diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index baf7817a2af..bd33a0d2007 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -2360,7 +2360,7 @@ function addEventTypeSQL(&$sql, $actioncode, $sqlANDOR = "AND") * @param string $sql $sql modified * @param string $donetodo donetodo * @param string $now now - * @param string $filters array + * @param array $filters array * @return string sql request */ function addOtherFilterSQL(&$sql, $donetodo, $now, $filters) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index df3383dab6c..aa99d09dfe6 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -370,6 +370,7 @@ function convertDurationtoHour($duration_value, $duration_unit) * @param mixed $gm False or 0 or 'tzserver' = Input date fields are date info in the server TZ. True or 1 or 'gmt' = Input are date info in GMT TZ. * Note: In database, dates are always for the server TZ. * @return string $sqldate String with SQL filter + * @see forgeSQLFromUniversalSearchCriteria() */ function dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand = 0, $gm = false) { @@ -586,7 +587,7 @@ function dol_get_next_week($day, $week, $month, $year) * True or 1 or 'gmt' to compare with GMT date. * Example: dol_get_first_day(1970,1,false) will return -3600 with TZ+1, a dol_print_date on it will return 1970-01-01 00:00:00 * Example: dol_get_first_day(1970,1,true) will return 0 whatever is TZ, a dol_print_date on it will return 1970-01-01 00:00:00 - * @return int Date for first day, '' if error + * @return int|string Date as a timestamp, '' if error */ function dol_get_first_day($year, $month = 1, $gm = false) { @@ -605,7 +606,7 @@ function dol_get_first_day($year, $month = 1, $gm = false) * @param int $month Month * @param mixed $gm False or 0 or 'tzserver' = Return date to compare with server TZ, * True or 1 or 'gmt' to compare with GMT date. - * @return int Date for first day, '' if error + * @return int|string Date as a timestamp, '' if error */ function dol_get_last_day($year, $month = 12, $gm = false) { @@ -1186,5 +1187,5 @@ function getWeekNumber($day, $month, $year) { $date = new DateTime($year.'-'.$month.'-'.$day); $week = $date->format("W"); - return $week; + return (int) $week; } diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 060cb3f836f..cc48b80acc7 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -50,12 +50,12 @@ function dol_basename($pathfile) * but must not contains the start and end '/'. Filter is checked into basename only. * @param array $excludefilter Array of Regex for exclude filter (example: array('(\.meta|_preview.*\.png)$','^\.')). Exclude is checked both into fullpath and into basename (So '^xxx' may exclude 'xxx/dirscanned/...' and dirscanned/xxx'). * @param string $sortcriteria Sort criteria ('','fullname','relativename','name','date','size') - * @param string $sortorder Sort order (SORT_ASC, SORT_DESC) + * @param int $sortorder Sort order (SORT_ASC, SORT_DESC) * @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only, 4=Force load of perm * @param int $nohook Disable all hooks * @param string $relativename For recursive purpose only. Must be "" at first call. - * @param string $donotfollowsymlinks Do not follow symbolic links - * @param string $nbsecondsold Only files older than $nbsecondsold + * @param int $donotfollowsymlinks Do not follow symbolic links + * @param int $nbsecondsold Only files older than $nbsecondsold * @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file',...) * @see dol_dir_list_in_database() */ diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c9fed272eaa..637bbdb8743 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -234,6 +234,25 @@ function isModEnabled($module) //return !empty($conf->$module->enabled); } +/** + * isDolTms check if a timestamp is valid. + * + * @param int|string|null $timestamp timestamp to check + * @return bool + */ +function isDolTms($timestamp) +{ + if ($timestamp === '') { + dol_syslog('Using empty string for a timestamp is deprecated, prefer use of null when calling page '.$_SERVER["PHP_SELF"], LOG_NOTICE); + return false; + } + if (is_null($timestamp) || !is_numeric($timestamp)) { + return false; + } + + return true; +} + /** * Return a DoliDB instance (database handler). * @@ -2781,7 +2800,7 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs function dol_strftime($fmt, $ts = false, $is_gmt = false) { if ((abs($ts) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range - return ($is_gmt) ? @gmstrftime($fmt, $ts) : @strftime($fmt, $ts); + return ($is_gmt) ? @gmstrftime($fmt, $ts) : @dol_print_date($ts, $fmt); } else { return 'Error date into a not supported range'; } @@ -3104,7 +3123,7 @@ function dol_getdate($timestamp, $fast = false, $forcetimezone = '') * 'tzuserrel' = local to user TZ taking dst into account at the given date. Use this one to convert date input from user into a GMT date. * 'tz,TimeZone' = use specified timezone * @param int $check 0=No check on parameters (Can use day 32, etc...) - * @return int|string Date as a timestamp, '' or false if error + * @return int|string Date as a timestamp, '' if error * @see dol_print_date(), dol_stringtotime(), dol_getdate() */ function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm = 'auto', $check = 1) @@ -6724,7 +6743,7 @@ function get_product_vat_for_country($idprod, $thirdpartytouse, $idprodfournpric $found = 1; } } else { - // TODO Read default product vat according to product and another countrycode. + // TODO Read default product vat according to product and an other countrycode. // Vat for couple anothercountrycode/product is data that is not managed and store yet, so we will fallback on next rule. } } @@ -11878,6 +11897,9 @@ function getElementProperties($element_type) $module = 'societe'; $subelement = 'contact'; $table_element = 'socpeople'; + } elseif ($element_type == 'inventory') { + $module = 'product'; + $classpath = 'product/inventory/class'; } elseif ($element_type == 'stock') { $classpath = 'product/stock/class'; $classfile = 'entrepot'; @@ -12439,6 +12461,7 @@ function jsonOrUnserialize($stringtodecode) * @param int $nopar 1=Do not add the perenthesis around the condition string. * @param int $noerror 1=If search criteria is not valid, does not return an error string but invalidate the SQL * @return string Return forged SQL string + * @see dolSqlDateFilter() */ function forgeSQLFromUniversalSearchCriteria($filter, &$errorstr = '', $noand = 0, $nopar = 0, $noerror = 0) { diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 0db8cabbefb..292bbb82eaf 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -903,7 +903,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ if (!is_object($objsoc)) { $valueforccc = $objsoc; - } elseif ($table == "commande_fournisseur" || $table == "facture_fourn") { + } elseif ($table == "commande_fournisseur" || $table == "facture_fourn" || $table == "paiementfourn") { $valueforccc = dol_string_unaccent($objsoc->code_fournisseur); } else { $valueforccc = dol_string_unaccent($objsoc->code_client); @@ -1612,7 +1612,7 @@ function hexbin($hexa) */ function numero_semaine($time) { - $stime = strftime('%Y-%m-%d', $time); + $stime = dol_print_date($time, '%Y-%m-%d'); if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/i', $stime, $reg)) { // Date est au format 'YYYY-MM-DD' ou 'YYYY-MM-DD HH:MM:SS' diff --git a/htdocs/core/lib/memory.lib.php b/htdocs/core/lib/memory.lib.php index 82f4c355738..fad999b0d70 100644 --- a/htdocs/core/lib/memory.lib.php +++ b/htdocs/core/lib/memory.lib.php @@ -287,7 +287,7 @@ function dol_setshmop($memoryid, $data, $expire) * Read a memory area shared by all users, all sessions on server * * @param string $memoryid Memory id of shared area ('main', 'agenda', ...) - * @return int Return integer <0 if KO, data if OK, Null if no cache enabled or not found + * @return int|null Return integer <0 if KO, data if OK, null if no cache enabled or not found */ function dol_getshmop($memoryid) { diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index 33505fec7ce..d1ca7df5f7c 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -30,7 +30,7 @@ * @param string $objectname Name of object * @param string $newmask New mask * @param string $readdir Directory source (use $destdir when not defined) - * @param string $addfieldentry Array of 1 field entry to add array('key'=>,'type'=>,''label'=>,'visible'=>,'enabled'=>,'position'=>,'notnull'=>','index'=>,'searchall'=>,'comment'=>,'help'=>,'isameasure') + * @param array $addfieldentry Array of 1 field entry to add array('key'=>,'type'=>,''label'=>,'visible'=>,'enabled'=>,'position'=>,'notnull'=>','index'=>,'searchall'=>,'comment'=>,'help'=>,'isameasure') * @param string $delfieldentry Id of field to remove * @return int|object Return integer <=0 if KO, Object if OK * @see rebuildObjectSql() diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 1719172b40e..3fa50959535 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -430,7 +430,7 @@ function pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includeali * @param int $usecontact Use contact instead of company * @param string $mode Address type ('source', 'target', 'targetwithdetails', 'targetwithdetails_xxx': target but include also phone/fax/email/url) * @param Object $object Object we want to build document for - * @return string String with full address + * @return string|int String with full address or -1 if KO */ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $targetcontact = '', $usecontact = 0, $mode = 'source', $object = null) { diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 420867a1015..c0fe5fcf494 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -229,7 +229,7 @@ function dolDecrypt($chain, $key = '') * @param string $chain String to hash * @param string $type Type of hash ('0':auto will use MAIN_SECURITY_HASH_ALGO else md5, '1':sha1, '2':sha1+md5, '3':md5, '4': for OpenLdap, '5':sha256, '6':password_hash). * Use 'md5' if hash is not needed for security purpose. For security need, prefer 'auto'. - * @param string $nosalt Do not include any salt + * @param int $nosalt Do not include any salt * @return string Hash of string * @see getRandomPassword(), dol_verifyHash() */ @@ -1159,7 +1159,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl * @return void * @see accessforbidden() */ -function httponly_accessforbidden($message = 1, $http_response_code = 403, $stringalreadysanitized = 0) +function httponly_accessforbidden($message = '1', $http_response_code = 403, $stringalreadysanitized = 0) { top_httphead(); http_response_code($http_response_code); diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 770698d3ebf..1d5cacacb3f 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -186,7 +186,36 @@ function user_prepare_head(User $object) $h++; $head[$h][0] = DOL_URL_ROOT.'/user/info.php?id='.$object->id; - $head[$h][1] = $langs->trans("Info"); + $head[$h][1] = $langs->trans("Events"); + if (isModEnabled('agenda')&& ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { + $nbEvent = 0; + // Enable caching of thirdparty count actioncomm + require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; + $cachekey = 'count_events_user_'.$object->id; + $dataretrieved = dol_getcache($cachekey); + if (!is_null($dataretrieved)) { + $nbEvent = $dataretrieved; + } else { + $sql = "SELECT COUNT(id) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm"; + $sql .= " WHERE fk_user_done = ".((int) $object->id); + $sql .= " AND entity IN (".getEntity('agenda').")"; + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + $nbEvent = $obj->nb; + } else { + dol_syslog('Failed to count actioncomm '.$db->lasterror(), LOG_ERR); + } + dol_setcache($cachekey, $nbEvent, 120); // If setting cache fails, this is not a problem, so we do not test result. + } + + $head[$h][1] .= '/'; + $head[$h][1] .= $langs->trans("Agenda"); + if ($nbEvent > 0) { + $head[$h][1] .= ''.$nbEvent.''; + } + } $head[$h][2] = 'info'; $h++; } @@ -1173,3 +1202,523 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''; print ''; } + +/** + * Show html area with actions (done or not, ignore the name of function). + * Note: Global parameter $param must be defined. + * + * @param Conf $conf Object conf + * @param Translate $langs Object langs + * @param DoliDB $db Object db + * @param mixed $filterobj Filter on object Adherent|Societe|Project|Product|CommandeFournisseur|Dolresource|Ticket... to list events linked to an object + * @param Contact|null $objcon Filter on object contact to filter events on a contact + * @param int $noprint Return string but does not output it + * @param string|string[] $actioncode Filter on actioncode + * @param string $donetodo Filter on event 'done' or 'todo' or ''=nofilter (all). + * @param array $filters Filter on other fields + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param string $module You can add module name here if elementtype in table llx_actioncomm is objectkey@module + * @return string|void Return html part or void if noprint is 1 + */ +function show_actions_done_user($conf, $langs, $db, $filterobj, $objcon = null, $noprint = 0, $actioncode = '', $donetodo = 'done', $filters = array(), $sortfield = 'a.datep,a.id', $sortorder = 'DESC', $module = '') +{ + global $user, $conf, $hookmanager; + global $form; + global $param, $massactionbutton; + + $start_year = GETPOST('dateevent_startyear', 'int'); + $start_month = GETPOST('dateevent_startmonth', 'int'); + $start_day = GETPOST('dateevent_startday', 'int'); + $end_year = GETPOST('dateevent_endyear', 'int'); + $end_month = GETPOST('dateevent_endmonth', 'int'); + $end_day = GETPOST('dateevent_endday', 'int'); + $tms_start = ''; + $tms_end = ''; + + if (!empty($start_year) && !empty($start_month) && !empty($start_day)) { + $tms_start = dol_mktime(0, 0, 0, $start_month, $start_day, $start_year, 'tzuserrel'); + } + if (!empty($end_year) && !empty($end_month) && !empty($end_day)) { + $tms_end = dol_mktime(23, 59, 59, $end_month, $end_day, $end_year, 'tzuserrel'); + } + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers + $tms_start = ''; + $tms_end = ''; + } + dol_include_once('/comm/action/class/actioncomm.class.php'); + + // Check parameters + if (!is_object($filterobj) && !is_object($objcon)) { + dol_print_error('', 'BadParameter'); + } + + $out = ''; + $histo = array(); + $numaction = 0; + $now = dol_now('tzuser'); + + // Open DSI -- Fix order by -- Begin + $sortfield_list = explode(',', $sortfield); + $sortfield_label_list = array('a.id' => 'id', 'a.datep' => 'dp', 'a.percent' => 'percent'); + $sortfield_new_list = array(); + foreach ($sortfield_list as $sortfield_value) { + $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)]; + } + $sortfield_new = implode(',', $sortfield_new_list); + + $sql = ''; + + if (isModEnabled('agenda')) { + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context + $hookmanager->initHooks(array('agendadao')); + + // Recherche histo sur actioncomm + if (is_object($objcon) && $objcon->id > 0) { + $sql = "SELECT DISTINCT a.id, a.label as label,"; + } else { + $sql = "SELECT a.id, a.label as label,"; + } + $sql .= " a.datep as dp,"; + $sql .= " a.datep2 as dp2,"; + $sql .= " a.percent as percent, 'action' as type,"; + $sql .= " a.fk_element, a.elementtype,"; + $sql .= " c.code as acode, c.libelle as alabel, c.picto as apicto,"; + $sql .= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; + if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur'))) { + $sql .= ", sp.lastname, sp.firstname"; + } elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') { + /* Nothing */ + } elseif (is_object($filterobj) && get_class($filterobj) == 'Project') { + /* Nothing */ + } elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') { + $sql .= ", m.lastname, m.firstname"; + } elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') { + $sql .= ", o.ref"; + } elseif (is_object($filterobj) && get_class($filterobj) == 'Product') { + $sql .= ", o.ref"; + } elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') { + $sql .= ", o.ref"; + } elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') { + $sql .= ", o.ref"; + } elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') { + $sql .= ", o.ref"; + } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) && $filterobj->table_element && $filterobj->element) { + if (!empty($filterobj->fields['ref'])) { + $sql .= ", o.ref"; + } elseif (!empty($filterobj->fields['label'])) { + $sql .= ", o.label"; + } + } + + // Fields from hook + $parameters = array('sql' => &$sql, 'filterobj' => $filterobj, 'objcon' => $objcon); + $reshook = $hookmanager->executeHooks('showActionsDoneListSelect', $parameters); // Note that $action and $object may have been modified by hook + if (!empty($hookmanager->resPrint)) { + $sql.= $hookmanager->resPrint; + } + + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; + $force_filter_contact = false; + if (is_object($objcon) && $objcon->id > 0) { + $force_filter_contact = true; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm_resources as r ON a.id = r.fk_actioncomm"; + $sql .= " AND r.element_type = '".$db->escape($objcon->table_element)."' AND r.fk_element = ".((int) $objcon->id); + } + + + // Fields from hook + $parameters = array('sql' => &$sql, 'filterobj' => $filterobj, 'objcon' => $objcon); + $reshook = $hookmanager->executeHooks('showActionsDoneListFrom', $parameters); // Note that $action and $object may have been modified by hook + if (!empty($hookmanager->resPrint)) { + $sql.= $hookmanager->resPrint; + } + + $sql .= " WHERE a.entity IN (".getEntity('agenda').")"; + $sql .= " AND u.rowid = ".((int) $filterobj->id); + + + if (!empty($tms_start) && !empty($tms_end)) { + $sql .= " AND ((a.datep BETWEEN '".$db->idate($tms_start)."' AND '".$db->idate($tms_end)."') OR (a.datep2 BETWEEN '".$db->idate($tms_start)."' AND '".$db->idate($tms_end)."'))"; + } elseif (empty($tms_start) && !empty($tms_end)) { + $sql .= " AND ((a.datep <= '".$db->idate($tms_end)."') OR (a.datep2 <= '".$db->idate($tms_end)."'))"; + } elseif (!empty($tms_start) && empty($tms_end)) { + $sql .= " AND ((a.datep >= '".$db->idate($tms_start)."') OR (a.datep2 >= '".$db->idate($tms_start)."'))"; + } + if (is_array($actioncode) && !empty($actioncode)) { + $sql .= ' AND ('; + foreach ($actioncode as $key => $code) { + if ($key != 0) { + $sql .= " OR "; + } + if (!empty($code)) { + addEventTypeSQL($sql, $code, ""); + } + } + $sql .= ')'; + } elseif (!empty($actioncode)) { + addEventTypeSQL($sql, $actioncode); + } + + addOtherFilterSQL($sql, $donetodo, $now, $filters); + + // Fields from hook + $parameters = array('sql' => &$sql, 'filterobj' => $filterobj, 'objcon' => $objcon, 'module' => $module); + $reshook = $hookmanager->executeHooks('showActionsDoneListWhere', $parameters); // Note that $action and $object may have been modified by hook + if (!empty($hookmanager->resPrint)) { + $sql.= $hookmanager->resPrint; + } + + if (is_array($actioncode)) { + foreach ($actioncode as $code) { + $sql2 = addMailingEventTypeSQL($code, $objcon, $filterobj); + if (!empty($sql2)) { + if (!empty($sql)) { + $sql = $sql." UNION ".$sql2; + } elseif (empty($sql)) { + $sql = $sql2; + } + break; + } + } + } else { + $sql2 = addMailingEventTypeSQL($actioncode, $objcon, $filterobj); + if (!empty($sql) && !empty($sql2)) { + $sql = $sql." UNION ".$sql2; + } elseif (empty($sql) && !empty($sql2)) { + $sql = $sql2; + } + } + } + + //TODO Add limit in nb of results + if ($sql) { + $sql .= $db->order($sortfield_new, $sortorder); + + dol_syslog("usergroups.lib::show_actions_dones", LOG_DEBUG); + + $resql = $db->query($sql); + if ($resql) { + $i = 0; + $num = $db->num_rows($resql); + + while ($i < $num) { + $obj = $db->fetch_object($resql); + + if ($obj->type == 'action') { + $contactaction = new ActionComm($db); + $contactaction->id = $obj->id; + $result = $contactaction->fetchResources(); + if ($result < 0) { + dol_print_error($db); + setEventMessage("user.lib::show_actions_done Error fetch resource", 'errors'); + } + + //if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; + //elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; + $tododone = ''; + if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && (!empty($obj->datep) && $obj->datep > $now))) { + $tododone = 'todo'; + } + + $histo[$numaction] = array( + 'type'=>$obj->type, + 'tododone'=>$tododone, + 'id'=>$obj->id, + 'datestart'=>$db->jdate($obj->dp), + 'dateend'=>$db->jdate($obj->dp2), + 'note'=>$obj->label, + 'percent'=>$obj->percent, + + 'userid'=>$obj->user_id, + 'login'=>$obj->user_login, + 'userfirstname'=>$obj->user_firstname, + 'userlastname'=>$obj->user_lastname, + 'userphoto'=>$obj->user_photo, + + 'contact_id'=>$obj->fk_contact, + 'socpeopleassigned' => $contactaction->socpeopleassigned, + 'lastname' => empty($obj->lastname) ? '' : $obj->lastname, + 'firstname' => empty($obj->firstname) ? '' : $obj->firstname, + 'fk_element'=>$obj->fk_element, + 'elementtype'=>$obj->elementtype, + // Type of event + 'acode'=>$obj->acode, + 'alabel'=>$obj->alabel, + 'libelle'=>$obj->alabel, // deprecated + 'apicto'=>$obj->apicto + ); + } else { + $histo[$numaction] = array( + 'type'=>$obj->type, + 'tododone'=>'done', + 'id'=>$obj->id, + 'datestart'=>$db->jdate($obj->dp), + 'dateend'=>$db->jdate($obj->dp2), + 'note'=>$obj->label, + 'percent'=>$obj->percent, + 'acode'=>$obj->acode, + + 'userid'=>$obj->user_id, + 'login'=>$obj->user_login, + 'userfirstname'=>$obj->user_firstname, + 'userlastname'=>$obj->user_lastname, + 'userphoto'=>$obj->user_photo + ); + } + + $numaction++; + $i++; + } + } else { + dol_print_error($db); + } + } + + if (isModEnabled('agenda')|| (isModEnabled('mailing') && !empty($objcon->email))) { + $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; + + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; + + $formactions = new FormActions($db); + + $actionstatic = new ActionComm($db); + $userstatic = new User($db); + $userlinkcache = array(); + $contactstatic = new Contact($db); + $elementlinkcache = array(); + + $out .= '
'; + $out .= ''; + if ($objcon && get_class($objcon) == 'User' && + (is_null($filterobj) || get_class($filterobj) == 'User')) { + $out .= ''; + } else { + $out .= ''; + } + if ($filterobj && get_class($filterobj) == 'User') { + $out .= ''; + } + + $out .= "\n"; + + $out .= '
'; + $out .= ''; + + $out .= ''; + + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + $out .= ''; + } + + if ($donetodo) { + $out .= ''; + } + + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + $out .= ''; + } + $out .= ''; + + $out .= ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + $out .= getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'maxwidthsearch '); + } + if ($donetodo) { + $tmp = ''; + if (get_class($filterobj) == 'User') { + $tmp .= ''; + } + $tmp .= ($donetodo != 'done' ? $langs->trans("ActionsToDoShort") : ''); + $tmp .= ($donetodo != 'done' && $donetodo != 'todo' ? ' / ' : ''); + $tmp .= ($donetodo != 'todo' ? $langs->trans("ActionsDoneShort") : ''); + //$out.=$langs->trans("ActionsToDoShort").' / '.$langs->trans("ActionsDoneShort"); + if (get_class($filterobj) == 'User') { + $tmp .= ''; + } + $out .= getTitleFieldOfList($tmp); + } + $out .= getTitleFieldOfList("Ref", 0, $_SERVER["PHP_SELF"], 'a.id', '', $param, '', $sortfield, $sortorder); + $out .= getTitleFieldOfList("Owner"); + $out .= getTitleFieldOfList("Type"); + $out .= getTitleFieldOfList("Label", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); + $out .= getTitleFieldOfList("Date", 0, $_SERVER["PHP_SELF"], 'a.datep,a.id', '', $param, '', $sortfield, $sortorder, 'center '); + $out .= getTitleFieldOfList("Status", 0, $_SERVER["PHP_SELF"], 'a.percent', '', $param, '', $sortfield, $sortorder, 'center '); + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + $out .= getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'maxwidthsearch '); + } + $out .= ''; + $out .= ''; + + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; + $caction = new CActionComm($db); + $arraylist = $caction->liste_array(1, 'code', '', (!getDolGlobalString('AGENDA_USE_EVENT_TYPE') ? 1 : 0), '', 1); + + foreach ($histo as $key => $value) { + $actionstatic->fetch($histo[$key]['id']); // TODO Do we need this, we already have a lot of data of line into $histo + + $actionstatic->type_picto = $histo[$key]['apicto']; + $actionstatic->type_code = $histo[$key]['acode']; + + $out .= ''; + + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + $out .= ''; + } + + // Done or todo + if ($donetodo) { + $out .= ''; + } + + // Ref + $out .= ''; + + // Author of event + $out .= ''; + + // Type + $labeltype = $actionstatic->type_code; + if (!getDolGlobalString('AGENDA_USE_EVENT_TYPE') && empty($arraylist[$labeltype])) { + $labeltype = 'AC_OTH'; + } + if (!empty($actionstatic->code) && preg_match('/^TICKET_MSG/', $actionstatic->code)) { + $labeltype = $langs->trans("Message"); + } else { + if (!empty($arraylist[$labeltype])) { + $labeltype = $arraylist[$labeltype]; + } + if ($actionstatic->type_code == 'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labeltype && !empty($arraylist[$actionstatic->code])) { + $labeltype .= ' - '.$arraylist[$actionstatic->code]; // Use code in priority on type_code + } + } + $out .= ''; + + // Title/Label of event + $out .= ''; + + // Date + $out .= '\n"; + + // Status + $out .= ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + $out .= ''; + } + + $out .= "\n"; + $i++; + } + if (empty($histo)) { + $colspan = 9; + $out .= ''; + } + + $out .= "
'; + $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); + $out .= $searchpicto; + $out .= ''; + $out .= $formactions->select_type_actions($actioncode, "actioncode", '', !getDolGlobalString('AGENDA_USE_EVENT_TYPE') ? 1 : -1, 0, (!getDolGlobalString('AGENDA_USE_MULTISELECT_TYPE') ? 0 : 1), 1, 'minwidth100 maxwidth150'); + $out .= ''; + $out .= $form->selectDateToDate($tms_start, $tms_end, 'dateevent', 1); + $out .= ''; + $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); + $out .= $searchpicto; + $out .= '
'; + $out .= ''; + if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') { + $out .= ''.img_object($langs->trans("ShowEMailing"), "email").' '; + $out .= $histo[$key]['id']; + $out .= ''; + } else { + $out .= $actionstatic->getNomUrl(1, -1); + } + $out .= ''; + if ($histo[$key]['userid'] > 0) { + if (isset($userlinkcache[$histo[$key]['userid']])) { + $link = $userlinkcache[$histo[$key]['userid']]; + } else { + $userstatic->fetch($histo[$key]['userid']); + $link = $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', ''); + $userlinkcache[$histo[$key]['userid']] = $link; + } + $out .= $link; + } + $out .= ''; + $out .= $actionstatic->getTypePicto(); + //if (empty($conf->dol_optimize_smallscreen)) { + $out .= $labeltype; + //} + $out .= 'trans("Action".$histo[$key]['acode']); + //$libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : $histo[$key]['alabel']); + $libelle = $histo[$key]['note']; + $actionstatic->id = $histo[$key]['id']; + $out .= ' title="'.dol_escape_htmltag($libelle).'">'; + $out .= dol_trunc($libelle, 120); + } + if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') { + $out .= ''.img_object($langs->trans("ShowEMailing"), "email").' '; + $transcode = $langs->trans("Action".$histo[$key]['acode']); + $libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : 'Send mass mailing'); + $out .= ' title="'.dol_escape_htmltag($libelle).'">'; + $out .= dol_trunc($libelle, 120); + } + $out .= ''; + $out .= dol_print_date($histo[$key]['datestart'], 'dayhour', 'tzuserrel'); + if ($histo[$key]['dateend'] && $histo[$key]['dateend'] != $histo[$key]['datestart']) { + $tmpa = dol_getdate($histo[$key]['datestart'], true); + $tmpb = dol_getdate($histo[$key]['dateend'], true); + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) { + $out .= '-'.dol_print_date($histo[$key]['dateend'], 'hour', 'tzuserrel'); + } else { + $out .= '-'.dol_print_date($histo[$key]['dateend'], 'dayhour', 'tzuserrel'); + } + } + $late = 0; + if ($histo[$key]['percent'] == 0 && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) { + $late = 1; + } + if ($histo[$key]['percent'] == 0 && !$histo[$key]['datestart'] && $histo[$key]['dateend'] && $histo[$key]['datestart'] < ($now - $delay_warning)) { + $late = 1; + } + if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && $histo[$key]['dateend'] && $histo[$key]['dateend'] < ($now - $delay_warning)) { + $late = 1; + } + if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && !$histo[$key]['dateend'] && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) { + $late = 1; + } + if ($late) { + $out .= img_warning($langs->trans("Late")).' '; + } + $out .= "'.$actionstatic->LibStatut($histo[$key]['percent'], 2, 0, $histo[$key]['datestart']).'
'.$langs->trans("NoRecordFound").'
\n"; + $out .= "
\n"; + + $out .= '
'; + } + + if ($noprint) { + return $out; + } else { + print $out; + } +} diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index bc9400e0476..aa03923aa7b 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -118,7 +118,7 @@ function dolKeepOnlyPhpCode($str) * @return boolean True if OK * @see dolWebsiteOutput() for function used to replace content in a web server context */ -function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0, $contenttype = 'html', $containerid = '') +function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0, $contenttype = 'html', $containerid = 0) { $nbrep = 0; @@ -279,7 +279,7 @@ function dolReplaceSmileyCodeWithUTF8($content) * @return void * @see dolWebsiteReplacementOfLinks() for function used to replace content in the backoffice context. */ -function dolWebsiteOutput($content, $contenttype = 'html', $containerid = '') +function dolWebsiteOutput($content, $contenttype = 'html', $containerid = 0) { global $db, $langs, $conf, $user; global $dolibarr_main_url_root, $dolibarr_main_data_root; diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 6b5d192a349..6d57af2a4f3 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -30,10 +30,10 @@ insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, left -- Sub-Menus -- Home - Dashboard -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '1', __HANDLER__, 'left', 90__+MAX_llx_menu__, 'home', '', 1__+MAX_llx_menu__, '/index.php', 'MyDashboard', 0, '', '', '', 2, 0, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity, prefix) values ('', '1', __HANDLER__, 'left', 90__+MAX_llx_menu__, 'home', '', 1__+MAX_llx_menu__, '/index.php', 'MyDashboard', 0, '', '', '', 2, 0, __ENTITY__, ''); -- Home - Setup -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$user->admin' , __HANDLER__, 'left', 100__+MAX_llx_menu__, 'home', 'setup', 1__+MAX_llx_menu__, '/admin/index.php?mainmenu=home&leftmenu=setup', 'Setup', 0, 'admin', '', '', 2, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity, prefix) values ('', '$user->admin' , __HANDLER__, 'left', 100__+MAX_llx_menu__, 'home', 'setup', 1__+MAX_llx_menu__, '/admin/index.php?mainmenu=home&leftmenu=setup', 'Setup', 0, 'admin', '', '', 2, 1, __ENTITY__, ''); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="setup"', __HANDLER__, 'left', 101__+MAX_llx_menu__, 'home', '' , 100__+MAX_llx_menu__, '/admin/company.php?mainmenu=home&leftmenu=setup', 'MenuCompanySetup', 1, 'admin', '', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="setup"', __HANDLER__, 'left', 102__+MAX_llx_menu__, 'home', '' , 100__+MAX_llx_menu__, '/admin/ihm.php?mainmenu=home&leftmenu=setup', 'GUISetup', 1, 'admin', '', '', 2, 4, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="setup"', __HANDLER__, 'left', 114__+MAX_llx_menu__, 'home', '' , 100__+MAX_llx_menu__, '/admin/translation.php?mainmenu=home&leftmenu=setup', 'Translation', 1, 'admin', '', '', 2, 4, __ENTITY__); @@ -52,7 +52,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="setup"', __HANDLER__, 'left', 112__+MAX_llx_menu__, 'home', '', 100__+MAX_llx_menu__, '/admin/const.php?mainmenu=home&leftmenu=setup', 'OtherSetup', 1, 'admin', '', '', 2, 14, __ENTITY__); -- Home - Admin tools -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$user->admin', __HANDLER__, 'left', 300__+MAX_llx_menu__, 'home', 'admintools', 1__+MAX_llx_menu__, '/admin/tools/index.php?mainmenu=home&leftmenu=admintools', 'AdminTools', 0, 'admin', '', '', 2, 2, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity, prefix) values ('', '$user->admin', __HANDLER__, 'left', 300__+MAX_llx_menu__, 'home', 'admintools', 1__+MAX_llx_menu__, '/admin/tools/index.php?mainmenu=home&leftmenu=admintools', 'AdminTools', 0, 'admin', '', '', 2, 2, __ENTITY__, ''); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="admintools"', __HANDLER__, 'left', 201__+MAX_llx_menu__, 'home', '', 300__+MAX_llx_menu__, '/admin/system/dolibarr.php?mainmenu=home&leftmenu=admintools', 'InfoDolibarr', 1, 'admin', '', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="admintools"', __HANDLER__, 'left', 202__+MAX_llx_menu__, 'home', '', 201__+MAX_llx_menu__, '/admin/system/modules.php?mainmenu=home&leftmenu=admintools', 'Modules', 2, 'admin', '', '', 2, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="admintools"', __HANDLER__, 'left', 203__+MAX_llx_menu__, 'home', '', 201__+MAX_llx_menu__, '/admin/triggers.php?mainmenu=home&leftmenu=admintools', 'Triggers', 2, 'admin', '', '', 2, 3, __ENTITY__); @@ -75,7 +75,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="admintools"', __HANDLER__, 'left', 320__+MAX_llx_menu__, 'home', '', 300__+MAX_llx_menu__, '/product/admin/product_tools.php?mainmenu=home&leftmenu=admintools', 'ProductVatMassChange', 1, 'products', '', '', 2, 15, __ENTITY__); -- Home - Menu users and groups -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '1', __HANDLER__, 'left', 400__+MAX_llx_menu__, 'home', 'users', 1__+MAX_llx_menu__, '/user/home.php?mainmenu=home&leftmenu=users', 'MenuUsersAndGroups', 0, 'users', '', '', 2, 4, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity, prefix) values ('', '1', __HANDLER__, 'left', 400__+MAX_llx_menu__, 'home', 'users', 1__+MAX_llx_menu__, '/user/home.php?mainmenu=home&leftmenu=users', 'MenuUsersAndGroups', 0, 'users', '', '', 2, 4, __ENTITY__, ''); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="users"', __HANDLER__, 'left', 401__+MAX_llx_menu__, 'home', '', 400__+MAX_llx_menu__, '/user/list.php?mainmenu=home&leftmenu=users', 'Users', 1, 'users', '$user->hasRight("user","user","lire") || $user->admin', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="users"', __HANDLER__, 'left', 402__+MAX_llx_menu__, 'home', '', 401__+MAX_llx_menu__, '/user/card.php?mainmenu=home&leftmenu=users&action=create', 'NewUser', 2, 'users', '($user->hasRight("user","user","creer") || $user->admin) && !(isModEnabled("multicompany") && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)', '', 2, 0, __ENTITY__); @@ -87,7 +87,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="users"', __HANDLER__, 'left', 408__+MAX_llx_menu__, 'home', '', 407__+MAX_llx_menu__, '/user/group/card.php?mainmenu=home&leftmenu=users&action=create', 'NewGroup', 2, 'users', '(($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->write:$user->hasRight("user","user","creer")) || $user->admin) && !(isModEnabled("multicompany") && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)', '', 2, 0, __ENTITY__); -- Third parties -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 500__+MAX_llx_menu__, 'companies', 'thirdparties', 2__+MAX_llx_menu__, '/societe/index.php?mainmenu=companies&leftmenu=thirdparties', 'ThirdParty', 0, 'companies', '$user->hasRight("societe","lire")', '', 2, 0, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity, prefix) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 500__+MAX_llx_menu__, 'companies', 'thirdparties', 2__+MAX_llx_menu__, '/societe/index.php?mainmenu=companies&leftmenu=thirdparties', 'ThirdParty', 0, 'companies', '$user->hasRight("societe","lire")', '', 2, 0, __ENTITY__, ''); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 501__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/card.php?mainmenu=companies&action=create', 'MenuNewThirdParty', 1, 'companies', '$user->hasRight("societe","creer")', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 502__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/list.php?mainmenu=companies&leftmenu=thirdparties', 'List', 1, 'companies', '$user->hasRight("societe","lire")', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe") && (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))', __HANDLER__, 'left', 503__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/list.php?mainmenu=companies&type=f&leftmenu=suppliers', 'ListSuppliersShort', 1, 'suppliers', '$user->hasRight("societe","lire") && $user->rights->fournisseur->lire', '', 2, 5, __ENTITY__); @@ -98,7 +98,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 510__+MAX_llx_menu__, 'companies', '', 509__+MAX_llx_menu__, '/societe/card.php?mainmenu=companies&leftmenu=customers&action=create&type=c', 'MenuNewCustomer', 2, 'companies', '$user->hasRight("societe","creer")', '', 2, 0, __ENTITY__); -- Third parties - Contacts -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 600__+MAX_llx_menu__, 'companies', 'contacts', 2__+MAX_llx_menu__, '/contact/list.php?mainmenu=companies&leftmenu=contacts', 'ContactsAddresses', 0, 'companies', '$user->hasRight("societe","lire")', '', 2, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity, prefix) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 600__+MAX_llx_menu__, 'companies', 'contacts', 2__+MAX_llx_menu__, '/contact/list.php?mainmenu=companies&leftmenu=contacts', 'ContactsAddresses', 0, 'companies', '$user->hasRight("societe","lire")', '', 2, 1, __ENTITY__, ''); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 601__+MAX_llx_menu__, 'companies', '', 600__+MAX_llx_menu__, '/contact/card.php?mainmenu=companies&leftmenu=contacts&action=create', 'NewContactAddress', 1, 'companies', '$user->hasRight("societe","creer")', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 602__+MAX_llx_menu__, 'companies', '', 600__+MAX_llx_menu__, '/contact/list.php?mainmenu=companies&leftmenu=contacts', 'List', 1, 'companies', '$user->hasRight("societe","lire")', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 604__+MAX_llx_menu__, 'companies', '', 602__+MAX_llx_menu__, '/contact/list.php?mainmenu=companies&leftmenu=contacts&type=p', 'ThirdPartyProspects', 2, 'companies', '$user->hasRight("societe","contact","lire")', '', 2, 1, __ENTITY__); diff --git a/htdocs/core/modules/export/export_excel2007.modules.php b/htdocs/core/modules/export/export_excel2007.modules.php index 1c5aa0a29c2..4be27acc2c9 100644 --- a/htdocs/core/modules/export/export_excel2007.modules.php +++ b/htdocs/core/modules/export/export_excel2007.modules.php @@ -1,6 +1,7 @@ * Copyright (C) 2012 Marcos García + * Copyright (C) 2024 William Mead * * 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 @@ -651,11 +652,11 @@ class ExportExcel2007 extends ModeleExports /** * Set a value cell and merging it by giving a starting cell and a length * - * @param string $val Cell value - * @param string $startCell Starting cell - * @param int $length Length - * @param int $offset Starting offset - * @return string Coordinate or -1 if KO + * @param string $val Cell value + * @param string $startCell Starting cell + * @param int $length Length + * @param int $offset Starting offset + * @return int|string Coordinate or if KO: -1 */ public function setMergeCellValueByLength($val, $startCell, $length, $offset = 0) { diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php index 95bc0dc27d2..f7937701a3b 100644 --- a/htdocs/core/modules/facture/mod_facture_terre.php +++ b/htdocs/core/modules/facture/mod_facture_terre.php @@ -262,7 +262,7 @@ class mod_facture_terre extends ModeleNumRefFactures return $ref; } elseif ($mode == 'next') { $date = $invoice->date; // This is invoice date (not creation date) - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is diff --git a/htdocs/core/modules/modAi.class.php b/htdocs/core/modules/modAi.class.php new file mode 100644 index 00000000000..b2546e2553d --- /dev/null +++ b/htdocs/core/modules/modAi.class.php @@ -0,0 +1,570 @@ + + * Copyright (C) 2018-2019 Nicolas ZABOURI + * Copyright (C) 2019-2022 Frédéric France + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \defgroup ai Module Ai + * \brief Ai module descriptor. + * + * \file htdocs/ai/core/modules/modAi.class.php + * \ingroup ai + * \brief Description and activation file for module Ai + */ +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; + +/** + * Description and activation class for module Ai + */ +class modAi extends DolibarrModules +{ + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $langs, $conf; + + $this->db = $db; + + // Id for module (must be unique). + // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). + $this->numero = 4560; + + // Key text used to identify module (for permissions, menus, etc...) + $this->rights_class = 'ai'; + + // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' + // It is used to group modules by family in module setup page + $this->family = "mailings"; + + // Module position in the family on 2 digits ('01', '10', '20', ...) + $this->module_position = '50'; + + // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) + //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); + // Module label (no space allowed), used if translation string 'ModuleAiName' not found (Ai is name of module). + $this->name = preg_replace('/^mod/i', '', get_class($this)); + + // Module description, used if translation string 'ModuleAiDesc' not found (Ai is name of module). + $this->description = "AiDescription"; + // Used only if file README.md and README-LL.md not found. + $this->descriptionlong = "AiDescription"; + + // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' + $this->version = 'development'; + + // Key used in llx_const table to save module status enabled/disabled (where BOOKCAL is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + + // Name of image file used for this module. + // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' + // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' + // To use a supported fa-xxx css style of font awesome, use this->picto='xxx' + $this->picto = 'fa-microchip"'; + + // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) + $this->module_parts = array( + // Set this to 1 if module has its own trigger directory (core/triggers) + 'triggers' => 0, + // Set this to 1 if module has its own login method file (core/login) + 'login' => 0, + // Set this to 1 if module has its own substitution function file (core/substitutions) + 'substitutions' => 0, + // Set this to 1 if module has its own menus handler directory (core/menus) + 'menus' => 0, + // Set this to 1 if module overwrite template dir (core/tpl) + 'tpl' => 0, + // Set this to 1 if module has its own barcode directory (core/modules/barcode) + 'barcode' => 0, + // Set this to 1 if module has its own models directory (core/modules/xxx) + 'models' => 0, + // Set this to 1 if module has its own printing directory (core/modules/printing) + 'printing' => 0, + // Set this to 1 if module has its own theme directory (theme) + 'theme' => 0, + // Set this to relative path of css file if module has its own css file + 'css' => array( + // '/ai/css/ai.css.php', + ), + // Set this to relative path of js file if module must load a js on all pages + 'js' => array( + // '/ai/js/ai.js.php', + ), + // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context to 'all' + 'hooks' => array( + // 'data' => array( + // 'hookcontext1', + // 'hookcontext2', + // ), + // 'entity' => '0', + ), + // Set this to 1 if features of module are opened to external users + 'moduleforexternal' => 0, + ); + + // Data directories to create when module is enabled. + // Example: this->dirs = array("/ai/temp","/ai/subdir"); + $this->dirs = array("/ai/temp"); + + // Config pages. Put here list of php page, stored into ai/admin directory, to use to setup module. + $this->config_page_url = array("setup.php@ai"); + + // Dependencies + // A condition to hide module + $this->hidden = false; + // List of module class names as string that must be enabled if this module is enabled. Example: array('always'=>array('modModuleToEnable1','modModuleToEnable2'), 'FR'=>array('modModuleToEnableFR'...)) + $this->depends = array(); + $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) + $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) + + // The language file dedicated to your module + $this->langfiles = array("ai"); + + // Prerequisites + $this->phpmin = array(7, 0); // Minimum version of PHP required by module + + // Messages at activation + $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','MX'='textmx'...) + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','MX'='textmx'...) + //$this->automatic_activation = array('FR'=>'AiWasAutomaticallyActivatedBecauseOfYourCountryChoice'); + //$this->always_enabled = true; // If true, can't be disabled + + // Constants + // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) + // Example: $this->const=array(1 => array('BOOKCAL_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1), + // 2 => array('BOOKCAL_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1) + // ); + $this->const = array(); + + // Some keys to add into the overwriting translation tables + /*$this->overwrite_translation = array( + 'en_US:ParentCompany'=>'Parent company or reseller', + 'fr_FR:ParentCompany'=>'Maison mère ou revendeur' + )*/ + + if (!isset($conf->ai) || !isset($conf->ai->enabled)) { + $conf->ai = new stdClass(); + $conf->ai->enabled = 0; + } + + // Array to add new pages in new tabs + $this->tabs = array(); + // Example: + // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@ai:$user->rights->ai->read:/ai/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 + // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@ai:$user->rights->othermodule->read:/ai/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. + // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname + // + // Where objecttype can be + // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) + // 'contact' to add a tab in contact view + // 'contract' to add a tab in contract view + // 'group' to add a tab in group view + // 'intervention' to add a tab in intervention view + // 'invoice' to add a tab in customer invoice view + // 'invoice_supplier' to add a tab in supplier invoice view + // 'member' to add a tab in foundation member view + // 'opensurveypoll' to add a tab in opensurvey poll view + // 'order' to add a tab in customer order view + // 'order_supplier' to add a tab in supplier order view + // 'payment' to add a tab in payment view + // 'payment_supplier' to add a tab in supplier payment view + // 'product' to add a tab in product view + // 'propal' to add a tab in propal view + // 'project' to add a tab in project view + // 'stock' to add a tab in stock view + // 'thirdparty' to add a tab in third party view + // 'user' to add a tab in user view + + // Dictionaries + $this->dictionaries = array(); + /* Example: + $this->dictionaries=array( + 'langs'=>'ai@ai', + // List of tables we want to see into dictonnary editor + 'tabname'=>array("table1", "table2", "table3"), + // Label of tables + 'tablib'=>array("Table1", "Table2", "Table3"), + // Request to select fields + 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), + // Sort order + 'tabsqlsort'=>array("label ASC", "label ASC", "label ASC"), + // List of fields (result of select to show dictionary) + 'tabfield'=>array("code,label", "code,label", "code,label"), + // List of fields (list of fields to edit a record) + 'tabfieldvalue'=>array("code,label", "code,label", "code,label"), + // List of fields (list of fields for insert) + 'tabfieldinsert'=>array("code,label", "code,label", "code,label"), + // Name of columns with primary key (try to always name it 'rowid') + 'tabrowid'=>array("rowid", "rowid", "rowid"), + // Condition to show each dictionary + 'tabcond'=>array($conf->ai->enabled, $conf->ai->enabled, $conf->ai->enabled) + // Help tooltip for each fields of the dictionary + 'tabhelp'=>array(array('code'=>$langs->trans('CodeTooltipHelp'))) + ); + */ + + // Boxes/Widgets + // Add here list of php file(s) stored in ai/core/boxes that contains a class to show a widget. + $this->boxes = array( + // 0 => array( + // 'file' => 'aiwidget1.php@ai', + // 'note' => 'Widget provided by Ai', + // 'enabledbydefaulton' => 'Home', + // ), + // ... + ); + + // Cronjobs (List of cron jobs entries to add when module is enabled) + // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week + $this->cronjobs = array( + // 0 => array( + // 'label' => 'MyJob label', + // 'jobtype' => 'method', + // 'class' => '/ai/class/availabilities.class.php', + // 'objectname' => 'Availabilities', + // 'method' => 'doScheduledJob', + // 'parameters' => '', + // 'comment' => 'Comment', + // 'frequency' => 2, + // 'unitfrequency' => 3600, + // 'status' => 0, + // 'test' => '$conf->ai->enabled', + // 'priority' => 50, + // ), + ); + // Example: $this->cronjobs=array( + // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->ai->enabled', 'priority'=>50), + // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->ai->enabled', 'priority'=>50) + // ); + + // Permissions provided by this module + $this->rights = array(); + $r = 0; + // Add here entries to declare new permissions + /* BEGIN MODULEBUILDER PERMISSIONS */ + $this->rights[$r][0] = $this->numero . sprintf('%02d', (0 * 10) + 1); + $this->rights[$r][1] = 'Read objects of Ai'; + $this->rights[$r][4] = 'availabilities'; + $this->rights[$r][5] = 'read'; + $r++; + $this->rights[$r][0] = $this->numero . sprintf('%02d', (0 * 10) + 2); + $this->rights[$r][1] = 'Create/Update objects of Ai'; + $this->rights[$r][4] = 'availabilities'; + $this->rights[$r][5] = 'write'; + $r++; + $this->rights[$r][0] = $this->numero . sprintf('%02d', (0 * 10) + 3); + $this->rights[$r][1] = 'Delete objects of Ai'; + $this->rights[$r][4] = 'availabilities'; + $this->rights[$r][5] = 'delete'; + $r++; + $this->rights[$r][0] = $this->numero . sprintf('%02d', (1 * 10) + 1); + $this->rights[$r][1] = 'Read Calendar object of Ai'; + $this->rights[$r][4] = 'calendar'; + $this->rights[$r][5] = 'read'; + $r++; + $this->rights[$r][0] = $this->numero . sprintf('%02d', (1 * 10) + 2); + $this->rights[$r][1] = 'Create/Update Calendar object of Ai'; + $this->rights[$r][4] = 'calendar'; + $this->rights[$r][5] = 'write'; + $r++; + $this->rights[$r][0] = $this->numero . sprintf('%02d', (1 * 10) + 3); + $this->rights[$r][1] = 'Delete Calendar object of Ai'; + $this->rights[$r][4] = 'calendar'; + $this->rights[$r][5] = 'delete'; + $r++; + + /* END MODULEBUILDER PERMISSIONS */ + + // Main menu entries to add + $this->menu = array(); + $r = 0; + // Add here entries to declare new menus + /* BEGIN MODULEBUILDER TOPMENU */ + /*$this->menu[$r++] = array( + 'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'top', // This is a Top menu entry + 'titre'=>'ModuleAiName', + 'prefix' => img_picto('', $this->picto, 'class="pictofixedwidth valignmiddle"'), + 'mainmenu'=>'ai', + 'leftmenu'=>'', + 'url'=>'/ai/aiindex.php', + 'langs'=>'ai', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1000 + $r, + 'enabled'=>'$conf->ai->enabled', // Define condition to show or hide menu entry. Use '$conf->ai->enabled' if entry must be visible if module is enabled. + 'perms'=>'$user->rights->ai->availabilities->read', // Use 'perms'=>'$user->rights->ai->availabilities->read' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both + );*/ + /* END MODULEBUILDER TOPMENU */ + + /* BEGIN MODULEBUILDER LEFTMENU CALENDAR */ + $this->menu[$r++] = array( + 'fk_menu'=>'fk_mainmenu=agenda', + 'type'=>'left', + 'titre'=> 'MenuBookcalIndex', + 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth em92"'), + 'mainmenu'=>'agenda', + 'leftmenu'=> 'ai', + 'url'=> '/ai/aiindex.php', + 'langs'=> 'ai', + 'position'=> 1100+$r, + 'enabled'=> '1', + 'perms'=> '$user->rights->ai->read', + 'user'=> 0 + ); + + $this->menu[$r++]=array( + // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'fk_menu'=>'fk_mainmenu=agenda,fk_leftmenu=ai', + // This is a Left menu entry + 'type'=>'left', + 'titre'=>'Calendar', + 'mainmenu'=>'agenda', + 'leftmenu'=>'ai_list', + 'url'=>'/ai/list.php', + // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'langs'=>'ai', + 'position'=>1100+$r, + // Define condition to show or hide menu entry. Use '$conf->ai->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'enabled'=>'$conf->ai->enabled', + // Use 'perms'=>'$user->rights->ai->level1->level2' if you want your menu with a permission rules + 'perms'=>'$user->rights->ai->read', + 'target'=>'', + // 0=Menu for internal users, 1=external users, 2=both + 'user'=>2, + ); + $this->menu[$r++]=array( + // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'fk_menu'=>'fk_mainmenu=agenda,fk_leftmenu=ai_list', + // This is a Left menu entry + 'type'=>'left', + 'titre'=>'NewKey', + 'mainmenu'=>'agenda', + 'leftmenu'=>'ai_new_key', + 'url'=>'/ai/ai_card.php?action=create', + // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'langs'=>'ai', + 'position'=>1100+$r, + // Define condition to show or hide menu entry. Use '$conf->ai->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'enabled'=>'$conf->ai->enabled', + // Use 'perms'=>'$user->rights->ai->level1->level2' if you want your menu with a permission rules + 'perms'=>'$user->rights->ai->read', + 'target'=>'', + // 0=Menu for internal users, 1=external users, 2=both + 'user'=>2 + ); + /* END MODULEBUILDER LEFTMENU CALENDAR */ + + /* BEGIN MODULEBUILDER LEFTMENU AVAILABILITIES + $this->menu[$r++]=array( + 'fk_menu'=>'fk_mainmenu=ai', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', // This is a Left menu entry + 'titre'=>'Availabilities', + 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth valignmiddle"'), + 'mainmenu'=>'ai', + 'leftmenu'=>'availabilities', + 'url'=>'/ai/aiindex.php', + 'langs'=>'ai@ai', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1000+$r, + 'enabled'=>'$conf->ai->enabled', // Define condition to show or hide menu entry. Use '$conf->ai->enabled' if entry must be visible if module is enabled. + 'perms'=>'$user->rights->ai->availabilities->read', // Use 'perms'=>'$user->rights->ai->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both + ); + $this->menu[$r++]=array( + 'fk_menu'=>'fk_mainmenu=ai,fk_leftmenu=availabilities', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', // This is a Left menu entry + 'titre'=>'List_Availabilities', + 'mainmenu'=>'ai', + 'leftmenu'=>'ai_availabilities_list', + 'url'=>'/ai/availabilities_list.php', + 'langs'=>'ai@ai', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1000+$r, + 'enabled'=>'$conf->ai->enabled', // Define condition to show or hide menu entry. Use '$conf->ai->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms'=>'$user->rights->ai->availabilities->read', // Use 'perms'=>'$user->rights->ai->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both + ); + $this->menu[$r++]=array( + 'fk_menu'=>'fk_mainmenu=ai,fk_leftmenu=availabilities', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', // This is a Left menu entry + 'titre'=>'New_Availabilities', + 'mainmenu'=>'ai', + 'leftmenu'=>'ai_availabilities_new', + 'url'=>'/ai/availabilities_card.php?action=create', + 'langs'=>'ai@ai', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1000+$r, + 'enabled'=>'$conf->ai->enabled', // Define condition to show or hide menu entry. Use '$conf->ai->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms'=>'$user->rights->ai->availabilities->write', // Use 'perms'=>'$user->rights->ai->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both + ); + */ + + /* END MODULEBUILDER LEFTMENU AVAILABILITIES */ + // Exports profiles provided by this module + $r = 1; + /* BEGIN MODULEBUILDER EXPORT AVAILABILITIES */ + /* + $langs->load("agenda"); + $this->export_code[$r]=$this->rights_class.'_'.$r; + $this->export_label[$r]='AvailabilitiesLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_icon[$r]='availabilities@ai'; + // Define $this->export_fields_array, $this->export_TypeFields_array and $this->export_entities_array + $keyforclass = 'Availabilities'; $keyforclassfile='/ai/class/availabilities.class.php'; $keyforelement='availabilities@ai'; + include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; + //$this->export_fields_array[$r]['t.fieldtoadd']='FieldToAdd'; $this->export_TypeFields_array[$r]['t.fieldtoadd']='Text'; + //unset($this->export_fields_array[$r]['t.fieldtoremove']); + //$keyforclass = 'AvailabilitiesLine'; $keyforclassfile='/ai/class/availabilities.class.php'; $keyforelement='availabilitiesline@ai'; $keyforalias='tl'; + //include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; + $keyforselect='availabilities'; $keyforaliasextra='extra'; $keyforelement='availabilities@ai'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + //$keyforselect='availabilitiesline'; $keyforaliasextra='extraline'; $keyforelement='availabilitiesline@ai'; + //include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + //$this->export_dependencies_array[$r] = array('availabilitiesline'=>array('tl.rowid','tl.ref')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) + //$this->export_special_array[$r] = array('t.field'=>'...'); + //$this->export_examplevalues_array[$r] = array('t.field'=>'Example'); + //$this->export_help_array[$r] = array('t.field'=>'FieldDescHelp'); + $this->export_sql_start[$r]='SELECT DISTINCT '; + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'availabilities as t'; + //$this->export_sql_end[$r] =' LEFT JOIN '.MAIN_DB_PREFIX.'availabilities_line as tl ON tl.fk_availabilities = t.rowid'; + $this->export_sql_end[$r] .=' WHERE 1 = 1'; + $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('availabilities').')'; + $r++; */ + /* END MODULEBUILDER EXPORT AVAILABILITIES */ + + // Imports profiles provided by this module + $r = 1; + /* BEGIN MODULEBUILDER IMPORT AVAILABILITIES */ + /* + $langs->load("agenda"); + $this->import_code[$r]=$this->rights_class.'_'.$r; + $this->import_label[$r]='AvailabilitiesLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->import_icon[$r]='availabilities@ai'; + $this->import_tables_array[$r] = array('t' => MAIN_DB_PREFIX.'ai_availabilities', 'extra' => MAIN_DB_PREFIX.'ai_availabilities_extrafields'); + $this->import_tables_creator_array[$r] = array('t' => 'fk_user_author'); // Fields to store import user id + $import_sample = array(); + $keyforclass = 'Availabilities'; $keyforclassfile='/ai/class/availabilities.class.php'; $keyforelement='availabilities@ai'; + include DOL_DOCUMENT_ROOT.'/core/commonfieldsinimport.inc.php'; + $import_extrafield_sample = array(); + $keyforselect='availabilities'; $keyforaliasextra='extra'; $keyforelement='availabilities@ai'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinimport.inc.php'; + $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'ai_availabilities'); + $this->import_regex_array[$r] = array(); + $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample); + $this->import_updatekeys_array[$r] = array('t.ref' => 'Ref'); + $this->import_convertvalue_array[$r] = array( + 't.ref' => array( + 'rule'=>'getrefifauto', + 'class'=>(empty($conf->global->BOOKCAL_AVAILABILITIES_ADDON) ? 'mod_availabilities_standard' : $conf->global->BOOKCAL_AVAILABILITIES_ADDON), + 'path'=>"/core/modules/commande/".(empty($conf->global->BOOKCAL_AVAILABILITIES_ADDON) ? 'mod_availabilities_standard' : $conf->global->BOOKCAL_AVAILABILITIES_ADDON).'.php' + 'classobject'=>'Availabilities', + 'pathobject'=>'/ai/class/availabilities.class.php', + ), + 't.fk_soc' => array('rule' => 'fetchidfromref', 'file' => '/societe/class/societe.class.php', 'class' => 'Societe', 'method' => 'fetch', 'element' => 'ThirdParty'), + 't.fk_user_valid' => array('rule' => 'fetchidfromref', 'file' => '/user/class/user.class.php', 'class' => 'User', 'method' => 'fetch', 'element' => 'user'), + 't.fk_mode_reglement' => array('rule' => 'fetchidfromcodeorlabel', 'file' => '/compta/paiement/class/cpaiement.class.php', 'class' => 'Cpaiement', 'method' => 'fetch', 'element' => 'cpayment'), + ); + $r++; */ + /* END MODULEBUILDER IMPORT AVAILABILITIES */ + } + + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + global $conf, $langs; + + // $result = $this->_load_tables('/install/mysql/', 'ai'); + // if ($result < 0) { + // return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default') + // } + + // Create extrafields during init + //include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + //$extrafields = new ExtraFields($this->db); + //$result1=$extrafields->addExtraField('ai_myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'ai@ai', '$conf->ai->enabled'); + //$result2=$extrafields->addExtraField('ai_myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'ai@ai', '$conf->ai->enabled'); + //$result3=$extrafields->addExtraField('ai_myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'ai@ai', '$conf->ai->enabled'); + //$result4=$extrafields->addExtraField('ai_myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'ai@ai', '$conf->ai->enabled'); + //$result5=$extrafields->addExtraField('ai_myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'ai@ai', '$conf->ai->enabled'); + + // Permissions + $this->remove($options); + + $sql = array(); + + // Document templates + $moduledir = dol_sanitizeFileName('ai'); + $myTmpObjects = array(); + $myTmpObjects['Availabilities'] = array('includerefgeneration'=>0, 'includedocgeneration'=>0); + + // foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { + // if ($myTmpObjectKey == 'Availabilities') { + // continue; + // } + // if ($myTmpObjectArray['includerefgeneration']) { + // $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/'.$moduledir.'/template_availabilitiess.odt'; + // $dirodt = DOL_DATA_ROOT.'/doctemplates/'.$moduledir; + // $dest = $dirodt.'/template_availabilitiess.odt'; + + // if (file_exists($src) && !file_exists($dest)) { + // require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + // dol_mkdir($dirodt); + // $result = dol_copy($src, $dest, 0, 0); + // if ($result < 0) { + // $langs->load("errors"); + // $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest); + // return 0; + // } + // } + + // $sql = array_merge($sql, array( + // "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'standard_".strtolower($myTmpObjectKey)."' AND type = '".$this->db->escape(strtolower($myTmpObjectKey))."' AND entity = ".((int) $conf->entity), + // "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('standard_".strtolower($myTmpObjectKey)."', '".$this->db->escape(strtolower($myTmpObjectKey))."', ".((int) $conf->entity).")", + // "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'generic_".strtolower($myTmpObjectKey)."_odt' AND type = '".$this->db->escape(strtolower($myTmpObjectKey))."' AND entity = ".((int) $conf->entity), + // "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('generic_".strtolower($myTmpObjectKey)."_odt', '".$this->db->escape(strtolower($myTmpObjectKey))."', ".((int) $conf->entity).")" + // )); + // } + // } + + return $this->_init($sql, $options); + } + + /** + * Function called when module is disabled. + * Remove from database constants, boxes and permissions from Dolibarr database. + * Data directories are not deleted + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function remove($options = '') + { + $sql = array(); + return $this->_remove($sql, $options); + } +} diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index c27d72f7f67..183bae2e0a6 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -6,6 +6,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2021 Alexandre Spangaro * Copyright (C) 2022 Frédéric France + * Copyright (C) 2024 William Mead * * 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 @@ -503,7 +504,7 @@ class modFacture extends DolibarrModules 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra', 't.libelle'=>"ThirdPartyType", // 'ce.code'=>"Staff", "cfj.libelle"=>"JuridicalStatus", - 'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_client'=>'RefCustomer', + 'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_client'=>'RefCustomer', 'f.fk_facture_source'=>'SourceInvoiceId', 'f.type'=>"Type", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>"DateDue", 'f.total_ht'=>"TotalHT", 'f.total_ttc'=>"TotalTTC", 'f.total_tva'=>"TotalVAT", 'f.localtax1'=>'LT1', 'f.localtax2'=>'LT2', 'f.paye'=>"InvoicePaidCompletely", 'f.fk_statut'=>'InvoiceStatus', 'f.close_code'=>'EarlyClosingReason', 'f.close_note'=>'EarlyClosingComment', 'none.rest'=>'Rest', @@ -546,7 +547,7 @@ class modFacture extends DolibarrModules 's.rowid'=>'Numeric', 's.nom'=>'Text', 'ps.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 'cd.nom'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text', 't.libelle'=>"Text", // 'ce.code'=>"List:c_effectif:libelle:code", "cfj.libelle"=>"Text", - 'f.rowid'=>'Numeric', 'f.ref'=>"Text", 'f.ref_client'=>'Text', 'f.type'=>"Numeric", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>"Date", 'f.fk_mode_reglement'=>'Numeric', + 'f.rowid'=>'Numeric', 'f.ref'=>"Text", 'f.ref_client'=>'Text', 'f.fk_facture_source'=>'Numeric', 'f.type'=>"Numeric", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>"Date", 'f.fk_mode_reglement'=>'Numeric', 'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.total_tva'=>"Numeric", 'f.localtax1'=>'Numeric', 'f.localtax2'=>'Numeric', 'f.paye'=>"Boolean", 'f.fk_statut'=>'Numeric', 'f.close_code'=>'Text', 'f.close_note'=>'Text', 'none.rest'=>"NumericCompute", 'f.note_private'=>"Text", 'f.note_public'=>"Text", @@ -630,7 +631,7 @@ class modFacture extends DolibarrModules 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra', - 'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_client'=>'RefCustomer', + 'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_client'=>'RefCustomer', 'f.fk_facture_source'=>'SourceInvoiceId', 'f.type'=>"Type", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>"DateDue", 'f.total_ht'=>"TotalHT", 'f.total_ttc'=>"TotalTTC", 'f.total_tva'=>"TotalVAT", 'f.localtax1'=>'LT1', 'f.localtax2'=>'LT2', 'f.paye'=>"InvoicePaidCompletely", 'f.fk_statut'=>'InvoiceStatus', 'f.close_code'=>'EarlyClosingReason', 'f.close_note'=>'EarlyClosingComment', 'none.rest'=>'Rest', @@ -655,7 +656,7 @@ class modFacture extends DolibarrModules $this->export_TypeFields_array[$r] = array( 's.rowid'=>'Numeric', 's.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 'cd.nom'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text', - 'f.rowid'=>"Numeric", 'f.ref'=>"Text", 'f.ref_client'=>'Text', 'f.type'=>"Numeric", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>"Date", + 'f.rowid'=>"Numeric", 'f.ref'=>"Text", 'f.ref_client'=>'Text', 'f.fk_facture_source'=>'Numeric', 'f.type'=>"Numeric", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>"Date", 'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.total_tva'=>"Numeric", 'f.localtax1'=>'Numeric', 'f.localtax2'=>'Numeric', 'f.paye'=>"Boolean", 'f.fk_statut'=>'Status', 'f.close_code'=>'Text', 'f.close_note'=>'Text', 'none.rest'=>'NumericCompute', 'f.note_private'=>"Text", 'f.note_public'=>"Text", 'f.fk_user_author'=>'Numeric', 'uc.login'=>'Text', 'f.fk_user_valid'=>'Numeric', 'uv.login'=>'Text', diff --git a/htdocs/core/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php index 49b1ed8f19d..350953ad4c6 100644 --- a/htdocs/core/modules/modResource.class.php +++ b/htdocs/core/modules/modResource.class.php @@ -92,7 +92,7 @@ class modResource extends DolibarrModules // List of modules id that must be enabled if this module is enabled $this->depends = array(); // List of modules id to disable if this one is disabled - $this->requiredby = array('modPlace'); + $this->requiredby = array(''); // Minimum version of PHP required by module $this->phpmin = array(7, 0); diff --git a/htdocs/core/modules/modStockTransfer.class.php b/htdocs/core/modules/modStockTransfer.class.php index 73e4a7c9397..e8d2a452d56 100644 --- a/htdocs/core/modules/modStockTransfer.class.php +++ b/htdocs/core/modules/modStockTransfer.class.php @@ -63,7 +63,7 @@ class modStockTransfer extends DolibarrModules // Used only if file README.md and README-LL.md not found. $this->descriptionlong = "Advanced management of stock transfer orders with generation of stock transfer sheets"; // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' - $this->version = 'dolibarr'; + $this->version = 'experimental'; // Url to the file with your last numberversion of this module //$this->url_last_version = 'http://www.example.com/versionmodule.txt'; diff --git a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php index f77891d4635..33fc9caee68 100644 --- a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php +++ b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php @@ -132,7 +132,7 @@ class pdf_vinci extends ModelePDFMo * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs = null, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user, $langs, $conf, $hookmanager, $mysoc; diff --git a/htdocs/core/modules/mrp/mod_mo_standard.php b/htdocs/core/modules/mrp/mod_mo_standard.php index c27c36c8849..72ea06d05ab 100644 --- a/htdocs/core/modules/mrp/mod_mo_standard.php +++ b/htdocs/core/modules/mrp/mod_mo_standard.php @@ -142,7 +142,7 @@ class mod_mo_standard extends ModeleNumRefMos //$date=time(); $date = $object->date_creation; - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is diff --git a/htdocs/core/modules/product_batch/mod_lot_standard.php b/htdocs/core/modules/product_batch/mod_lot_standard.php index f6b674cf3f6..b63aff30a84 100644 --- a/htdocs/core/modules/product_batch/mod_lot_standard.php +++ b/htdocs/core/modules/product_batch/mod_lot_standard.php @@ -144,7 +144,7 @@ class mod_lot_standard extends ModeleNumRefBatch //$date=time(); $date = dol_now(); - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; diff --git a/htdocs/core/modules/product_batch/mod_sn_standard.php b/htdocs/core/modules/product_batch/mod_sn_standard.php index 42d55ff92b7..5f569baa498 100644 --- a/htdocs/core/modules/product_batch/mod_sn_standard.php +++ b/htdocs/core/modules/product_batch/mod_sn_standard.php @@ -144,7 +144,7 @@ class mod_sn_standard extends ModeleNumRefBatch //$date=time(); $date = dol_now(); - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php index 7973c3425f9..9d6bc9a33c9 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php @@ -1602,7 +1602,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes ), 'border-left' => true, // add left line separator ); - if ($conf->global->PRODUCT_USE_UNITS) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $this->cols['unit']['status'] = true; } diff --git a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php index 96e637adca2..0fdea1e01fe 100644 --- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php @@ -2,7 +2,7 @@ /* Copyright (C) 2010-2011 Juanjo Menent * Copyright (C) 2010-2014 Laurent Destailleur * Copyright (C) 2015 Marcos García - * Copyright (C) 2018-2021 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * * 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 @@ -156,7 +156,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs = null, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user, $langs, $conf, $mysoc, $hookmanager, $nblines; diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 61681bc51e0..14de46cbd33 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -5,7 +5,7 @@ * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2015 Marcos García * Copyright (C) 2017 Ferran Marcet - * Copyright (C) 2018-2022 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2023 William Mead * * This program is free software; you can redistribute it and/or modify @@ -144,7 +144,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs = null, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user, $langs, $conf, $hookmanager, $mysoc, $nblines; diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index c5319938818..3b7f2f417c0 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -155,7 +155,7 @@ class pdf_standard extends ModelePDFSuppliersPayments * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs = null, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user, $langs, $conf, $mysoc, $hookmanager; diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php index f7db023cd8f..fccce3eaf22 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php @@ -143,7 +143,7 @@ class pdf_zenith extends ModelePDFSupplierProposal * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs = null, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user, $langs, $conf, $hookmanager, $mysoc, $nblines; diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index 2eab1e2d90e..e358e2c0f76 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -138,32 +138,32 @@ if ($action == 'presend') { } if ($object->element == 'salary' && getDolGlobalString('INVOICE_EMAIL_SENDER')) { $formmail->frommail = getDolGlobalString('SINVOICE_EMAIL_SENDER'); - $formmail->fromname = (getDolGlobalString('INVOICE_EMAIL_SENDER_NAME') ? $conf->global->INVOICE_EMAIL_SENDER_NAME : ''); + $formmail->fromname = getDolGlobalString('INVOICE_EMAIL_SENDER_NAME', ''); $formmail->fromtype = 'special'; } if ($object->element === 'facture' && getDolGlobalString('INVOICE_EMAIL_SENDER')) { $formmail->frommail = getDolGlobalString('INVOICE_EMAIL_SENDER'); - $formmail->fromname = (getDolGlobalString('INVOICE_EMAIL_SENDER_NAME') ? $conf->global->INVOICE_EMAIL_SENDER_NAME : ''); + $formmail->fromname = getDolGlobalString('INVOICE_EMAIL_SENDER_NAME', ''); $formmail->fromtype = 'special'; } if ($object->element === 'shipping' && getDolGlobalString('SHIPPING_EMAIL_SENDER')) { $formmail->frommail = getDolGlobalString('SHIPPING_EMAIL_SENDER'); - $formmail->fromname = (getDolGlobalString('SHIPPING_EMAIL_SENDER_NAME') ? $conf->global->SHIPPING_EMAIL_SENDER_NAME : ''); + $formmail->fromname = getDolGlobalString('SHIPPING_EMAIL_SENDER_NAME', ''); $formmail->fromtype = 'special'; } if ($object->element === 'commande' && getDolGlobalString('COMMANDE_EMAIL_SENDER')) { $formmail->frommail = getDolGlobalString('COMMANDE_EMAIL_SENDER'); - $formmail->fromname = (getDolGlobalString('COMMANDE_EMAIL_SENDER_NAME') ? $conf->global->COMMANDE_EMAIL_SENDER_NAME : ''); + $formmail->fromname = getDolGlobalString('COMMANDE_EMAIL_SENDER_NAME', ''); $formmail->fromtype = 'special'; } if ($object->element === 'order_supplier' && getDolGlobalString('ORDER_SUPPLIER_EMAIL_SENDER')) { $formmail->frommail = getDolGlobalString('ORDER_SUPPLIER_EMAIL_SENDER'); - $formmail->fromname = (getDolGlobalString('ORDER_SUPPLIER_EMAIL_SENDER_NAME') ? $conf->global->ORDER_SUPPLIER_EMAIL_SENDER_NAME : ''); + $formmail->fromname = getDolGlobalString('ORDER_SUPPLIER_EMAIL_SENDER_NAME', ''); $formmail->fromtype = 'special'; } if ($object->element === 'recruitmentcandidature') { - $formmail->frommail = (getDolGlobalString('RECRUITMENT_EMAIL_SENDER') ? $conf->global->RECRUITMENT_EMAIL_SENDER : $recruitermail); - $formmail->fromname = (getDolGlobalString('RECRUITMENT_EMAIL_SENDER_NAME') ? $conf->global->RECRUITMENT_EMAIL_SENDER_NAME : (!empty($recruitername) ? $recruitername : '')); + $formmail->frommail = getDolGlobalString('RECRUITMENT_EMAIL_SENDER', (!empty($recruitermail) ? $recruitermail : '')); + $formmail->fromname = getDolGlobalString('RECRUITMENT_EMAIL_SENDER_NAME', (!empty($recruitername) ? $recruitername : '')); $formmail->fromtype = 'special'; } @@ -387,7 +387,6 @@ if ($action == 'presend') { $formmail->param['id'] = $object->id; $formmail->param['returnurl'] = $_SERVER["PHP_SELF"].'?id='.$object->id; $formmail->param['fileinit'] = array($file); - // Show form print $formmail->get_form(); diff --git a/htdocs/core/tpl/resource_add.tpl.php b/htdocs/core/tpl/resource_add.tpl.php index 0595d636956..7fd994793d8 100644 --- a/htdocs/core/tpl/resource_add.tpl.php +++ b/htdocs/core/tpl/resource_add.tpl.php @@ -32,7 +32,7 @@ $out .= '
'; $events = array(); $out .= img_picto('', 'resource', 'class="pictofixedwidth"'); -$out .= $formresources->select_resource_list('', 'fk_resource', '', 1, 1, 0, $events, '', 2, null); +$out .= $formresources->select_resource_list(0, 'fk_resource', '', 1, 1, 0, $events, '', 2, null); $out .= '
'; $out .= '
'; diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 1431dc400fd..7e55e65f8f8 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -188,6 +188,7 @@ class Cronjob extends CommonObject const STATUS_DISABLED = 0; const STATUS_ENABLED = 1; const STATUS_ARCHIVED = 2; + const MAXIMUM_LENGTH_FOR_LASTOUTPUT_FIELD = 65535; /** @@ -1223,6 +1224,16 @@ class Cronjob extends CommonObject // Run a method if ($this->jobtype == 'method') { + // Deny to launch a method from a deactivated module + if (!empty($this->module_name) && !isModEnabled(strtolower($this->module_name))) { + $this->error = $langs->transnoentitiesnoconv('CronMethodNotAllowed', $this->methodename, $this->objectname); + dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); + $this->lastoutput = $this->error; + $this->lastresult = -1; + $retval = $this->lastresult; + $error++; + } + // load classes if (!$error) { $ret = dol_include_once($this->classesname); @@ -1313,13 +1324,13 @@ class Cronjob extends CommonObject dol_syslog(get_class($this)."::run_jobs END result=".$result." error=".$errmsg, LOG_ERR); $this->error = $errmsg; - $this->lastoutput = (!empty($object->output) ? $object->output."\n" : "").$errmsg; + $this->lastoutput = dol_substr((empty($object->output) ? "" : $object->output."\n").$errmsg, 0, $this::MAXIMUM_LENGTH_FOR_LASTOUTPUT_FIELD, 'UTF-8', 1); $this->lastresult = is_numeric($result) ? $result : -1; $retval = $this->lastresult; $error++; } else { dol_syslog(get_class($this)."::run_jobs END"); - $this->lastoutput = (!empty($object->output) ? $object->output : ""); + $this->lastoutput = dol_substr((empty($object->output) ? "" : $object->output."\n").$errmsg, 0, $this::MAXIMUM_LENGTH_FOR_LASTOUTPUT_FIELD, 'UTF-8', 1); $this->lastresult = var_export($result, true); $retval = $this->lastresult; } diff --git a/htdocs/dav/fileserver.php b/htdocs/dav/fileserver.php index 9ebe9ae4099..d6df1a7af4d 100644 --- a/htdocs/dav/fileserver.php +++ b/htdocs/dav/fileserver.php @@ -49,7 +49,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/dav/dav.class.php'; require_once DOL_DOCUMENT_ROOT.'/dav/dav.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/includes/sabre/autoload.php'; +//require_once DOL_DOCUMENT_ROOT.'/includes/autoload.php'; $user = new User($db); diff --git a/htdocs/don/card.php b/htdocs/don/card.php index b8e7c01c763..44e5b207156 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -324,6 +324,30 @@ if (empty($reshook)) { $object->setProject($projectid); } + if ($action == 'update_extras') { + $object->fetch($id); + + $object->oldcopy = dol_clone($object); + + // Fill array 'array_options' with data from update form + $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); + + if ($ret < 0) { + $error++; + } + + if (!$error) { + $result = $object->insertExtraFields('DON_MODIFY'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } + } + + if ($error) { + $action = 'edit_extras'; + } + } // Actions to build doc include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index bc0f189cdd7..92b371ef5e9 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -877,15 +877,13 @@ class Don extends CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the indicators this->nb for the state board * * @return int Return integer <0 if KO, >0 if OK */ - public function load_state_board() + public function loadStateBoard() { - // phpcs:enable $this->nb = array(); $sql = "SELECT count(d.rowid) as nb"; diff --git a/htdocs/ecm/dir_card.php b/htdocs/ecm/dir_card.php index b45dc44c185..3d9dc31336f 100644 --- a/htdocs/ecm/dir_card.php +++ b/htdocs/ecm/dir_card.php @@ -204,9 +204,9 @@ if ($action == 'update' && !GETPOST('cancel', 'alpha') && $permissiontoadd) { // Fetch was already done $ecmdir->label = dol_sanitizeFileName(GETPOST("label")); - $fk_parent = GETPOST("catParent", 'int'); - if ($fk_parent == "-1") { - $ecmdir->fk_parent = "0"; + $fk_parent = GETPOSTINT("catParent"); + if ($fk_parent == -1) { + $ecmdir->fk_parent = 0; } else { $ecmdir->fk_parent = $fk_parent; } diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index b23e16dfa04..afe1b7b0836 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -874,6 +874,7 @@ if (empty($reshook)) { } $triggersendname = 'SHIPPING_SENTBYMAIL'; $paramname = 'id'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_SHIPMENT_TO'; $mode = 'emailfromshipment'; $trackid = 'shi'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 605b1979fd3..bd764eb966c 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -259,7 +259,7 @@ if (empty($reshook)) { $object->date_debut = $date_start; $object->date_fin = $date_end; - $object->fk_user_author = GETPOST('fk_user_author', 'int'); + $object->fk_user_author = GETPOSTINT('fk_user_author'); if (!($object->fk_user_author > 0)) { $object->fk_user_author = $user->id; } @@ -284,7 +284,7 @@ if (empty($reshook)) { $object->status = 1; $object->fk_c_paiement = GETPOST('fk_c_paiement', 'int'); - $object->fk_user_validator = GETPOST('fk_user_validator', 'int'); + $object->fk_user_validator = GETPOSTINT('fk_user_validator'); $object->note_public = GETPOST('note_public', 'restricthtml'); $object->note_private = GETPOST('note_private', 'restricthtml'); // Fill array 'array_options' with data from add form @@ -333,7 +333,7 @@ if (empty($reshook)) { $object->date_fin = $date_end; if ($object->status < 3) { - $object->fk_user_validator = GETPOST('fk_user_validator', 'int'); + $object->fk_user_validator = GETPOSTINT('fk_user_validator'); } $object->fk_c_paiement = GETPOST('fk_c_paiement', 'int'); diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 337e60410f8..a46b61ad3b1 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -2337,10 +2337,13 @@ class ExpenseReport extends CommonObject */ public function periode_existe($fuser, $date_debut, $date_fin) { + global $conf; + // phpcs:enable $sql = "SELECT rowid, date_debut, date_fin"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; - $sql .= " WHERE fk_user_author = ".((int) $fuser->id); + $sql .= " WHERE entity = ".((int) $conf->entity); // not shared, only for the current entity + $sql .= " AND fk_user_author = ".((int) $fuser->id); dol_syslog(get_class($this)."::periode_existe sql=".$sql); $result = $this->db->query($sql); @@ -2479,15 +2482,13 @@ class ExpenseReport extends CommonObject return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the indicators this->nb for the state board * * @return int Return integer <0 if KO, >0 if OK */ - public function load_state_board() + public function loadStateBoard() { - // phpcs:enable global $conf, $user; $this->nb = array(); diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 018c2e3f076..b5e2fe02407 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -207,15 +207,13 @@ class Fichinter extends CommonObject $this->db = $db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators into this->nb for board * * @return int Return integer <0 if KO, >0 if OK */ - public function load_state_board() + public function loadStateBoard() { - // phpcs:enable global $user; $this->nb = array(); diff --git a/htdocs/fichinter/class/fichinterrec.class.php b/htdocs/fichinter/class/fichinterrec.class.php index 671c566009d..beb2d6358c2 100644 --- a/htdocs/fichinter/class/fichinterrec.class.php +++ b/htdocs/fichinter/class/fichinterrec.class.php @@ -471,7 +471,7 @@ class FichinterRec extends Fichinter * @param double $remise_percent Percentage of discount on line * @param string $price_base_type HT or TTC * @param int $info_bits Bits for type of lines - * @param int $fk_remise_except Id discount + * @param int $fk_remise_except Id discount (not used) * @param double $pu_ttc Unit price with tax (> 0 even for credit note) * @param int $type Type of line (0=product, 1=service) * @param int $special_code Special code @@ -479,7 +479,7 @@ class FichinterRec extends Fichinter * @param string $fk_unit Unit * @return int Return integer <0 if KO, Id of line if OK */ - public function addline($desc, $duration, $date, $rang = -1, $pu_ht = 0, $qty = 0, $txtva = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $special_code = 0, $label = '', $fk_unit = null) + public function addline($desc, $duration, $date, $rang = -1, $pu_ht = 0, $qty = 0, $txtva = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = 0, $pu_ttc = 0, $type = 0, $special_code = 0, $label = '', $fk_unit = null) { global $mysoc; diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index ccd50b505e3..2c6251a1249 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -61,12 +61,17 @@ class SupplierInvoices extends DolibarrApi * @param int $id ID of supplier invoice * @return Object Object with cleaned properties * - * @throws RestException + * @throws RestException 403 + * @throws RestException 404 */ public function get($id) { if (!DolibarrApiAccess::$user->hasRight("fournisseur", "facture", "lire")) { - throw new RestException(401); + throw new RestException(403); + } + + if (!DolibarrApi::_checkAccessToResource('fournisseur', $id, 'facture_fourn', 'facture')) { + throw new RestException(403, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); } $result = $this->invoice->fetch($id); @@ -74,10 +79,6 @@ class SupplierInvoices extends DolibarrApi throw new RestException(404, 'Supplier invoice not found'); } - if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { - throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); - } - $this->invoice->fetchObjectLinked(); return $this->_cleanObjectDatas($this->invoice); } @@ -101,10 +102,8 @@ class SupplierInvoices extends DolibarrApi */ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '', $properties = '') { - global $db; - if (!DolibarrApiAccess::$user->hasRight("fournisseur", "facture", "lire")) { - throw new RestException(401); + throw new RestException(403); } $obj_ret = array(); @@ -196,13 +195,13 @@ class SupplierInvoices extends DolibarrApi * * @return int ID of supplier invoice * - * @throws RestException 401 + * @throws RestException 403 * @throws RestException 500 System error */ public function post($request_data = null) { if (!DolibarrApiAccess::$user->hasRight("fournisseur", "facture", "creer")) { - throw new RestException(401, "Insuffisant rights"); + throw new RestException(403, "Insuffisant rights"); } // Check mandatory fields $result = $this->_validate($request_data); @@ -234,13 +233,17 @@ class SupplierInvoices extends DolibarrApi * * @return int * - * @throws RestException 401 + * @throws RestException 403 * @throws RestException 404 */ public function put($id, $request_data = null) { if (!DolibarrApiAccess::$user->hasRight("fournisseur", "facture", "creer")) { - throw new RestException(401); + throw new RestException(403); + } + + if (!DolibarrApi::_checkAccessToResource('fournisseur', $id, 'facture_fourn', 'facture')) { + throw new RestException(403, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); } $result = $this->invoice->fetch($id); @@ -248,10 +251,6 @@ class SupplierInvoices extends DolibarrApi throw new RestException(404, 'Supplier invoice not found'); } - if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { - throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); - } - foreach ($request_data as $field => $value) { if ($field == 'id') { continue; @@ -279,24 +278,23 @@ class SupplierInvoices extends DolibarrApi * * @return array * - * @throws RestException 401 + * @throws RestException 403 * @throws RestException 404 * @throws RestException 500 System error */ public function delete($id) { if (!DolibarrApiAccess::$user->hasRight("fournisseur", "facture", "supprimer")) { - throw new RestException(401); + throw new RestException(403); + } + if (!DolibarrApi::_checkAccessToResource('fournisseur', $id, 'facture_fourn', 'facture')) { + throw new RestException(403, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); } $result = $this->invoice->fetch($id); if (!$result) { throw new RestException(404, 'Supplier invoice not found'); } - if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { - throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); - } - if ($this->invoice->delete(DolibarrApiAccess::$user) < 0) { throw new RestException(500, 'Error when deleting invoice'); } @@ -321,7 +319,7 @@ class SupplierInvoices extends DolibarrApi * @return array * * @throws RestException 304 - * @throws RestException 401 + * @throws RestException 403 * @throws RestException 404 * @throws RestException 405 * @throws RestException 500 System error @@ -329,17 +327,18 @@ class SupplierInvoices extends DolibarrApi public function validate($id, $idwarehouse = 0, $notrigger = 0) { if (!DolibarrApiAccess::$user->hasRight("fournisseur", "facture", "creer")) { - throw new RestException(401); + throw new RestException(403); } + + if (!DolibarrApi::_checkAccessToResource('fournisseur', $id, 'facture_fourn', 'facture')) { + throw new RestException(403, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); + } + $result = $this->invoice->fetch($id); if (!$result) { throw new RestException(404, 'Invoice not found'); } - if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { - throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); - } - $result = $this->invoice->validate(DolibarrApiAccess::$user, '', $idwarehouse, $notrigger); if ($result == 0) { throw new RestException(304, 'Error nothing done. The invoice is already validated'); @@ -365,21 +364,21 @@ class SupplierInvoices extends DolibarrApi * * @return array * @throws RestException 400 - * @throws RestException 401 + * @throws RestException 403 * @throws RestException 404 * @throws RestException 405 */ public function getPayments($id) { - if (!DolibarrApiAccess::$user->hasRight("fournisseur", "facture", "lire")) { - throw new RestException(401); - } if (empty($id)) { throw new RestException(400, 'Invoice ID is mandatory'); } - if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { - throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); + if (!DolibarrApiAccess::$user->hasRight("fournisseur", "facture", "lire")) { + throw new RestException(403); + } + if (!DolibarrApi::_checkAccessToResource('fournisseur', $id, 'facture_fourn', 'facture')) { + throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $result = $this->invoice->fetch($id); @@ -413,23 +412,27 @@ class SupplierInvoices extends DolibarrApi * @url POST {id}/payments * * @return int Payment ID + * * @throws RestException 400 - * @throws RestException 401 + * @throws RestException 403 * @throws RestException 404 */ public function addPayment($id, $datepaye, $payment_mode_id, $closepaidinvoices, $accountid, $num_payment = '', $comment = '', $chqemetteur = '', $chqbank = '', $amount = null) { - global $conf; - - if (!DolibarrApiAccess::$user->hasRight("fournisseur", "facture", "creer")) { - throw new RestException(403); - } if (empty($id)) { throw new RestException(400, 'Invoice ID is mandatory'); } - if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { - throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); + if (!DolibarrApiAccess::$user->hasRight("fournisseur", "facture", "creer")) { + throw new RestException(403); + } + if (!DolibarrApi::_checkAccessToResource('fournisseur', $id, 'facture_fourn', 'facture')) { + throw new RestException(403, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); + } + + $result = $this->invoice->fetch($id); + if (!$result) { + throw new RestException(404, 'Invoice not found'); } if (isModEnabled("banque")) { @@ -442,12 +445,6 @@ class SupplierInvoices extends DolibarrApi throw new RestException(400, 'Payment mode ID is mandatory'); } - - $result = $this->invoice->fetch($id); - if (!$result) { - throw new RestException(404, 'Invoice not found'); - } - if (null !== $amount && $amount > 0) { // We use the amount given in parameter $paymentamount = $amount; @@ -508,11 +505,17 @@ class SupplierInvoices extends DolibarrApi * @url GET {id}/lines * * @return array + * + * @throws RestException 403 + * @throws RestException 404 */ public function getLines($id) { if (!DolibarrApiAccess::$user->hasRight("fournisseur", "facture", "creer")) { - throw new RestException(401); + throw new RestException(403); + } + if (!DolibarrApi::_checkAccessToResource('fournisseur', $id, 'facture_fourn', 'facture')) { + throw new RestException(403, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); } $result = $this->invoice->fetch($id); @@ -520,9 +523,6 @@ class SupplierInvoices extends DolibarrApi throw new RestException(404, 'Supplier invoice not found'); } - if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { - throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); - } $this->invoice->fetch_lines(); $result = array(); foreach ($this->invoice->lines as $line) { @@ -544,11 +544,18 @@ class SupplierInvoices extends DolibarrApi * @url POST {id}/lines * * @return int|bool + * + * @throws RestException 403 + * @throws RestException 404 */ public function postLine($id, $request_data = null) { if (!DolibarrApiAccess::$user->hasRight("fournisseur", "facture", "creer")) { - throw new RestException(401); + throw new RestException(403); + } + + if (!DolibarrApi::_checkAccessToResource('fournisseur', $id, 'facture_fourn', 'facture')) { + throw new RestException(403, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); } $result = $this->invoice->fetch($id); @@ -556,10 +563,6 @@ class SupplierInvoices extends DolibarrApi throw new RestException(404, 'Supplier invoice not found'); } - if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { - throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); - } - $request_data = (object) $request_data; $request_data->description = sanitizeVal($request_data->description, 'restricthtml'); @@ -608,14 +611,18 @@ class SupplierInvoices extends DolibarrApi * * @return object * - * @throws RestException 401 Not allowed + * @throws RestException 403 Not allowed * @throws RestException 404 Not found * @throws RestException 304 Error */ public function putLine($id, $lineid, $request_data = null) { if (!DolibarrApiAccess::$user->hasRight("fournisseur", "facture", "creer")) { - throw new RestException(401); + throw new RestException(403); + } + + if (!DolibarrApi::_checkAccessToResource('fournisseur', $id, 'facture_fourn', 'facture')) { + throw new RestException(403, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); } $result = $this->invoice->fetch($id); @@ -623,10 +630,6 @@ class SupplierInvoices extends DolibarrApi throw new RestException(404, 'Supplier invoice not found'); } - if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { - throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); - } - $request_data = (object) $request_data; $request_data->description = sanitizeVal($request_data->description, 'restricthtml'); @@ -675,14 +678,21 @@ class SupplierInvoices extends DolibarrApi * @return array * * @throws RestException 400 Bad parameters - * @throws RestException 401 Not allowed + * @throws RestException 403 Not allowed * @throws RestException 404 Not found * @throws RestException 405 Error */ public function deleteLine($id, $lineid) { + if (empty($lineid)) { + throw new RestException(400, 'Line ID is mandatory'); + } + if (!DolibarrApiAccess::$user->hasRight("fournisseur", "facture", "creer")) { - throw new RestException(401); + throw new RestException(403); + } + if (!DolibarrApi::_checkAccessToResource('fournisseur', $id, 'facture_fourn', 'facture')) { + throw new RestException(403, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); } $result = $this->invoice->fetch($id); @@ -690,14 +700,6 @@ class SupplierInvoices extends DolibarrApi throw new RestException(404, 'Supplier invoice not found'); } - if (empty($lineid)) { - throw new RestException(400, 'Line ID is mandatory'); - } - - if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { - throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); - } - // TODO Check the lineid $lineid is a line of object $updateRes = $this->invoice->deleteline($lineid); diff --git a/htdocs/fourn/class/fournisseur.class.php b/htdocs/fourn/class/fournisseur.class.php index 2fb646d69f8..cf3263ec3df 100644 --- a/htdocs/fourn/class/fournisseur.class.php +++ b/htdocs/fourn/class/fournisseur.class.php @@ -94,15 +94,13 @@ class Fournisseur extends Societe } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load statistics indicators * * @return int Return integer <0 if KO, >0 if OK */ - public function load_state_board() + public function loadStateBoard() { - // phpcs:enable global $conf, $user, $hookmanager; $this->nb = array(); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 102399eb4d9..f15643f9811 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1833,7 +1833,7 @@ class CommandeFournisseur extends CommonOrder * @param int $special_code Special code * @return int Return integer <=0 if KO, >0 if OK */ - public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $fk_product = 0, $fk_prod_fourn_price = 0, $ref_supplier = '', $remise_percent = 0.0, $price_base_type = 'HT', $pu_ttc = 0.0, $type = 0, $info_bits = 0, $notrigger = 0, $date_start = null, $date_end = null, $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $origin = '', $origin_id = 0, $rang = -1, $special_code = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $fk_product = 0, $fk_prod_fourn_price = 0, $ref_supplier = '', $remise_percent = 0.0, $price_base_type = 'HT', $pu_ttc = 0.0, $type = 0, $info_bits = 0, $notrigger = 0, $date_start = null, $date_end = null, $array_options = [], $fk_unit = null, $pu_ht_devise = 0, $origin = '', $origin_id = 0, $rang = -1, $special_code = 0) { global $langs, $mysoc, $conf; @@ -3097,15 +3097,13 @@ class CommandeFournisseur extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the indicators this->nb for the state board * * @return int Return integer <0 si ko, >0 si ok */ - public function load_state_board() + public function loadStateBoard() { - // phpcs:enable global $conf, $user; $this->nb = array(); diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index f710a5e409c..ea1bf8d16ca 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -3086,15 +3086,13 @@ class FactureFournisseur extends CommonInvoice $this->total_ttc = $xnbp * 119.6; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * * @return int Return integer <0 if KO, >0 if OK */ - public function load_state_board() + public function loadStateBoard() { - // phpcs:enable global $conf, $user; $this->nb = array(); diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index aa68f7a9da6..5bd59060ce8 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1057,7 +1057,7 @@ if (empty($reshook)) { if ($cancel) { $action = ''; - } elseif ($methodecommande <= 0) { + } elseif ($methodecommande <= 0 && !getDolGlobalInt('SUPPLIER_ORDER_MODE_OPTIONAL')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("OrderMode")), null, 'errors'); $action = 'createorder'; } diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 5c0a245310e..811cf27e77b 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -259,7 +259,9 @@ if ($action == 'dispatch' && $permissiontoreceive) { } // We ask to move a qty - if (GETPOST($qty) != 0) { + $qtytomove = (float) price2num(GETPOST($qty, 'alphanohtml')); + $puformove = (float) price2num(GETPOST($pu, 'alphanohtml')); + if ($qtytomove != 0) { if (!(GETPOST($ent, 'int') > 0)) { dol_syslog('No dispatch for line '.$key.' as no warehouse was chosen.'); $text = $langs->transnoentities('Warehouse').', '.$langs->transnoentities('Line').' '.($numline); @@ -268,7 +270,7 @@ if ($action == 'dispatch' && $permissiontoreceive) { } if (!$error) { - $result = $object->dispatchProduct($user, GETPOST($prod, 'int'), GETPOST($qty), GETPOST($ent, 'int'), GETPOST($pu), GETPOST('comment'), '', '', '', GETPOST($fk_commandefourndet, 'int'), $notrigger); + $result = $object->dispatchProduct($user, GETPOSTINT($prod), $qtytomove, GETPOSTINT($ent), $puformove, GETPOST('comment'), '', '', '', GETPOST($fk_commandefourndet, 'int'), $notrigger); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; @@ -327,7 +329,9 @@ if ($action == 'dispatch' && $permissiontoreceive) { } // We ask to move a qty - if (GETPOST($qty) > 0) { + $qtytomove = (float) price2num(GETPOST($qty, 'alphanohtml')); + $puformove = (float) price2num(GETPOST($pu, 'alphanohtml')); + if ($qtytomove > 0) { $productId = GETPOSTINT($prod); if (!(GETPOST($ent, 'int') > 0)) { @@ -345,7 +349,7 @@ if ($action == 'dispatch' && $permissiontoreceive) { } if (!$error) { - $result = $object->dispatchProduct($user, $productId, GETPOST($qty), GETPOST($ent, 'int'), GETPOST($pu), GETPOST('comment'), $dDLUO, $dDLC, GETPOST($lot, 'alpha'), GETPOST($fk_commandefourndet, 'int'), $notrigger); + $result = $object->dispatchProduct($user, $productId, $qtytomove, GETPOSTINT($ent), $puformove, GETPOST('comment'), $dDLUO, $dDLC, GETPOST($lot, 'alpha'), GETPOST($fk_commandefourndet, 'int'), $notrigger); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 39e6aac7e84..5178244186a 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -1020,7 +1020,6 @@ if ($resql) { exit; } - llxHeader('', $title, $help_url); llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-supplier-order page-list'); $param = ''; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 8b793d3b471..73ce39159ff 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -2362,15 +2362,13 @@ class Holiday extends CommonObject $this->statut = Holiday::STATUS_VALIDATED; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load this->nb for dashboard * * @return int Return integer <0 if KO, >0 if OK */ - public function load_state_board() + public function loadStateBoard() { - // phpcs:enable global $user; $this->nb = array(); diff --git a/htdocs/hrm/establishment/card.php b/htdocs/hrm/establishment/card.php index 9c0a33ce4c6..904627e7cfb 100644 --- a/htdocs/hrm/establishment/card.php +++ b/htdocs/hrm/establishment/card.php @@ -96,8 +96,8 @@ if ($action == 'confirm_delete' && $confirm == "yes") { $object->address = GETPOST('address', 'alpha'); $object->zip = GETPOST('zipcode', 'alpha'); $object->town = GETPOST('town', 'alpha'); - $object->country_id = GETPOST("country_id", 'int'); - $object->status = GETPOST('status', 'int'); + $object->country_id = GETPOSTINT("country_id"); + $object->status = GETPOSTINT('status'); $object->fk_user_author = $user->id; $object->datec = dol_now(); $object->entity = GETPOST('entity', 'int') > 0 ? GETPOST('entity', 'int') : $conf->entity; @@ -133,9 +133,9 @@ if ($action == 'confirm_delete' && $confirm == "yes") { $object->address = GETPOST('address', 'alpha'); $object->zip = GETPOST('zipcode', 'alpha'); $object->town = GETPOST('town', 'alpha'); - $object->country_id = GETPOST('country_id', 'int'); + $object->country_id = GETPOSTINT('country_id'); $object->fk_user_mod = $user->id; - $object->status = GETPOST('status', 'int'); + $object->status = GETPOSTINT('status'); $object->entity = GETPOST('entity', 'int') > 0 ? GETPOST('entity', 'int') : $conf->entity; $result = $object->update($user); diff --git a/htdocs/includes/sabre/autoload.php b/htdocs/includes/sabre/autoload.php index d8ccc5f35c3..fffd9ae73be 100644 --- a/htdocs/includes/sabre/autoload.php +++ b/htdocs/includes/sabre/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit60b9ac98a8448ede6c445b0fd4bd31e0::getLoader(); +return ComposerAutoloaderInit51cd53f153efda61d1f1f814155d1c4a::getLoader(); diff --git a/htdocs/includes/sabre/composer.json b/htdocs/includes/sabre/composer.json new file mode 100644 index 00000000000..dc9dcc24803 --- /dev/null +++ b/htdocs/includes/sabre/composer.json @@ -0,0 +1,6 @@ +{ + "require" : { + "php": ">=7.1.0", + "sabre/dav" : ">=3.0.0" + } +} \ No newline at end of file diff --git a/htdocs/includes/sabre/composer.lock b/htdocs/includes/sabre/composer.lock new file mode 100644 index 00000000000..e42ea662f93 --- /dev/null +++ b/htdocs/includes/sabre/composer.lock @@ -0,0 +1,513 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "fffed375dc9f645f46fc681f0b1b7f07", + "packages": [ + { + "name": "psr/log", + "version": "1.1.4", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/1.1.4" + }, + "time": "2021-05-03T11:20:27+00:00" + }, + { + "name": "sabre/dav", + "version": "4.6.0", + "source": { + "type": "git", + "url": "https://github.com/sabre-io/dav.git", + "reference": "554145304b4a026477d130928d16e626939b0b2a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sabre-io/dav/zipball/554145304b4a026477d130928d16e626939b0b2a", + "reference": "554145304b4a026477d130928d16e626939b0b2a", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-date": "*", + "ext-dom": "*", + "ext-iconv": "*", + "ext-json": "*", + "ext-mbstring": "*", + "ext-pcre": "*", + "ext-simplexml": "*", + "ext-spl": "*", + "lib-libxml": ">=2.7.0", + "php": "^7.1.0 || ^8.0", + "psr/log": "^1.0 || ^2.0 || ^3.0", + "sabre/event": "^5.0", + "sabre/http": "^5.0.5", + "sabre/uri": "^2.0", + "sabre/vobject": "^4.2.1", + "sabre/xml": "^2.0.1" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.19", + "monolog/monolog": "^1.27 || ^2.0", + "phpstan/phpstan": "^0.12 || ^1.0", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.6" + }, + "suggest": { + "ext-curl": "*", + "ext-imap": "*", + "ext-pdo": "*" + }, + "bin": [ + "bin/sabredav", + "bin/naturalselection" + ], + "type": "library", + "autoload": { + "psr-4": { + "Sabre\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Evert Pot", + "email": "me@evertpot.com", + "homepage": "http://evertpot.com/", + "role": "Developer" + } + ], + "description": "WebDAV Framework for PHP", + "homepage": "http://sabre.io/", + "keywords": [ + "CalDAV", + "CardDAV", + "WebDAV", + "framework", + "iCalendar" + ], + "support": { + "forum": "https://groups.google.com/group/sabredav-discuss", + "issues": "https://github.com/sabre-io/dav/issues", + "source": "https://github.com/fruux/sabre-dav" + }, + "time": "2023-12-11T13:01:23+00:00" + }, + { + "name": "sabre/event", + "version": "5.1.4", + "source": { + "type": "git", + "url": "https://github.com/sabre-io/event.git", + "reference": "d7da22897125d34d7eddf7977758191c06a74497" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sabre-io/event/zipball/d7da22897125d34d7eddf7977758191c06a74497", + "reference": "d7da22897125d34d7eddf7977758191c06a74497", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "~2.17.1", + "phpstan/phpstan": "^0.12", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.0" + }, + "type": "library", + "autoload": { + "files": [ + "lib/coroutine.php", + "lib/Loop/functions.php", + "lib/Promise/functions.php" + ], + "psr-4": { + "Sabre\\Event\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Evert Pot", + "email": "me@evertpot.com", + "homepage": "http://evertpot.com/", + "role": "Developer" + } + ], + "description": "sabre/event is a library for lightweight event-based programming", + "homepage": "http://sabre.io/event/", + "keywords": [ + "EventEmitter", + "async", + "coroutine", + "eventloop", + "events", + "hooks", + "plugin", + "promise", + "reactor", + "signal" + ], + "support": { + "forum": "https://groups.google.com/group/sabredav-discuss", + "issues": "https://github.com/sabre-io/event/issues", + "source": "https://github.com/fruux/sabre-event" + }, + "time": "2021-11-04T06:51:17+00:00" + }, + { + "name": "sabre/http", + "version": "5.1.10", + "source": { + "type": "git", + "url": "https://github.com/sabre-io/http.git", + "reference": "f9f3d1fba8916fa2f4ec25636c4fedc26cb94e02" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sabre-io/http/zipball/f9f3d1fba8916fa2f4ec25636c4fedc26cb94e02", + "reference": "f9f3d1fba8916fa2f4ec25636c4fedc26cb94e02", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-curl": "*", + "ext-mbstring": "*", + "php": "^7.1 || ^8.0", + "sabre/event": ">=4.0 <6.0", + "sabre/uri": "^2.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "~2.17.1", + "phpstan/phpstan": "^0.12", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.0" + }, + "suggest": { + "ext-curl": " to make http requests with the Client class" + }, + "type": "library", + "autoload": { + "files": [ + "lib/functions.php" + ], + "psr-4": { + "Sabre\\HTTP\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Evert Pot", + "email": "me@evertpot.com", + "homepage": "http://evertpot.com/", + "role": "Developer" + } + ], + "description": "The sabre/http library provides utilities for dealing with http requests and responses. ", + "homepage": "https://github.com/fruux/sabre-http", + "keywords": [ + "http" + ], + "support": { + "forum": "https://groups.google.com/group/sabredav-discuss", + "issues": "https://github.com/sabre-io/http/issues", + "source": "https://github.com/fruux/sabre-http" + }, + "time": "2023-08-18T01:55:28+00:00" + }, + { + "name": "sabre/uri", + "version": "2.2.4", + "source": { + "type": "git", + "url": "https://github.com/sabre-io/uri.git", + "reference": "c0c9af9f7754e60a49ebd760e1708adc6d1510c0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sabre-io/uri/zipball/c0c9af9f7754e60a49ebd760e1708adc6d1510c0", + "reference": "c0c9af9f7754e60a49ebd760e1708adc6d1510c0", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "~2.19.3", + "phpstan/phpstan": "^0.12", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.0" + }, + "type": "library", + "autoload": { + "files": [ + "lib/functions.php" + ], + "psr-4": { + "Sabre\\Uri\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Evert Pot", + "email": "me@evertpot.com", + "homepage": "http://evertpot.com/", + "role": "Developer" + } + ], + "description": "Functions for making sense out of URIs.", + "homepage": "http://sabre.io/uri/", + "keywords": [ + "rfc3986", + "uri", + "url" + ], + "support": { + "forum": "https://groups.google.com/group/sabredav-discuss", + "issues": "https://github.com/sabre-io/uri/issues", + "source": "https://github.com/fruux/sabre-uri" + }, + "time": "2022-09-19T12:25:28+00:00" + }, + { + "name": "sabre/vobject", + "version": "4.5.4", + "source": { + "type": "git", + "url": "https://github.com/sabre-io/vobject.git", + "reference": "a6d53a3e5bec85ed3dd78868b7de0f5b4e12f772" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sabre-io/vobject/zipball/a6d53a3e5bec85ed3dd78868b7de0f5b4e12f772", + "reference": "a6d53a3e5bec85ed3dd78868b7de0f5b4e12f772", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": "^7.1 || ^8.0", + "sabre/xml": "^2.1 || ^3.0 || ^4.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "~2.17.1", + "phpstan/phpstan": "^0.12", + "phpunit/php-invoker": "^2.0 || ^3.1", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.0" + }, + "suggest": { + "hoa/bench": "If you would like to run the benchmark scripts" + }, + "bin": [ + "bin/vobject", + "bin/generate_vcards" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Sabre\\VObject\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Evert Pot", + "email": "me@evertpot.com", + "homepage": "http://evertpot.com/", + "role": "Developer" + }, + { + "name": "Dominik Tobschall", + "email": "dominik@fruux.com", + "homepage": "http://tobschall.de/", + "role": "Developer" + }, + { + "name": "Ivan Enderlin", + "email": "ivan.enderlin@hoa-project.net", + "homepage": "http://mnt.io/", + "role": "Developer" + } + ], + "description": "The VObject library for PHP allows you to easily parse and manipulate iCalendar and vCard objects", + "homepage": "http://sabre.io/vobject/", + "keywords": [ + "availability", + "freebusy", + "iCalendar", + "ical", + "ics", + "jCal", + "jCard", + "recurrence", + "rfc2425", + "rfc2426", + "rfc2739", + "rfc4770", + "rfc5545", + "rfc5546", + "rfc6321", + "rfc6350", + "rfc6351", + "rfc6474", + "rfc6638", + "rfc6715", + "rfc6868", + "vCalendar", + "vCard", + "vcf", + "xCal", + "xCard" + ], + "support": { + "forum": "https://groups.google.com/group/sabredav-discuss", + "issues": "https://github.com/sabre-io/vobject/issues", + "source": "https://github.com/fruux/sabre-vobject" + }, + "time": "2023-11-09T12:54:37+00:00" + }, + { + "name": "sabre/xml", + "version": "2.2.6", + "source": { + "type": "git", + "url": "https://github.com/sabre-io/xml.git", + "reference": "9cde7cdab1e50893cc83b037b40cd47bfde42a2b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sabre-io/xml/zipball/9cde7cdab1e50893cc83b037b40cd47bfde42a2b", + "reference": "9cde7cdab1e50893cc83b037b40cd47bfde42a2b", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-xmlreader": "*", + "ext-xmlwriter": "*", + "lib-libxml": ">=2.6.20", + "php": "^7.1 || ^8.0", + "sabre/uri": ">=1.0,<3.0.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "~2.17.1", + "phpstan/phpstan": "^0.12", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.0" + }, + "type": "library", + "autoload": { + "files": [ + "lib/Deserializer/functions.php", + "lib/Serializer/functions.php" + ], + "psr-4": { + "Sabre\\Xml\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Evert Pot", + "email": "me@evertpot.com", + "homepage": "http://evertpot.com/", + "role": "Developer" + }, + { + "name": "Markus Staab", + "email": "markus.staab@redaxo.de", + "role": "Developer" + } + ], + "description": "sabre/xml is an XML library that you may not hate.", + "homepage": "https://sabre.io/xml/", + "keywords": [ + "XMLReader", + "XMLWriter", + "dom", + "xml" + ], + "support": { + "forum": "https://groups.google.com/group/sabredav-discuss", + "issues": "https://github.com/sabre-io/xml/issues", + "source": "https://github.com/fruux/sabre-xml" + }, + "time": "2023-06-28T12:56:05+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=7.1.0" + }, + "platform-dev": [], + "plugin-api-version": "2.2.0" +} diff --git a/htdocs/includes/sabre/composer/ClassLoader.php b/htdocs/includes/sabre/composer/ClassLoader.php index 4626994fd4d..afef3fa2ad8 100644 --- a/htdocs/includes/sabre/composer/ClassLoader.php +++ b/htdocs/includes/sabre/composer/ClassLoader.php @@ -37,57 +37,130 @@ namespace Composer\Autoload; * * @author Fabien Potencier * @author Jordi Boggiano - * @see http://www.php-fig.org/psr/psr-0/ - * @see http://www.php-fig.org/psr/psr-4/ + * @see https://www.php-fig.org/psr/psr-0/ + * @see https://www.php-fig.org/psr/psr-4/ */ class ClassLoader { + /** @var ?string */ + private $vendorDir; + // PSR-4 + /** + * @var array[] + * @psalm-var array> + */ private $prefixLengthsPsr4 = array(); + /** + * @var array[] + * @psalm-var array> + */ private $prefixDirsPsr4 = array(); + /** + * @var array[] + * @psalm-var array + */ private $fallbackDirsPsr4 = array(); // PSR-0 + /** + * @var array[] + * @psalm-var array> + */ private $prefixesPsr0 = array(); + /** + * @var array[] + * @psalm-var array + */ private $fallbackDirsPsr0 = array(); + /** @var bool */ private $useIncludePath = false; + + /** + * @var string[] + * @psalm-var array + */ private $classMap = array(); + + /** @var bool */ private $classMapAuthoritative = false; + + /** + * @var bool[] + * @psalm-var array + */ private $missingClasses = array(); + + /** @var ?string */ private $apcuPrefix; + /** + * @var self[] + */ + private static $registeredLoaders = array(); + + /** + * @param ?string $vendorDir + */ + public function __construct($vendorDir = null) + { + $this->vendorDir = $vendorDir; + } + + /** + * @return string[] + */ public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); } + /** + * @return array[] + * @psalm-return array> + */ public function getPrefixesPsr4() { return $this->prefixDirsPsr4; } + /** + * @return array[] + * @psalm-return array + */ public function getFallbackDirs() { return $this->fallbackDirsPsr0; } + /** + * @return array[] + * @psalm-return array + */ public function getFallbackDirsPsr4() { return $this->fallbackDirsPsr4; } + /** + * @return string[] Array of classname => path + * @psalm-return array + */ public function getClassMap() { return $this->classMap; } /** - * @param array $classMap Class to filename map + * @param string[] $classMap Class to filename map + * @psalm-param array $classMap + * + * @return void */ public function addClassMap(array $classMap) { @@ -102,9 +175,11 @@ class ClassLoader * Registers a set of PSR-0 directories for a given prefix, either * appending or prepending to the ones previously set for this prefix. * - * @param string $prefix The prefix - * @param array|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories + * @param string $prefix The prefix + * @param string[]|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + * + * @return void */ public function add($prefix, $paths, $prepend = false) { @@ -147,11 +222,13 @@ class ClassLoader * Registers a set of PSR-4 directories for a given namespace, either * appending or prepending to the ones previously set for this namespace. * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param array|string $paths The PSR-4 base directories - * @param bool $prepend Whether to prepend the directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param string[]|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories * * @throws \InvalidArgumentException + * + * @return void */ public function addPsr4($prefix, $paths, $prepend = false) { @@ -195,8 +272,10 @@ class ClassLoader * Registers a set of PSR-0 directories for a given prefix, * replacing any others previously set for this prefix. * - * @param string $prefix The prefix - * @param array|string $paths The PSR-0 base directories + * @param string $prefix The prefix + * @param string[]|string $paths The PSR-0 base directories + * + * @return void */ public function set($prefix, $paths) { @@ -211,10 +290,12 @@ class ClassLoader * Registers a set of PSR-4 directories for a given namespace, * replacing any others previously set for this namespace. * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param array|string $paths The PSR-4 base directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param string[]|string $paths The PSR-4 base directories * * @throws \InvalidArgumentException + * + * @return void */ public function setPsr4($prefix, $paths) { @@ -234,6 +315,8 @@ class ClassLoader * Turns on searching the include path for class files. * * @param bool $useIncludePath + * + * @return void */ public function setUseIncludePath($useIncludePath) { @@ -256,6 +339,8 @@ class ClassLoader * that have not been registered with the class map. * * @param bool $classMapAuthoritative + * + * @return void */ public function setClassMapAuthoritative($classMapAuthoritative) { @@ -276,10 +361,12 @@ class ClassLoader * APCu prefix to use to cache found/not-found classes, if the extension is enabled. * * @param string|null $apcuPrefix + * + * @return void */ public function setApcuPrefix($apcuPrefix) { - $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; + $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; } /** @@ -296,25 +383,44 @@ class ClassLoader * Registers this instance as an autoloader. * * @param bool $prepend Whether to prepend the autoloader or not + * + * @return void */ public function register($prepend = false) { spl_autoload_register(array($this, 'loadClass'), true, $prepend); + + if (null === $this->vendorDir) { + return; + } + + if ($prepend) { + self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; + } else { + unset(self::$registeredLoaders[$this->vendorDir]); + self::$registeredLoaders[$this->vendorDir] = $this; + } } /** * Unregisters this instance as an autoloader. + * + * @return void */ public function unregister() { spl_autoload_unregister(array($this, 'loadClass')); + + if (null !== $this->vendorDir) { + unset(self::$registeredLoaders[$this->vendorDir]); + } } /** * Loads the given class or interface. * * @param string $class The name of the class - * @return bool|null True if loaded, null otherwise + * @return true|null True if loaded, null otherwise */ public function loadClass($class) { @@ -323,6 +429,8 @@ class ClassLoader return true; } + + return null; } /** @@ -367,6 +475,21 @@ class ClassLoader return $file; } + /** + * Returns the currently registered loaders indexed by their corresponding vendor directories. + * + * @return self[] + */ + public static function getRegisteredLoaders() + { + return self::$registeredLoaders; + } + + /** + * @param string $class + * @param string $ext + * @return string|false + */ private function findFileWithExtension($class, $ext) { // PSR-4 lookup @@ -374,10 +497,14 @@ class ClassLoader $first = $class[0]; if (isset($this->prefixLengthsPsr4[$first])) { - foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { - if (0 === strpos($class, $prefix)) { - foreach ($this->prefixDirsPsr4[$prefix] as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { + $subPath = $class; + while (false !== $lastPos = strrpos($subPath, '\\')) { + $subPath = substr($subPath, 0, $lastPos); + $search = $subPath . '\\'; + if (isset($this->prefixDirsPsr4[$search])) { + $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); + foreach ($this->prefixDirsPsr4[$search] as $dir) { + if (file_exists($file = $dir . $pathEnd)) { return $file; } } @@ -434,6 +561,10 @@ class ClassLoader * Scope isolated include. * * Prevents access to $this/self from included files. + * + * @param string $file + * @return void + * @private */ function includeFile($file) { diff --git a/htdocs/includes/sabre/composer/InstalledVersions.php b/htdocs/includes/sabre/composer/InstalledVersions.php new file mode 100644 index 00000000000..d50e0c9fcc4 --- /dev/null +++ b/htdocs/includes/sabre/composer/InstalledVersions.php @@ -0,0 +1,350 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer; + +use Composer\Autoload\ClassLoader; +use Composer\Semver\VersionParser; + +/** + * This class is copied in every Composer installed project and available to all + * + * See also https://getcomposer.org/doc/07-runtime.md#installed-versions + * + * To require its presence, you can require `composer-runtime-api ^2.0` + */ +class InstalledVersions +{ + /** + * @var mixed[]|null + * @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array}|array{}|null + */ + private static $installed; + + /** + * @var bool|null + */ + private static $canGetVendors; + + /** + * @var array[] + * @psalm-var array}> + */ + private static $installedByVendor = array(); + + /** + * Returns a list of all package names which are present, either by being installed, replaced or provided + * + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackages() + { + $packages = array(); + foreach (self::getInstalled() as $installed) { + $packages[] = array_keys($installed['versions']); + } + + if (1 === \count($packages)) { + return $packages[0]; + } + + return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); + } + + /** + * Returns a list of all package names with a specific type e.g. 'library' + * + * @param string $type + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackagesByType($type) + { + $packagesByType = array(); + + foreach (self::getInstalled() as $installed) { + foreach ($installed['versions'] as $name => $package) { + if (isset($package['type']) && $package['type'] === $type) { + $packagesByType[] = $name; + } + } + } + + return $packagesByType; + } + + /** + * Checks whether the given package is installed + * + * This also returns true if the package name is provided or replaced by another package + * + * @param string $packageName + * @param bool $includeDevRequirements + * @return bool + */ + public static function isInstalled($packageName, $includeDevRequirements = true) + { + foreach (self::getInstalled() as $installed) { + if (isset($installed['versions'][$packageName])) { + return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']); + } + } + + return false; + } + + /** + * Checks whether the given package satisfies a version constraint + * + * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call: + * + * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3') + * + * @param VersionParser $parser Install composer/semver to have access to this class and functionality + * @param string $packageName + * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package + * @return bool + */ + public static function satisfies(VersionParser $parser, $packageName, $constraint) + { + $constraint = $parser->parseConstraints($constraint); + $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); + + return $provided->matches($constraint); + } + + /** + * Returns a version constraint representing all the range(s) which are installed for a given package + * + * It is easier to use this via isInstalled() with the $constraint argument if you need to check + * whether a given version of a package is installed, and not just whether it exists + * + * @param string $packageName + * @return string Version constraint usable with composer/semver + */ + public static function getVersionRanges($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + $ranges = array(); + if (isset($installed['versions'][$packageName]['pretty_version'])) { + $ranges[] = $installed['versions'][$packageName]['pretty_version']; + } + if (array_key_exists('aliases', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); + } + if (array_key_exists('replaced', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); + } + if (array_key_exists('provided', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); + } + + return implode(' || ', $ranges); + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['version'])) { + return null; + } + + return $installed['versions'][$packageName]['version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getPrettyVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['pretty_version'])) { + return null; + } + + return $installed['versions'][$packageName]['pretty_version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference + */ + public static function getReference($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['reference'])) { + return null; + } + + return $installed['versions'][$packageName]['reference']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path. + */ + public static function getInstallPath($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @return array + * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string} + */ + public static function getRootPackage() + { + $installed = self::getInstalled(); + + return $installed[0]['root']; + } + + /** + * Returns the raw installed.php data for custom implementations + * + * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. + * @return array[] + * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array} + */ + public static function getRawData() + { + @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED); + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + self::$installed = include __DIR__ . '/installed.php'; + } else { + self::$installed = array(); + } + } + + return self::$installed; + } + + /** + * Returns the raw data of all installed.php which are currently loaded for custom implementations + * + * @return array[] + * @psalm-return list}> + */ + public static function getAllRawData() + { + return self::getInstalled(); + } + + /** + * Lets you reload the static array from another file + * + * This is only useful for complex integrations in which a project needs to use + * this class but then also needs to execute another project's autoloader in process, + * and wants to ensure both projects have access to their version of installed.php. + * + * A typical case would be PHPUnit, where it would need to make sure it reads all + * the data it needs from this class, then call reload() with + * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure + * the project in which it runs can then also use this class safely, without + * interference between PHPUnit's dependencies and the project's dependencies. + * + * @param array[] $data A vendor/composer/installed.php data set + * @return void + * + * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array} $data + */ + public static function reload($data) + { + self::$installed = $data; + self::$installedByVendor = array(); + } + + /** + * @return array[] + * @psalm-return list}> + */ + private static function getInstalled() + { + if (null === self::$canGetVendors) { + self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); + } + + $installed = array(); + + if (self::$canGetVendors) { + foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { + if (isset(self::$installedByVendor[$vendorDir])) { + $installed[] = self::$installedByVendor[$vendorDir]; + } elseif (is_file($vendorDir.'/composer/installed.php')) { + $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; + if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { + self::$installed = $installed[count($installed) - 1]; + } + } + } + } + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + self::$installed = require __DIR__ . '/installed.php'; + } else { + self::$installed = array(); + } + } + $installed[] = self::$installed; + + return $installed; + } +} diff --git a/htdocs/includes/sabre/composer/LICENSE b/htdocs/includes/sabre/composer/LICENSE index 1a28124886d..f27399a042d 100644 --- a/htdocs/includes/sabre/composer/LICENSE +++ b/htdocs/includes/sabre/composer/LICENSE @@ -1,5 +1,5 @@ -Copyright (c) 2016 Nils Adermann, Jordi Boggiano +Copyright (c) Nils Adermann, Jordi Boggiano Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/htdocs/includes/sabre/composer/autoload_classmap.php b/htdocs/includes/sabre/composer/autoload_classmap.php index 7a91153b0d8..b26f1b13b1f 100644 --- a/htdocs/includes/sabre/composer/autoload_classmap.php +++ b/htdocs/includes/sabre/composer/autoload_classmap.php @@ -6,4 +6,5 @@ $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( + 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', ); diff --git a/htdocs/includes/sabre/composer/autoload_files.php b/htdocs/includes/sabre/composer/autoload_files.php index 24ffd37183a..a78cbe6fb59 100644 --- a/htdocs/includes/sabre/composer/autoload_files.php +++ b/htdocs/includes/sabre/composer/autoload_files.php @@ -7,10 +7,10 @@ $baseDir = dirname($vendorDir); return array( '383eaff206634a77a1be54e64e6459c7' => $vendorDir . '/sabre/uri/lib/functions.php', - '3569eecfeed3bcf0bad3c998a494ecb8' => $vendorDir . '/sabre/xml/lib/Deserializer/functions.php', - '93aa591bc4ca510c520999e34229ee79' => $vendorDir . '/sabre/xml/lib/Serializer/functions.php', '2b9d0f43f9552984cfa82fee95491826' => $vendorDir . '/sabre/event/lib/coroutine.php', 'd81bab31d3feb45bfe2f283ea3c8fdf7' => $vendorDir . '/sabre/event/lib/Loop/functions.php', 'a1cce3d26cc15c00fcd0b3354bd72c88' => $vendorDir . '/sabre/event/lib/Promise/functions.php', + '3569eecfeed3bcf0bad3c998a494ecb8' => $vendorDir . '/sabre/xml/lib/Deserializer/functions.php', + '93aa591bc4ca510c520999e34229ee79' => $vendorDir . '/sabre/xml/lib/Serializer/functions.php', 'ebdb698ed4152ae445614b69b5e4bb6a' => $vendorDir . '/sabre/http/lib/functions.php', ); diff --git a/htdocs/includes/sabre/composer/autoload_psr4.php b/htdocs/includes/sabre/composer/autoload_psr4.php index 3928c989660..100702eadc8 100644 --- a/htdocs/includes/sabre/composer/autoload_psr4.php +++ b/htdocs/includes/sabre/composer/autoload_psr4.php @@ -11,9 +11,6 @@ return array( 'Sabre\\Uri\\' => array($vendorDir . '/sabre/uri/lib'), 'Sabre\\HTTP\\' => array($vendorDir . '/sabre/http/lib'), 'Sabre\\Event\\' => array($vendorDir . '/sabre/event/lib'), - 'Sabre\\DAV\\' => array($vendorDir . '/sabre/dav/lib/DAV'), - 'Sabre\\DAVACL\\' => array($vendorDir . '/sabre/dav/lib/DAVACL'), - 'Sabre\\CardDAV\\' => array($vendorDir . '/sabre/dav/lib/CardDAV'), - 'Sabre\\CalDAV\\' => array($vendorDir . '/sabre/dav/lib/CalDAV'), + 'Sabre\\' => array($vendorDir . '/sabre/dav/lib'), 'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'), ); diff --git a/htdocs/includes/sabre/composer/autoload_real.php b/htdocs/includes/sabre/composer/autoload_real.php index bb9949a91c4..3c57540c52e 100644 --- a/htdocs/includes/sabre/composer/autoload_real.php +++ b/htdocs/includes/sabre/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit60b9ac98a8448ede6c445b0fd4bd31e0 +class ComposerAutoloaderInit51cd53f153efda61d1f1f814155d1c4a { private static $loader; @@ -13,21 +13,26 @@ class ComposerAutoloaderInit60b9ac98a8448ede6c445b0fd4bd31e0 } } + /** + * @return \Composer\Autoload\ClassLoader + */ public static function getLoader() { if (null !== self::$loader) { return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit60b9ac98a8448ede6c445b0fd4bd31e0', 'loadClassLoader'), true, true); - self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInit60b9ac98a8448ede6c445b0fd4bd31e0', 'loadClassLoader')); + require __DIR__ . '/platform_check.php'; + + spl_autoload_register(array('ComposerAutoloaderInit51cd53f153efda61d1f1f814155d1c4a', 'loadClassLoader'), true, true); + self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); + spl_autoload_unregister(array('ComposerAutoloaderInit51cd53f153efda61d1f1f814155d1c4a', 'loadClassLoader')); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); if ($useStaticLoader) { - require_once __DIR__ . '/autoload_static.php'; + require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit60b9ac98a8448ede6c445b0fd4bd31e0::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit51cd53f153efda61d1f1f814155d1c4a::getInitializer($loader)); } else { $map = require __DIR__ . '/autoload_namespaces.php'; foreach ($map as $namespace => $path) { @@ -48,23 +53,28 @@ class ComposerAutoloaderInit60b9ac98a8448ede6c445b0fd4bd31e0 $loader->register(true); if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInit60b9ac98a8448ede6c445b0fd4bd31e0::$files; + $includeFiles = Composer\Autoload\ComposerStaticInit51cd53f153efda61d1f1f814155d1c4a::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; } foreach ($includeFiles as $fileIdentifier => $file) { - composerRequire60b9ac98a8448ede6c445b0fd4bd31e0($fileIdentifier, $file); + composerRequire51cd53f153efda61d1f1f814155d1c4a($fileIdentifier, $file); } return $loader; } } -function composerRequire60b9ac98a8448ede6c445b0fd4bd31e0($fileIdentifier, $file) +/** + * @param string $fileIdentifier + * @param string $file + * @return void + */ +function composerRequire51cd53f153efda61d1f1f814155d1c4a($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { - require $file; - $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; + + require $file; } } diff --git a/htdocs/includes/sabre/composer/autoload_static.php b/htdocs/includes/sabre/composer/autoload_static.php index d76d2c4c34b..c4a8c8f3d18 100644 --- a/htdocs/includes/sabre/composer/autoload_static.php +++ b/htdocs/includes/sabre/composer/autoload_static.php @@ -4,15 +4,15 @@ namespace Composer\Autoload; -class ComposerStaticInit60b9ac98a8448ede6c445b0fd4bd31e0 +class ComposerStaticInit51cd53f153efda61d1f1f814155d1c4a { public static $files = array ( '383eaff206634a77a1be54e64e6459c7' => __DIR__ . '/..' . '/sabre/uri/lib/functions.php', - '3569eecfeed3bcf0bad3c998a494ecb8' => __DIR__ . '/..' . '/sabre/xml/lib/Deserializer/functions.php', - '93aa591bc4ca510c520999e34229ee79' => __DIR__ . '/..' . '/sabre/xml/lib/Serializer/functions.php', '2b9d0f43f9552984cfa82fee95491826' => __DIR__ . '/..' . '/sabre/event/lib/coroutine.php', 'd81bab31d3feb45bfe2f283ea3c8fdf7' => __DIR__ . '/..' . '/sabre/event/lib/Loop/functions.php', 'a1cce3d26cc15c00fcd0b3354bd72c88' => __DIR__ . '/..' . '/sabre/event/lib/Promise/functions.php', + '3569eecfeed3bcf0bad3c998a494ecb8' => __DIR__ . '/..' . '/sabre/xml/lib/Deserializer/functions.php', + '93aa591bc4ca510c520999e34229ee79' => __DIR__ . '/..' . '/sabre/xml/lib/Serializer/functions.php', 'ebdb698ed4152ae445614b69b5e4bb6a' => __DIR__ . '/..' . '/sabre/http/lib/functions.php', ); @@ -24,10 +24,7 @@ class ComposerStaticInit60b9ac98a8448ede6c445b0fd4bd31e0 'Sabre\\Uri\\' => 10, 'Sabre\\HTTP\\' => 11, 'Sabre\\Event\\' => 12, - 'Sabre\\DAV\\' => 10, - 'Sabre\\DAVACL\\' => 13, - 'Sabre\\CardDAV\\' => 14, - 'Sabre\\CalDAV\\' => 13, + 'Sabre\\' => 6, ), 'P' => array ( @@ -56,21 +53,9 @@ class ComposerStaticInit60b9ac98a8448ede6c445b0fd4bd31e0 array ( 0 => __DIR__ . '/..' . '/sabre/event/lib', ), - 'Sabre\\DAV\\' => + 'Sabre\\' => array ( - 0 => __DIR__ . '/..' . '/sabre/dav/lib/DAV', - ), - 'Sabre\\DAVACL\\' => - array ( - 0 => __DIR__ . '/..' . '/sabre/dav/lib/DAVACL', - ), - 'Sabre\\CardDAV\\' => - array ( - 0 => __DIR__ . '/..' . '/sabre/dav/lib/CardDAV', - ), - 'Sabre\\CalDAV\\' => - array ( - 0 => __DIR__ . '/..' . '/sabre/dav/lib/CalDAV', + 0 => __DIR__ . '/..' . '/sabre/dav/lib', ), 'Psr\\Log\\' => array ( @@ -78,11 +63,16 @@ class ComposerStaticInit60b9ac98a8448ede6c445b0fd4bd31e0 ), ); + public static $classMap = array ( + 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', + ); + public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit60b9ac98a8448ede6c445b0fd4bd31e0::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit60b9ac98a8448ede6c445b0fd4bd31e0::$prefixDirsPsr4; + $loader->prefixLengthsPsr4 = ComposerStaticInit51cd53f153efda61d1f1f814155d1c4a::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit51cd53f153efda61d1f1f814155d1c4a::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit51cd53f153efda61d1f1f814155d1c4a::$classMap; }, null, ClassLoader::class); } diff --git a/htdocs/includes/sabre/composer/installed.json b/htdocs/includes/sabre/composer/installed.json index c226d3ef4a6..cadcc120067 100644 --- a/htdocs/includes/sabre/composer/installed.json +++ b/htdocs/includes/sabre/composer/installed.json @@ -1,470 +1,519 @@ -[ - { - "name": "sabre/uri", - "version": "1.2.0", - "version_normalized": "1.2.0.0", - "source": { - "type": "git", - "url": "https://github.com/fruux/sabre-uri.git", - "reference": "8545a3335f741d4b7700bb14efb41b4c03775dcd" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/fruux/sabre-uri/zipball/8545a3335f741d4b7700bb14efb41b4c03775dcd", - "reference": "8545a3335f741d4b7700bb14efb41b4c03775dcd", - "shasum": "" - }, - "require": { - "php": ">=5.4.7" - }, - "require-dev": { - "phpunit/phpunit": "*", - "sabre/cs": "~1.0.0" - }, - "time": "2016-12-07T01:17:59+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "files": [ - "lib/functions.php" +{ + "packages": [ + { + "name": "psr/log", + "version": "1.1.4", + "version_normalized": "1.1.4.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "time": "2021-05-03T11:20:27+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" ], - "psr-4": { - "Sabre\\Uri\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Evert Pot", - "email": "me@evertpot.com", - "homepage": "http://evertpot.com/", - "role": "Developer" - } - ], - "description": "Functions for making sense out of URIs.", - "homepage": "http://sabre.io/uri/", - "keywords": [ - "rfc3986", - "uri", - "url" - ] - }, - { - "name": "sabre/xml", - "version": "1.5.0", - "version_normalized": "1.5.0.0", - "source": { - "type": "git", - "url": "https://github.com/fruux/sabre-xml.git", - "reference": "59b20e5bbace9912607481634f97d05a776ffca7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/fruux/sabre-xml/zipball/59b20e5bbace9912607481634f97d05a776ffca7", - "reference": "59b20e5bbace9912607481634f97d05a776ffca7", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-xmlreader": "*", - "ext-xmlwriter": "*", - "lib-libxml": ">=2.6.20", - "php": ">=5.5.5", - "sabre/uri": ">=1.0,<3.0.0" - }, - "require-dev": { - "phpunit/phpunit": "*", - "sabre/cs": "~1.0.0" - }, - "time": "2016-10-09T22:57:52+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-4": { - "Sabre\\Xml\\": "lib/" - }, - "files": [ - "lib/Deserializer/functions.php", - "lib/Serializer/functions.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Evert Pot", - "email": "me@evertpot.com", - "homepage": "http://evertpot.com/", - "role": "Developer" - }, - { - "name": "Markus Staab", - "email": "markus.staab@redaxo.de", - "role": "Developer" - } - ], - "description": "sabre/xml is an XML library that you may not hate.", - "homepage": "https://sabre.io/xml/", - "keywords": [ - "XMLReader", - "XMLWriter", - "dom", - "xml" - ] - }, - { - "name": "sabre/vobject", - "version": "4.1.2", - "version_normalized": "4.1.2.0", - "source": { - "type": "git", - "url": "https://github.com/fruux/sabre-vobject.git", - "reference": "d0fde2fafa2a3dad1f559c2d1c2591d4fd75ae3c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/fruux/sabre-vobject/zipball/d0fde2fafa2a3dad1f559c2d1c2591d4fd75ae3c", - "reference": "d0fde2fafa2a3dad1f559c2d1c2591d4fd75ae3c", - "shasum": "" - }, - "require": { - "ext-mbstring": "*", - "php": ">=5.5", - "sabre/xml": ">=1.5 <3.0" - }, - "require-dev": { - "phpunit/phpunit": "*", - "sabre/cs": "^1.0.0" - }, - "suggest": { - "hoa/bench": "If you would like to run the benchmark scripts" - }, - "time": "2016-12-06T04:14:09+00:00", - "bin": [ - "bin/vobject", - "bin/generate_vcards" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.0.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Sabre\\VObject\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Evert Pot", - "email": "me@evertpot.com", - "homepage": "http://evertpot.com/", - "role": "Developer" - }, - { - "name": "Dominik Tobschall", - "email": "dominik@fruux.com", - "homepage": "http://tobschall.de/", - "role": "Developer" - }, - { - "name": "Ivan Enderlin", - "email": "ivan.enderlin@hoa-project.net", - "homepage": "http://mnt.io/", - "role": "Developer" - } - ], - "description": "The VObject library for PHP allows you to easily parse and manipulate iCalendar and vCard objects", - "homepage": "http://sabre.io/vobject/", - "keywords": [ - "availability", - "freebusy", - "iCalendar", - "ical", - "ics", - "jCal", - "jCard", - "recurrence", - "rfc2425", - "rfc2426", - "rfc2739", - "rfc4770", - "rfc5545", - "rfc5546", - "rfc6321", - "rfc6350", - "rfc6351", - "rfc6474", - "rfc6638", - "rfc6715", - "rfc6868", - "vCalendar", - "vCard", - "vcf", - "xCal", - "xCard" - ] - }, - { - "name": "sabre/event", - "version": "3.0.0", - "version_normalized": "3.0.0.0", - "source": { - "type": "git", - "url": "https://github.com/fruux/sabre-event.git", - "reference": "831d586f5a442dceacdcf5e9c4c36a4db99a3534" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/fruux/sabre-event/zipball/831d586f5a442dceacdcf5e9c4c36a4db99a3534", - "reference": "831d586f5a442dceacdcf5e9c4c36a4db99a3534", - "shasum": "" - }, - "require": { - "php": ">=5.5" - }, - "require-dev": { - "phpunit/phpunit": "*", - "sabre/cs": "~0.0.4" - }, - "time": "2015-11-05T20:14:39+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-4": { - "Sabre\\Event\\": "lib/" - }, - "files": [ - "lib/coroutine.php", - "lib/Loop/functions.php", - "lib/Promise/functions.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Evert Pot", - "email": "me@evertpot.com", - "homepage": "http://evertpot.com/", - "role": "Developer" - } - ], - "description": "sabre/event is a library for lightweight event-based programming", - "homepage": "http://sabre.io/event/", - "keywords": [ - "EventEmitter", - "async", - "events", - "hooks", - "plugin", - "promise", - "signal" - ] - }, - { - "name": "sabre/http", - "version": "4.2.2", - "version_normalized": "4.2.2.0", - "source": { - "type": "git", - "url": "https://github.com/fruux/sabre-http.git", - "reference": "dd50e7260356f4599d40270826f9548b23efa204" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/fruux/sabre-http/zipball/dd50e7260356f4599d40270826f9548b23efa204", - "reference": "dd50e7260356f4599d40270826f9548b23efa204", - "shasum": "" - }, - "require": { - "ext-ctype": "*", - "ext-mbstring": "*", - "php": ">=5.4", - "sabre/event": ">=1.0.0,<4.0.0", - "sabre/uri": "~1.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.3", - "sabre/cs": "~0.0.1" - }, - "suggest": { - "ext-curl": " to make http requests with the Client class" - }, - "time": "2017-01-02T19:38:42+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "files": [ - "lib/functions.php" + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } ], - "psr-4": { - "Sabre\\HTTP\\": "lib/" - } + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/1.1.4" + }, + "install-path": "../psr/log" }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Evert Pot", - "email": "me@evertpot.com", - "homepage": "http://evertpot.com/", - "role": "Developer" - } - ], - "description": "The sabre/http library provides utilities for dealing with http requests and responses. ", - "homepage": "https://github.com/fruux/sabre-http", - "keywords": [ - "http" - ] - }, - { - "name": "psr/log", - "version": "1.0.2", - "version_normalized": "1.0.2.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" + { + "name": "sabre/dav", + "version": "4.6.0", + "version_normalized": "4.6.0.0", + "source": { + "type": "git", + "url": "https://github.com/sabre-io/dav.git", + "reference": "554145304b4a026477d130928d16e626939b0b2a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sabre-io/dav/zipball/554145304b4a026477d130928d16e626939b0b2a", + "reference": "554145304b4a026477d130928d16e626939b0b2a", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-date": "*", + "ext-dom": "*", + "ext-iconv": "*", + "ext-json": "*", + "ext-mbstring": "*", + "ext-pcre": "*", + "ext-simplexml": "*", + "ext-spl": "*", + "lib-libxml": ">=2.7.0", + "php": "^7.1.0 || ^8.0", + "psr/log": "^1.0 || ^2.0 || ^3.0", + "sabre/event": "^5.0", + "sabre/http": "^5.0.5", + "sabre/uri": "^2.0", + "sabre/vobject": "^4.2.1", + "sabre/xml": "^2.0.1" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.19", + "monolog/monolog": "^1.27 || ^2.0", + "phpstan/phpstan": "^0.12 || ^1.0", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.6" + }, + "suggest": { + "ext-curl": "*", + "ext-imap": "*", + "ext-pdo": "*" + }, + "time": "2023-12-11T13:01:23+00:00", + "bin": [ + "bin/sabredav", + "bin/naturalselection" + ], + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Sabre\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Evert Pot", + "email": "me@evertpot.com", + "homepage": "http://evertpot.com/", + "role": "Developer" + } + ], + "description": "WebDAV Framework for PHP", + "homepage": "http://sabre.io/", + "keywords": [ + "CalDAV", + "CardDAV", + "WebDAV", + "framework", + "iCalendar" + ], + "support": { + "forum": "https://groups.google.com/group/sabredav-discuss", + "issues": "https://github.com/sabre-io/dav/issues", + "source": "https://github.com/fruux/sabre-dav" + }, + "install-path": "../sabre/dav" }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", - "shasum": "" + { + "name": "sabre/event", + "version": "5.1.4", + "version_normalized": "5.1.4.0", + "source": { + "type": "git", + "url": "https://github.com/sabre-io/event.git", + "reference": "d7da22897125d34d7eddf7977758191c06a74497" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sabre-io/event/zipball/d7da22897125d34d7eddf7977758191c06a74497", + "reference": "d7da22897125d34d7eddf7977758191c06a74497", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "~2.17.1", + "phpstan/phpstan": "^0.12", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.0" + }, + "time": "2021-11-04T06:51:17+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "lib/coroutine.php", + "lib/Loop/functions.php", + "lib/Promise/functions.php" + ], + "psr-4": { + "Sabre\\Event\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Evert Pot", + "email": "me@evertpot.com", + "homepage": "http://evertpot.com/", + "role": "Developer" + } + ], + "description": "sabre/event is a library for lightweight event-based programming", + "homepage": "http://sabre.io/event/", + "keywords": [ + "EventEmitter", + "async", + "coroutine", + "eventloop", + "events", + "hooks", + "plugin", + "promise", + "reactor", + "signal" + ], + "support": { + "forum": "https://groups.google.com/group/sabredav-discuss", + "issues": "https://github.com/sabre-io/event/issues", + "source": "https://github.com/fruux/sabre-event" + }, + "install-path": "../sabre/event" }, - "require": { - "php": ">=5.3.0" + { + "name": "sabre/http", + "version": "5.1.10", + "version_normalized": "5.1.10.0", + "source": { + "type": "git", + "url": "https://github.com/sabre-io/http.git", + "reference": "f9f3d1fba8916fa2f4ec25636c4fedc26cb94e02" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sabre-io/http/zipball/f9f3d1fba8916fa2f4ec25636c4fedc26cb94e02", + "reference": "f9f3d1fba8916fa2f4ec25636c4fedc26cb94e02", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-curl": "*", + "ext-mbstring": "*", + "php": "^7.1 || ^8.0", + "sabre/event": ">=4.0 <6.0", + "sabre/uri": "^2.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "~2.17.1", + "phpstan/phpstan": "^0.12", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.0" + }, + "suggest": { + "ext-curl": " to make http requests with the Client class" + }, + "time": "2023-08-18T01:55:28+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "lib/functions.php" + ], + "psr-4": { + "Sabre\\HTTP\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Evert Pot", + "email": "me@evertpot.com", + "homepage": "http://evertpot.com/", + "role": "Developer" + } + ], + "description": "The sabre/http library provides utilities for dealing with http requests and responses. ", + "homepage": "https://github.com/fruux/sabre-http", + "keywords": [ + "http" + ], + "support": { + "forum": "https://groups.google.com/group/sabredav-discuss", + "issues": "https://github.com/sabre-io/http/issues", + "source": "https://github.com/fruux/sabre-http" + }, + "install-path": "../sabre/http" }, - "time": "2016-10-10T12:19:37+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } + { + "name": "sabre/uri", + "version": "2.2.4", + "version_normalized": "2.2.4.0", + "source": { + "type": "git", + "url": "https://github.com/sabre-io/uri.git", + "reference": "c0c9af9f7754e60a49ebd760e1708adc6d1510c0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sabre-io/uri/zipball/c0c9af9f7754e60a49ebd760e1708adc6d1510c0", + "reference": "c0c9af9f7754e60a49ebd760e1708adc6d1510c0", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "~2.19.3", + "phpstan/phpstan": "^0.12", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.0" + }, + "time": "2022-09-19T12:25:28+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "lib/functions.php" + ], + "psr-4": { + "Sabre\\Uri\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Evert Pot", + "email": "me@evertpot.com", + "homepage": "http://evertpot.com/", + "role": "Developer" + } + ], + "description": "Functions for making sense out of URIs.", + "homepage": "http://sabre.io/uri/", + "keywords": [ + "rfc3986", + "uri", + "url" + ], + "support": { + "forum": "https://groups.google.com/group/sabredav-discuss", + "issues": "https://github.com/sabre-io/uri/issues", + "source": "https://github.com/fruux/sabre-uri" + }, + "install-path": "../sabre/uri" }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Psr\\Log\\": "Psr/Log/" - } + { + "name": "sabre/vobject", + "version": "4.5.4", + "version_normalized": "4.5.4.0", + "source": { + "type": "git", + "url": "https://github.com/sabre-io/vobject.git", + "reference": "a6d53a3e5bec85ed3dd78868b7de0f5b4e12f772" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sabre-io/vobject/zipball/a6d53a3e5bec85ed3dd78868b7de0f5b4e12f772", + "reference": "a6d53a3e5bec85ed3dd78868b7de0f5b4e12f772", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": "^7.1 || ^8.0", + "sabre/xml": "^2.1 || ^3.0 || ^4.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "~2.17.1", + "phpstan/phpstan": "^0.12", + "phpunit/php-invoker": "^2.0 || ^3.1", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.0" + }, + "suggest": { + "hoa/bench": "If you would like to run the benchmark scripts" + }, + "time": "2023-11-09T12:54:37+00:00", + "bin": [ + "bin/vobject", + "bin/generate_vcards" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Sabre\\VObject\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Evert Pot", + "email": "me@evertpot.com", + "homepage": "http://evertpot.com/", + "role": "Developer" + }, + { + "name": "Dominik Tobschall", + "email": "dominik@fruux.com", + "homepage": "http://tobschall.de/", + "role": "Developer" + }, + { + "name": "Ivan Enderlin", + "email": "ivan.enderlin@hoa-project.net", + "homepage": "http://mnt.io/", + "role": "Developer" + } + ], + "description": "The VObject library for PHP allows you to easily parse and manipulate iCalendar and vCard objects", + "homepage": "http://sabre.io/vobject/", + "keywords": [ + "availability", + "freebusy", + "iCalendar", + "ical", + "ics", + "jCal", + "jCard", + "recurrence", + "rfc2425", + "rfc2426", + "rfc2739", + "rfc4770", + "rfc5545", + "rfc5546", + "rfc6321", + "rfc6350", + "rfc6351", + "rfc6474", + "rfc6638", + "rfc6715", + "rfc6868", + "vCalendar", + "vCard", + "vcf", + "xCal", + "xCard" + ], + "support": { + "forum": "https://groups.google.com/group/sabredav-discuss", + "issues": "https://github.com/sabre-io/vobject/issues", + "source": "https://github.com/fruux/sabre-vobject" + }, + "install-path": "../sabre/vobject" }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ] - }, - { - "name": "sabre/dav", - "version": "3.2.2", - "version_normalized": "3.2.2.0", - "source": { - "type": "git", - "url": "https://github.com/fruux/sabre-dav.git", - "reference": "e987775e619728f12205606c9cc3ee565ffb1516" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/fruux/sabre-dav/zipball/e987775e619728f12205606c9cc3ee565ffb1516", - "reference": "e987775e619728f12205606c9cc3ee565ffb1516", - "shasum": "" - }, - "require": { - "ext-ctype": "*", - "ext-date": "*", - "ext-dom": "*", - "ext-iconv": "*", - "ext-mbstring": "*", - "ext-pcre": "*", - "ext-simplexml": "*", - "ext-spl": "*", - "lib-libxml": ">=2.7.0", - "php": ">=5.5.0", - "psr/log": "^1.0", - "sabre/event": ">=2.0.0, <4.0.0", - "sabre/http": "^4.2.1", - "sabre/uri": "^1.0.1", - "sabre/vobject": "^4.1.0", - "sabre/xml": "^1.4.0" - }, - "require-dev": { - "evert/phpdoc-md": "~0.1.0", - "monolog/monolog": "^1.18", - "phpunit/phpunit": "> 4.8, <6.0.0", - "sabre/cs": "^1.0.0" - }, - "suggest": { - "ext-curl": "*", - "ext-pdo": "*" - }, - "time": "2017-02-15T03:06:08+00:00", - "bin": [ - "bin/sabredav", - "bin/naturalselection" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.1.0-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Sabre\\DAV\\": "lib/DAV/", - "Sabre\\DAVACL\\": "lib/DAVACL/", - "Sabre\\CalDAV\\": "lib/CalDAV/", - "Sabre\\CardDAV\\": "lib/CardDAV/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Evert Pot", - "email": "me@evertpot.com", - "homepage": "http://evertpot.com/", - "role": "Developer" - } - ], - "description": "WebDAV Framework for PHP", - "homepage": "http://sabre.io/", - "keywords": [ - "CalDAV", - "CardDAV", - "WebDAV", - "framework", - "iCalendar" - ] - } -] + { + "name": "sabre/xml", + "version": "2.2.6", + "version_normalized": "2.2.6.0", + "source": { + "type": "git", + "url": "https://github.com/sabre-io/xml.git", + "reference": "9cde7cdab1e50893cc83b037b40cd47bfde42a2b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sabre-io/xml/zipball/9cde7cdab1e50893cc83b037b40cd47bfde42a2b", + "reference": "9cde7cdab1e50893cc83b037b40cd47bfde42a2b", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-xmlreader": "*", + "ext-xmlwriter": "*", + "lib-libxml": ">=2.6.20", + "php": "^7.1 || ^8.0", + "sabre/uri": ">=1.0,<3.0.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "~2.17.1", + "phpstan/phpstan": "^0.12", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.0" + }, + "time": "2023-06-28T12:56:05+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "lib/Deserializer/functions.php", + "lib/Serializer/functions.php" + ], + "psr-4": { + "Sabre\\Xml\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Evert Pot", + "email": "me@evertpot.com", + "homepage": "http://evertpot.com/", + "role": "Developer" + }, + { + "name": "Markus Staab", + "email": "markus.staab@redaxo.de", + "role": "Developer" + } + ], + "description": "sabre/xml is an XML library that you may not hate.", + "homepage": "https://sabre.io/xml/", + "keywords": [ + "XMLReader", + "XMLWriter", + "dom", + "xml" + ], + "support": { + "forum": "https://groups.google.com/group/sabredav-discuss", + "issues": "https://github.com/sabre-io/xml/issues", + "source": "https://github.com/fruux/sabre-xml" + }, + "install-path": "../sabre/xml" + } + ], + "dev": false, + "dev-package-names": [] +} diff --git a/htdocs/includes/sabre/composer/installed.php b/htdocs/includes/sabre/composer/installed.php new file mode 100644 index 00000000000..a88a2bc131e --- /dev/null +++ b/htdocs/includes/sabre/composer/installed.php @@ -0,0 +1,86 @@ + array( + 'pretty_version' => 'dev-develop', + 'version' => 'dev-develop', + 'type' => 'library', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'reference' => 'a2df2f2553a3f36892665f58c0e5a115a4d56038', + 'name' => '__root__', + 'dev' => false, + ), + 'versions' => array( + '__root__' => array( + 'pretty_version' => 'dev-develop', + 'version' => 'dev-develop', + 'type' => 'library', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'reference' => 'a2df2f2553a3f36892665f58c0e5a115a4d56038', + 'dev_requirement' => false, + ), + 'psr/log' => array( + 'pretty_version' => '1.1.4', + 'version' => '1.1.4.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/log', + 'aliases' => array(), + 'reference' => 'd49695b909c3b7628b6289db5479a1c204601f11', + 'dev_requirement' => false, + ), + 'sabre/dav' => array( + 'pretty_version' => '4.6.0', + 'version' => '4.6.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../sabre/dav', + 'aliases' => array(), + 'reference' => '554145304b4a026477d130928d16e626939b0b2a', + 'dev_requirement' => false, + ), + 'sabre/event' => array( + 'pretty_version' => '5.1.4', + 'version' => '5.1.4.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../sabre/event', + 'aliases' => array(), + 'reference' => 'd7da22897125d34d7eddf7977758191c06a74497', + 'dev_requirement' => false, + ), + 'sabre/http' => array( + 'pretty_version' => '5.1.10', + 'version' => '5.1.10.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../sabre/http', + 'aliases' => array(), + 'reference' => 'f9f3d1fba8916fa2f4ec25636c4fedc26cb94e02', + 'dev_requirement' => false, + ), + 'sabre/uri' => array( + 'pretty_version' => '2.2.4', + 'version' => '2.2.4.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../sabre/uri', + 'aliases' => array(), + 'reference' => 'c0c9af9f7754e60a49ebd760e1708adc6d1510c0', + 'dev_requirement' => false, + ), + 'sabre/vobject' => array( + 'pretty_version' => '4.5.4', + 'version' => '4.5.4.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../sabre/vobject', + 'aliases' => array(), + 'reference' => 'a6d53a3e5bec85ed3dd78868b7de0f5b4e12f772', + 'dev_requirement' => false, + ), + 'sabre/xml' => array( + 'pretty_version' => '2.2.6', + 'version' => '2.2.6.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../sabre/xml', + 'aliases' => array(), + 'reference' => '9cde7cdab1e50893cc83b037b40cd47bfde42a2b', + 'dev_requirement' => false, + ), + ), +); diff --git a/htdocs/includes/sabre/composer/platform_check.php b/htdocs/includes/sabre/composer/platform_check.php new file mode 100644 index 00000000000..6d3407dbb68 --- /dev/null +++ b/htdocs/includes/sabre/composer/platform_check.php @@ -0,0 +1,26 @@ += 70100)) { + $issues[] = 'Your Composer dependencies require a PHP version ">= 7.1.0". You are running ' . PHP_VERSION . '.'; +} + +if ($issues) { + if (!headers_sent()) { + header('HTTP/1.1 500 Internal Server Error'); + } + if (!ini_get('display_errors')) { + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { + fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); + } elseif (!headers_sent()) { + echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; + } + } + trigger_error( + 'Composer detected issues in your platform: ' . implode(' ', $issues), + E_USER_ERROR + ); +} diff --git a/htdocs/includes/sabre/psr/log/.gitignore b/htdocs/includes/sabre/psr/log/.gitignore deleted file mode 100644 index 22d0d82f809..00000000000 --- a/htdocs/includes/sabre/psr/log/.gitignore +++ /dev/null @@ -1 +0,0 @@ -vendor diff --git a/htdocs/includes/sabre/psr/log/Psr/Log/AbstractLogger.php b/htdocs/includes/sabre/psr/log/Psr/Log/AbstractLogger.php index 90e721af2d3..e02f9daf3d5 100644 --- a/htdocs/includes/sabre/psr/log/Psr/Log/AbstractLogger.php +++ b/htdocs/includes/sabre/psr/log/Psr/Log/AbstractLogger.php @@ -14,8 +14,8 @@ abstract class AbstractLogger implements LoggerInterface /** * System is unusable. * - * @param string $message - * @param array $context + * @param string $message + * @param mixed[] $context * * @return void */ @@ -30,8 +30,8 @@ abstract class AbstractLogger implements LoggerInterface * Example: Entire website down, database unavailable, etc. This should * trigger the SMS alerts and wake you up. * - * @param string $message - * @param array $context + * @param string $message + * @param mixed[] $context * * @return void */ @@ -45,8 +45,8 @@ abstract class AbstractLogger implements LoggerInterface * * Example: Application component unavailable, unexpected exception. * - * @param string $message - * @param array $context + * @param string $message + * @param mixed[] $context * * @return void */ @@ -59,8 +59,8 @@ abstract class AbstractLogger implements LoggerInterface * Runtime errors that do not require immediate action but should typically * be logged and monitored. * - * @param string $message - * @param array $context + * @param string $message + * @param mixed[] $context * * @return void */ @@ -75,8 +75,8 @@ abstract class AbstractLogger implements LoggerInterface * Example: Use of deprecated APIs, poor use of an API, undesirable things * that are not necessarily wrong. * - * @param string $message - * @param array $context + * @param string $message + * @param mixed[] $context * * @return void */ @@ -88,8 +88,8 @@ abstract class AbstractLogger implements LoggerInterface /** * Normal but significant events. * - * @param string $message - * @param array $context + * @param string $message + * @param mixed[] $context * * @return void */ @@ -103,8 +103,8 @@ abstract class AbstractLogger implements LoggerInterface * * Example: User logs in, SQL logs. * - * @param string $message - * @param array $context + * @param string $message + * @param mixed[] $context * * @return void */ @@ -116,8 +116,8 @@ abstract class AbstractLogger implements LoggerInterface /** * Detailed debug information. * - * @param string $message - * @param array $context + * @param string $message + * @param mixed[] $context * * @return void */ diff --git a/htdocs/includes/sabre/psr/log/Psr/Log/LoggerAwareTrait.php b/htdocs/includes/sabre/psr/log/Psr/Log/LoggerAwareTrait.php index 639f79bdaa5..82bf45c89ba 100644 --- a/htdocs/includes/sabre/psr/log/Psr/Log/LoggerAwareTrait.php +++ b/htdocs/includes/sabre/psr/log/Psr/Log/LoggerAwareTrait.php @@ -10,7 +10,7 @@ trait LoggerAwareTrait /** * The logger instance. * - * @var LoggerInterface + * @var LoggerInterface|null */ protected $logger; diff --git a/htdocs/includes/sabre/psr/log/Psr/Log/LoggerInterface.php b/htdocs/includes/sabre/psr/log/Psr/Log/LoggerInterface.php index 5ea72438b56..2206cfde41a 100644 --- a/htdocs/includes/sabre/psr/log/Psr/Log/LoggerInterface.php +++ b/htdocs/includes/sabre/psr/log/Psr/Log/LoggerInterface.php @@ -22,8 +22,8 @@ interface LoggerInterface /** * System is unusable. * - * @param string $message - * @param array $context + * @param string $message + * @param mixed[] $context * * @return void */ @@ -35,8 +35,8 @@ interface LoggerInterface * Example: Entire website down, database unavailable, etc. This should * trigger the SMS alerts and wake you up. * - * @param string $message - * @param array $context + * @param string $message + * @param mixed[] $context * * @return void */ @@ -47,8 +47,8 @@ interface LoggerInterface * * Example: Application component unavailable, unexpected exception. * - * @param string $message - * @param array $context + * @param string $message + * @param mixed[] $context * * @return void */ @@ -58,8 +58,8 @@ interface LoggerInterface * Runtime errors that do not require immediate action but should typically * be logged and monitored. * - * @param string $message - * @param array $context + * @param string $message + * @param mixed[] $context * * @return void */ @@ -71,8 +71,8 @@ interface LoggerInterface * Example: Use of deprecated APIs, poor use of an API, undesirable things * that are not necessarily wrong. * - * @param string $message - * @param array $context + * @param string $message + * @param mixed[] $context * * @return void */ @@ -81,8 +81,8 @@ interface LoggerInterface /** * Normal but significant events. * - * @param string $message - * @param array $context + * @param string $message + * @param mixed[] $context * * @return void */ @@ -93,8 +93,8 @@ interface LoggerInterface * * Example: User logs in, SQL logs. * - * @param string $message - * @param array $context + * @param string $message + * @param mixed[] $context * * @return void */ @@ -103,8 +103,8 @@ interface LoggerInterface /** * Detailed debug information. * - * @param string $message - * @param array $context + * @param string $message + * @param mixed[] $context * * @return void */ @@ -113,11 +113,13 @@ interface LoggerInterface /** * Logs with an arbitrary level. * - * @param mixed $level - * @param string $message - * @param array $context + * @param mixed $level + * @param string $message + * @param mixed[] $context * * @return void + * + * @throws \Psr\Log\InvalidArgumentException */ public function log($level, $message, array $context = array()); } diff --git a/htdocs/includes/sabre/psr/log/Psr/Log/LoggerTrait.php b/htdocs/includes/sabre/psr/log/Psr/Log/LoggerTrait.php index 867225df1d1..e392fef0a0c 100644 --- a/htdocs/includes/sabre/psr/log/Psr/Log/LoggerTrait.php +++ b/htdocs/includes/sabre/psr/log/Psr/Log/LoggerTrait.php @@ -135,6 +135,8 @@ trait LoggerTrait * @param array $context * * @return void + * + * @throws \Psr\Log\InvalidArgumentException */ abstract public function log($level, $message, array $context = array()); } diff --git a/htdocs/includes/sabre/psr/log/Psr/Log/NullLogger.php b/htdocs/includes/sabre/psr/log/Psr/Log/NullLogger.php index d8cd682c8f9..c8f7293b1c6 100644 --- a/htdocs/includes/sabre/psr/log/Psr/Log/NullLogger.php +++ b/htdocs/includes/sabre/psr/log/Psr/Log/NullLogger.php @@ -20,6 +20,8 @@ class NullLogger extends AbstractLogger * @param array $context * * @return void + * + * @throws \Psr\Log\InvalidArgumentException */ public function log($level, $message, array $context = array()) { diff --git a/htdocs/includes/sabre/psr/log/Psr/Log/Test/DummyTest.php b/htdocs/includes/sabre/psr/log/Psr/Log/Test/DummyTest.php new file mode 100644 index 00000000000..9638c110186 --- /dev/null +++ b/htdocs/includes/sabre/psr/log/Psr/Log/Test/DummyTest.php @@ -0,0 +1,18 @@ + true, 'null' => null, @@ -110,6 +114,7 @@ abstract class LoggerInterfaceTest extends \PHPUnit_Framework_TestCase 'nested' => array('with object' => new DummyTest), 'object' => new \DateTime, 'resource' => fopen('php://memory', 'r'), + 'closed' => $closed, ); $this->getLogger()->warning('Crazy context data', $context); @@ -131,10 +136,3 @@ abstract class LoggerInterfaceTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expected, $this->getLogs()); } } - -class DummyTest -{ - public function __toString() - { - } -} diff --git a/htdocs/includes/sabre/psr/log/Psr/Log/Test/TestLogger.php b/htdocs/includes/sabre/psr/log/Psr/Log/Test/TestLogger.php new file mode 100644 index 00000000000..1be3230496b --- /dev/null +++ b/htdocs/includes/sabre/psr/log/Psr/Log/Test/TestLogger.php @@ -0,0 +1,147 @@ + $level, + 'message' => $message, + 'context' => $context, + ]; + + $this->recordsByLevel[$record['level']][] = $record; + $this->records[] = $record; + } + + public function hasRecords($level) + { + return isset($this->recordsByLevel[$level]); + } + + public function hasRecord($record, $level) + { + if (is_string($record)) { + $record = ['message' => $record]; + } + return $this->hasRecordThatPasses(function ($rec) use ($record) { + if ($rec['message'] !== $record['message']) { + return false; + } + if (isset($record['context']) && $rec['context'] !== $record['context']) { + return false; + } + return true; + }, $level); + } + + public function hasRecordThatContains($message, $level) + { + return $this->hasRecordThatPasses(function ($rec) use ($message) { + return strpos($rec['message'], $message) !== false; + }, $level); + } + + public function hasRecordThatMatches($regex, $level) + { + return $this->hasRecordThatPasses(function ($rec) use ($regex) { + return preg_match($regex, $rec['message']) > 0; + }, $level); + } + + public function hasRecordThatPasses(callable $predicate, $level) + { + if (!isset($this->recordsByLevel[$level])) { + return false; + } + foreach ($this->recordsByLevel[$level] as $i => $rec) { + if (call_user_func($predicate, $rec, $i)) { + return true; + } + } + return false; + } + + public function __call($method, $args) + { + if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) { + $genericMethod = $matches[1] . ('Records' !== $matches[3] ? 'Record' : '') . $matches[3]; + $level = strtolower($matches[2]); + if (method_exists($this, $genericMethod)) { + $args[] = $level; + return call_user_func_array([$this, $genericMethod], $args); + } + } + throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()'); + } + + public function reset() + { + $this->records = []; + $this->recordsByLevel = []; + } +} diff --git a/htdocs/includes/sabre/psr/log/README.md b/htdocs/includes/sabre/psr/log/README.md index 574bc1cb2a8..a9f20c437b3 100644 --- a/htdocs/includes/sabre/psr/log/README.md +++ b/htdocs/includes/sabre/psr/log/README.md @@ -7,6 +7,13 @@ This repository holds all interfaces/classes/traits related to Note that this is not a logger of its own. It is merely an interface that describes a logger. See the specification for more details. +Installation +------------ + +```bash +composer require psr/log +``` + Usage ----- @@ -31,6 +38,12 @@ class Foo if ($this->logger) { $this->logger->info('Doing work'); } + + try { + $this->doSomethingElse(); + } catch (Exception $exception) { + $this->logger->error('Oh no!', array('exception' => $exception)); + } // do something useful } diff --git a/htdocs/includes/sabre/psr/log/composer.json b/htdocs/includes/sabre/psr/log/composer.json index 87934d707e7..ca056953770 100644 --- a/htdocs/includes/sabre/psr/log/composer.json +++ b/htdocs/includes/sabre/psr/log/composer.json @@ -7,7 +7,7 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "require": { @@ -20,7 +20,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.1.x-dev" } } } diff --git a/htdocs/includes/sabre/sabre/dav/.travis.yml b/htdocs/includes/sabre/sabre/dav/.travis.yml deleted file mode 100644 index 6214d80b39e..00000000000 --- a/htdocs/includes/sabre/sabre/dav/.travis.yml +++ /dev/null @@ -1,73 +0,0 @@ -language: php -sudo: required - -branches: - only: - - master - -php: - - 7.1 - - 7.2 - - 7.3 - - 7.4 - -env: - global: - - SABRE_MYSQLUSER="root" - - SABRE_MYSQLPASS="" - - SABRE_MYSQLDSN="mysql:host=127.0.0.1;dbname=sabredav_test" - - RUN_PHPCSFIXER="TRUE" - - RUN_PHPUNIT="TRUE" - - RUN_PHPSTAN="FALSE" - matrix: - - PREFER_LOWEST="" TEST_DEPS="" REPORT_COVERAGE="TRUE" WITH_COVERAGE="--coverage-clover=coverage.xml" - - PREFER_LOWEST="--prefer-lowest" TEST_DEPS="tests/Sabre/" REPORT_COVERAGE="FALSE" WITH_COVERAGE="" - -matrix: - include: - - name: 'PHP8' - dist: bionic - php: 8.0 - env: - - RUN_PHPCSFIXER="FALSE" - - REPORT_COVERAGE="FALSE" - - name: 'PHPStan' - php: 7.4 - env: - - RUN_PHPCSFIXER="FALSE" - - RUN_PHPUNIT="FALSE" - - RUN_PHPSTAN="TRUE" - - REPORT_COVERAGE="FALSE" - - name: 'Test with streaming propfind' - php: 7.2 - env: - - RUN_TEST_WITH_STREAMING_PROPFIND="TRUE" - - REPORT_COVERAGE="FALSE" - fast_finish: true - -services: - - mysql - - postgresql - -before_script: - - mysql -u root -h 127.0.0.1 -e 'create database sabredav_test' - - psql -c "create database sabredav_test" -U postgres - - psql -c "create user sabredav with PASSWORD 'sabredav';GRANT ALL PRIVILEGES ON DATABASE sabredav_test TO sabredav" -U postgres - - if [ $RUN_PHPCSFIXER == "FALSE" ]; then composer remove --no-update --dev friendsofphp/php-cs-fixer; fi - - composer update $PREFER_LOWEST - -addons: - postgresql: "9.5" - -script: - - if [ $RUN_PHPCSFIXER == "TRUE" ]; then php vendor/bin/php-cs-fixer fix --dry-run --diff; fi - - if [ $RUN_PHPUNIT == "TRUE" ]; then php vendor/bin/phpunit --configuration tests/phpunit.xml $WITH_COVERAGE $TEST_DEPS; fi - - if [ $RUN_PHPUNIT == "TRUE" ]; then rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini; fi - - if [ $RUN_PHPSTAN == "TRUE" ]; then composer phpstan; fi - -after_success: - - if [ $REPORT_COVERAGE == "TRUE" ]; then bash <(curl -s https://codecov.io/bash); fi - -cache: - directories: - - $HOME/.composer/cache diff --git a/htdocs/includes/sabre/sabre/dav/composer.json b/htdocs/includes/sabre/sabre/dav/composer.json index 6e9b9cb6b39..3154173398e 100644 --- a/htdocs/includes/sabre/sabre/dav/composer.json +++ b/htdocs/includes/sabre/sabre/dav/composer.json @@ -15,11 +15,11 @@ ], "require": { "php": "^7.1.0 || ^8.0", - "sabre/vobject": "^4.5.1", - "sabre/event" : "^5.0.0", - "sabre/xml" : "^2.5.5", + "sabre/vobject": "^4.2.1", + "sabre/event" : "^5.0", + "sabre/xml" : "^2.0.1", "sabre/http" : "^5.0.5", - "sabre/uri" : "^2.2.3", + "sabre/uri" : "^2.0", "ext-dom": "*", "ext-pcre": "*", "ext-spl": "*", @@ -33,11 +33,11 @@ "ext-json": "*" }, "require-dev" : { - "friendsofphp/php-cs-fixer": "^2.17.1", - "phpstan/phpstan": "^0.12", - "phpunit/phpunit" : "^7.5 || ^8.5 || ^9.0", - "evert/phpdoc-md" : "~0.1.0", - "monolog/monolog": "^1.18" + "friendsofphp/php-cs-fixer": "^2.19", + "monolog/monolog": "^1.27 || ^2.0", + "phpstan/phpstan": "^0.12 || ^1.0", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.6" }, "suggest" : { "ext-curl" : "*", @@ -46,21 +46,12 @@ }, "autoload": { "psr-4" : { - "Sabre\\DAV\\" : "lib/DAV/", - "Sabre\\DAVACL\\" : "lib/DAVACL/", - "Sabre\\CalDAV\\" : "lib/CalDAV/", - "Sabre\\CardDAV\\" : "lib/CardDAV/" + "Sabre\\" : "lib/" } }, "autoload-dev" : { "psr-4" : { - "Sabre\\" : "tests/Sabre/", - "Sabre\\CalDAV\\" : "tests/Sabre/CalDAV", - "Sabre\\CardDAV\\" : "tests/Sabre/CardDAV", - "Sabre\\DAV\\" : "tests/Sabre/DAV", - "Sabre\\DAV\\Property\\" : "tests/Sabre/DAV/Xml/Property", - "Sabre\\DAVACL\\" : "tests/Sabre/DAVACL", - "Sabre\\HTTP\\" : "tests/Sabre/HTTP" + "Sabre\\" : "tests/Sabre/" } }, "support" : { diff --git a/htdocs/includes/sabre/sabre/dav/lib/CalDAV/Backend/AbstractBackend.php b/htdocs/includes/sabre/sabre/dav/lib/CalDAV/Backend/AbstractBackend.php index c32c86489da..c761bff51b5 100644 --- a/htdocs/includes/sabre/sabre/dav/lib/CalDAV/Backend/AbstractBackend.php +++ b/htdocs/includes/sabre/sabre/dav/lib/CalDAV/Backend/AbstractBackend.php @@ -78,7 +78,7 @@ abstract class AbstractBackend implements BackendInterface * * This default may well be good enough for personal use, and calendars * that aren't very large. But if you anticipate high usage, big calendars - * or high loads, you are strongly adviced to optimize certain paths. + * or high loads, you are strongly advised to optimize certain paths. * * The best way to do so is override this method and to optimize * specifically for 'common filters'. @@ -95,7 +95,7 @@ abstract class AbstractBackend implements BackendInterface * Note that especially time-range-filters may be difficult to parse. A * time-range filter specified on a VEVENT must for instance also handle * recurrence rules correctly. - * A good example of how to interprete all these filters can also simply + * A good example of how to interpret all these filters can also simply * be found in \Sabre\CalDAV\CalendarQueryFilter. This class is as correct * as possible, so it gives you a good idea on what type of stuff you need * to think of. diff --git a/htdocs/includes/sabre/sabre/dav/lib/CalDAV/Backend/PDO.php b/htdocs/includes/sabre/sabre/dav/lib/CalDAV/Backend/PDO.php index 2f48ab9828d..b9f112cf8da 100644 --- a/htdocs/includes/sabre/sabre/dav/lib/CalDAV/Backend/PDO.php +++ b/htdocs/includes/sabre/sabre/dav/lib/CalDAV/Backend/PDO.php @@ -939,7 +939,7 @@ SQL; * @param int $syncLevel * @param int $limit * - * @return array + * @return array|null */ public function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null) { diff --git a/htdocs/includes/sabre/sabre/dav/lib/CalDAV/Backend/SyncSupport.php b/htdocs/includes/sabre/sabre/dav/lib/CalDAV/Backend/SyncSupport.php index c7f67d17615..bfc1dafc2ea 100644 --- a/htdocs/includes/sabre/sabre/dav/lib/CalDAV/Backend/SyncSupport.php +++ b/htdocs/includes/sabre/sabre/dav/lib/CalDAV/Backend/SyncSupport.php @@ -77,7 +77,7 @@ interface SyncSupport extends BackendInterface * @param int $syncLevel * @param int $limit * - * @return array + * @return array|null */ public function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null); } diff --git a/htdocs/includes/sabre/sabre/dav/lib/CalDAV/Calendar.php b/htdocs/includes/sabre/sabre/dav/lib/CalDAV/Calendar.php index 6e989314dcf..6c0bf541155 100644 --- a/htdocs/includes/sabre/sabre/dav/lib/CalDAV/Calendar.php +++ b/htdocs/includes/sabre/sabre/dav/lib/CalDAV/Calendar.php @@ -186,17 +186,17 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, * The contents of the new file must be a valid ICalendar string. * * @param string $name - * @param resource $calendarData + * @param resource $data * * @return string|null */ - public function createFile($name, $calendarData = null) + public function createFile($name, $data = null) { - if (is_resource($calendarData)) { - $calendarData = stream_get_contents($calendarData); + if (is_resource($data)) { + $data = stream_get_contents($data); } - return $this->caldavBackend->createCalendarObject($this->calendarInfo['id'], $name, $calendarData); + return $this->caldavBackend->createCalendarObject($this->calendarInfo['id'], $name, $data); } /** @@ -442,7 +442,7 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, * @param int $syncLevel * @param int $limit * - * @return array + * @return array|null */ public function getChanges($syncToken, $syncLevel, $limit = null) { diff --git a/htdocs/includes/sabre/sabre/dav/lib/CalDAV/CalendarHome.php b/htdocs/includes/sabre/sabre/dav/lib/CalDAV/CalendarHome.php index 159ddcc67c1..49c54a37a7a 100644 --- a/htdocs/includes/sabre/sabre/dav/lib/CalDAV/CalendarHome.php +++ b/htdocs/includes/sabre/sabre/dav/lib/CalDAV/CalendarHome.php @@ -96,10 +96,10 @@ class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL * * This is currently not allowed * - * @param string $filename + * @param string $name * @param resource $data */ - public function createFile($filename, $data = null) + public function createFile($name, $data = null) { throw new DAV\Exception\MethodNotAllowed('Creating new files in this collection is not supported'); } diff --git a/htdocs/includes/sabre/sabre/dav/lib/CalDAV/Schedule/IMipPlugin.php b/htdocs/includes/sabre/sabre/dav/lib/CalDAV/Schedule/IMipPlugin.php index e050ac273d2..dcaf951efdf 100644 --- a/htdocs/includes/sabre/sabre/dav/lib/CalDAV/Schedule/IMipPlugin.php +++ b/htdocs/includes/sabre/sabre/dav/lib/CalDAV/Schedule/IMipPlugin.php @@ -30,13 +30,6 @@ class IMipPlugin extends DAV\ServerPlugin */ protected $senderEmail; - /** - * ITipMessage. - * - * @var ITip\Message - */ - protected $itipMessage; - /** * Creates the email handler. * diff --git a/htdocs/includes/sabre/sabre/dav/lib/CalDAV/Schedule/Plugin.php b/htdocs/includes/sabre/sabre/dav/lib/CalDAV/Schedule/Plugin.php index 3cc360f1d45..5e565961019 100644 --- a/htdocs/includes/sabre/sabre/dav/lib/CalDAV/Schedule/Plugin.php +++ b/htdocs/includes/sabre/sabre/dav/lib/CalDAV/Schedule/Plugin.php @@ -605,10 +605,9 @@ class Plugin extends ServerPlugin * * This method may update $newObject to add any status changes. * - * @param VCalendar|string $oldObject - * @param array $ignore any addresses to not send messages to - * @param bool $modified a marker to indicate that the original object - * modified by this process + * @param VCalendar|string|null $oldObject + * @param array $ignore any addresses to not send messages to + * @param bool $modified a marker to indicate that the original object modified by this process */ protected function processICalendarChange($oldObject, VCalendar $newObject, array $addresses, array $ignore = [], &$modified = false) { @@ -969,7 +968,7 @@ class Plugin extends ServerPlugin * * @return bool */ - private function scheduleReply(RequestInterface $request) + protected function scheduleReply(RequestInterface $request) { $scheduleReply = $request->getHeader('Schedule-Reply'); diff --git a/htdocs/includes/sabre/sabre/dav/lib/CalDAV/Xml/Filter/PropFilter.php b/htdocs/includes/sabre/sabre/dav/lib/CalDAV/Xml/Filter/PropFilter.php index c9a3cb5acfa..f1d66cc0d66 100644 --- a/htdocs/includes/sabre/sabre/dav/lib/CalDAV/Xml/Filter/PropFilter.php +++ b/htdocs/includes/sabre/sabre/dav/lib/CalDAV/Xml/Filter/PropFilter.php @@ -53,7 +53,7 @@ class PropFilter implements XmlDeserializable 'is-not-defined' => false, 'param-filters' => [], 'text-match' => null, - 'time-range' => false, + 'time-range' => [], ]; $att = $reader->parseAttributes(); diff --git a/htdocs/includes/sabre/sabre/dav/lib/CardDAV/AddressBook.php b/htdocs/includes/sabre/sabre/dav/lib/CardDAV/AddressBook.php index 86994f2d5f6..f5744f644b2 100644 --- a/htdocs/includes/sabre/sabre/dav/lib/CardDAV/AddressBook.php +++ b/htdocs/includes/sabre/sabre/dav/lib/CardDAV/AddressBook.php @@ -129,19 +129,19 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie * This method may return an ETag. * * @param string $name - * @param resource $vcardData + * @param resource $data * * @return string|null */ - public function createFile($name, $vcardData = null) + public function createFile($name, $data = null) { - if (is_resource($vcardData)) { - $vcardData = stream_get_contents($vcardData); + if (is_resource($data)) { + $data = stream_get_contents($data); } // Converting to UTF-8, if needed - $vcardData = DAV\StringUtil::ensureUTF8($vcardData); + $data = DAV\StringUtil::ensureUTF8($data); - return $this->carddavBackend->createCard($this->addressBookInfo['id'], $name, $vcardData); + return $this->carddavBackend->createCard($this->addressBookInfo['id'], $name, $data); } /** @@ -317,7 +317,7 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie * @param int $syncLevel * @param int $limit * - * @return array + * @return array|null */ public function getChanges($syncToken, $syncLevel, $limit = null) { diff --git a/htdocs/includes/sabre/sabre/dav/lib/CardDAV/AddressBookHome.php b/htdocs/includes/sabre/sabre/dav/lib/CardDAV/AddressBookHome.php index 884e9b24e08..d7365fbe826 100644 --- a/htdocs/includes/sabre/sabre/dav/lib/CardDAV/AddressBookHome.php +++ b/htdocs/includes/sabre/sabre/dav/lib/CardDAV/AddressBookHome.php @@ -92,10 +92,10 @@ class AddressBookHome extends DAV\Collection implements DAV\IExtendedCollection, * * This is currently not allowed * - * @param string $filename + * @param string $name * @param resource $data */ - public function createFile($filename, $data = null) + public function createFile($name, $data = null) { throw new DAV\Exception\MethodNotAllowed('Creating new files in this collection is not supported'); } diff --git a/htdocs/includes/sabre/sabre/dav/lib/CardDAV/Backend/PDO.php b/htdocs/includes/sabre/sabre/dav/lib/CardDAV/Backend/PDO.php index 966d7ba095d..4ca9284a9ef 100644 --- a/htdocs/includes/sabre/sabre/dav/lib/CardDAV/Backend/PDO.php +++ b/htdocs/includes/sabre/sabre/dav/lib/CardDAV/Backend/PDO.php @@ -452,7 +452,7 @@ class PDO extends AbstractBackend implements SyncSupport * @param int $syncLevel * @param int $limit * - * @return array + * @return array|null */ public function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, $limit = null) { diff --git a/htdocs/includes/sabre/sabre/dav/lib/CardDAV/Backend/SyncSupport.php b/htdocs/includes/sabre/sabre/dav/lib/CardDAV/Backend/SyncSupport.php index 071361ed027..6aaad141540 100644 --- a/htdocs/includes/sabre/sabre/dav/lib/CardDAV/Backend/SyncSupport.php +++ b/htdocs/includes/sabre/sabre/dav/lib/CardDAV/Backend/SyncSupport.php @@ -77,7 +77,7 @@ interface SyncSupport extends BackendInterface * @param int $syncLevel * @param int $limit * - * @return array + * @return array|null */ public function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, $limit = null); } diff --git a/htdocs/includes/sabre/sabre/dav/lib/CardDAV/Xml/Request/AddressBookMultiGetReport.php b/htdocs/includes/sabre/sabre/dav/lib/CardDAV/Xml/Request/AddressBookMultiGetReport.php index c11d2dd7368..491f969088f 100644 --- a/htdocs/includes/sabre/sabre/dav/lib/CardDAV/Xml/Request/AddressBookMultiGetReport.php +++ b/htdocs/includes/sabre/sabre/dav/lib/CardDAV/Xml/Request/AddressBookMultiGetReport.php @@ -38,7 +38,7 @@ class AddressBookMultiGetReport implements XmlDeserializable public $hrefs; /** - * The mimetype of the content that should be returend. Usually + * The mimetype of the content that should be returned. Usually * text/vcard. * * @var string @@ -53,6 +53,13 @@ class AddressBookMultiGetReport implements XmlDeserializable */ public $version = null; + /** + * An array with requested vcard properties. + * + * @var array + */ + public $addressDataProperties; + /** * The deserialize method is called during xml parsing. * diff --git a/htdocs/includes/sabre/sabre/dav/lib/DAV/Client.php b/htdocs/includes/sabre/sabre/dav/lib/DAV/Client.php index a9de71cdbb5..1028a6b9d55 100644 --- a/htdocs/includes/sabre/sabre/dav/lib/DAV/Client.php +++ b/htdocs/includes/sabre/sabre/dav/lib/DAV/Client.php @@ -173,28 +173,99 @@ class Client extends HTTP\Client $this->propertyMap = &$this->xml->elementMap; } + /** + * Does a PROPFIND request with filtered response returning only available properties. + * + * The list of requested properties must be specified as an array, in clark + * notation. + * + * Depth should be either 0 or 1. A depth of 1 will cause a request to be + * made to the server to also return all child resources. + * + * For depth 0, just the array of properties for the resource is returned. + * + * For depth 1, the returned array will contain a list of resource names as keys, + * and an array of properties as values. + * + * The array of properties will contain the properties as keys with their values as the value. + * Only properties that are actually returned from the server without error will be + * returned, anything else is discarded. + * + * @param 1|0 $depth + */ + public function propFind($url, array $properties, $depth = 0): array + { + $result = $this->doPropFind($url, $properties, $depth); + + // If depth was 0, we only return the top item + if (0 === $depth) { + reset($result); + $result = current($result); + + return isset($result[200]) ? $result[200] : []; + } + + $newResult = []; + foreach ($result as $href => $statusList) { + $newResult[$href] = isset($statusList[200]) ? $statusList[200] : []; + } + + return $newResult; + } + + /** + * Does a PROPFIND request with unfiltered response. + * + * The list of requested properties must be specified as an array, in clark + * notation. + * + * Depth should be either 0 or 1. A depth of 1 will cause a request to be + * made to the server to also return all child resources. + * + * For depth 0, just the multi-level array of status and properties for the resource is returned. + * + * For depth 1, the returned array will contain a list of resources as keys and + * a multi-level array containing status and properties as value. + * + * The multi-level array of status and properties is formatted the same as what is + * documented for parseMultiStatus. + * + * All properties that are actually returned from the server are returned by this method. + * + * @param 1|0 $depth + */ + public function propFindUnfiltered(string $url, array $properties, int $depth = 0): array + { + $result = $this->doPropFind($url, $properties, $depth); + + // If depth was 0, we only return the top item + if (0 === $depth) { + reset($result); + + return current($result); + } else { + return $result; + } + } + /** * Does a PROPFIND request. * * The list of requested properties must be specified as an array, in clark * notation. * - * The returned array will contain a list of filenames as keys, and - * properties as values. - * - * The properties array will contain the list of properties. Only properties - * that are actually returned from the server (without error) will be - * returned, anything else is discarded. - * * Depth should be either 0 or 1. A depth of 1 will cause a request to be * made to the server to also return all child resources. * - * @param string $url - * @param int $depth + * The returned array will contain a list of resources as keys and + * a multi-level array containing status and properties as value. * - * @return array + * The multi-level array of status and properties is formatted the same as what is + * documented for parseMultiStatus. + * + * @param 1|0 $depth */ - public function propFind($url, array $properties, $depth = 0) + private function doPropFind($url, array $properties, $depth = 0): array { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->formatOutput = true; @@ -232,22 +303,7 @@ class Client extends HTTP\Client throw new HTTP\ClientHttpException($response); } - $result = $this->parseMultiStatus($response->getBodyAsString()); - - // If depth was 0, we only return the top item - if (0 === $depth) { - reset($result); - $result = current($result); - - return isset($result[200]) ? $result[200] : []; - } - - $newResult = []; - foreach ($result as $href => $statusList) { - $newResult[$href] = isset($statusList[200]) ? $statusList[200] : []; - } - - return $newResult; + return $this->parseMultiStatus($response->getBodyAsString()); } /** @@ -385,7 +441,7 @@ class Client extends HTTP\Client { return Uri\resolve( $this->baseUri, - $url + (string) $url ); } diff --git a/htdocs/includes/sabre/sabre/dav/lib/DAV/INodeByPath.php b/htdocs/includes/sabre/sabre/dav/lib/DAV/INodeByPath.php new file mode 100644 index 00000000000..4d63a33bd7d --- /dev/null +++ b/htdocs/includes/sabre/sabre/dav/lib/DAV/INodeByPath.php @@ -0,0 +1,36 @@ +rootNode; } - // Attempting to fetch its parent - list($parentName, $baseName) = Uri\split($path); + $parts = explode('/', $path); + $node = $this->rootNode; - // If there was no parent, we must simply ask it from the root node. - if ('' === $parentName) { - $node = $this->rootNode->getChild($baseName); - } else { - // Otherwise, we recursively grab the parent and ask him/her. - $parent = $this->getNodeForPath($parentName); - - if (!($parent instanceof ICollection)) { + while (count($parts)) { + if (!($node instanceof ICollection)) { throw new Exception\NotFound('Could not find node at path: '.$path); } - $node = $parent->getChild($baseName); + + if ($node instanceof INodeByPath) { + $targetNode = $node->getNodeForPath(implode('/', $parts)); + if ($targetNode instanceof Node) { + $node = $targetNode; + break; + } + } + + $part = array_shift($parts); + if ('' !== $part) { + $node = $node->getChild($part); + } } $this->cache[$path] = $node; diff --git a/htdocs/includes/sabre/sabre/dav/lib/DAV/Version.php b/htdocs/includes/sabre/sabre/dav/lib/DAV/Version.php index c87901d8083..345c62d7ec9 100644 --- a/htdocs/includes/sabre/sabre/dav/lib/DAV/Version.php +++ b/htdocs/includes/sabre/sabre/dav/lib/DAV/Version.php @@ -16,5 +16,5 @@ class Version /** * Full version number. */ - const VERSION = '4.4.0'; + public const VERSION = '4.6.0'; } diff --git a/htdocs/includes/sabre/sabre/dav/lib/DAV/Xml/Element/Response.php b/htdocs/includes/sabre/sabre/dav/lib/DAV/Xml/Element/Response.php index 79f06a09bf8..df92914650e 100644 --- a/htdocs/includes/sabre/sabre/dav/lib/DAV/Xml/Element/Response.php +++ b/htdocs/includes/sabre/sabre/dav/lib/DAV/Xml/Element/Response.php @@ -40,7 +40,7 @@ class Response implements Element * * This is currently only used in WebDAV-Sync * - * @var string + * @var string|null */ protected $httpStatus; @@ -112,13 +112,21 @@ class Response implements Element */ public function xmlSerialize(Writer $writer) { - if ($status = $this->getHTTPStatus()) { - $writer->writeElement('{DAV:}status', 'HTTP/1.1 '.$status.' '.\Sabre\HTTP\Response::$statusCodes[$status]); - } + /* + * Accordingly to the RFC the element looks like: + * + * + * So the response + * - MUST contain a href and + * - EITHER a status and additional href(s) + * OR one or more propstat(s) + */ $writer->writeElement('{DAV:}href', $writer->contextUri.\Sabre\HTTP\encodePath($this->getHref())); $empty = true; + $httpStatus = $this->getHTTPStatus(); + // Add propstat elements foreach ($this->getResponseProperties() as $status => $properties) { // Skipping empty lists if (!$properties || (!is_int($status) && !ctype_digit($status))) { @@ -130,19 +138,25 @@ class Response implements Element $writer->writeElement('{DAV:}status', 'HTTP/1.1 '.$status.' '.\Sabre\HTTP\Response::$statusCodes[$status]); $writer->endElement(); // {DAV:}propstat } + + // The WebDAV spec only allows the status element on responses _without_ a propstat if ($empty) { - /* - * The WebDAV spec _requires_ at least one DAV:propstat to appear for - * every DAV:response. In some circumstances however, there are no - * properties to encode. - * - * In those cases we MUST specify at least one DAV:propstat anyway, with - * no properties. - */ - $writer->writeElement('{DAV:}propstat', [ - '{DAV:}prop' => [], - '{DAV:}status' => 'HTTP/1.1 418 '.\Sabre\HTTP\Response::$statusCodes[418], - ]); + if (null !== $httpStatus) { + $writer->writeElement('{DAV:}status', 'HTTP/1.1 '.$httpStatus.' '.\Sabre\HTTP\Response::$statusCodes[$httpStatus]); + } else { + /* + * The WebDAV spec _requires_ at least one DAV:propstat to appear for + * every DAV:response if there is no status. + * In some circumstances however, there are no properties to encode. + * + * In those cases we MUST specify at least one DAV:propstat anyway, with + * no properties. + */ + $writer->writeElement('{DAV:}propstat', [ + '{DAV:}prop' => [], + '{DAV:}status' => 'HTTP/1.1 418 '.\Sabre\HTTP\Response::$statusCodes[418], + ]); + } } } diff --git a/htdocs/includes/sabre/sabre/dav/lib/DAV/Xml/Property/Href.php b/htdocs/includes/sabre/sabre/dav/lib/DAV/Xml/Property/Href.php index f88ce814ad6..d4e43da7cd9 100644 --- a/htdocs/includes/sabre/sabre/dav/lib/DAV/Xml/Property/Href.php +++ b/htdocs/includes/sabre/sabre/dav/lib/DAV/Xml/Property/Href.php @@ -34,6 +34,19 @@ class Href implements Element, HtmlOutput */ protected $hrefs; + /** + * Automatically prefix the url with the server base directory. + * Note: use of this property in code was removed in PR: + * https://github.com/sabre-io/dav/pull/801 + * But the property is left here because old data may still exist + * that has this property saved. + * See discussion in issue: + * https://github.com/sabre-io/Baikal/issues/1154. + * + * @var bool + */ + protected $autoPrefix = true; + /** * Constructor. * diff --git a/htdocs/includes/sabre/sabre/dav/lib/DAVACL/PrincipalBackend/BackendInterface.php b/htdocs/includes/sabre/sabre/dav/lib/DAVACL/PrincipalBackend/BackendInterface.php index 7140a929544..2fd31913daa 100644 --- a/htdocs/includes/sabre/sabre/dav/lib/DAVACL/PrincipalBackend/BackendInterface.php +++ b/htdocs/includes/sabre/sabre/dav/lib/DAVACL/PrincipalBackend/BackendInterface.php @@ -48,7 +48,7 @@ interface BackendInterface public function getPrincipalByPath($path); /** - * Updates one ore more webdav properties on a principal. + * Updates one or more webdav properties on a principal. * * The list of mutations is stored in a Sabre\DAV\PropPatch object. * To do the actual updates, you must tell this object which properties diff --git a/htdocs/includes/sabre/sabre/event/.gitignore b/htdocs/includes/sabre/sabre/event/.gitignore deleted file mode 100644 index d06a78164db..00000000000 --- a/htdocs/includes/sabre/sabre/event/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -#composer -vendor -composer.lock - -#binaries -bin/sabre-cs-fixer -bin/php-cs-fixer -bin/phpunit - -#vim lock files -.*.swp - -#development stuff -tests/cov diff --git a/htdocs/includes/sabre/sabre/dav/.php_cs.dist b/htdocs/includes/sabre/sabre/event/.php_cs.dist similarity index 100% rename from htdocs/includes/sabre/sabre/dav/.php_cs.dist rename to htdocs/includes/sabre/sabre/event/.php_cs.dist diff --git a/htdocs/includes/sabre/sabre/event/.travis.yml b/htdocs/includes/sabre/sabre/event/.travis.yml deleted file mode 100644 index 7089e370b7d..00000000000 --- a/htdocs/includes/sabre/sabre/event/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -language: php -php: - - 7 - -matrix: - allow_failures: - - php: hhvm - -env: - matrix: - - LOWEST_DEPS="" - - LOWEST_DEPS="--prefer-lowest" - -before_script: - - composer update --prefer-source $LOWEST_DEPS - -script: - - ./bin/phpunit - - ./bin/sabre-cs-fixer fix . --dry-run --diff - -sudo: false - -cache: vendor diff --git a/htdocs/includes/sabre/sabre/event/CHANGELOG.md b/htdocs/includes/sabre/sabre/event/CHANGELOG.md deleted file mode 100644 index f46e9d0f76b..00000000000 --- a/htdocs/includes/sabre/sabre/event/CHANGELOG.md +++ /dev/null @@ -1,104 +0,0 @@ -ChangeLog -========= - -5.0.0 (2016-10-23) ------------------- - -* #42: The `coroutine` function now supports `return` in the passed generator - function. This allows you to more generally return a value. This is a BC - break as this is a feature that was only made possible with PHP 7, and - before the coroutine function would only ever return the last thing that - was yielded. If you depended on that feature, replace your last `yield` with - a `return`. - - -4.0.0 (2016-09-19) ------------------- - -* sabre/event now requires PHP 7. If you need PHP 5.5 support, just keep - using 3.0.0. -* PHP 7 type hints are now used everywhere. We're also using strict_types. -* Support for a new `WildcardEmitter` which allows you to listen for events - using the `*` wildcard. -* Removed deprecated functions `Promise::error` and `Promise::all`. Instead, - use `Promise::otherwise` and `Promise\all()`. -* `EventEmitter`, `EventEmitterTrait` and `EventEmitterInterface` are now just - called `Emitter`, `EmitterTrait`, and `EmitterInterface`. -* When rejecting Promises, it's now _required_ to use an `Exception` or - `Throwable`. This makes the typical case simpler and reduces special cases. - -3.0.0 (2015-11-05) ------------------- - -* Now requires PHP 5.5! -* `Promise::all()` is moved to `Promise\all()`. -* Aside from the `Promise\all()` function, there's now also `Promise\race()`. -* `Promise\reject()` and `Promise\resolve()` have also been added. -* Now 100% compatible with the Ecmascript 6 Promise. - - -3.0.0-alpha1 (2015-10-23) -------------------------- - -* This package now requires PHP 5.5. -* #26: Added an event loop implementation. Also knows as the Reactor Pattern. -* Renamed `Promise::error` to `Promise::otherwise` to be consistent with - ReactPHP and Guzzle. The `error` method is kept for BC but will be removed - in a future version. -* #27: Support for Promise-based coroutines via the `Sabre\Event\coroutine` - function. -* BC Break: Promises now use the EventLoop to run "then"-events in a separate - execution context. In practise that means you need to run the event loop to - wait for any `then`/`otherwise` callbacks to trigger. -* Promises now have a `wait()` method. Allowing you to make a promise - synchronous and simply wait for a result (or exception) to happen. - - -2.0.2 (2015-05-19) ------------------- - -* This release has no functional changes. It's just been brought up to date - with the latest coding standards. - - -2.0.1 (2014-10-06) ------------------- - -* Fixed: `$priority` was ignored in `EventEmitter::once` method. -* Fixed: Breaking the event chain was not possible in `EventEmitter::once`. - - -2.0.0 (2014-06-21) ------------------- - -* Added: When calling emit, it's now possible to specify a callback that will be - triggered after each method handled. This is dubbed the 'continueCallback' and - can be used to implement strategy patterns. -* Added: Promise object! -* Changed: EventEmitter::listeners now returns just the callbacks for an event, - and no longer returns the list by reference. The list is now automatically - sorted by priority. -* Update: Speed improvements. -* Updated: It's now possible to remove all listeners for every event. -* Changed: Now uses psr-4 autoloading. - - -1.0.1 (2014-06-12) ------------------- - -* hhvm compatible! -* Fixed: Issue #4. Compatiblitiy for PHP < 5.4.14. - - -1.0.0 (2013-07-19) ------------------- - -* Added: removeListener, removeAllListeners -* Added: once, to only listen to an event emitting once. -* Added README.md. - - -0.0.1-alpha (2013-06-29) ------------------------- - -* First version! diff --git a/htdocs/includes/sabre/sabre/event/README.md b/htdocs/includes/sabre/sabre/event/README.md deleted file mode 100644 index a20473fd5d5..00000000000 --- a/htdocs/includes/sabre/sabre/event/README.md +++ /dev/null @@ -1,51 +0,0 @@ -sabre/event -=========== - -A lightweight library for event-based development in PHP. - -This library provides the following event-based concepts: - -1. EventEmitter. -2. Promises. -3. An event loop. -4. Co-routines. - -Full documentation can be found on [the website][1]. - -Installation ------------- - -Make sure you have [composer][3] installed, and then run: - - composer require sabre/event "^3.0" - -This package requires PHP 5.5. The 2.0 branch is still maintained as well, and -supports PHP 5.4. - -Build status ------------- - -| branch | status | -| ------ | ------ | -| master | [![Build Status](https://travis-ci.org/fruux/sabre-event.svg?branch=master)](https://travis-ci.org/fruux/sabre-event) | -| 3.0 | [![Build Status](https://travis-ci.org/fruux/sabre-event.svg?branch=2.0)](https://travis-ci.org/fruux/sabre-event) | -| 2.0 | [![Build Status](https://travis-ci.org/fruux/sabre-event.svg?branch=2.0)](https://travis-ci.org/fruux/sabre-event) | -| 1.0 | [![Build Status](https://travis-ci.org/fruux/sabre-event.svg?branch=1.0)](https://travis-ci.org/fruux/sabre-event) | -| php53 | [![Build Status](https://travis-ci.org/fruux/sabre-event.svg?branch=php53)](https://travis-ci.org/fruux/sabre-event) | - - -Questions? ----------- - -Head over to the [sabre/dav mailinglist][4], or you can also just open a ticket -on [GitHub][5]. - -Made at fruux -------------- - -This library is being developed by [fruux](https://fruux.com/). Drop us a line for commercial services or enterprise support. - -[1]: http://sabre.io/event/ -[3]: http://getcomposer.org/ -[4]: http://groups.google.com/group/sabredav-discuss -[5]: https://github.com/fruux/sabre-event/issues/ diff --git a/htdocs/includes/sabre/sabre/event/composer.json b/htdocs/includes/sabre/sabre/event/composer.json index 6eb192e7a19..42fb4aa2297 100644 --- a/htdocs/includes/sabre/sabre/event/composer.json +++ b/htdocs/includes/sabre/sabre/event/composer.json @@ -16,7 +16,7 @@ "homepage": "http://sabre.io/event/", "license": "BSD-3-Clause", "require": { - "php": ">=7.0" + "php": "^7.1 || ^8.0" }, "authors": [ { @@ -40,11 +40,30 @@ "lib/Promise/functions.php" ] }, - "require-dev": { - "sabre/cs": "~1.0.0", - "phpunit/phpunit" : "*" + "autoload-dev": { + "psr-4" : { + "Sabre\\Event\\" : "tests/Event" + } }, - "config" : { - "bin-dir" : "bin/" + "require-dev": { + "friendsofphp/php-cs-fixer": "~2.17.1", + "phpstan/phpstan": "^0.12", + "phpunit/phpunit" : "^7.5 || ^8.5 || ^9.0" + }, + "scripts": { + "phpstan": [ + "phpstan analyse lib tests" + ], + "cs-fixer": [ + "php-cs-fixer fix" + ], + "phpunit": [ + "phpunit --configuration tests/phpunit.xml" + ], + "test": [ + "composer phpstan", + "composer cs-fixer", + "composer phpunit" + ] } } diff --git a/htdocs/includes/sabre/sabre/event/examples/curl.php b/htdocs/includes/sabre/sabre/event/examples/curl.php deleted file mode 100644 index c2455760bc0..00000000000 --- a/htdocs/includes/sabre/sabre/event/examples/curl.php +++ /dev/null @@ -1,131 +0,0 @@ -#!/usr/bin/env php -curlMultiHandle = curl_multi_init(); - - } - - function addHandle($curlHandle) { - - curl_multi_add_handle($mh, $curlHandle); - - } - -} - -$active = null; - -function curl_multi_loop_scheduler($mh, callable $done) { - - $mrc = curl_multi_exec($mh, $active); - switch ($mrc) { - - /** - * From the curl docs. If CURM_CALL_MULTI_PERFORM is returned, simply - * call curl_multi_perform immediately again. In PHP this means we - * actually call curl_multi_exec immediately again. - * - * We're doing this in the next tick. - */ - case CURLM_CALL_MULTI_PERFORM : - Loop\nextTick(function() use ($mh, $done) { - - curl_multi_loop_scheduler($mh, $done); - - }); - break; - case CURLM_OK : - if (!$active) { - // We're done! - $done(); - return; - } - // Check again after 0.02 seconds - Loop\setTimeout(function() use ($mh, $done) { - - curl_multi_loop_scheduler($mh, $done); - - }, 0.02); - break; - - default : - throw Exception('Curl error: ' . curl_multi_strerror($mrc)); - - } - -} - -curl_multi_loop_scheduler($mh, function() { - - echo "Success!\n"; - -}); - -Loop\run(); - -//close the handles -curl_multi_remove_handle($mh, $ch1); -curl_multi_remove_handle($mh, $ch2); -curl_multi_close($mh); diff --git a/htdocs/includes/sabre/sabre/event/examples/promise.php b/htdocs/includes/sabre/sabre/event/examples/promise.php deleted file mode 100755 index 16ef3c53d71..00000000000 --- a/htdocs/includes/sabre/sabre/event/examples/promise.php +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/env php -fulfill("hello"); - -}, 2); - - -/* Callback chain */ - -$result = $promise - ->then(function($value) { - - echo "Step 2\n"; - // Immediately returning a new value. - return $value . " world"; - - }) - ->then(function($value) { - - echo "Step 3\n"; - // This 'then' returns a new promise which we resolve later. - $promise = new Promise(); - - // Resolving after 2 seconds - Loop\setTimeout(function() use ($promise, $value) { - - $promise->fulfill($value . ", how are ya?"); - - }, 2); - - return $promise; - }) - ->then(function($value) { - - echo "Step 4\n"; - // This is the final event handler. - return $value . " you rock!"; - - }) - // Making all async calls synchronous by waiting for the final result. - ->wait(); - -echo $result, "\n"; - -/* Now an identical example, this time with coroutines. */ - -$result = coroutine(function() { - - $promise = new Promise(); - - /* After 2 seconds we fulfill it */ - Loop\setTimeout(function() use ($promise) { - - echo "Step 1\n"; - $promise->fulfill("hello"); - - }, 2); - - $value = (yield $promise); - - echo "Step 2\n"; - $value .= ' world'; - - echo "Step 3\n"; - $promise = new Promise(); - Loop\setTimeout(function() use ($promise, $value) { - - $promise->fulfill($value . ", how are ya?"); - - }, 2); - - $value = (yield $promise); - - echo "Step 4\n"; - - // This is the final event handler. - yield $value . " you rock!"; - -})->wait(); - -echo $result, "\n"; diff --git a/htdocs/includes/sabre/sabre/event/examples/tail.php b/htdocs/includes/sabre/sabre/event/examples/tail.php deleted file mode 100755 index 334bd23f8bd..00000000000 --- a/htdocs/includes/sabre/sabre/event/examples/tail.php +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env php -listeners[$eventName])) { $this->listeners[$eventName] = [ true, // If there's only one item, it's sorted [$priority], - [$callBack] + [$callBack], ]; } else { $this->listeners[$eventName][0] = false; // marked as unsorted $this->listeners[$eventName][1][] = $priority; $this->listeners[$eventName][2][] = $callBack; } - } /** * Subscribe to an event exactly once. - * - * @return void */ - function once(string $eventName, callable $callBack, int $priority = 100) { - + public function once(string $eventName, callable $callBack, int $priority = 100) + { $wrapper = null; - $wrapper = function() use ($eventName, $callBack, &$wrapper) { - + $wrapper = function () use ($eventName, $callBack, &$wrapper) { $this->removeListener($eventName, $wrapper); - return call_user_func_array($callBack, func_get_args()); + return \call_user_func_array($callBack, \func_get_args()); }; $this->on($eventName, $wrapper, $priority); - } /** * Emits an event. * - * This method will return true if 0 or more listeners were succesfully + * This method will return true if 0 or more listeners were successfully * handled. false is returned if one of the events broke the event chain. * * If the continueCallBack is specified, this callback will be called every @@ -79,41 +73,35 @@ trait EmitterTrait { * Lastly, if there are 5 event handlers for an event. The continueCallback * will be called at most 4 times. */ - function emit(string $eventName, array $arguments = [], callable $continueCallBack = null) : bool { - - if (is_null($continueCallBack)) { - + public function emit(string $eventName, array $arguments = [], callable $continueCallBack = null): bool + { + if (\is_null($continueCallBack)) { foreach ($this->listeners($eventName) as $listener) { - - $result = call_user_func_array($listener, $arguments); - if ($result === false) { + $result = \call_user_func_array($listener, $arguments); + if (false === $result) { return false; } } - } else { - $listeners = $this->listeners($eventName); - $counter = count($listeners); + $counter = \count($listeners); foreach ($listeners as $listener) { - - $counter--; - $result = call_user_func_array($listener, $arguments); - if ($result === false) { + --$counter; + $result = \call_user_func_array($listener, $arguments); + if (false === $result) { return false; } if ($counter > 0) { - if (!$continueCallBack()) break; + if (!$continueCallBack()) { + break; + } } - } - } return true; - } /** @@ -124,24 +112,22 @@ trait EmitterTrait { * * @return callable[] */ - function listeners(string $eventName) : array { - + public function listeners(string $eventName): array + { if (!isset($this->listeners[$eventName])) { return []; } // The list is not sorted if (!$this->listeners[$eventName][0]) { - // Sorting - array_multisort($this->listeners[$eventName][1], SORT_NUMERIC, $this->listeners[$eventName][2]); + \array_multisort($this->listeners[$eventName][1], SORT_NUMERIC, $this->listeners[$eventName][2]); // Marking the listeners as sorted $this->listeners[$eventName][0] = true; } return $this->listeners[$eventName][2]; - } /** @@ -150,8 +136,8 @@ trait EmitterTrait { * If the listener could not be found, this method will return false. If it * was removed it will return true. */ - function removeListener(string $eventName, callable $listener) : bool { - + public function removeListener(string $eventName, callable $listener): bool + { if (!isset($this->listeners[$eventName])) { return false; } @@ -159,11 +145,12 @@ trait EmitterTrait { if ($check === $listener) { unset($this->listeners[$eventName][1][$index]); unset($this->listeners[$eventName][2][$index]); + return true; } } - return false; + return false; } /** @@ -172,24 +159,20 @@ trait EmitterTrait { * If the eventName argument is specified, all listeners for that event are * removed. If it is not specified, every listener for every event is * removed. - * - * @return void */ - function removeAllListeners(string $eventName = null) { - - if (!is_null($eventName)) { + public function removeAllListeners(string $eventName = null) + { + if (!\is_null($eventName)) { unset($this->listeners[$eventName]); } else { $this->listeners = []; } - } /** - * The list of listeners + * The list of listeners. * * @var array */ protected $listeners = []; - } diff --git a/htdocs/includes/sabre/sabre/event/lib/EventEmitter.php b/htdocs/includes/sabre/sabre/event/lib/EventEmitter.php index cae6ac2a6ad..865c99b5386 100644 --- a/htdocs/includes/sabre/sabre/event/lib/EventEmitter.php +++ b/htdocs/includes/sabre/sabre/event/lib/EventEmitter.php @@ -1,19 +1,20 @@ -timers) { // Special case when the timers array was empty. $this->timers[] = [$triggerTime, $cb]; + return; } @@ -46,14 +47,12 @@ class Loop { [[$triggerTime, $cb]] ); break; - } elseif ($index === 0) { + } elseif (0 === $index) { array_unshift($this->timers, [$triggerTime, $cb]); break; } - $index--; - + --$index; } - } /** @@ -62,12 +61,12 @@ class Loop { * The value this function returns can be used to stop the interval with * clearInterval. */ - function setInterval(callable $cb, float $timeout) : array { - + public function setInterval(callable $cb, float $timeout): array + { $keepGoing = true; $f = null; - $f = function() use ($cb, &$f, $timeout, &$keepGoing) { + $f = function () use ($cb, &$f, $timeout, &$keepGoing) { if ($keepGoing) { $cb(); $this->setTimeout($f, $timeout); @@ -82,32 +81,24 @@ class Loop { // Because I'm worried people will be confused by using a boolean as a // sort of identifier, I added an extra string. return ['I\'m an implementation detail', &$keepGoing]; - } /** * Stops a running interval. - * - * @return void */ - function clearInterval(array $intervalId) { - + public function clearInterval(array $intervalId) + { $intervalId[1] = false; - } /** * Runs a function immediately at the next iteration of the loop. - * - * @return void */ - function nextTick(callable $cb) { - + public function nextTick(callable $cb) + { $this->nextTick[] = $cb; - } - /** * Adds a read stream. * @@ -118,13 +109,11 @@ class Loop { * prevent the eventloop from never stopping. * * @param resource $stream - * @return void */ - function addReadStream($stream, callable $cb) { - - $this->readStreams[(int)$stream] = $stream; - $this->readCallbacks[(int)$stream] = $cb; - + public function addReadStream($stream, callable $cb) + { + $this->readStreams[(int) $stream] = $stream; + $this->readCallbacks[(int) $stream] = $cb; } /** @@ -137,65 +126,53 @@ class Loop { * prevent the eventloop from never stopping. * * @param resource $stream - * @return void */ - function addWriteStream($stream, callable $cb) { - - $this->writeStreams[(int)$stream] = $stream; - $this->writeCallbacks[(int)$stream] = $cb; - + public function addWriteStream($stream, callable $cb) + { + $this->writeStreams[(int) $stream] = $stream; + $this->writeCallbacks[(int) $stream] = $cb; } /** * Stop watching a stream for reads. * * @param resource $stream - * @return void */ - function removeReadStream($stream) { - + public function removeReadStream($stream) + { unset( - $this->readStreams[(int)$stream], - $this->readCallbacks[(int)$stream] + $this->readStreams[(int) $stream], + $this->readCallbacks[(int) $stream] ); - } /** * Stop watching a stream for writes. * * @param resource $stream - * @return void */ - function removeWriteStream($stream) { - + public function removeWriteStream($stream) + { unset( - $this->writeStreams[(int)$stream], - $this->writeCallbacks[(int)$stream] + $this->writeStreams[(int) $stream], + $this->writeCallbacks[(int) $stream] ); - } - /** * Runs the loop. * - * This function will run continiously, until there's no more events to + * This function will run continuously, until there's no more events to * handle. - * - * @return void */ - function run() { - + public function run() + { $this->running = true; do { - $hasEvents = $this->tick(true); - } while ($this->running && $hasEvents); $this->running = false; - } /** @@ -210,8 +187,8 @@ class Loop { * This function will return true if there are _any_ events left in the * loop after the tick. */ - function tick(bool $block = false) : bool { - + public function tick(bool $block = false): bool + { $this->runNextTicks(); $nextTimeout = $this->runTimers(); @@ -232,19 +209,15 @@ class Loop { $this->runStreams($streamWait); - return ($this->readStreams || $this->writeStreams || $this->nextTick || $this->timers); - + return $this->readStreams || $this->writeStreams || $this->nextTick || $this->timers; } /** - * Stops a running eventloop - * - * @return void + * Stops a running eventloop. */ - function stop() { - + public function stop() + { $this->running = false; - } /** @@ -252,15 +225,14 @@ class Loop { * * return void */ - protected function runNextTicks() { - + protected function runNextTicks() + { $nextTick = $this->nextTick; $this->nextTick = []; foreach ($nextTick as $cb) { $cb(); } - } /** @@ -273,8 +245,8 @@ class Loop { * * @return float|null */ - protected function runTimers() { - + protected function runTimers() + { $now = microtime(true); while (($timer = array_pop($this->timers)) && $timer[0] < $now) { $timer[1](); @@ -282,9 +254,9 @@ class Loop { // Add the last timer back to the array. if ($timer) { $this->timers[] = $timer; + return max(0, $timer[0] - microtime(true)); } - } /** @@ -295,36 +267,33 @@ class Loop { * * @param float|null timeout */ - protected function runStreams($timeout) { - + protected function runStreams($timeout) + { if ($this->readStreams || $this->writeStreams) { - $read = $this->readStreams; $write = $this->writeStreams; $except = null; - if (stream_select($read, $write, $except, ($timeout === null) ? null : 0, $timeout ? (int)($timeout * 1000000) : 0)) { - + // stream_select changes behavior in 8.1 to forbid passing non-null microseconds when the seconds are null. + // Older versions of php don't allow passing null to microseconds. + if (null !== $timeout ? stream_select($read, $write, $except, 0, (int) ($timeout * 1000000)) : stream_select($read, $write, $except, null)) { // See PHP Bug https://bugs.php.net/bug.php?id=62452 // Fixed in PHP7 foreach ($read as $readStream) { - $readCb = $this->readCallbacks[(int)$readStream]; + $readCb = $this->readCallbacks[(int) $readStream]; $readCb(); } foreach ($write as $writeStream) { - $writeCb = $this->writeCallbacks[(int)$writeStream]; + $writeCb = $this->writeCallbacks[(int) $writeStream]; $writeCb(); } - } - } elseif ($this->running && ($this->nextTick || $this->timers)) { - usleep($timeout !== null ? intval($timeout * 1000000) : 200000); + usleep(null !== $timeout ? intval($timeout * 1000000) : 200000); } - } /** - * Is the main loop active + * Is the main loop active. * * @var bool */ @@ -361,16 +330,14 @@ class Loop { /** * List of read callbacks, indexed by stream id. * - * @var callback[] + * @var callable[] */ protected $readCallbacks = []; /** * List of write callbacks, indexed by stream id. * - * @var callback[] + * @var callable[] */ protected $writeCallbacks = []; - - } diff --git a/htdocs/includes/sabre/sabre/event/lib/Loop/functions.php b/htdocs/includes/sabre/sabre/event/lib/Loop/functions.php index b5884b2b62f..bf4d933f2d5 100644 --- a/htdocs/includes/sabre/sabre/event/lib/Loop/functions.php +++ b/htdocs/includes/sabre/sabre/event/lib/Loop/functions.php @@ -1,16 +1,15 @@ -setTimeout($cb, $timeout); - } /** @@ -19,35 +18,27 @@ function setTimeout(callable $cb, float $timeout) { * The value this function returns can be used to stop the interval with * clearInterval. */ -function setInterval(callable $cb, float $timeout) : array { - +function setInterval(callable $cb, float $timeout): array +{ return instance()->setInterval($cb, $timeout); - } /** * Stops a running interval. - * - * @return void */ -function clearInterval(array $intervalId) { - +function clearInterval(array $intervalId) +{ instance()->clearInterval($intervalId); - } /** * Runs a function immediately at the next iteration of the loop. - * - * @return void */ -function nextTick(callable $cb) { - +function nextTick(callable $cb) +{ instance()->nextTick($cb); - } - /** * Adds a read stream. * @@ -58,12 +49,10 @@ function nextTick(callable $cb) { * prevent the eventloop from never stopping. * * @param resource $stream - * @return void */ -function addReadStream($stream, callable $cb) { - +function addReadStream($stream, callable $cb) +{ instance()->addReadStream($stream, $cb); - } /** @@ -76,51 +65,41 @@ function addReadStream($stream, callable $cb) { * prevent the eventloop from never stopping. * * @param resource $stream - * @return void */ -function addWriteStream($stream, callable $cb) { - +function addWriteStream($stream, callable $cb) +{ instance()->addWriteStream($stream, $cb); - } /** * Stop watching a stream for reads. * * @param resource $stream - * @return void */ -function removeReadStream($stream) { - +function removeReadStream($stream) +{ instance()->removeReadStream($stream); - } /** * Stop watching a stream for writes. * * @param resource $stream - * @return void */ -function removeWriteStream($stream) { - +function removeWriteStream($stream) +{ instance()->removeWriteStream($stream); - } - /** * Runs the loop. * - * This function will run continiously, until there's no more events to + * This function will run continuously, until there's no more events to * handle. - * - * @return void */ -function run() { - +function run() +{ instance()->run(); - } /** @@ -135,34 +114,30 @@ function run() { * This function will return true if there are _any_ events left in the * loop after the tick. */ -function tick(bool $block = false) : bool { - +function tick(bool $block = false): bool +{ return instance()->tick($block); - } /** - * Stops a running eventloop - * - * @return void + * Stops a running eventloop. */ -function stop() { - +function stop() +{ instance()->stop(); - } /** * Retrieves or sets the global Loop object. */ -function instance(Loop $newLoop = null) : Loop { - +function instance(Loop $newLoop = null): Loop +{ static $loop; if ($newLoop) { $loop = $newLoop; } elseif (!$loop) { $loop = new Loop(); } - return $loop; + return $loop; } diff --git a/htdocs/includes/sabre/sabre/event/lib/Promise.php b/htdocs/includes/sabre/sabre/event/lib/Promise.php index 1d04bd4d456..42969a55f85 100644 --- a/htdocs/includes/sabre/sabre/event/lib/Promise.php +++ b/htdocs/includes/sabre/sabre/event/lib/Promise.php @@ -1,4 +1,6 @@ -fulfill and $this->reject. * Using the executor is optional. */ - function __construct(callable $executor = null) { - + public function __construct(callable $executor = null) + { if ($executor) { $executor( [$this, 'fulfill'], [$this, 'reject'] ); } - } /** @@ -84,32 +87,32 @@ class Promise { * If either of the callbacks throw an exception, the returned promise will * be rejected and the exception will be passed back. */ - function then(callable $onFulfilled = null, callable $onRejected = null) : Promise { - + public function then(callable $onFulfilled = null, callable $onRejected = null): Promise + { // This new subPromise will be returned from this function, and will // be fulfilled with the result of the onFulfilled or onRejected event // handlers. $subPromise = new self(); switch ($this->state) { - case self::PENDING : + case self::PENDING: // The operation is pending, so we keep a reference to the // event handlers so we can call them later. $this->subscribers[] = [$subPromise, $onFulfilled, $onRejected]; break; - case self::FULFILLED : + case self::FULFILLED: // The async operation is already fulfilled, so we trigger the // onFulfilled callback asap. $this->invokeCallback($subPromise, $onFulfilled); break; - case self::REJECTED : - // The async operation failed, so we call teh onRejected + case self::REJECTED: + // The async operation failed, so we call the onRejected // callback asap. $this->invokeCallback($subPromise, $onRejected); break; } - return $subPromise; + return $subPromise; } /** @@ -118,20 +121,19 @@ class Promise { * Its usage is identical to then(). However, the otherwise() function is * preferred. */ - function otherwise(callable $onRejected) : Promise { - + public function otherwise(callable $onRejected): Promise + { return $this->then(null, $onRejected); - } /** * Marks this promise as fulfilled and sets its return value. * * @param mixed $value - * @return void */ - function fulfill($value = null) { - if ($this->state !== self::PENDING) { + public function fulfill($value = null) + { + if (self::PENDING !== $this->state) { throw new PromiseAlreadyResolvedException('This promise is already resolved, and you\'re not allowed to resolve a promise more than once'); } $this->state = self::FULFILLED; @@ -142,12 +144,11 @@ class Promise { } /** - * Marks this promise as rejected, and set it's rejection reason. - * - * @return void + * Marks this promise as rejected, and set its rejection reason. */ - function reject(Throwable $reason) { - if ($this->state !== self::PENDING) { + public function reject(Throwable $reason) + { + if (self::PENDING !== $this->state) { throw new PromiseAlreadyResolvedException('This promise is already resolved, and you\'re not allowed to resolve a promise more than once'); } $this->state = self::REJECTED; @@ -155,13 +156,12 @@ class Promise { foreach ($this->subscribers as $subscriber) { $this->invokeCallback($subscriber[0], $subscriber[2]); } - } /** * Stops execution until this promise is resolved. * - * This method stops exection completely. If the promise is successful with + * This method stops execution completely. If the promise is successful with * a value, this method will return this value. If the promise was * rejected, this method will throw an exception. * @@ -170,12 +170,12 @@ class Promise { * chain. * * @return mixed + * @psalm-return TReturn */ - function wait() { - + public function wait() + { $hasEvents = true; - while ($this->state === self::PENDING) { - + while (self::PENDING === $this->state) { if (!$hasEvents) { throw new \LogicException('There were no more events in the loop. This promise will never be fulfilled.'); } @@ -183,10 +183,9 @@ class Promise { // As long as the promise is not fulfilled, we tell the event loop // to handle events, and to block. $hasEvents = Loop\tick(true); - } - if ($this->state === self::FULFILLED) { + if (self::FULFILLED === $this->state) { // If the state of this promise is fulfilled, we can return the value. return $this->value; } else { @@ -194,11 +193,8 @@ class Promise { // errored. Therefore we need to throw an exception. throw $this->value; } - - } - /** * A list of subscribers. Subscribers are the callbacks that want us to let * them know if the callback was fulfilled or rejected. @@ -224,21 +220,18 @@ class Promise { * correctly, and any chained promises are also correctly fulfilled or * rejected. * - * @param Promise $subPromise * @param callable $callBack - * @return void */ - private function invokeCallback(Promise $subPromise, callable $callBack = null) { - + private function invokeCallback(Promise $subPromise, callable $callBack = null) + { // We use 'nextTick' to ensure that the event handlers are always // triggered outside of the calling stack in which they were originally // passed to 'then'. // // This makes the order of execution more predictable. - Loop\nextTick(function() use ($callBack, $subPromise) { + Loop\nextTick(function () use ($callBack, $subPromise) { if (is_callable($callBack)) { try { - $result = $callBack($this->value); if ($result instanceof self) { // If the callback (onRejected or onFulfilled) @@ -257,7 +250,7 @@ class Promise { $subPromise->reject($e); } } else { - if ($this->state === self::FULFILLED) { + if (self::FULFILLED === $this->state) { $subPromise->fulfill($this->value); } else { $subPromise->reject($this->value); @@ -265,5 +258,4 @@ class Promise { } }); } - } diff --git a/htdocs/includes/sabre/sabre/event/lib/Promise/functions.php b/htdocs/includes/sabre/sabre/event/lib/Promise/functions.php index b846b7b84d1..fbed6347194 100644 --- a/htdocs/includes/sabre/sabre/event/lib/Promise/functions.php +++ b/htdocs/includes/sabre/sabre/event/lib/Promise/functions.php @@ -1,4 +1,6 @@ - $subPromise) { - $subPromise->then( - function($result) use ($promiseIndex, &$completeResult, &$successCount, $success, $promises) { + function ($result) use ($promiseIndex, &$completeResult, &$successCount, $success, $promises) { $completeResult[$promiseIndex] = $result; - $successCount++; + ++$successCount; if ($successCount === count($promises)) { $success($completeResult); } + return $result; } )->otherwise( - function($reason) use ($fail) { + function ($reason) use ($fail) { $fail($reason); } ); - } }); - } /** @@ -67,22 +71,20 @@ function all(array $promises) : Promise { * * @param Promise[] $promises */ -function race(array $promises) : Promise { - - return new Promise(function($success, $fail) use ($promises) { - +function race(array $promises): Promise +{ + return new Promise(function ($success, $fail) use ($promises) { $alreadyDone = false; foreach ($promises as $promise) { - $promise->then( - function($result) use ($success, &$alreadyDone) { + function ($result) use ($success, &$alreadyDone) { if ($alreadyDone) { return; } $alreadyDone = true; $success($result); }, - function($reason) use ($fail, &$alreadyDone) { + function ($reason) use ($fail, &$alreadyDone) { if ($alreadyDone) { return; } @@ -90,14 +92,10 @@ function race(array $promises) : Promise { $fail($reason); } ); - } - }); - } - /** * Returns a Promise that resolves with the given value. * @@ -106,25 +104,25 @@ function race(array $promises) : Promise { * * @param mixed $value */ -function resolve($value) : Promise { - +function resolve($value): Promise +{ if ($value instanceof Promise) { return $value->then(); } else { $promise = new Promise(); $promise->fulfill($value); + return $promise; } - } /** * Returns a Promise that will reject with the given reason. */ -function reject(Throwable $reason) : Promise { - +function reject(Throwable $reason): Promise +{ $promise = new Promise(); $promise->reject($reason); - return $promise; + return $promise; } diff --git a/htdocs/includes/sabre/sabre/event/lib/PromiseAlreadyResolvedException.php b/htdocs/includes/sabre/sabre/event/lib/PromiseAlreadyResolvedException.php index 534a3d49416..abb6c108e5c 100644 --- a/htdocs/includes/sabre/sabre/event/lib/PromiseAlreadyResolvedException.php +++ b/htdocs/includes/sabre/sabre/event/lib/PromiseAlreadyResolvedException.php @@ -1,4 +1,6 @@ -wildcardListeners; + public function on(string $eventName, callable $callBack, int $priority = 100) + { + // If it ends with a wildcard, we use the wildcardListeners array + if ('*' === $eventName[\strlen($eventName) - 1]) { + $eventName = \substr($eventName, 0, -1); + $listeners = &$this->wildcardListeners; } else { - $listeners = & $this->listeners; + $listeners = &$this->listeners; } // Always fully reset the listener index. This is fairly sane for most @@ -44,32 +44,27 @@ trait WildcardEmitterTrait { $listeners[$eventName] = []; } $listeners[$eventName][] = [$priority, $callBack]; - } /** * Subscribe to an event exactly once. - * - * @return void */ - function once(string $eventName, callable $callBack, int $priority = 100) { - + public function once(string $eventName, callable $callBack, int $priority = 100) + { $wrapper = null; - $wrapper = function() use ($eventName, $callBack, &$wrapper) { - + $wrapper = function () use ($eventName, $callBack, &$wrapper) { $this->removeListener($eventName, $wrapper); - return call_user_func_array($callBack, func_get_args()); + return \call_user_func_array($callBack, \func_get_args()); }; $this->on($eventName, $wrapper, $priority); - } /** * Emits an event. * - * This method will return true if 0 or more listeners were succesfully + * This method will return true if 0 or more listeners were successfully * handled. false is returned if one of the events broke the event chain. * * If the continueCallBack is specified, this callback will be called every @@ -87,42 +82,35 @@ trait WildcardEmitterTrait { * Lastly, if there are 5 event handlers for an event. The continueCallback * will be called at most 4 times. */ - function emit(string $eventName, array $arguments = [], callable $continueCallBack = null) : bool { - - if (is_null($continueCallBack)) { - + public function emit(string $eventName, array $arguments = [], callable $continueCallBack = null): bool + { + if (\is_null($continueCallBack)) { foreach ($this->listeners($eventName) as $listener) { - - $result = call_user_func_array($listener, $arguments); - if ($result === false) { + $result = \call_user_func_array($listener, $arguments); + if (false === $result) { return false; } } - } else { - $listeners = $this->listeners($eventName); - $counter = count($listeners); + $counter = \count($listeners); foreach ($listeners as $listener) { - - $counter--; - $result = call_user_func_array($listener, $arguments); - if ($result === false) { + --$counter; + $result = \call_user_func_array($listener, $arguments); + if (false === $result) { return false; } if ($counter > 0) { - if (!$continueCallBack()) break; + if (!$continueCallBack()) { + break; + } } - } - } return true; - - } /** @@ -133,46 +121,37 @@ trait WildcardEmitterTrait { * * @return callable[] */ - function listeners(string $eventName) : array { - - if (!array_key_exists($eventName, $this->listenerIndex)) { - + public function listeners(string $eventName): array + { + if (!\array_key_exists($eventName, $this->listenerIndex)) { // Create a new index. $listeners = []; $listenersPriority = []; - if (isset($this->listeners[$eventName])) foreach ($this->listeners[$eventName] as $listener) { - - $listenersPriority[] = $listener[0]; - $listeners[] = $listener[1]; - + if (isset($this->listeners[$eventName])) { + foreach ($this->listeners[$eventName] as $listener) { + $listenersPriority[] = $listener[0]; + $listeners[] = $listener[1]; + } } foreach ($this->wildcardListeners as $wcEvent => $wcListeners) { - // Wildcard match - if (substr($eventName, 0, strlen($wcEvent)) === $wcEvent) { - + if (\substr($eventName, 0, \strlen($wcEvent)) === $wcEvent) { foreach ($wcListeners as $listener) { - $listenersPriority[] = $listener[0]; $listeners[] = $listener[1]; - } - } - } // Sorting by priority - array_multisort($listenersPriority, SORT_NUMERIC, $listeners); + \array_multisort($listenersPriority, SORT_NUMERIC, $listeners); // Creating index - $this->listenersIndex[$eventName] = $listeners; - + $this->listenerIndex[$eventName] = $listeners; } - return $this->listenersIndex[$eventName]; - + return $this->listenerIndex[$eventName]; } /** @@ -181,14 +160,14 @@ trait WildcardEmitterTrait { * If the listener could not be found, this method will return false. If it * was removed it will return true. */ - function removeListener(string $eventName, callable $listener) : bool { - - // If it ends with a wildcard, we use the wildcardListeners array - if ($eventName[strlen($eventName) - 1] === '*') { - $eventName = substr($eventName, 0, -1); - $listeners = & $this->wildcardListeners; + public function removeListener(string $eventName, callable $listener): bool + { + // If it ends with a wildcard, we use the wildcardListeners array + if ('*' === $eventName[\strlen($eventName) - 1]) { + $eventName = \substr($eventName, 0, -1); + $listeners = &$this->wildcardListeners; } else { - $listeners = & $this->listeners; + $listeners = &$this->listeners; } if (!isset($listeners[$eventName])) { @@ -196,21 +175,17 @@ trait WildcardEmitterTrait { } foreach ($listeners[$eventName] as $index => $check) { - if ($check[1] === $listener) { - // Remove listener unset($listeners[$eventName][$index]); // Reset index $this->listenerIndex = []; + return true; - } - } return false; - } /** @@ -219,38 +194,32 @@ trait WildcardEmitterTrait { * If the eventName argument is specified, all listeners for that event are * removed. If it is not specified, every listener for every event is * removed. - * - * @return void */ - function removeAllListeners(string $eventName = null) { - - if (is_null($eventName)) { + public function removeAllListeners(string $eventName = null) + { + if (\is_null($eventName)) { $this->listeners = []; $this->wildcardListeners = []; - } else { - - if ($eventName[strlen($eventName) - 1] === '*') { + if ('*' === $eventName[\strlen($eventName) - 1]) { // Wildcard event - unset($this->wildcardListeners[substr($eventName, 0, -1)]); + unset($this->wildcardListeners[\substr($eventName, 0, -1)]); } else { unset($this->listeners[$eventName]); } - } // Reset index $this->listenerIndex = []; - } /** - * The list of listeners + * The list of listeners. */ protected $listeners = []; /** - * The list of "wildcard listeners". + * The list of "wildcard listeners". */ protected $wildcardListeners = []; diff --git a/htdocs/includes/sabre/sabre/event/lib/coroutine.php b/htdocs/includes/sabre/sabre/event/lib/coroutine.php index f571a8ba0c9..cdf2d3ecdb6 100644 --- a/htdocs/includes/sabre/sabre/event/lib/coroutine.php +++ b/htdocs/includes/sabre/sabre/event/lib/coroutine.php @@ -1,4 +1,6 @@ - $gen + * @psalm-return Promise + * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -function coroutine(callable $gen) : Promise { - +function coroutine(callable $gen): Promise +{ $generator = $gen(); if (!$generator instanceof Generator) { throw new \InvalidArgumentException('You must pass a generator function'); @@ -59,22 +66,20 @@ function coroutine(callable $gen) : Promise { * So tempted to use the mythical y-combinator here, but it's not needed in * PHP. */ - $advanceGenerator = function() use (&$advanceGenerator, $generator, $promise, &$lastYieldResult) { - + $advanceGenerator = function () use (&$advanceGenerator, $generator, $promise) { while ($generator->valid()) { - $yieldedValue = $generator->current(); if ($yieldedValue instanceof Promise) { $yieldedValue->then( - function($value) use ($generator, &$advanceGenerator, &$lastYieldResult) { + function ($value) use ($generator, &$advanceGenerator) { $generator->send($value); $advanceGenerator(); }, - function(Throwable $reason) use ($generator, $advanceGenerator) { + function (Throwable $reason) use ($generator, $advanceGenerator) { $generator->throw($reason); $advanceGenerator(); } - )->otherwise(function(Throwable $reason) use ($promise) { + )->otherwise(function (Throwable $reason) use ($promise) { // This error handler would be called, if something in the // generator throws an exception, and it's not caught // locally. @@ -87,31 +92,25 @@ function coroutine(callable $gen) : Promise { // If the value was not a promise, we'll just let it pass through. $generator->send($yieldedValue); } - } // If the generator is at the end, and we didn't run into an exception, // We're grabbing the "return" value and fulfilling our top-level // promise with its value. - if (!$generator->valid() && $promise->state === Promise::PENDING) { - $returnValue = $generator->getReturn(); - - // The return value is a promise. - if ($returnValue instanceof Promise) { - $returnValue->then(function($value) use ($promise) { - $promise->fulfill($value); - }, function(Throwable $reason) { - $promise->reject($reason); - }); - } else { - - $promise->fulfill($returnValue); - - } - + if (!$generator->valid() && Promise::PENDING === $promise->state) { + $returnValue = $generator->getReturn(); + // The return value is a promise. + if ($returnValue instanceof Promise) { + $returnValue->then(function ($value) use ($promise) { + $promise->fulfill($value); + }, function (Throwable $reason) use ($promise) { + $promise->reject($reason); + }); + } else { + $promise->fulfill($returnValue); + } } - }; try { @@ -121,5 +120,4 @@ function coroutine(callable $gen) : Promise { } return $promise; - } diff --git a/htdocs/includes/sabre/sabre/event/phpstan.neon b/htdocs/includes/sabre/sabre/event/phpstan.neon new file mode 100644 index 00000000000..213da6dad2a --- /dev/null +++ b/htdocs/includes/sabre/sabre/event/phpstan.neon @@ -0,0 +1,2 @@ +parameters: + level: 1 diff --git a/htdocs/includes/sabre/sabre/event/phpunit.xml.dist b/htdocs/includes/sabre/sabre/event/phpunit.xml.dist deleted file mode 100644 index ccd59be9c2a..00000000000 --- a/htdocs/includes/sabre/sabre/event/phpunit.xml.dist +++ /dev/null @@ -1,18 +0,0 @@ - - - tests/ - - - - - ./lib/ - - - diff --git a/htdocs/includes/sabre/sabre/http/.gitignore b/htdocs/includes/sabre/sabre/http/.gitignore index 5f85ecc1b98..367bba576a4 100644 --- a/htdocs/includes/sabre/sabre/http/.gitignore +++ b/htdocs/includes/sabre/sabre/http/.gitignore @@ -4,15 +4,5 @@ composer.lock # Tests tests/cov/ - -# Composer binaries -bin/phpunit* -bin/phpcs* -bin/php-cs-fixer* -bin/sabre-cs-fixer* - -# Vim -.*.swp - -# development stuff +.phpunit.result.cache .php_cs.cache diff --git a/htdocs/includes/sabre/sabre/http/.php_cs.dist b/htdocs/includes/sabre/sabre/http/.php_cs.dist index 8d61ee25924..c5c78a971df 100644 --- a/htdocs/includes/sabre/sabre/http/.php_cs.dist +++ b/htdocs/includes/sabre/sabre/http/.php_cs.dist @@ -6,7 +6,7 @@ $config->getFinder() ->in(__DIR__); $config->setRules([ '@PSR1' => true, - '@Symfony' =>true + '@Symfony' => true ]); return $config; \ No newline at end of file diff --git a/htdocs/includes/sabre/sabre/http/.travis.yml b/htdocs/includes/sabre/sabre/http/.travis.yml deleted file mode 100644 index 3b85d5f3913..00000000000 --- a/htdocs/includes/sabre/sabre/http/.travis.yml +++ /dev/null @@ -1,41 +0,0 @@ -language: php -sudo: required -php: - - 7.0 - - 7.1 - - 7.2 - - 7.3 - - 7.4snapshot - -env: - global: - - RUN_PHPSTAN="FALSE" - matrix: - - PREFER_LOWEST="" WITH_COVERAGE="--coverage-clover=coverage.xml" - - PREFER_LOWEST="--prefer-lowest" $WITH_COVERAGE="" - -matrix: - include: - - name: 'PHPStan' - php: 7.2 - env: RUN_PHPSTAN="TRUE" - fast_finish: true - -cache: - directories: - - $HOME/.composer/cache - -install: - - if [ $RUN_PHPSTAN == "TRUE" ]; then composer require --dev phpstan/phpstan; fi - -before_script: - - composer update --prefer-source $PREFER_LOWEST - - PHP_BIN=$(phpenv which php) - - sudo $PHP_BIN -S localhost:80 -t $TRAVIS_BUILD_DIR/tests/www 2>/dev/null & - -script: - - if [ $RUN_PHPSTAN == "FALSE" ]; then ./bin/phpunit --configuration tests/phpunit.xml $WITH_COVERAGE; fi - - if [ $RUN_PHPSTAN == "TRUE" ]; then php ./bin/phpstan analyse -c phpstan.neon lib; fi - -after_success: - - bash <(curl -s https://codecov.io/bash) diff --git a/htdocs/includes/sabre/sabre/http/CHANGELOG.md b/htdocs/includes/sabre/sabre/http/CHANGELOG.md index e300aad09bc..7c6f4b6ec83 100644 --- a/htdocs/includes/sabre/sabre/http/CHANGELOG.md +++ b/htdocs/includes/sabre/sabre/http/CHANGELOG.md @@ -1,6 +1,68 @@ ChangeLog ========= +5.1.10 (2023-08-18) +------------------ + +* #225 Enhance tests/bootstrap.php to find autoloader in more environments (@phil-davis) + +5.1.9 (2023-08-17) +------------------ + +* #223 skip testParseMimeTypeOnInvalidMimeType (@phil-davis) + +5.1.8 (2023-08-17) +------------------ + +* #215 Improve CURLOPT_HTTPHEADER Setting Assignment (@amrita-shrestha) + +5.1.7 (2023-06-26) +------------------ + +* #98 and #176 Add more tests (@peter279k) +* #207 fix: handle client disconnect properly with ignore_user_abort true (@kesselb) + +5.1.6 (2022-07-15) +------------------ + +* #187 Allow testSendToGetLargeContent peak memory usage to be specified externally (@phil-davis) +* #188 Fix various small typos and grammar (@phil-davis) +* #189 Fix typo in text of status code 203 'Non-Authoritative Information' (@phil-davis) + +5.1.5 (2022-07-09) +------------------ + +* #184 Remove 4GB file size workaround for 32bit OS / Stream Videos on IOS (@schoetju) + +5.1.4 (2022-06-24) +------------------ + +* #182 Fix encoding detection on PHP 8.1 (@come-nc) + +5.1.3 (2021-11-04) +------------------ + +* #179 version bump that was missed in 5.1.2 (@phil-davis) + +5.1.2 (2021-11-04) +------------------------- + +* #169 Ensure $_SERVER keys are read as strings (@fredrik-eriksson) +* #170 Fix deprecated usages on PHP 8.1 (@cedric-anne) +* #175 Add resource size to CURL options in client (from #172 ) (@Dartui) + +5.1.1 (2020-10-03) +------------------------- + +* #160: Added support for PHP 8.0 (@phil-davis) + +5.1.0 (2020-01-31) +------------------------- + +* Added support for PHP 7.4, dropped support for PHP 7.0 (@phil-davis) +* Updated testsuite for phpunit8, added phpstan coverage (@phil-davis) +* Added autoload-dev for test classes (@C0pyR1ght) + 5.0.5 (2019-11-28) ------------------------- @@ -48,7 +110,7 @@ ChangeLog * #65: It's now possible to supply request/response bodies using a callback functions. This allows very high-speed/low-memory responses to be created. (@petrkotek). -* Strict typing is used every where this is applicable. +* Strict typing is used everywhere this is applicable. * Removed `URLUtil` class. It was deprecated a long time ago, and most of its functions moved to the `sabre/uri` package. * Removed `Util` class. Most of its functions moved to the `functions.php` @@ -67,7 +129,7 @@ ChangeLog 4.2.3 (2017-06-12) ------------------ -* #74, #77: Work around 4GB file size limit at 32 Bit systems +* #74, #77: Work around 4GB file size limit at 32-Bit systems 4.2.2 (2017-01-02) @@ -255,7 +317,7 @@ ChangeLog * Changed: Response::send() is now Sapi::sendResponse($response). * Changed: Request::createFromPHPRequest is now Sapi::getRequest(). * Changed: Message::getBodyAsStream and Message::getBodyAsString were added. The - existing Message::getBody changed it's behavior, so be careful. + existing Message::getBody changed its behavior, so be careful. 2.0.0alpha5 (2013-11-07) diff --git a/htdocs/includes/sabre/sabre/http/README.md b/htdocs/includes/sabre/sabre/http/README.md index 8159b4d4976..2f01c144857 100644 --- a/htdocs/includes/sabre/sabre/http/README.md +++ b/htdocs/includes/sabre/sabre/http/README.md @@ -28,11 +28,11 @@ The objects are extendable and easily mockable. Build status ------------ -| branch | status | -| ------ | ------ | +| branch | status | +|--------|---------------------------------------------------------------------------------------------------------------| | master | [![Build Status](https://travis-ci.org/sabre-io/http.svg?branch=master)](https://travis-ci.org/sabre-io/http) | -| 4.2 | [![Build Status](https://travis-ci.org/sabre-io/http.svg?branch=4.2)](https://travis-ci.org/sabre-io/http) | -| 3.0 | [![Build Status](https://travis-ci.org/sabre-io/http.svg?branch=3.0)](https://travis-ci.org/sabre-io/http) | +| 4.2 | [![Build Status](https://travis-ci.org/sabre-io/http.svg?branch=4.2)](https://travis-ci.org/sabre-io/http) | +| 3.0 | [![Build Status](https://travis-ci.org/sabre-io/http.svg?branch=3.0)](https://travis-ci.org/sabre-io/http) | Installation ------------ @@ -84,7 +84,7 @@ $request = HTTP\Sapi::getRequest(); This line should only happen once in your entire application. Everywhere else you should pass this request object around using dependency injection. -You should always typehint on it's interface: +You should always typehint on its interface: ```php function handleRequest(HTTP\RequestInterface $request) { @@ -133,9 +133,9 @@ Simply extending Request and Response may pose some problems: 1. You may want to extend the objects with new behaviors differently, in different subsystems of your application, -2. The `Sapi::getRequest` factory always returns a instance of +2. The `Sapi::getRequest` factory always returns an instance of `Request` so you would have to override the factory method as well, -3. By controlling the instantation and depend on specific `Request` and +3. By controlling the instantiation and depend on specific `Request` and `Response` instances in your library or application, you make it harder to work with other applications which also use `sabre/http`. @@ -162,7 +162,7 @@ class MyRequest extends HTTP\RequestDecorator { Our application assumes that the true `Request` object was instantiated somewhere else, by some other subsystem. This could simply be a call like `$request = Sapi::getRequest()` at the top of your application, -but could also be somewhere in a unittest. +but could also be somewhere in a unit test. All we know in the current subsystem, is that we received a `$request` and that it implements `Sabre\HTTP\RequestInterface`. To decorate this object, @@ -296,7 +296,7 @@ $remoteUrl = 'http://example.org/'; // The url we're proxying from. Please note that this must be a relative url, // and basically acts as the base url. // -// If youre $remoteUrl doesn't end with a slash, this one probably shouldn't +// If your $remoteUrl doesn't end with a slash, this one probably shouldn't // either. $myBaseUrl = '/reverseproxy.php'; // $myBaseUrl = '/~evert/sabre/http/examples/reverseproxy.php/'; @@ -412,10 +412,10 @@ function setBaseUrl($url); * If the full path is equal to the base url, this method will return an * empty string. * - * This method will also urldecode the path, and if the url was incoded as + * This method will also urldecode the path, and if the url was encoded as * ISO-8859-1, it will convert it to UTF-8. * - * If the path is outside of the base url, a LogicException will be thrown. + * If the path is outside the base url, a LogicException will be thrown. * * @return string */ @@ -491,7 +491,7 @@ function getBodyAsStream(); function getBodyAsString(); /** - * Returns the message body, as it's internal representation. + * Returns the message body, as its internal representation. * * This could be either a string or a stream. * @@ -515,7 +515,7 @@ function setBody($body); function getHeaders(); /** - * Returns a specific HTTP header, based on it's name. + * Returns a specific HTTP header, based on its name. * * The name must be treated as case-insensitive. * @@ -529,7 +529,7 @@ function getHeader($name); /** * Updates a HTTP header. * - * The case-sensitity of the name value must be retained as-is. + * The case-sensitivity of the name value must be retained as-is. * * @param string $name * @param string $value @@ -561,7 +561,7 @@ function addHeaders(array $headers); /** * Removes a HTTP header. * - * The specified header name must be treated as case-insenstive. + * The specified header name must be treated as case-insensitive. * This method should return true if the header was successfully deleted, * and false if the header did not exist. * @@ -593,7 +593,7 @@ function getHttpVersion(); /** * Returns the current HTTP status. * - * This is the status-code as well as the human readable string. + * This is the status-code as well as the human-readable string. * * @return string */ @@ -602,7 +602,7 @@ function getStatus(); /** * Sets the HTTP status code. * - * This can be either the full HTTP status code with human readable string, + * This can be either the full HTTP status code with human-readable string, * for example: "403 I can't let you do that, Dave". * * Or just the code, in which case the appropriate default message will be @@ -635,7 +635,7 @@ function getBodyAsStream(); function getBodyAsString(); /** - * Returns the message body, as it's internal representation. + * Returns the message body, as its internal representation. * * This could be either a string or a stream. * @@ -660,7 +660,7 @@ function setBody($body); function getHeaders(); /** - * Returns a specific HTTP header, based on it's name. + * Returns a specific HTTP header, based on its name. * * The name must be treated as case-insensitive. * @@ -674,7 +674,7 @@ function getHeader($name); /** * Updates a HTTP header. * - * The case-sensitity of the name value must be retained as-is. + * The case-sensitivity of the name value must be retained as-is. * * @param string $name * @param string $value @@ -706,7 +706,7 @@ function addHeaders(array $headers); /** * Removes a HTTP header. * - * The specified header name must be treated as case-insenstive. + * The specified header name must be treated as case-insensitive. * This method should return true if the header was successfully deleted, * and false if the header did not exist. * diff --git a/htdocs/includes/sabre/sabre/http/composer.json b/htdocs/includes/sabre/sabre/http/composer.json index 851a08730ff..547a1b5efd9 100644 --- a/htdocs/includes/sabre/sabre/http/composer.json +++ b/htdocs/includes/sabre/sabre/http/composer.json @@ -1,44 +1,59 @@ { - "name": "sabre/http", - "description" : "The sabre/http library provides utilities for dealing with http requests and responses. ", - "keywords" : [ "HTTP" ], - "homepage" : "https://github.com/fruux/sabre-http", - "license" : "BSD-3-Clause", - "require" : { - "php" : "^7.0", - "ext-mbstring" : "*", - "ext-ctype" : "*", - "ext-curl" : "*", - "sabre/event" : ">=4.0 <6.0", - "sabre/uri" : "^2.0" - }, - "require-dev" : { - "phpunit/phpunit" : "^6.0 || ^7.0" - }, - "suggest" : { - "ext-curl" : " to make http requests with the Client class" - }, - "authors" : [ - { - "name" : "Evert Pot", - "email" : "me@evertpot.com", - "homepage" : "http://evertpot.com/", - "role" : "Developer" - } - ], - "support" : { - "forum" : "https://groups.google.com/group/sabredav-discuss", - "source" : "https://github.com/fruux/sabre-http" - }, - "autoload" : { - "files" : [ - "lib/functions.php" - ], - "psr-4" : { - "Sabre\\HTTP\\" : "lib/" - } - }, - "config" : { - "bin-dir" : "bin/" - } -} + "name" : "sabre/http", + "description" : "The sabre/http library provides utilities for dealing with http requests and responses. ", + "keywords" : [ + "HTTP" + ], + "homepage" : "https://github.com/fruux/sabre-http", + "license" : "BSD-3-Clause", + "require" : { + "php" : "^7.1 || ^8.0", + "ext-mbstring" : "*", + "ext-ctype" : "*", + "ext-curl" : "*", + "sabre/event" : ">=4.0 <6.0", + "sabre/uri" : "^2.0" + }, + "require-dev" : { + "friendsofphp/php-cs-fixer" : "~2.17.1", + "phpstan/phpstan" : "^0.12", + "phpunit/phpunit" : "^7.5 || ^8.5 || ^9.0" + }, + "suggest" : { + "ext-curl" : " to make http requests with the Client class" + }, + "authors" : [{ + "name" : "Evert Pot", + "email" : "me@evertpot.com", + "homepage" : "http://evertpot.com/", + "role" : "Developer" + } + ], + "support" : { + "forum" : "https://groups.google.com/group/sabredav-discuss", + "source" : "https://github.com/fruux/sabre-http" + }, + "autoload" : { + "files" : [ + "lib/functions.php" + ], + "psr-4" : { + "Sabre\\HTTP\\" : "lib/" + } + }, + "autoload-dev" : { + "psr-4" : { + "Sabre\\HTTP\\" : "tests/HTTP" + } + }, + "scripts" : { + "phpstan" : "phpstan analyse lib tests", + "cs-fixer" : "php-cs-fixer fix", + "phpunit" : "phpunit --configuration tests/phpunit.xml", + "test" : [ + "composer phpstan", + "composer cs-fixer", + "composer phpunit" + ] + } +} \ No newline at end of file diff --git a/htdocs/includes/sabre/sabre/http/examples/asyncclient.php b/htdocs/includes/sabre/sabre/http/examples/asyncclient.php deleted file mode 100644 index af98e253c8d..00000000000 --- a/htdocs/includes/sabre/sabre/http/examples/asyncclient.php +++ /dev/null @@ -1,62 +0,0 @@ -sendAsync( - $request, - - // This is the 'success' callback - function ($response) use ($i) { - echo "$i -> ".$response->getStatus()."\n"; - }, - - // This is the 'error' callback. It is called for general connection - // problems (such as not being able to connect to a host, dns errors, - // etc.) and also cases where a response was returned, but it had a - // status code of 400 or higher. - function ($error) use ($i) { - if (Client::STATUS_CURLERROR === $error['status']) { - // Curl errors - echo "$i -> curl error: ".$error['curl_errmsg']."\n"; - } else { - // HTTP errors - echo "$i -> ".$error['response']->getStatus()."\n"; - } - } - ); -} - -// After everything is done, we call 'wait'. This causes the client to wait for -// all outstanding http requests to complete. -$client->wait(); diff --git a/htdocs/includes/sabre/sabre/http/examples/basicauth.php b/htdocs/includes/sabre/sabre/http/examples/basicauth.php deleted file mode 100644 index 9c13da840b4..00000000000 --- a/htdocs/includes/sabre/sabre/http/examples/basicauth.php +++ /dev/null @@ -1,50 +0,0 @@ - 'password', - 'user2' => 'password', -]; - -use Sabre\HTTP\Auth; -use Sabre\HTTP\Response; -use Sabre\HTTP\Sapi; - -// Find the autoloader -$paths = [ - __DIR__.'/../vendor/autoload.php', - __DIR__.'/../../../autoload.php', - __DIR__.'/vendor/autoload.php', -]; - -foreach ($paths as $path) { - if (file_exists($path)) { - include $path; - break; - } -} - -$request = Sapi::getRequest(); -$response = new Response(); - -$basicAuth = new Auth\Basic('Locked down area', $request, $response); -if (!$userPass = $basicAuth->getCredentials()) { - // No username or password given - $basicAuth->requireLogin(); -} elseif (!isset($userList[$userPass[0]]) || $userList[$userPass[0]] !== $userPass[1]) { - // Username or password are incorrect - $basicAuth->requireLogin(); -} else { - // Success ! - $response->setBody('You are logged in!'); -} - -// Sending the response -Sapi::sendResponse($response); diff --git a/htdocs/includes/sabre/sabre/http/examples/client.php b/htdocs/includes/sabre/sabre/http/examples/client.php deleted file mode 100644 index a7cbfc3b4e2..00000000000 --- a/htdocs/includes/sabre/sabre/http/examples/client.php +++ /dev/null @@ -1,37 +0,0 @@ -addCurlSetting(CURLOPT_PROXY,'localhost:8888'); -$response = $client->send($request); - -echo "Response:\n"; - -echo (string) $response; diff --git a/htdocs/includes/sabre/sabre/http/examples/digestauth.php b/htdocs/includes/sabre/sabre/http/examples/digestauth.php deleted file mode 100644 index 5594306f510..00000000000 --- a/htdocs/includes/sabre/sabre/http/examples/digestauth.php +++ /dev/null @@ -1,51 +0,0 @@ - 'password', - 'user2' => 'password', -]; - -use Sabre\HTTP\Auth; -use Sabre\HTTP\Response; -use Sabre\HTTP\Sapi; - -// Find the autoloader -$paths = [ - __DIR__.'/../vendor/autoload.php', - __DIR__.'/../../../autoload.php', - __DIR__.'/vendor/autoload.php', -]; - -foreach ($paths as $path) { - if (file_exists($path)) { - include $path; - break; - } -} - -$request = Sapi::getRequest(); -$response = new Response(); - -$digestAuth = new Auth\Digest('Locked down area', $request, $response); -$digestAuth->init(); -if (!$userName = $digestAuth->getUsername()) { - // No username given - $digestAuth->requireLogin(); -} elseif (!isset($userList[$userName]) || !$digestAuth->validatePassword($userList[$userName])) { - // Username or password are incorrect - $digestAuth->requireLogin(); -} else { - // Success ! - $response->setBody('You are logged in!'); -} - -// Sending the response -Sapi::sendResponse($response); diff --git a/htdocs/includes/sabre/sabre/http/examples/reverseproxy.php b/htdocs/includes/sabre/sabre/http/examples/reverseproxy.php deleted file mode 100644 index ce51ad43d23..00000000000 --- a/htdocs/includes/sabre/sabre/http/examples/reverseproxy.php +++ /dev/null @@ -1,48 +0,0 @@ -setBaseUrl($myBaseUrl); - -$subRequest = clone $request; - -// Removing the Host header. -$subRequest->removeHeader('Host'); - -// Rewriting the url. -$subRequest->setUrl($remoteUrl.$request->getPath()); - -$client = new Client(); - -// Sends the HTTP request to the server -$response = $client->send($subRequest); - -// Sends the response back to the client that connected to the proxy. -Sapi::sendResponse($response); diff --git a/htdocs/includes/sabre/sabre/http/examples/stringify.php b/htdocs/includes/sabre/sabre/http/examples/stringify.php deleted file mode 100644 index 96f7da84b31..00000000000 --- a/htdocs/includes/sabre/sabre/http/examples/stringify.php +++ /dev/null @@ -1,50 +0,0 @@ -setHeaders([ - 'Host' => 'example.org', - 'Content-Type' => 'application/json', - ]); - -$request->setBody(json_encode(['foo' => 'bar'])); - -echo $request; -echo "\r\n\r\n"; - -$response = new Response(424); -$response->setHeaders([ - 'Content-Type' => 'text/plain', - 'Connection' => 'close', - ]); - -$response->setBody('ABORT! ABORT!'); - -echo $response; - -echo "\r\n"; diff --git a/htdocs/includes/sabre/sabre/http/lib/Auth/AbstractAuth.php b/htdocs/includes/sabre/sabre/http/lib/Auth/AbstractAuth.php index ada6bf0f0d3..07f451bc098 100644 --- a/htdocs/includes/sabre/sabre/http/lib/Auth/AbstractAuth.php +++ b/htdocs/includes/sabre/sabre/http/lib/Auth/AbstractAuth.php @@ -42,7 +42,7 @@ abstract class AbstractAuth /** * Creates the object. */ - public function __construct(string $realm = 'SabreTooth', RequestInterface $request, ResponseInterface $response) + public function __construct(string $realm, RequestInterface $request, ResponseInterface $response) { $this->realm = $realm; $this->request = $request; @@ -50,7 +50,7 @@ abstract class AbstractAuth } /** - * This method sends the needed HTTP header and statuscode (401) to force + * This method sends the needed HTTP header and status code (401) to force * the user to login. */ abstract public function requireLogin(); diff --git a/htdocs/includes/sabre/sabre/http/lib/Auth/Basic.php b/htdocs/includes/sabre/sabre/http/lib/Auth/Basic.php index d04b4a81126..c1bad1a5bb0 100644 --- a/htdocs/includes/sabre/sabre/http/lib/Auth/Basic.php +++ b/htdocs/includes/sabre/sabre/http/lib/Auth/Basic.php @@ -49,7 +49,7 @@ class Basic extends AbstractAuth } /** - * This method sends the needed HTTP header and statuscode (401) to force + * This method sends the needed HTTP header and status code (401) to force * the user to login. */ public function requireLogin() diff --git a/htdocs/includes/sabre/sabre/http/lib/Auth/Bearer.php b/htdocs/includes/sabre/sabre/http/lib/Auth/Bearer.php index 988bb29d2a6..580e239410f 100644 --- a/htdocs/includes/sabre/sabre/http/lib/Auth/Bearer.php +++ b/htdocs/includes/sabre/sabre/http/lib/Auth/Bearer.php @@ -42,7 +42,7 @@ class Bearer extends AbstractAuth } /** - * This method sends the needed HTTP header and statuscode (401) to force + * This method sends the needed HTTP header and status code (401) to force * authentication. */ public function requireLogin() diff --git a/htdocs/includes/sabre/sabre/http/lib/Auth/Digest.php b/htdocs/includes/sabre/sabre/http/lib/Auth/Digest.php index dd35a0b7448..e80e7830532 100644 --- a/htdocs/includes/sabre/sabre/http/lib/Auth/Digest.php +++ b/htdocs/includes/sabre/sabre/http/lib/Auth/Digest.php @@ -46,7 +46,7 @@ class Digest extends AbstractAuth /** * Initializes the object. */ - public function __construct(string $realm = 'SabreTooth', RequestInterface $request, ResponseInterface $response) + public function __construct(string $realm, RequestInterface $request, ResponseInterface $response) { $this->nonce = uniqid(); $this->opaque = md5($realm); @@ -133,7 +133,7 @@ class Digest extends AbstractAuth return false; } // We need to add an md5 of the entire request body to the A2 part of the hash - $body = $this->request->getBody($asString = true); + $body = $this->request->getBody(); $this->request->setBody($body); $A2 .= ':'.md5($body); } elseif (!($this->qop & self::QOP_AUTH)) { @@ -174,7 +174,7 @@ class Digest extends AbstractAuth /** * This method returns the full digest string. * - * It should be compatibile with mod_php format and other webservers. + * It should be compatible with mod_php format and other webservers. * * If the header could not be found, null will be returned * diff --git a/htdocs/includes/sabre/sabre/http/lib/Client.php b/htdocs/includes/sabre/sabre/http/lib/Client.php index 48862e7da4f..0837e8d2aa5 100644 --- a/htdocs/includes/sabre/sabre/http/lib/Client.php +++ b/htdocs/includes/sabre/sabre/http/lib/Client.php @@ -26,7 +26,7 @@ use Sabre\Uri; * request before it's done, such as adding authentication headers. * * The afterRequest event will be emitted after the request is completed - * succesfully. + * successfully. * * If a HTTP error is returned (status code higher than 399) the error event is * triggered. It's possible using this event to retry the request, by setting @@ -53,7 +53,7 @@ class Client extends EventEmitter protected $curlSettings = []; /** - * Wether or not exceptions should be thrown when a HTTP error is returned. + * Whether exceptions should be thrown when a HTTP error is returned. * * @var bool */ @@ -376,11 +376,16 @@ class Client extends EventEmitter default: $body = $request->getBody(); if (is_resource($body)) { + $bodyStat = fstat($body); + // This needs to be set to PUT, regardless of the actual // method used. Without it, INFILE will be ignored for some // reason. $settings[CURLOPT_PUT] = true; - $settings[CURLOPT_INFILE] = $request->getBody(); + $settings[CURLOPT_INFILE] = $body; + if (false !== $bodyStat && array_key_exists('size', $bodyStat)) { + $settings[CURLOPT_INFILESIZE] = $bodyStat['size']; + } } else { // For security we cast this to a string. If somehow an array could // be passed here, it would be possible for an attacker to use @ to @@ -397,7 +402,10 @@ class Client extends EventEmitter $nHeaders[] = $key.': '.$value; } } - $settings[CURLOPT_HTTPHEADER] = $nHeaders; + + if ([] !== $nHeaders) { + $settings[CURLOPT_HTTPHEADER] = $nHeaders; + } $settings[CURLOPT_URL] = $request->getUrl(); // FIXME: CURLOPT_PROTOCOLS is currently unsupported by HHVM if (defined('CURLOPT_PROTOCOLS')) { @@ -450,8 +458,6 @@ class Client extends EventEmitter * * http_code - HTTP status code, as an int. Only set if Only set if * status is STATUS_SUCCESS, or STATUS_HTTPERROR * - * @param array $headerLines - * @param string $body * @param resource $curlHandle */ protected function parseCurlResponse(array $headerLines, string $body, $curlHandle): array diff --git a/htdocs/includes/sabre/sabre/http/lib/Message.php b/htdocs/includes/sabre/sabre/http/lib/Message.php index fc34f8d7ff8..dc57ca9034e 100644 --- a/htdocs/includes/sabre/sabre/http/lib/Message.php +++ b/htdocs/includes/sabre/sabre/http/lib/Message.php @@ -88,7 +88,7 @@ abstract class Message implements MessageInterface * @var string|int|null */ $contentLength = $this->getHeader('Content-Length'); - if (is_int($contentLength) || ctype_digit($contentLength)) { + if (null !== $contentLength && (is_int($contentLength) || ctype_digit($contentLength))) { return stream_get_contents($body, (int) $contentLength); } @@ -96,7 +96,7 @@ abstract class Message implements MessageInterface } /** - * Returns the message body, as it's internal representation. + * Returns the message body, as its internal representation. * * This could be either a string, a stream or a callback writing the body to php://output. * @@ -141,7 +141,7 @@ abstract class Message implements MessageInterface } /** - * Returns a specific HTTP header, based on it's name. + * Returns a specific HTTP header, based on its name. * * The name must be treated as case-insensitive. * If the header does not exist, this method must return null. @@ -172,7 +172,7 @@ abstract class Message implements MessageInterface * For every time the HTTP header appeared in the request or response, an * item will appear in the array. * - * If the header did not exists, this method will return an empty array. + * If the header did not exist, this method will return an empty array. * * @return string[] */ @@ -283,8 +283,6 @@ abstract class Message implements MessageInterface /** * Returns the HTTP version. - * - * @return string */ public function getHttpVersion(): string { diff --git a/htdocs/includes/sabre/sabre/http/lib/MessageDecoratorTrait.php b/htdocs/includes/sabre/sabre/http/lib/MessageDecoratorTrait.php index d5504ac7895..191ba0f745a 100644 --- a/htdocs/includes/sabre/sabre/http/lib/MessageDecoratorTrait.php +++ b/htdocs/includes/sabre/sabre/http/lib/MessageDecoratorTrait.php @@ -51,7 +51,7 @@ trait MessageDecoratorTrait } /** - * Returns the message body, as it's internal representation. + * Returns the message body, as its internal representation. * * This could be either a string or a stream. * @@ -91,7 +91,7 @@ trait MessageDecoratorTrait } /** - * Returns a specific HTTP header, based on it's name. + * Returns a specific HTTP header, based on its name. * * The name must be treated as case-insensitive. * If the header does not exist, this method must return null. @@ -116,7 +116,7 @@ trait MessageDecoratorTrait * For every time the HTTP header appeared in the request or response, an * item will appear in the array. * - * If the header did not exists, this method will return an empty array. + * If the header did not exist, this method will return an empty array. */ public function getHeaderAsArray(string $name): array { @@ -180,8 +180,6 @@ trait MessageDecoratorTrait * The specified header name must be treated as case-insensitive. * This method should return true if the header was successfully deleted, * and false if the header did not exist. - * - * @return bool */ public function removeHeader(string $name): bool { diff --git a/htdocs/includes/sabre/sabre/http/lib/MessageInterface.php b/htdocs/includes/sabre/sabre/http/lib/MessageInterface.php index 8070845d995..4531654bc86 100644 --- a/htdocs/includes/sabre/sabre/http/lib/MessageInterface.php +++ b/htdocs/includes/sabre/sabre/http/lib/MessageInterface.php @@ -29,13 +29,11 @@ interface MessageInterface * * Note that because the underlying data may be based on a stream, this * method could only work correctly the first time. - * - * @return string */ public function getBodyAsString(): string; /** - * Returns the message body, as it's internal representation. + * Returns the message body, as its internal representation. * * This could be either a string, a stream or a callback writing the body to php://output * @@ -63,7 +61,7 @@ interface MessageInterface public function hasHeader(string $name): bool; /** - * Returns a specific HTTP header, based on it's name. + * Returns a specific HTTP header, based on its name. * * The name must be treated as case-insensitive. * If the header does not exist, this method must return null. @@ -85,7 +83,7 @@ interface MessageInterface * For every time the HTTP header appeared in the request or response, an * item will appear in the array. * - * If the header did not exists, this method will return an empty array. + * If the header did not exist, this method will return an empty array. * * @return string[] */ @@ -94,7 +92,7 @@ interface MessageInterface /** * Updates a HTTP header. * - * The case-sensitity of the name value must be retained as-is. + * The case-sensitivity of the name value must be retained as-is. * * If the header already existed, it will be overwritten. * @@ -133,7 +131,7 @@ interface MessageInterface /** * Removes a HTTP header. * - * The specified header name must be treated as case-insenstive. + * The specified header name must be treated as case-insensitive. * This method should return true if the header was successfully deleted, * and false if the header did not exist. */ diff --git a/htdocs/includes/sabre/sabre/http/lib/Request.php b/htdocs/includes/sabre/sabre/http/lib/Request.php index 496629a5b1e..b8395ff45c5 100644 --- a/htdocs/includes/sabre/sabre/http/lib/Request.php +++ b/htdocs/includes/sabre/sabre/http/lib/Request.php @@ -155,7 +155,7 @@ class Request extends Message implements RequestInterface * If the full path is equal to the base url, this method will return an * empty string. * - * This method will also urldecode the path, and if the url was incoded as + * This method will also urldecode the path, and if the url was encoded as * ISO-8859-1, it will convert it to UTF-8. * * If the path is outside of the base url, a LogicException will be thrown. diff --git a/htdocs/includes/sabre/sabre/http/lib/RequestDecorator.php b/htdocs/includes/sabre/sabre/http/lib/RequestDecorator.php index 0ad24925f4e..23e790e7d3b 100644 --- a/htdocs/includes/sabre/sabre/http/lib/RequestDecorator.php +++ b/htdocs/includes/sabre/sabre/http/lib/RequestDecorator.php @@ -104,7 +104,7 @@ class RequestDecorator implements RequestInterface * If the full path is equal to the base url, this method will return an * empty string. * - * This method will also urldecode the path, and if the url was incoded as + * This method will also urldecode the path, and if the url was encoded as * ISO-8859-1, it will convert it to UTF-8. * * If the path is outside of the base url, a LogicException will be thrown. diff --git a/htdocs/includes/sabre/sabre/http/lib/RequestInterface.php b/htdocs/includes/sabre/sabre/http/lib/RequestInterface.php index 83fa85bdc39..5ec7777c67e 100644 --- a/htdocs/includes/sabre/sabre/http/lib/RequestInterface.php +++ b/htdocs/includes/sabre/sabre/http/lib/RequestInterface.php @@ -67,7 +67,7 @@ interface RequestInterface extends MessageInterface * If the full path is equal to the base url, this method will return an * empty string. * - * This method will also urldecode the path, and if the url was incoded as + * This method will also urldecode the path, and if the url was encoded as * ISO-8859-1, it will convert it to UTF-8. * * If the path is outside of the base url, a LogicException will be thrown. diff --git a/htdocs/includes/sabre/sabre/http/lib/Response.php b/htdocs/includes/sabre/sabre/http/lib/Response.php index 64dfbc0b2ec..c06c9637ea1 100644 --- a/htdocs/includes/sabre/sabre/http/lib/Response.php +++ b/htdocs/includes/sabre/sabre/http/lib/Response.php @@ -25,7 +25,7 @@ class Response extends Message implements ResponseInterface 200 => 'OK', 201 => 'Created', 202 => 'Accepted', - 203 => 'Non-Authorative Information', + 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', @@ -137,7 +137,7 @@ class Response extends Message implements ResponseInterface /** * Sets the HTTP status code. * - * This can be either the full HTTP status code with human readable string, + * This can be either the full HTTP status code with human-readable string, * for example: "403 I can't let you do that, Dave". * * Or just the code, in which case the appropriate default message will be @@ -149,7 +149,7 @@ class Response extends Message implements ResponseInterface */ public function setStatus($status) { - if (ctype_digit($status) || is_int($status)) { + if (is_int($status) || ctype_digit($status)) { $statusCode = $status; $statusText = self::$statusCodes[$status] ?? 'Unknown'; } else { diff --git a/htdocs/includes/sabre/sabre/http/lib/ResponseDecorator.php b/htdocs/includes/sabre/sabre/http/lib/ResponseDecorator.php index 289dba5cc59..30b9ec0e58c 100644 --- a/htdocs/includes/sabre/sabre/http/lib/ResponseDecorator.php +++ b/htdocs/includes/sabre/sabre/http/lib/ResponseDecorator.php @@ -47,7 +47,7 @@ class ResponseDecorator implements ResponseInterface /** * Sets the HTTP status code. * - * This can be either the full HTTP status code with human readable string, + * This can be either the full HTTP status code with human-readable string, * for example: "403 I can't let you do that, Dave". * * Or just the code, in which case the appropriate default message will be @@ -64,8 +64,6 @@ class ResponseDecorator implements ResponseInterface * Serializes the request object as a string. * * This is useful for debugging purposes. - * - * @return string */ public function __toString(): string { diff --git a/htdocs/includes/sabre/sabre/http/lib/ResponseInterface.php b/htdocs/includes/sabre/sabre/http/lib/ResponseInterface.php index 9bd93f179ad..fd73d25cdd2 100644 --- a/htdocs/includes/sabre/sabre/http/lib/ResponseInterface.php +++ b/htdocs/includes/sabre/sabre/http/lib/ResponseInterface.php @@ -28,7 +28,7 @@ interface ResponseInterface extends MessageInterface /** * Sets the HTTP status code. * - * This can be either the full HTTP status code with human readable string, + * This can be either the full HTTP status code with human-readable string, * for example: "403 I can't let you do that, Dave". * * Or just the code, in which case the appropriate default message will be diff --git a/htdocs/includes/sabre/sabre/http/lib/Sapi.php b/htdocs/includes/sabre/sabre/http/lib/Sapi.php index 73674a5a131..55a4c46e7e3 100644 --- a/htdocs/includes/sabre/sabre/http/lib/Sapi.php +++ b/htdocs/includes/sabre/sabre/http/lib/Sapi.php @@ -26,7 +26,7 @@ use InvalidArgumentException; * * php://output * * You can choose to either call all these methods statically, but you can also - * instantiate this as an object to allow for polymorhpism. + * instantiate this as an object to allow for polymorphism. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) @@ -89,41 +89,39 @@ class Sapi if (null !== $contentLength) { $output = fopen('php://output', 'wb'); if (is_resource($body) && 'stream' == get_resource_type($body)) { - if (PHP_INT_SIZE > 4) { - // use the dedicated function on 64 Bit systems - // a workaround to make PHP more possible to use mmap based copy, see https://github.com/sabre-io/http/pull/119 - $left = (int) $contentLength; - // copy with 4MiB chunks - $chunk_size = 4 * 1024 * 1024; - stream_set_chunk_size($output, $chunk_size); - // If this is a partial response, flush the beginning bytes until the first position that is a multiple of the page size. - $contentRange = $response->getHeader('Content-Range'); - // Matching "Content-Range: bytes 1234-5678/7890" - if (null !== $contentRange && preg_match('/^bytes\s([0-9]+)-([0-9]+)\//i', $contentRange, $matches)) { - // 4kB should be the default page size on most architectures - $pageSize = 4096; - $offset = (int) $matches[1]; - $delta = ($offset % $pageSize) > 0 ? ($pageSize - $offset % $pageSize) : 0; - if ($delta > 0) { - $left -= stream_copy_to_stream($body, $output, min($delta, $left)); - } + // a workaround to make PHP more possible to use mmap based copy, see https://github.com/sabre-io/http/pull/119 + $left = (int) $contentLength; + // copy with 4MiB chunks + $chunk_size = 4 * 1024 * 1024; + stream_set_chunk_size($output, $chunk_size); + // If this is a partial response, flush the beginning bytes until the first position that is a multiple of the page size. + $contentRange = $response->getHeader('Content-Range'); + // Matching "Content-Range: bytes 1234-5678/7890" + if (null !== $contentRange && preg_match('/^bytes\s([0-9]+)-([0-9]+)\//i', $contentRange, $matches)) { + // 4kB should be the default page size on most architectures + $pageSize = 4096; + $offset = (int) $matches[1]; + $delta = ($offset % $pageSize) > 0 ? ($pageSize - $offset % $pageSize) : 0; + if ($delta > 0) { + $left -= stream_copy_to_stream($body, $output, min($delta, $left)); } - while ($left > 0) { - $copied = stream_copy_to_stream($body, $output, min($left, $chunk_size)); - // stream_copy_to_stream($src, $dest, $maxLength) must return the number of bytes copied or false in case of failure - // But when the $maxLength is greater than the total number of bytes remaining in the stream, - // It returns the negative number of bytes copied - // So break the loop in such cases. - if ($copied <= 0) { - break; - } - $left -= $copied; + } + while ($left > 0) { + $copied = stream_copy_to_stream($body, $output, min($left, $chunk_size)); + // stream_copy_to_stream($src, $dest, $maxLength) must return the number of bytes copied or false in case of failure + // But when the $maxLength is greater than the total number of bytes remaining in the stream, + // It returns the negative number of bytes copied + // So break the loop in such cases. + if ($copied <= 0) { + break; } - } else { - // workaround for 32 Bit systems to avoid stream_copy_to_stream - while (!feof($body)) { - fwrite($output, fread($body, 8192)); + // Abort on client disconnect. + // With ignore_user_abort(true), the script is not aborted on client disconnect. + // To avoid reading the entire stream and dismissing the data afterward, check between the chunks if the client is still there. + if (1 === ignore_user_abort() && 1 === connection_aborted()) { + break; } + $left -= $copied; } } else { fwrite($output, $body, (int) $contentLength); @@ -154,6 +152,7 @@ class Sapi $hostName = 'localhost'; foreach ($serverArray as $key => $value) { + $key = (string) $key; switch ($key) { case 'SERVER_PROTOCOL': if ('HTTP/1.0' === $value) { @@ -214,7 +213,7 @@ class Sapi // Normalizing it to be prettier $header = strtolower(substr($key, 5)); - // Transforming dashes into spaces, and uppercasing + // Transforming dashes into spaces, and upper-casing // every first letter. $header = ucwords(str_replace('_', ' ', $header)); diff --git a/htdocs/includes/sabre/sabre/http/lib/Version.php b/htdocs/includes/sabre/sabre/http/lib/Version.php index 655753acfc4..93c64797bc6 100644 --- a/htdocs/includes/sabre/sabre/http/lib/Version.php +++ b/htdocs/includes/sabre/sabre/http/lib/Version.php @@ -16,5 +16,5 @@ class Version /** * Full version number. */ - const VERSION = '5.0.5'; + const VERSION = '5.1.10'; } diff --git a/htdocs/includes/sabre/sabre/http/lib/functions.php b/htdocs/includes/sabre/sabre/http/lib/functions.php index 728bbc13240..d0477d9434b 100644 --- a/htdocs/includes/sabre/sabre/http/lib/functions.php +++ b/htdocs/includes/sabre/sabre/http/lib/functions.php @@ -29,8 +29,6 @@ use InvalidArgumentException; * See: * http://tools.ietf.org/html/rfc7231#section-7.1.1.1 * - * @param string $dateString - * * @return bool|DateTime */ function parseDate(string $dateString) @@ -75,10 +73,6 @@ function parseDate(string $dateString) /** * Transforms a DateTime object to a valid HTTP/1.1 Date header value. - * - * @param DateTime $dateTime - * - * @return string */ function toDate(DateTime $dateTime): string { @@ -107,7 +101,6 @@ function toDate(DateTime $dateTime): string * implying that no accept header was sent. * * @param string|null $acceptHeaderValue - * @param array $availableOptions * * @return string|null */ @@ -218,8 +211,6 @@ function negotiateContentType($acceptHeaderValue, array $availableOptions) * uses them. * * @param string|string[] $input - * - * @return array */ function parsePrefer($input): array { @@ -303,7 +294,7 @@ function getHeaderValues($values, $values2 = null): array $values = array_merge($values, (array) $values2); } - $result = array(); + $result = []; foreach ($values as $l1) { foreach (explode(',', $l1) as $l2) { $result[] = trim($l2); @@ -320,10 +311,6 @@ function getHeaderValues($values, $values2 = null): array * 2. subtype * 3. quality * 4. parameters - * - * @param string $str - * - * @return array */ function parseMimeType(string $str): array { @@ -344,8 +331,8 @@ function parseMimeType(string $str): array if (2 !== count($mimeType)) { // Illegal value var_dump($mimeType); - die(); - throw new InvalidArgumentException('Not a valid mime-type: '.$str); + exit(); + // throw new InvalidArgumentException('Not a valid mime-type: '.$str); } list($type, $subType) = $mimeType; @@ -362,7 +349,7 @@ function parseMimeType(string $str): array // The quality parameter, if it appears, also marks the end of // the parameter list. Anything after the q= counts as an // 'accept extension' and could introduce new semantics in - // content-negotation. + // content-negotiation. if ('q' !== $partName) { $parameters[$partName] = $part; } else { @@ -417,11 +404,9 @@ function decodePath(string $path): string function decodePathSegment(string $path): string { $path = rawurldecode($path); - $encoding = mb_detect_encoding($path, ['UTF-8', 'ISO-8859-1']); - switch ($encoding) { - case 'ISO-8859-1': - $path = mb_convert_encoding($path, 'UTF-8', 'ISO-8859-1'); + if (!mb_check_encoding($path, 'UTF-8') && mb_check_encoding($path, 'ISO-8859-1')) { + $path = mb_convert_encoding($path, 'UTF-8', 'ISO-8859-1'); } return $path; diff --git a/htdocs/includes/sabre/sabre/http/phpstan.neon b/htdocs/includes/sabre/sabre/http/phpstan.neon index 241663a7271..213da6dad2a 100644 --- a/htdocs/includes/sabre/sabre/http/phpstan.neon +++ b/htdocs/includes/sabre/sabre/http/phpstan.neon @@ -1,3 +1,2 @@ parameters: level: 1 - bootstrap: %currentWorkingDirectory%/vendor/autoload.php diff --git a/htdocs/includes/sabre/sabre/uri/lib/Version.php b/htdocs/includes/sabre/sabre/uri/lib/Version.php index 04aa30f154a..4f05b2adef7 100644 --- a/htdocs/includes/sabre/sabre/uri/lib/Version.php +++ b/htdocs/includes/sabre/sabre/uri/lib/Version.php @@ -16,5 +16,5 @@ class Version /** * Full version number. */ - const VERSION = '2.2.3'; + const VERSION = '2.2.4'; } diff --git a/htdocs/includes/sabre/sabre/uri/lib/functions.php b/htdocs/includes/sabre/sabre/uri/lib/functions.php index cf30136b767..fd656832bb4 100644 --- a/htdocs/includes/sabre/sabre/uri/lib/functions.php +++ b/htdocs/includes/sabre/sabre/uri/lib/functions.php @@ -196,19 +196,6 @@ function parse(string $uri): array $result = parse_url($uri); if (!$result) { $result = _parse_fallback($uri); - } else { - // Add empty host and trailing slash to Windows file paths - // file:///C:/path or file:///C:\path - // Note: the regex fragment [a-zA-Z]:[\/\\\\].* end up being - // [a-zA-Z]:[\/\\].* - // The 4 backslash in a row are the way to get 2 backslash into the actual string - // that is used as the regex. The 2 backslash are then the way to get 1 backslash - // character into the character set "a forward slash or a backslash" - if (isset($result['scheme']) && 'file' === $result['scheme'] && isset($result['path']) && - preg_match('/^(? [a-zA-Z]:([\/\\\\].*)?)$/x', $result['path'])) { - $result['path'] = '/'.$result['path']; - $result['host'] = ''; - } } return diff --git a/htdocs/includes/sabre/sabre/vobject/composer.json b/htdocs/includes/sabre/sabre/vobject/composer.json index b745b1fa6a9..b08684bce8b 100644 --- a/htdocs/includes/sabre/sabre/vobject/composer.json +++ b/htdocs/includes/sabre/sabre/vobject/composer.json @@ -34,7 +34,7 @@ "require" : { "php" : "^7.1 || ^8.0", "ext-mbstring" : "*", - "sabre/xml" : "^2.1" + "sabre/xml" : "^2.1 || ^3.0 || ^4.0" }, "require-dev" : { "friendsofphp/php-cs-fixer": "~2.17.1", diff --git a/htdocs/includes/sabre/sabre/vobject/lib/Component.php b/htdocs/includes/sabre/sabre/vobject/lib/Component.php index a929387a3ce..ca82ad49bcb 100644 --- a/htdocs/includes/sabre/sabre/vobject/lib/Component.php +++ b/htdocs/includes/sabre/sabre/vobject/lib/Component.php @@ -368,7 +368,7 @@ class Component extends Node * * @param Xml\Writer $writer XML writer */ - public function xmlSerialize(Xml\Writer $writer) + public function xmlSerialize(Xml\Writer $writer): void { $components = []; $properties = []; diff --git a/htdocs/includes/sabre/sabre/vobject/lib/Component/VCard.php b/htdocs/includes/sabre/sabre/vobject/lib/Component/VCard.php index 90a6df72f76..82fab82bb28 100644 --- a/htdocs/includes/sabre/sabre/vobject/lib/Component/VCard.php +++ b/htdocs/includes/sabre/sabre/vobject/lib/Component/VCard.php @@ -473,7 +473,7 @@ class VCard extends VObject\Document * * @param Xml\Writer $writer XML writer */ - public function xmlSerialize(Xml\Writer $writer) + public function xmlSerialize(Xml\Writer $writer): void { $propertiesByGroup = []; diff --git a/htdocs/includes/sabre/sabre/vobject/lib/DateTimeParser.php b/htdocs/includes/sabre/sabre/vobject/lib/DateTimeParser.php index 1c253437abd..c5dbac97d3a 100644 --- a/htdocs/includes/sabre/sabre/vobject/lib/DateTimeParser.php +++ b/htdocs/includes/sabre/sabre/vobject/lib/DateTimeParser.php @@ -104,7 +104,7 @@ class DateTimeParser if (!$asString) { $invert = false; - if ('-' === $matches['plusminus']) { + if (isset($matches['plusminus']) && '-' === $matches['plusminus']) { $invert = true; } diff --git a/htdocs/includes/sabre/sabre/vobject/lib/ITip/Broker.php b/htdocs/includes/sabre/sabre/vobject/lib/ITip/Broker.php index b66a59f545f..80d9a5b3162 100644 --- a/htdocs/includes/sabre/sabre/vobject/lib/ITip/Broker.php +++ b/htdocs/includes/sabre/sabre/vobject/lib/ITip/Broker.php @@ -156,9 +156,9 @@ class Broker * people. If the user was an attendee, we need to make sure that the * organizer gets the 'declined' message. * - * @param VCalendar|string $calendar - * @param string|array $userHref - * @param VCalendar|string $oldCalendar + * @param VCalendar|string $calendar + * @param string|array $userHref + * @param VCalendar|string|null $oldCalendar * * @return array */ diff --git a/htdocs/includes/sabre/sabre/vobject/lib/Node.php b/htdocs/includes/sabre/sabre/vobject/lib/Node.php index 2041b2ac7b9..852ffced05a 100644 --- a/htdocs/includes/sabre/sabre/vobject/lib/Node.php +++ b/htdocs/includes/sabre/sabre/vobject/lib/Node.php @@ -82,7 +82,7 @@ abstract class Node implements \IteratorAggregate, \ArrayAccess, \Countable, \Js * * @param Xml\Writer $writer XML writer */ - abstract public function xmlSerialize(Xml\Writer $writer); + abstract public function xmlSerialize(Xml\Writer $writer): void; /** * Call this method on a document if you're done using it. diff --git a/htdocs/includes/sabre/sabre/vobject/lib/Parameter.php b/htdocs/includes/sabre/sabre/vobject/lib/Parameter.php index c27b2aa47cb..0f0b5860cde 100644 --- a/htdocs/includes/sabre/sabre/vobject/lib/Parameter.php +++ b/htdocs/includes/sabre/sabre/vobject/lib/Parameter.php @@ -334,7 +334,7 @@ class Parameter extends Node * * @param Xml\Writer $writer XML writer */ - public function xmlSerialize(Xml\Writer $writer) + public function xmlSerialize(Xml\Writer $writer): void { foreach (explode(',', $this->value) as $value) { $writer->writeElement('text', $value); diff --git a/htdocs/includes/sabre/sabre/vobject/lib/Parser/XML/Element/KeyValue.php b/htdocs/includes/sabre/sabre/vobject/lib/Parser/XML/Element/KeyValue.php index c0bbf0d9b34..e01772510b6 100644 --- a/htdocs/includes/sabre/sabre/vobject/lib/Parser/XML/Element/KeyValue.php +++ b/htdocs/includes/sabre/sabre/vobject/lib/Parser/XML/Element/KeyValue.php @@ -34,10 +34,8 @@ class KeyValue extends SabreXml\Element\KeyValue * the next element. * * @param XML\Reader $reader - * - * @return mixed */ - public static function xmlDeserialize(SabreXml\Reader $reader) + public static function xmlDeserialize(SabreXml\Reader $reader): array { // If there's no children, we don't do anything. if ($reader->isEmptyElement) { diff --git a/htdocs/includes/sabre/sabre/vobject/lib/Property.php b/htdocs/includes/sabre/sabre/vobject/lib/Property.php index 56096dafea6..f6550246a7a 100644 --- a/htdocs/includes/sabre/sabre/vobject/lib/Property.php +++ b/htdocs/includes/sabre/sabre/vobject/lib/Property.php @@ -318,7 +318,7 @@ abstract class Property extends Node * * @param Xml\Writer $writer XML writer */ - public function xmlSerialize(Xml\Writer $writer) + public function xmlSerialize(Xml\Writer $writer): void { $parameters = []; diff --git a/htdocs/includes/sabre/sabre/vobject/lib/Version.php b/htdocs/includes/sabre/sabre/vobject/lib/Version.php index 92882f2f1e2..c7ca69e14a4 100644 --- a/htdocs/includes/sabre/sabre/vobject/lib/Version.php +++ b/htdocs/includes/sabre/sabre/vobject/lib/Version.php @@ -14,5 +14,5 @@ class Version /** * Full version number. */ - const VERSION = '4.5.1'; + public const VERSION = '4.5.4'; } diff --git a/htdocs/includes/sabre/sabre/vobject/lib/timezonedata/exchangezones.php b/htdocs/includes/sabre/sabre/vobject/lib/timezonedata/exchangezones.php index debbf438ce1..89bddc27c5b 100644 --- a/htdocs/includes/sabre/sabre/vobject/lib/timezonedata/exchangezones.php +++ b/htdocs/includes/sabre/sabre/vobject/lib/timezonedata/exchangezones.php @@ -71,7 +71,7 @@ return [ 'Mid-Atlantic' => 'America/Noronha', 'Brasilia' => 'America/Sao_Paulo', // Best guess 'Buenos Aires' => 'America/Argentina/Buenos_Aires', - 'Greenland' => 'America/Nuuk', + 'Greenland' => 'America/Godthab', 'Newfoundland' => 'America/St_Johns', 'Atlantic Time (Canada)' => 'America/Halifax', 'Caracas, La Paz' => 'America/Caracas', diff --git a/htdocs/includes/sabre/sabre/vobject/lib/timezonedata/lotuszones.php b/htdocs/includes/sabre/sabre/vobject/lib/timezonedata/lotuszones.php index 9740f6aa8d7..4b50808f908 100644 --- a/htdocs/includes/sabre/sabre/vobject/lib/timezonedata/lotuszones.php +++ b/htdocs/includes/sabre/sabre/vobject/lib/timezonedata/lotuszones.php @@ -34,7 +34,7 @@ return [ 'Newfoundland' => 'America/St_Johns', 'Argentina' => 'America/Argentina/Buenos_Aires', 'E. South America' => 'America/Belem', - 'Greenland' => 'America/Nuuk', + 'Greenland' => 'America/Godthab', 'Montevideo' => 'America/Montevideo', 'SA Eastern' => 'America/Belem', // 'Mid-Atlantic' => 'Etc/GMT-2', // conflict with windows timezones. diff --git a/htdocs/includes/sabre/sabre/vobject/lib/timezonedata/php-bc.php b/htdocs/includes/sabre/sabre/vobject/lib/timezonedata/php-bc.php index ea2366cf66c..3116c6868e6 100644 --- a/htdocs/includes/sabre/sabre/vobject/lib/timezonedata/php-bc.php +++ b/htdocs/includes/sabre/sabre/vobject/lib/timezonedata/php-bc.php @@ -16,319 +16,67 @@ * @license http://sabre.io/license/ Modified BSD License */ return [ - 'Africa/Abidjan', - 'Africa/Accra', - 'Africa/Addis_Ababa', - 'Africa/Algiers', - 'Africa/Asmara', - 'Africa/Bamako', - 'Africa/Bangui', - 'Africa/Banjul', - 'Africa/Bissau', - 'Africa/Blantyre', - 'Africa/Brazzaville', - 'Africa/Bujumbura', - 'Africa/Cairo', - 'Africa/Casablanca', - 'Africa/Ceuta', - 'Africa/Conakry', - 'Africa/Dakar', - 'Africa/Dar_es_Salaam', - 'Africa/Djibouti', - 'Africa/Douala', - 'Africa/El_Aaiun', - 'Africa/Freetown', - 'Africa/Gaborone', - 'Africa/Harare', - 'Africa/Johannesburg', - 'Africa/Juba', - 'Africa/Kampala', - 'Africa/Khartoum', - 'Africa/Kigali', - 'Africa/Kinshasa', - 'Africa/Lagos', - 'Africa/Libreville', - 'Africa/Lome', - 'Africa/Luanda', - 'Africa/Lubumbashi', - 'Africa/Lusaka', - 'Africa/Malabo', - 'Africa/Maputo', - 'Africa/Maseru', - 'Africa/Mbabane', - 'Africa/Mogadishu', - 'Africa/Monrovia', - 'Africa/Nairobi', - 'Africa/Ndjamena', - 'Africa/Niamey', - 'Africa/Nouakchott', - 'Africa/Ouagadougou', - 'Africa/Porto-Novo', - 'Africa/Sao_Tome', - 'Africa/Tripoli', - 'Africa/Tunis', - 'Africa/Windhoek', - 'America/Adak', - 'America/Anchorage', - 'America/Anguilla', - 'America/Antigua', - 'America/Araguaina', - 'America/Argentina/Buenos_Aires', - 'America/Argentina/Catamarca', - 'America/Argentina/Cordoba', - 'America/Argentina/Jujuy', - 'America/Argentina/La_Rioja', - 'America/Argentina/Mendoza', - 'America/Argentina/Rio_Gallegos', - 'America/Argentina/Salta', - 'America/Argentina/San_Juan', - 'America/Argentina/San_Luis', - 'America/Argentina/Tucuman', - 'America/Argentina/Ushuaia', - 'America/Aruba', - 'America/Asuncion', - 'America/Atikokan', - 'America/Bahia', - 'America/Bahia_Banderas', - 'America/Barbados', - 'America/Belem', - 'America/Belize', - 'America/Blanc-Sablon', - 'America/Boa_Vista', - 'America/Bogota', - 'America/Boise', - 'America/Cambridge_Bay', - 'America/Campo_Grande', - 'America/Cancun', - 'America/Caracas', - 'America/Cayenne', - 'America/Cayman', - 'America/Chicago', - 'America/Chihuahua', - 'America/Ciudad_Juarez', - 'America/Costa_Rica', - 'America/Creston', - 'America/Cuiaba', - 'America/Curacao', - 'America/Danmarkshavn', - 'America/Dawson', - 'America/Dawson_Creek', - 'America/Denver', - 'America/Detroit', - 'America/Dominica', - 'America/Edmonton', - 'America/Eirunepe', - 'America/El_Salvador', - 'America/Fort_Nelson', - 'America/Fortaleza', - 'America/Glace_Bay', - 'America/Goose_Bay', - 'America/Grand_Turk', - 'America/Grenada', - 'America/Guadeloupe', - 'America/Guatemala', - 'America/Guayaquil', - 'America/Guyana', - 'America/Halifax', - 'America/Havana', - 'America/Hermosillo', - 'America/Indiana/Indianapolis', - 'America/Indiana/Knox', - 'America/Indiana/Marengo', - 'America/Indiana/Petersburg', - 'America/Indiana/Tell_City', - 'America/Indiana/Vevay', - 'America/Indiana/Vincennes', - 'America/Indiana/Winamac', - 'America/Inuvik', - 'America/Iqaluit', - 'America/Jamaica', - 'America/Juneau', - 'America/Kentucky/Louisville', - 'America/Kentucky/Monticello', - 'America/Kralendijk', - 'America/La_Paz', - 'America/Lima', - 'America/Los_Angeles', - 'America/Lower_Princes', - 'America/Maceio', - 'America/Managua', - 'America/Manaus', - 'America/Marigot', - 'America/Martinique', - 'America/Matamoros', - 'America/Mazatlan', - 'America/Menominee', - 'America/Merida', - 'America/Metlakatla', - 'America/Mexico_City', - 'America/Miquelon', - 'America/Moncton', - 'America/Monterrey', - 'America/Montevideo', - 'America/Montserrat', - 'America/Nassau', - 'America/New_York', - 'America/Nome', - 'America/Noronha', - 'America/North_Dakota/Beulah', - 'America/North_Dakota/Center', - 'America/North_Dakota/New_Salem', - 'America/Nuuk', - 'America/Ojinaga', - 'America/Panama', - 'America/Paramaribo', - 'America/Phoenix', - 'America/Port-au-Prince', - 'America/Port_of_Spain', - 'America/Porto_Velho', - 'America/Puerto_Rico', - 'America/Punta_Arenas', - 'America/Rankin_Inlet', - 'America/Recife', - 'America/Regina', - 'America/Resolute', - 'America/Rio_Branco', - 'America/Santarem', - 'America/Santiago', - 'America/Santo_Domingo', - 'America/Sao_Paulo', - 'America/Scoresbysund', - 'America/Sitka', - 'America/St_Barthelemy', - 'America/St_Johns', - 'America/St_Kitts', - 'America/St_Lucia', - 'America/St_Thomas', - 'America/St_Vincent', - 'America/Swift_Current', - 'America/Tegucigalpa', - 'America/Thule', - 'America/Tijuana', - 'America/Toronto', - 'America/Tortola', - 'America/Vancouver', - 'America/Whitehorse', - 'America/Winnipeg', - 'America/Yakutat', - 'Antarctica/Casey', - 'Antarctica/Davis', - 'Antarctica/DumontDUrville', - 'Antarctica/Macquarie', - 'Antarctica/Mawson', - 'Antarctica/McMurdo', - 'Antarctica/Palmer', - 'Antarctica/Rothera', - 'Antarctica/Syowa', - 'Antarctica/Troll', - 'Antarctica/Vostok', - 'Arctic/Longyearbyen', - 'Asia/Aden', - 'Asia/Almaty', - 'Asia/Amman', - 'Asia/Anadyr', - 'Asia/Aqtau', - 'Asia/Aqtobe', - 'Asia/Ashgabat', - 'Asia/Atyrau', - 'Asia/Baghdad', - 'Asia/Bahrain', - 'Asia/Baku', - 'Asia/Bangkok', - 'Asia/Barnaul', - 'Asia/Beirut', - 'Asia/Bishkek', - 'Asia/Brunei', + 'Africa/Asmera', + 'Africa/Timbuktu', + 'America/Argentina/ComodRivadavia', + 'America/Atka', + 'America/Buenos_Aires', + 'America/Catamarca', + 'America/Coral_Harbour', + 'America/Cordoba', + 'America/Ensenada', + 'America/Fort_Wayne', + 'America/Indianapolis', + 'America/Jujuy', + 'America/Knox_IN', + 'America/Louisville', + 'America/Mendoza', + 'America/Montreal', + 'America/Porto_Acre', + 'America/Rosario', + 'America/Shiprock', + 'America/Virgin', + 'Antarctica/South_Pole', + 'Asia/Ashkhabad', 'Asia/Calcutta', - 'Asia/Chita', - 'Asia/Choibalsan', - 'Asia/Colombo', - 'Asia/Damascus', - 'Asia/Dhaka', - 'Asia/Dili', - 'Asia/Dubai', - 'Asia/Dushanbe', - 'Asia/Famagusta', - 'Asia/Gaza', - 'Asia/Hebron', - 'Asia/Ho_Chi_Minh', - 'Asia/Hong_Kong', - 'Asia/Hovd', - 'Asia/Irkutsk', - 'Asia/Jakarta', - 'Asia/Jayapura', - 'Asia/Jerusalem', - 'Asia/Kabul', - 'Asia/Kamchatka', - 'Asia/Karachi', - 'Asia/Kathmandu', + 'Asia/Chungking', + 'Asia/Dacca', + 'Asia/Istanbul', 'Asia/Katmandu', - 'Asia/Khandyga', - 'Asia/Kolkata', - 'Asia/Krasnoyarsk', - 'Asia/Kuala_Lumpur', - 'Asia/Kuching', - 'Asia/Kuwait', - 'Asia/Macau', - 'Asia/Magadan', - 'Asia/Makassar', - 'Asia/Manila', - 'Asia/Muscat', - 'Asia/Nicosia', - 'Asia/Novokuznetsk', - 'Asia/Novosibirsk', - 'Asia/Omsk', - 'Asia/Oral', - 'Asia/Phnom_Penh', - 'Asia/Pontianak', - 'Asia/Pyongyang', - 'Asia/Qatar', - 'Asia/Qostanay', - 'Asia/Qyzylorda', - 'Asia/Riyadh', - 'Asia/Sakhalin', - 'Asia/Samarkand', - 'Asia/Seoul', - 'Asia/Shanghai', - 'Asia/Singapore', - 'Asia/Srednekolymsk', - 'Asia/Taipei', - 'Asia/Tashkent', - 'Asia/Tbilisi', - 'Asia/Tehran', - 'Asia/Thimphu', - 'Asia/Tokyo', - 'Asia/Tomsk', - 'Asia/Ulaanbaatar', - 'Asia/Urumqi', - 'Asia/Ust-Nera', - 'Asia/Vientiane', - 'Asia/Vladivostok', - 'Asia/Yakutsk', - 'Asia/Yangon', - 'Asia/Yekaterinburg', - 'Asia/Yerevan', - 'Atlantic/Azores', - 'Atlantic/Bermuda', - 'Atlantic/Canary', - 'Atlantic/Cape_Verde', - 'Atlantic/Faroe', - 'Atlantic/Madeira', - 'Atlantic/Reykjavik', - 'Atlantic/South_Georgia', - 'Atlantic/St_Helena', - 'Atlantic/Stanley', - 'Australia/Adelaide', - 'Australia/Brisbane', - 'Australia/Broken_Hill', - 'Australia/Darwin', - 'Australia/Eucla', - 'Australia/Hobart', - 'Australia/Lindeman', - 'Australia/Lord_Howe', - 'Australia/Melbourne', - 'Australia/Perth', - 'Australia/Sydney', + 'Asia/Macao', + 'Asia/Saigon', + 'Asia/Tel_Aviv', + 'Asia/Thimbu', + 'Asia/Ujung_Pandang', + 'Asia/Ulan_Bator', + 'Atlantic/Faeroe', + 'Atlantic/Jan_Mayen', + 'Australia/ACT', + 'Australia/Canberra', + 'Australia/LHI', + 'Australia/North', + 'Australia/NSW', + 'Australia/Queensland', + 'Australia/South', + 'Australia/Tasmania', + 'Australia/Victoria', + 'Australia/West', + 'Australia/Yancowinna', + 'Brazil/Acre', + 'Brazil/DeNoronha', + 'Brazil/East', + 'Brazil/West', + 'Canada/Atlantic', + 'Canada/Central', + 'Canada/Eastern', + 'Canada/Mountain', + 'Canada/Newfoundland', + 'Canada/Pacific', + 'Canada/Saskatchewan', + 'Canada/Yukon', + 'CET', + 'Chile/Continental', + 'Chile/EasterIsland', 'EET', 'EST', 'Etc/GMT', @@ -363,127 +111,42 @@ return [ 'Etc/GMT0', 'Etc/Greenwich', 'Etc/UCT', - 'Etc/UTC', 'Etc/Universal', + 'Etc/UTC', 'Etc/Zulu', - 'Europe/Amsterdam', - 'Europe/Andorra', - 'Europe/Astrakhan', - 'Europe/Athens', - 'Europe/Belgrade', - 'Europe/Berlin', - 'Europe/Bratislava', - 'Europe/Brussels', - 'Europe/Bucharest', - 'Europe/Budapest', - 'Europe/Busingen', - 'Europe/Chisinau', - 'Europe/Copenhagen', - 'Europe/Dublin', - 'Europe/Gibraltar', - 'Europe/Guernsey', - 'Europe/Helsinki', - 'Europe/Isle_of_Man', - 'Europe/Istanbul', - 'Europe/Jersey', - 'Europe/Kaliningrad', - 'Europe/Kirov', - 'Europe/Kyiv', - 'Europe/Lisbon', - 'Europe/Ljubljana', - 'Europe/London', - 'Europe/Luxembourg', - 'Europe/Madrid', - 'Europe/Malta', - 'Europe/Mariehamn', - 'Europe/Minsk', - 'Europe/Monaco', - 'Europe/Moscow', - 'Europe/Oslo', - 'Europe/Paris', - 'Europe/Podgorica', - 'Europe/Prague', - 'Europe/Riga', - 'Europe/Rome', - 'Europe/Samara', - 'Europe/San_Marino', - 'Europe/Sarajevo', - 'Europe/Saratov', - 'Europe/Simferopol', - 'Europe/Skopje', - 'Europe/Sofia', - 'Europe/Stockholm', - 'Europe/Tallinn', - 'Europe/Tirane', - 'Europe/Ulyanovsk', - 'Europe/Vaduz', - 'Europe/Vatican', - 'Europe/Vienna', - 'Europe/Vilnius', - 'Europe/Volgograd', - 'Europe/Warsaw', - 'Europe/Zagreb', - 'Europe/Zurich', + 'Europe/Belfast', + 'Europe/Nicosia', + 'Europe/Tiraspol', 'GB', 'GMT', 'GMT+0', 'GMT-0', 'HST', - 'Indian/Antananarivo', - 'Indian/Chagos', - 'Indian/Christmas', - 'Indian/Cocos', - 'Indian/Comoro', - 'Indian/Kerguelen', - 'Indian/Mahe', - 'Indian/Maldives', - 'Indian/Mauritius', - 'Indian/Mayotte', - 'Indian/Reunion', 'MET', + 'Mexico/BajaNorte', + 'Mexico/BajaSur', + 'Mexico/General', 'MST', 'NZ', + 'Pacific/Ponape', + 'Pacific/Samoa', + 'Pacific/Truk', + 'Pacific/Yap', 'PRC', - 'Pacific/Apia', - 'Pacific/Auckland', - 'Pacific/Bougainville', - 'Pacific/Chatham', - 'Pacific/Chuuk', - 'Pacific/Easter', - 'Pacific/Efate', - 'Pacific/Fakaofo', - 'Pacific/Fiji', - 'Pacific/Funafuti', - 'Pacific/Galapagos', - 'Pacific/Gambier', - 'Pacific/Guadalcanal', - 'Pacific/Guam', - 'Pacific/Honolulu', - 'Pacific/Kanton', - 'Pacific/Kiritimati', - 'Pacific/Kosrae', - 'Pacific/Kwajalein', - 'Pacific/Majuro', - 'Pacific/Marquesas', - 'Pacific/Midway', - 'Pacific/Nauru', - 'Pacific/Niue', - 'Pacific/Norfolk', - 'Pacific/Noumea', - 'Pacific/Pago_Pago', - 'Pacific/Palau', - 'Pacific/Pitcairn', - 'Pacific/Pohnpei', - 'Pacific/Port_Moresby', - 'Pacific/Rarotonga', - 'Pacific/Saipan', - 'Pacific/Tahiti', - 'Pacific/Tarawa', - 'Pacific/Tongatapu', - 'Pacific/Wake', - 'Pacific/Wallis', 'ROC', 'ROK', 'UCT', + 'US/Alaska', + 'US/Aleutian', + 'US/Arizona', + 'US/Central', + 'US/East-Indiana', + 'US/Eastern', + 'US/Hawaii', + 'US/Indiana-Starke', + 'US/Michigan', + 'US/Mountain', + 'US/Pacific', + 'US/Samoa', 'WET', ]; diff --git a/htdocs/includes/sabre/sabre/vobject/lib/timezonedata/windowszones.php b/htdocs/includes/sabre/sabre/vobject/lib/timezonedata/windowszones.php index be1eceb6520..2049a95c185 100644 --- a/htdocs/includes/sabre/sabre/vobject/lib/timezonedata/windowszones.php +++ b/htdocs/includes/sabre/sabre/vobject/lib/timezonedata/windowszones.php @@ -20,7 +20,7 @@ return [ 'Arab Standard Time' => 'Asia/Riyadh', 'Arabian Standard Time' => 'Asia/Dubai', 'Arabic Standard Time' => 'Asia/Baghdad', - 'Argentina Standard Time' => 'America/Argentina/Buenos_Aires', + 'Argentina Standard Time' => 'America/Buenos_Aires', 'Astrakhan Standard Time' => 'Europe/Astrakhan', 'Atlantic Standard Time' => 'America/Halifax', 'Aus Central W. Standard Time' => 'Australia/Eucla', @@ -60,7 +60,7 @@ return [ 'GMT Standard Time' => 'Europe/London', 'GTB Standard Time' => 'Europe/Bucharest', 'Georgian Standard Time' => 'Asia/Tbilisi', - 'Greenland Standard Time' => 'America/Nuuk', + 'Greenland Standard Time' => 'America/Godthab', 'Greenwich Standard Time' => 'Atlantic/Reykjavik', 'Haiti Standard Time' => 'America/Port-au-Prince', 'Hawaiian Standard Time' => 'Pacific/Honolulu', @@ -127,7 +127,7 @@ return [ 'Transbaikal Standard Time' => 'Asia/Chita', 'Turkey Standard Time' => 'Europe/Istanbul', 'Turks And Caicos Standard Time' => 'America/Grand_Turk', - 'US Eastern Standard Time' => 'America/Indiana/Indianapolis', + 'US Eastern Standard Time' => 'America/Indianapolis', 'US Mountain Standard Time' => 'America/Phoenix', 'UTC' => 'Etc/GMT', 'UTC+12' => 'Etc/GMT-12', diff --git a/htdocs/includes/sabre/sabre/xml/lib/Deserializer/functions.php b/htdocs/includes/sabre/sabre/xml/lib/Deserializer/functions.php index c4f240970ec..62d4d0e0790 100644 --- a/htdocs/includes/sabre/sabre/xml/lib/Deserializer/functions.php +++ b/htdocs/includes/sabre/sabre/xml/lib/Deserializer/functions.php @@ -216,7 +216,7 @@ function valueObject(Reader $reader, string $className, string $namespace) $reader->next(); } } else { - if (!$reader->read()) { + if (Reader::END_ELEMENT !== $reader->nodeType && !$reader->read()) { break; } } diff --git a/htdocs/includes/sabre/sabre/xml/lib/Version.php b/htdocs/includes/sabre/sabre/xml/lib/Version.php index 1144bf08545..6b6c53b182d 100644 --- a/htdocs/includes/sabre/sabre/xml/lib/Version.php +++ b/htdocs/includes/sabre/sabre/xml/lib/Version.php @@ -16,5 +16,5 @@ class Version /** * Full version number. */ - const VERSION = '2.2.5'; + const VERSION = '2.2.6'; } diff --git a/htdocs/install/doctemplates/supplier_orders/template_supplier_order.odt b/htdocs/install/doctemplates/supplier_orders/template_supplier_order.odt index e5020aef036..c64de7fa1a7 100644 Binary files a/htdocs/install/doctemplates/supplier_orders/template_supplier_order.odt and b/htdocs/install/doctemplates/supplier_orders/template_supplier_order.odt differ diff --git a/htdocs/install/mysql/migration/18.0.0-19.0.0.sql b/htdocs/install/mysql/migration/18.0.0-19.0.0.sql index 4a6f4c0325c..c329502cf86 100644 --- a/htdocs/install/mysql/migration/18.0.0-19.0.0.sql +++ b/htdocs/install/mysql/migration/18.0.0-19.0.0.sql @@ -203,3 +203,5 @@ ALTER TABLE llx_expensereport DROP INDEX idx_expensereport_fk_refuse, ADD INDEX INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle) VALUES (1,'66','Société publique locale'); ALTER TABLE llx_prelevement_lignes ADD COLUMN tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; + +ALTER TABLE llx_bom_bomline ADD COLUMN tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; diff --git a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql index 665b9a7d868..11609aa8049 100644 --- a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql +++ b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql @@ -157,6 +157,8 @@ ALTER TABLE llx_user_extrafields ADD UNIQUE INDEX uk_user_extrafields (fk_object ALTER TABLE llx_usergroup_extrafields DROP INDEX idx_usergroup_extrafields; ALTER TABLE llx_usergroup_extrafields ADD UNIQUE INDEX uk_usergroup_extrafields (fk_object); +ALTER TABLE llx_website ADD COLUMN name_template varchar(255) NULL; + UPDATE llx_categorie SET date_creation = tms, tms = tms WHERE date_creation IS NULL AND tms IS NOT NULL; ALTER TABLE llx_product_price ADD COLUMN price_label varchar(255) AFTER fk_user_author; diff --git a/htdocs/install/mysql/tables/llx_bom_bomline.sql b/htdocs/install/mysql/tables/llx_bom_bomline.sql index 27f22e5c07e..54eb738ad94 100644 --- a/htdocs/install/mysql/tables/llx_bom_bomline.sql +++ b/htdocs/install/mysql/tables/llx_bom_bomline.sql @@ -19,6 +19,7 @@ CREATE TABLE llx_bom_bomline( fk_bom integer NOT NULL, fk_product integer NOT NULL, fk_bom_child integer NULL, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, description text, import_key varchar(14), qty double(24,8) NOT NULL, diff --git a/htdocs/install/mysql/tables/llx_website-website.sql b/htdocs/install/mysql/tables/llx_website-website.sql index 8ac580919aa..7380fe678df 100644 --- a/htdocs/install/mysql/tables/llx_website-website.sql +++ b/htdocs/install/mysql/tables/llx_website-website.sql @@ -41,5 +41,6 @@ CREATE TABLE llx_website pageviews_month BIGINT UNSIGNED DEFAULT 0, -- increased by 1 at each page access, saved into pageviews_previous_month when on different month than lastaccess pageviews_total BIGINT UNSIGNED DEFAULT 0, -- increased by 1 at each page access, no reset tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - import_key varchar(14) -- import key + import_key varchar(14), -- import key + name_template varchar(255) NULL --name of template imported ) ENGINE=innodb; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index aa9bb7328e9..52e1aff41e4 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1430,6 +1430,8 @@ DisableForgetPasswordLinkOnLogonPage=Do not show the "Password Forgotten" link o UsersSetup=Users module setup UserMailRequired=Email required to create a new user UserHideInactive=Hide inactive users from all combo lists of users (Not recommended: this may means you won't be able to filter or search on old users on some pages) +UserHideExternal=Hide external users (not linked to a third party) from all combo lists of users (Not recommended: this may means you won't be able to filter or search on external users on some pages) +UserHideNonEmployee=Hide non employee users from all combo lists of users (Not recommended: this may means you won't be able to filter or search on non employee users on some pages) UsersDocModules=Document templates for documents generated from user record GroupsDocModules=Document templates for documents generated from a group record ##### HRM setup ##### diff --git a/htdocs/langs/en_US/ai.lang b/htdocs/langs/en_US/ai.lang new file mode 100644 index 00000000000..5f685967132 --- /dev/null +++ b/htdocs/langs/en_US/ai.lang @@ -0,0 +1 @@ +AI_KEY_API_CHATGPT= Key for IA api \ No newline at end of file diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index e45de1d3553..6c14671a698 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -354,6 +354,7 @@ HelpAbandonOther=This amount has been abandoned since it was an error (wrong cus IdSocialContribution=Social/fiscal tax payment id PaymentId=Payment id PaymentRef=Payment ref. +SourceInvoiceId=Source invoice id InvoiceId=Invoice id InvoiceRef=Invoice ref. InvoiceDateCreation=Invoice creation date diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index 8a4d3783d64..5471c4afad0 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -103,3 +103,4 @@ WebsitePagesCategoriesArea=Page-Container Categories KnowledgemanagementsCategoriesArea=KM article Categories UseOrOperatorForCategories=Use 'OR' operator for categories AddObjectIntoCategory=Assign to the category +Position=Position diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 62cd3bca571..e16093e5a98 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -162,6 +162,7 @@ CalcModeVATDebt=Mode %sVAT on commitment accounting%s. CalcModeVATEngagement=Mode %sVAT on incomes-expenses%s. CalcModeDebt=Analysis of known recorded documents CalcModeEngagement=Analysis of known recorded payments +CalcModePayment=Analysis of known recorded payments CalcModeBookkeeping=Analysis of data journalized in Bookkeeping Ledger table. CalcModeNoBookKeeping=Even if they are not yet accounted in Ledger CalcModeLT1= Mode %sRE on customer invoices - suppliers invoices%s diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 3089eef2ae0..1fd9a75f1b3 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -184,3 +184,5 @@ EmailOptedOut=Email owner has requested to not contact him with this email anymo EvenUnsubscribe=Include opt-out emails EvenUnsubscribeDesc=Include opt-out emails when you select emails as targets. Useful for mandatory service emails for example. XEmailsDoneYActionsDone=%s emails pre-qualified, %s emails successfully processed (for %s record/actions done) +helpWithAi=Add instructions +YouCanMakeSomeInstructionForEmail=You Can Make Some Instruction For your Email (Exemple: generate image in email template...) \ No newline at end of file diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 94a4878fb11..9a3cceab0ab 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -1429,6 +1429,8 @@ DisableForgetPasswordLinkOnLogonPage=Cacher le lien "Mot de passe oublié" sur l UsersSetup=Configuration du module utilisateurs UserMailRequired=Email requis pour créer un nouvel utilisateur UserHideInactive=Masquer les utilisateurs inactifs sur toutes les listes déroulantes d'utilisateurs (non recommandé: cela peut signifier que vous ne pourrez pas filtrer ou rechercher les anciens utilisateurs sur certaines pages) +UserHideExternal=Masquer les utilisateurs externes (non liés à un tiers) sur toutes les listes déroulantes d'utilisateurs (non recommandé: cela peut signifier que vous ne pourrez pas filtrer ou rechercher les utilisateurs externes sur certaines pages) +UserHideNonEmployee=Masquer les utilisateurs externes (non salariés) sur toutes les listes déroulantes d'utilisateurs (non recommandé: cela peut signifier que vous ne pourrez pas filtrer ou rechercher les utilisateurs non salariés sur certaines pages) UsersDocModules=Modèles de documents pour les documents générés à partir de la fiche utilisateur GroupsDocModules=Modèles de documents pour les documents générés à partir de la fiche d'un groupe ##### HRM setup ##### diff --git a/htdocs/langs/fr_FR/ai.lang b/htdocs/langs/fr_FR/ai.lang new file mode 100644 index 00000000000..f6eb575e977 --- /dev/null +++ b/htdocs/langs/fr_FR/ai.lang @@ -0,0 +1 @@ +AI_KEY_API_CHATGPT= Clé pour l'api IA \ No newline at end of file diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 1fe210bd0a6..7316fb92d46 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -537,7 +537,7 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && getDolGlobalInt( // Array of action code where CSRFCHECK with token will be forced (so token must be provided on url request) $sensitiveget = false; if ((GETPOSTISSET('massaction') || GETPOST('action', 'aZ09')) && getDolGlobalInt('MAIN_SECURITY_CSRF_WITH_TOKEN') >= 3) { - // All GET actions (except the listed exception) and mass actions are processed as sensitive. + // All GET actions (except the listed exception that are post actions) and mass actions are processed as sensitive. if (GETPOSTISSET('massaction') || !in_array(GETPOST('action', 'aZ09'), array('create', 'createsite', 'createcard', 'edit', 'editvalidator', 'file_manager', 'presend', 'presend_addmessage', 'preview', 'specimen'))) { // We exclude some action that are legitimate $sensitiveget = true; } @@ -2202,7 +2202,7 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead } } else { foreach ($value as $value2) { - if ($value2 !== '') { + if (($value2 !== '') && (!is_array($value2))) { $qs .= '&'.$key.'[]='.urlencode($value2); } } diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index 25a086f58cd..42c8d9874ba 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -66,13 +66,16 @@ class MyModuleApi extends DolibarrApi * * @url GET myobjects/{id} * - * @throws RestException 401 Not allowed + * @throws RestException 403 Not allowed * @throws RestException 404 Not found */ public function get($id) { if (!DolibarrApiAccess::$user->rights->mymodule->myobject->read) { - throw new RestException(401); + throw new RestException(403); + } + if (!DolibarrApi::_checkAccessToResource('myobject', $id, 'mymodule_myobject')) { + throw new RestException(403, 'Access to instance id='.$this->myobject->id.' of object not allowed for login '.DolibarrApiAccess::$user->login); } $result = $this->myobject->fetch($id); @@ -80,10 +83,6 @@ class MyModuleApi extends DolibarrApi throw new RestException(404, 'MyObject not found'); } - if (!DolibarrApi::_checkAccessToResource('myobject', $this->myobject->id, 'mymodule_myobject')) { - throw new RestException(401, 'Access to instance id='.$this->myobject->id.' of object not allowed for login '.DolibarrApiAccess::$user->login); - } - return $this->_cleanObjectDatas($this->myobject); } @@ -101,7 +100,8 @@ class MyModuleApi extends DolibarrApi * @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names * @return array Array of order objects * - * @throws RestException + * @throws RestException 403 Not allowed + * @throws RestException 503 System error * * @url GET /myobjects/ */ @@ -111,7 +111,7 @@ class MyModuleApi extends DolibarrApi $tmpobject = new MyObject($this->db); if (!DolibarrApiAccess::$user->rights->mymodule->myobject->read) { - throw new RestException(401); + throw new RestException(403); } $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : 0; @@ -186,16 +186,17 @@ class MyModuleApi extends DolibarrApi * Create myobject object * * @param array $request_data Request datas - * @return int ID of myobject + * @return int ID of myobject * - * @throws RestException + * @throws RestException 403 Not allowed + * @throws RestException 500 System error * * @url POST myobjects/ */ public function post($request_data = null) { if (!DolibarrApiAccess::$user->rights->mymodule->myobject->write) { - throw new RestException(401); + throw new RestException(403); } // Check mandatory fields @@ -227,14 +228,19 @@ class MyModuleApi extends DolibarrApi * @param array $request_data Datas * @return int * - * @throws RestException + * @throws RestException 403 Not allowed + * @throws RestException 404 Not found + * @throws RestException 500 System error * * @url PUT myobjects/{id} */ public function put($id, $request_data = null) { if (!DolibarrApiAccess::$user->rights->mymodule->myobject->write) { - throw new RestException(401); + throw new RestException(403); + } + if (!DolibarrApi::_checkAccessToResource('myobject', $id, 'mymodule_myobject')) { + throw new RestException(403, 'Access to instance id='.$this->myobject->id.' of object not allowed for login '.DolibarrApiAccess::$user->login); } $result = $this->myobject->fetch($id); @@ -242,10 +248,6 @@ class MyModuleApi extends DolibarrApi throw new RestException(404, 'MyObject not found'); } - if (!DolibarrApi::_checkAccessToResource('myobject', $this->myobject->id, 'mymodule_myobject')) { - throw new RestException(401, 'Access to instance id='.$this->myobject->id.' of object not allowed for login '.DolibarrApiAccess::$user->login); - } - foreach ($request_data as $field => $value) { if ($field == 'id') { continue; @@ -275,24 +277,27 @@ class MyModuleApi extends DolibarrApi * @param int $id MyObject ID * @return array * - * @throws RestException + * @throws RestException 403 Not allowed + * @throws RestException 404 Not found + * @throws RestException 409 Nothing to do + * @throws RestException 500 System error * * @url DELETE myobjects/{id} */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->mymodule->myobject->delete) { - throw new RestException(401); + if (!DolibarrApiAccess::$user->hasRight('mymodule', 'myobject', 'delete')) { + throw new RestException(403); } + if (!DolibarrApi::_checkAccessToResource('myobject', $id, 'mymodule_myobject')) { + throw new RestException(403, 'Access to instance id='.$this->myobject->id.' of object not allowed for login '.DolibarrApiAccess::$user->login); + } + $result = $this->myobject->fetch($id); if (!$result) { throw new RestException(404, 'MyObject not found'); } - if (!DolibarrApi::_checkAccessToResource('myobject', $this->myobject->id, 'mymodule_myobject')) { - throw new RestException(401, 'Access to instance id='.$this->myobject->id.' of object not allowed for login '.DolibarrApiAccess::$user->login); - } - if ($this->myobject->delete(DolibarrApiAccess::$user) == 0) { throw new RestException(409, 'Error when deleting MyObject : '.$this->myobject->error); } elseif ($this->myobject->delete(DolibarrApiAccess::$user) < 0) { @@ -348,40 +353,6 @@ class MyModuleApi extends DolibarrApi unset($object->rowid); unset($object->canvas); - /*unset($object->name); - unset($object->lastname); - unset($object->firstname); - unset($object->civility_id); - unset($object->statut); - unset($object->state); - unset($object->state_id); - unset($object->state_code); - unset($object->region); - unset($object->region_code); - unset($object->country); - unset($object->country_id); - unset($object->country_code); - unset($object->barcode_type); - unset($object->barcode_type_code); - unset($object->barcode_type_label); - unset($object->barcode_type_coder); - unset($object->total_ht); - unset($object->total_tva); - unset($object->total_localtax1); - unset($object->total_localtax2); - unset($object->total_ttc); - unset($object->fk_account); - unset($object->comments); - unset($object->note); - unset($object->mode_reglement_id); - unset($object->cond_reglement_id); - unset($object->cond_reglement); - unset($object->shipping_method_id); - unset($object->fk_incoterms); - unset($object->label_incoterms); - unset($object->location_incoterms); - */ - // If object has lines, remove $db property if (isset($object->lines) && is_array($object->lines) && count($object->lines) > 0) { $nboflines = count($object->lines); diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index f0a3c8f3887..e50d22b3a69 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -432,17 +432,20 @@ class MyObject extends CommonObject /** - * Load list of objects in memory from the database. Using a fetchAll is a bad practice, instead try to forge you optimized and limited SQL request. + * Load list of objects in memory from the database. + * Using a fetchAll() with limit = 0 is a very bad practice. Instead try to forge yourself an optimized SQL request with + * your own loop with start and stop pagination. * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit limit - * @param int $offset Offset - * @param array $filter Filter array. Example array('mystringfield'=>'value', 'myintfield'=>4, 'customsql'=>...) - * @param string $filtermode Filter mode (AND or OR) - * @return array|int int <0 if KO, array of pages if OK + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit Limit the number of lines returned + * @param int $offset Offset + * @param string $filter Filter as an Universal Search string. + * Example: '((client:=:1) OR ((client:>=:2) AND (client:<=:3))) AND (client:!=:8) AND (nom:like:'a%')' + * @param string $filtermode Filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK */ - public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + public function fetchAll($sortorder = '', $sortfield = '', $limit = 1000, $offset = 0, string $filter = '', $filtermode = 'AND') { dol_syslog(__METHOD__, LOG_DEBUG); @@ -452,7 +455,7 @@ class MyObject extends CommonObject $sql .= $this->getFieldList('t'); $sql .= " FROM ".$this->db->prefix().$this->table_element." as t"; if (isset($this->isextrafieldmanaged) && $this->isextrafieldmanaged == 1) { - $sql .= " LEFT JOIN ".$this->db->prefix().$this->table_element."_extrafields as te ON tf.fk_object = t.rowid"; + $sql .= " LEFT JOIN ".$this->db->prefix().$this->table_element."_extrafields as te ON te.fk_object = t.rowid"; } if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { $sql .= " WHERE t.entity IN (".getEntity($this->element).")"; @@ -460,12 +463,14 @@ class MyObject extends CommonObject $sql .= " WHERE 1 = 1"; } // Manage filter + /* We keep this part of code that is still used by a lot of old class. The 'else" shows how to switch to Universal Search filters $sqlwhere = array(); - if (count($filter) > 0) { + if (is_array($filter) && count($filter) > 0) { + dol_syslog("Warning: Use of an array as filter is now forbidden and deprecated. Use an universal SQL filter string instead", LOG_WARNING); foreach ($filter as $key => $value) { $columnName = preg_replace('/^t\./', '', $key); if ($key === 'customsql') { - // Never use 'customsql' with a value from user input since it is injected as is. The value must be hard coded. + // Never use 'customsql' with a value from a user input since it is injected as is. The value must be hard coded. $sqlwhere[] = $value; continue; } elseif (isset($this->fields[$columnName])) { @@ -501,10 +506,19 @@ class MyObject extends CommonObject } } } + } else { */ + $errormessage = ''; + $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage); + if ($errormessage) { + $this->errors[] = $errormessage; + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + + return -1; } + /*} if (count($sqlwhere) > 0) { $sql .= " AND (".implode(" ".$filtermode." ", $sqlwhere).")"; - } + }*/ if (!empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); diff --git a/htdocs/modulebuilder/template/sql/llx_mymodule_myobject_extrafields.key.sql b/htdocs/modulebuilder/template/sql/llx_mymodule_myobject_extrafields.key.sql index 4c005e9d170..462a114674d 100644 --- a/htdocs/modulebuilder/template/sql/llx_mymodule_myobject_extrafields.key.sql +++ b/htdocs/modulebuilder/template/sql/llx_mymodule_myobject_extrafields.key.sql @@ -15,5 +15,5 @@ -- BEGIN MODULEBUILDER INDEXES -ALTER TABLE llx_mymodule_myobject_extrafields ADD INDEX idx_myobject_fk_object(fk_object); +ALTER TABLE llx_mymodule_myobject_extrafields ADD UNIQUE INDEX uk_myobject_fk_object(fk_object); -- END MODULEBUILDER INDEXES diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 7cbdcef0abc..23b996fcca0 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -204,7 +204,7 @@ if (empty($reshook)) { $moline->fk_default_workstation = $tmpproduct->fk_default_workstation; } $moline->disable_stock_change = ($tmpproduct->type == Product::TYPE_SERVICE ? 1 : 0); - if ($conf->global->PRODUCT_USE_UNITS) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $moline->fk_unit = $tmpproduct->fk_unit; } } @@ -840,7 +840,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Qty print ''.$langs->trans("Qty").''; // Unit - if ($conf->global->PRODUCT_USE_UNITS) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print '' . $langs->trans("Unit") . ''; } // Cost price @@ -911,7 +911,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; // Qty print ''; - if ($conf->global->PRODUCT_USE_UNITS) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print ''; } // Cost price @@ -1029,7 +1029,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; // Unit - if ($conf->global->PRODUCT_USE_UNITS) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print ''; print measuringUnitString($line->fk_unit, '', '', 1); print ''; @@ -1107,7 +1107,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print price2num($line->qty, 'MS'); print ''; // Unit - if ($conf->global->PRODUCT_USE_UNITS) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print ''; print measuringUnitString($line->fk_unit, '', '', 1); print ''; @@ -1323,7 +1323,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; // Unit - if ($conf->global->PRODUCT_USE_UNITS) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print ''; } @@ -1449,7 +1449,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Qty print ''.$langs->trans("Qty").''; /// Unit - if ($conf->global->PRODUCT_USE_UNITS) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print ''.$langs->trans("Unit").''; } // Cost price @@ -1502,7 +1502,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Qty print ''; //Unit - if ($conf->global->PRODUCT_USE_UNITS) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print ''; } // Cost price @@ -1569,7 +1569,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Qty print ''.$line->qty.''; // Unit - if ($conf->global->PRODUCT_USE_UNITS) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print ''.measuringUnitString($line->fk_unit, '', '', 1).''; } // Cost price @@ -1668,7 +1668,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Qty print ''; // Unit - if ($conf->global->PRODUCT_USE_UNITS) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print ''; } // Cost price @@ -1721,7 +1721,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Qty print ''; //Unit - if ($conf->global->PRODUCT_USE_UNITS) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print ''; } // Cost diff --git a/htdocs/product/admin/inventory_extrafields.php b/htdocs/product/admin/inventory_extrafields.php index 45c17e805d0..f28ca9af020 100644 --- a/htdocs/product/admin/inventory_extrafields.php +++ b/htdocs/product/admin/inventory_extrafields.php @@ -27,33 +27,9 @@ */ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; - $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../../main.inc.php'; + +global $conf, $langs, $user; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php'; @@ -94,7 +70,7 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; $textobject = $langs->transnoentitiesnoconv("Inventory"); -llxHeader('', $langs->trans("InventorySetup"), $help_url); +llxHeader('', $langs->trans("InventorySetup")); $linkback = ''.$langs->trans("BackToModuleList").''; diff --git a/htdocs/product/admin/stock_mouvement_extrafields.php b/htdocs/product/admin/stock_mouvement_extrafields.php index 82fe4de72b9..6ce64991f5d 100644 --- a/htdocs/product/admin/stock_mouvement_extrafields.php +++ b/htdocs/product/admin/stock_mouvement_extrafields.php @@ -27,34 +27,7 @@ */ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; - $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} - +require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php'; @@ -94,7 +67,7 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; $textobject = $langs->transnoentitiesnoconv("StockMovement"); -llxHeader('', $langs->trans("StockSetup"), $help_url); +llxHeader('', $langs->trans("StockSetup")); $linkback = ''.$langs->trans("BackToModuleList").''; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 99279e0b173..da2837c3aa5 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3889,8 +3889,8 @@ class Product extends CommonObject } if (empty($year)) { - $year = strftime('%Y', time()); - $month = strftime('%m', time()); + $year = dol_print_date(time(), '%Y'); + $month = dol_print_date(time(), '%m'); } elseif ($year == -1) { $year = ''; $month = 12; // We imagine we are at end of year, so we get last 12 month before, so all correct year. @@ -6123,15 +6123,13 @@ class Product extends CommonObject $this->imgHeight = $infoImg[1]; // Hauteur de l'image } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators this->nb for the dashboard * * @return int Return integer <0 if KO, >0 if OK */ - public function load_state_board() + public function loadStateBoard() { - // phpcs:enable global $hookmanager; $this->nb = array(); diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php index 254d0a8fe3c..cac5d5c05ee 100644 --- a/htdocs/product/class/productbatch.class.php +++ b/htdocs/product/class/productbatch.class.php @@ -477,14 +477,13 @@ class Productbatch extends CommonObject } if (getDolGlobalString('SHIPPING_DISPLAY_STOCK_ENTRY_DATE')) { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock AS ps ON (ps.rowid = fk_product_stock)'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'stock_mouvement AS sm ON (sm.batch = t.batch AND ps.fk_entrepot=sm.fk_entrepot)'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'stock_mouvement AS sm ON (sm.batch = t.batch AND ps.fk_entrepot=sm.fk_entrepot AND sm.type_mouvement IN (0,3))'; } $sql .= " WHERE fk_product_stock=".((int) $fk_product_stock); if ($with_qty) { $sql .= " AND t.qty <> 0"; } if (getDolGlobalString('SHIPPING_DISPLAY_STOCK_ENTRY_DATE')) { - $sql .= ' AND sm.type_mouvement IN (0,3)'; $sql .= ' GROUP BY t.rowid, t.tms, t.fk_product_stock,t.sellby,t.eatby , t.batch,t.qty,t.import_key'; if ($fk_product > 0) { $sql .= ', pl.rowid, pl.eatby, pl.sellby'; diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index 0416064f466..11c3dc31649 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -1146,8 +1146,8 @@ if ($resql) { $productidselected = $key; $productlabelselected = $val; } - $datebefore = dol_get_first_day($year ? $year : strftime("%Y", time()), $month ? $month : 1, true); - $dateafter = dol_get_last_day($year ? $year : strftime("%Y", time()), $month ? $month : 12, true); + $datebefore = dol_get_first_day($year ? $year : dol_print_date(time(), "%Y"), $month ? $month : 1, true); + $dateafter = dol_get_last_day($year ? $year : dol_print_date(time(), "%Y"), $month ? $month : 12, true); $balancebefore = $movement->calculateBalanceForProductBefore($productidselected, $datebefore); $balanceafter = $movement->calculateBalanceForProductBefore($productidselected, $dateafter); diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 9a447d213db..d8cb47f17fe 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -1641,8 +1641,8 @@ if (count($arrayofuniqueproduct) == 1 && !empty($year) && is_numeric($year)) { $productidselected = $key; $productlabelselected = $val; } - $datebefore = dol_get_first_day($year ? $year : strftime("%Y", time()), $month ? $month : 1, true); - $dateafter = dol_get_last_day($year ? $year : strftime("%Y", time()), $month ? $month : 12, true); + $datebefore = dol_get_first_day($year ? $year : dol_print_date(time(), "%Y"), $month ? $month : 1, true); + $dateafter = dol_get_last_day($year ? $year : dol_print_date(time(), "%Y"), $month ? $month : 12, true); $balancebefore = $movement->calculateBalanceForProductBefore($productidselected, $datebefore); $balanceafter = $movement->calculateBalanceForProductBefore($productidselected, $dateafter); diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index cb8b0192977..690d1f68e01 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -67,7 +67,7 @@ $cancel = GETPOST('cancel', 'alpha'); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$stocklimit = GETPOST('seuil_stock_alerte'); +$stocklimit = (float) GETPOST('seuil_stock_alerte'); $desiredstock = GETPOST('desiredstock'); $cancel = GETPOST('cancel', 'alpha'); $fieldid = isset($_GET["ref"]) ? 'ref' : 'rowid'; @@ -153,7 +153,7 @@ if ($reshook < 0) { if ($action == 'setcost_price') { if ($id) { $result = $object->fetch($id); - $object->cost_price = price2num($cost_price); + $object->cost_price = (float) price2num($cost_price); $result = $object->update($object->id, $user); if ($result > 0) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); @@ -190,7 +190,7 @@ if ($action == 'addlimitstockwarehouse' && $user->hasRight('produit', 'creer')) } } else { // Create - $pse->fk_entrepot = GETPOST('fk_entrepot', 'int'); + $pse->fk_entrepot = GETPOSTINT('fk_entrepot'); $pse->fk_product = $id; $pse->seuil_stock_alerte = GETPOST('seuil_stock_alerte'); $pse->desiredstock = GETPOST('desiredstock'); diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_card.php b/htdocs/product/stock/stocktransfer/stocktransfer_card.php index 1def7644d9d..48c2ae2ebf5 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_card.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_card.php @@ -773,7 +773,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print getTitleFieldOfList($langs->trans('WarehouseSource'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'tagtd maxwidthonsmartphone '); print getTitleFieldOfList($langs->trans('WarehouseTarget'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'tagtd maxwidthonsmartphone '); print getTitleFieldOfList($langs->trans('Qty'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'center tagtd maxwidthonsmartphone '); - if ($conf->global->PRODUCT_USE_UNITS) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print getTitleFieldOfList($langs->trans('Unit'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'tagtd maxwidthonsmartphone '); } print getTitleFieldOfList($langs->trans('AverageUnitPricePMPShort'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'center tagtd maxwidthonsmartphone '); @@ -846,7 +846,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''.$line->qty.''; } - if ($conf->global->PRODUCT_USE_UNITS) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print ''; $label = $productstatic->getLabelOfUnit('short'); if ($label !== '') { @@ -968,7 +968,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; // PMP print ''; - if ($conf->global->PRODUCT_USE_UNITS) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { // Unité print ''; } diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php index 8be73099cac..6d7f9656d73 100644 --- a/htdocs/projet/activity/index.php +++ b/htdocs/projet/activity/index.php @@ -327,7 +327,7 @@ if (getDolGlobalString('PROJECT_TASK_TIME_YEAR')) { print '
'; print '
'; print ''; - print ''; + print ''; print ''; print "\n"; @@ -340,7 +340,7 @@ if (getDolGlobalString('PROJECT_TASK_TIME_YEAR')) { $sql .= " AND tt.fk_element = t.rowid"; $sql .= " AND tt.elementtype = 'task'"; $sql .= " AND tt.fk_user = ".((int) $user->id); - $sql .= " AND YEAR(element_date) = '".strftime("%Y", $now)."'"; + $sql .= " AND YEAR(element_date) = '".dol_print_date($now, "%Y")."'"; $sql .= " AND p.rowid in (".$db->sanitize($projectsListId).")"; $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public"; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index f79bb10a1b9..90a7d140341 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -849,9 +849,9 @@ class Project extends CommonObject $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$tablename." WHERE ".$projectkey." IN (".$this->db->sanitize($ids).") AND entity IN (".getEntity($type).")"; } - if ($date_start > 0 && $type == 'loan') { + if (isDolTms($date_start) && $type == 'loan') { $sql .= " AND (dateend > '".$this->db->idate($date_start)."' OR dateend IS NULL)"; - } elseif ($date_start > 0 && ($type != 'project_task')) { // For table project_taks, we want the filter on date apply on project_time_spent table + } elseif (isDolTms($date_start) && ($type != 'project_task')) { // For table project_taks, we want the filter on date apply on project_time_spent table if (empty($datefieldname) && !empty($this->table_element_date)) { $datefieldname = $this->table_element_date; } @@ -861,9 +861,9 @@ class Project extends CommonObject $sql .= " AND (".$datefieldname." >= '".$this->db->idate($date_start)."' OR ".$datefieldname." IS NULL)"; } - if ($date_end > 0 && $type == 'loan') { + if (isDolTms($date_end) && $type == 'loan') { $sql .= " AND (datestart < '".$this->db->idate($date_end)."' OR datestart IS NULL)"; - } elseif ($date_end > 0 && ($type != 'project_task')) { // For table project_taks, we want the filter on date apply on project_time_spent table + } elseif (isDolTms($date_end) && ($type != 'project_task')) { // For table project_taks, we want the filter on date apply on project_time_spent table if (empty($datefieldname) && !empty($this->table_element_date)) { $datefieldname = $this->table_element_date; } @@ -2293,15 +2293,13 @@ class Project extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators this->nb for the state board * * @return int Return integer <0 if KO, >0 if OK */ - public function load_state_board() + public function loadStateBoard() { - // phpcs:enable global $user; $this->nb = array(); diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index c3cbe241739..64ce3e64cfc 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -2337,15 +2337,13 @@ class Task extends CommonObjectLine } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators this->nb for state board * * @return int Return integer <0 if ko, >0 if ok */ - public function load_state_board() + public function loadStateBoard() { - // phpcs:enable global $user; $mine = 0; diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index dc15eb7165b..1c2b7af3f9b 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -173,6 +173,9 @@ if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a ded } $arrayfields['author'] = array('label' => $langs->trans("By"), 'checked' => 1); $arrayfields['t.note'] = array('label' => $langs->trans("Note"), 'checked' => 1); +if (!getDolGlobalInt('PROJECT_HIDE_TASKS') && getDolGlobalInt('PROJECT_BILL_TIME_SPENT') && !$projectstatic->usage_bill_time ) { + $projectstatic->usage_bill_time=1; +} if (isModEnabled('service') && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) { $arrayfields['t.fk_product'] = array('label' => $langs->trans("Product"), 'checked' => 1); } @@ -2282,7 +2285,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $userstatic->lastname = $task_time->lastname; $userstatic->firstname = $task_time->firstname; $userstatic->photo = $task_time->photo; - $userstatic->statut = $task_time->user_status; + $userstatic->status = $task_time->user_status; print $userstatic->getNomUrl(-1); } print ''; @@ -2564,7 +2567,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $userstatic->lastname = $task_time->lastname; $userstatic->firstname = $task_time->firstname; $userstatic->photo = $task_time->photo; - $userstatic->statut = $task_time->user_status; + $userstatic->status = $task_time->user_status; print $userstatic->getNomUrl(-1); } print ''; @@ -2720,7 +2723,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $userstatic->lastname = $task_time->lastname; $userstatic->firstname = $task_time->firstname; $userstatic->photo = $task_time->photo; - $userstatic->statut = $task_time->user_status; + $userstatic->status = $task_time->user_status; print $userstatic->getNomUrl(-1); } print ''; diff --git a/htdocs/public/opensurvey/studs.php b/htdocs/public/opensurvey/studs.php index 3a0ae62c2a9..9e1c34076bc 100644 --- a/htdocs/public/opensurvey/studs.php +++ b/htdocs/public/opensurvey/studs.php @@ -342,15 +342,17 @@ print ''; print '
'; if (empty($object->description)) { - print '
'."\n"; + print '
'."\n"; +} else { + print '
'."\n"; } // show title of survey $titre = str_replace("\\", "", $object->title); -print '
'.img_picto('', 'poll', 'class="size15x paddingright"').' '.dol_htmlentities($titre).'
'; +print '
'.img_picto('', 'poll', 'class="size15x paddingright"').' '.dol_htmlentities($titre).'
'; if (!empty($object->description)) { - print '
'."\n"; + print '
'."\n"; } // show description of survey diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 0621eac22a2..dbbe83affc2 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -265,16 +265,16 @@ if ((empty($paymentmethod) || $paymentmethod == 'paypal') && isModEnabled('paypa $PAYPAL_API_KO = $urlko; } if (empty($PAYPAL_API_USER)) { - dol_print_error('', "Paypal setup param PAYPAL_API_USER not defined"); - return -1; + print 'Paypal parameter PAYPAL_API_USER is not defined. Please complete the setup of module PayPal first.'; + exit; } if (empty($PAYPAL_API_PASSWORD)) { - dol_print_error('', "Paypal setup param PAYPAL_API_PASSWORD not defined"); - return -1; + print 'Paypal parameter PAYPAL_API_PASSWORD is not defined. Please complete the setup of module PayPal first.'; + exit; } if (empty($PAYPAL_API_SIGNATURE)) { - dol_print_error('', "Paypal setup param PAYPAL_API_SIGNATURE not defined"); - return -1; + print 'Paypal parameter PAYPAL_API_SIGNATURE is not defined. Please complete the setup of module PayPal first.'; + exit; } } if ((empty($paymentmethod) || $paymentmethod == 'paybox') && isModEnabled('paybox')) { diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index e6ca0ded986..0aaae6bdcee 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -565,6 +565,18 @@ if ($ispaymentok) { if ($paymentmethod == 'stripe') { $accountid = getDolGlobalString('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS'); } + + //Get bank account for a specific paymentmedthod + $parameters = [ + 'paymentmethod' => $paymentmethod, + ]; + $reshook = $hookmanager->executeHooks('getBankAccountPaymentMethod', $parameters, $object, $action); + if ($reshook >= 0) { + if (isset($hookmanager->resArray['bankaccountid'])) { + dol_syslog('accountid overwrite by hook return with value='.$hookmanager->resArray['bankaccountid'], LOG_DEBUG, 0, '_payment'); + $accountid = $hookmanager->resArray['bankaccountid']; + } + } if ($accountid < 0) { $error++; $errmsg = 'Setup of bank account to use for payment is not correctly done for payment method '.$paymentmethod; @@ -903,6 +915,17 @@ if ($ispaymentok) { $bankaccountid = getDolGlobalString('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS'); } + //Get bank account for a specific paymentmedthod + $parameters = [ + 'paymentmethod' => $paymentmethod, + ]; + $reshook = $hookmanager->executeHooks('getBankAccountPaymentMethod', $parameters, $object, $action); + if ($reshook >= 0) { + if (isset($hookmanager->resArray['bankaccountid'])) { + dol_syslog('bankaccountid overwrite by hook return with value='.$hookmanager->resArray['bankaccountid'], LOG_DEBUG, 0, '_payment'); + $bankaccountid = $hookmanager->resArray['bankaccountid']; + } + } if ($bankaccountid > 0) { $label = '(CustomerInvoicePayment)'; if ($object->type == Facture::TYPE_CREDIT_NOTE) { @@ -1020,6 +1043,17 @@ if ($ispaymentok) { $bankaccountid = getDolGlobalString('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS'); } + //Get bank account for a specific paymentmedthod + $parameters = [ + 'paymentmethod' => $paymentmethod, + ]; + $reshook = $hookmanager->executeHooks('getBankAccountPaymentMethod', $parameters, $object, $action); + if ($reshook >= 0) { + if (isset($hookmanager->resArray['bankaccountid'])) { + dol_syslog('bankaccountid overwrite by hook return with value='.$hookmanager->resArray['bankaccountid'], LOG_DEBUG, 0, '_payment'); + $bankaccountid = $hookmanager->resArray['bankaccountid']; + } + } if ($bankaccountid > 0) { $label = '(CustomerInvoicePayment)'; if ($object->type == Facture::TYPE_CREDIT_NOTE) { @@ -1146,6 +1180,17 @@ if ($ispaymentok) { $bankaccountid = getDolGlobalString('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS'); } + //Get bank account for a specific paymentmedthod + $parameters = [ + 'paymentmethod' => $paymentmethod, + ]; + $reshook = $hookmanager->executeHooks('getBankAccountPaymentMethod', $parameters, $object, $action); + if ($reshook >= 0) { + if (isset($hookmanager->resArray['bankaccountid'])) { + dol_syslog('bankaccountid overwrite by hook return with value='.$hookmanager->resArray['bankaccountid'], LOG_DEBUG, 0, '_payment'); + $bankaccountid = $hookmanager->resArray['bankaccountid']; + } + } if ($bankaccountid > 0) { $label = '(DonationPayment)'; $result = $paiement->addPaymentToBank($user, 'payment_donation', $label, $bankaccountid, '', ''); @@ -1265,6 +1310,17 @@ if ($ispaymentok) { $bankaccountid = getDolGlobalString('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS'); } + //Get bank account for a specific paymentmedthod + $parameters = [ + 'paymentmethod' => $paymentmethod, + ]; + $reshook = $hookmanager->executeHooks('getBankAccountPaymentMethod', $parameters, $object, $action); + if ($reshook >= 0) { + if (isset($hookmanager->resArray['bankaccountid'])) { + dol_syslog('bankaccountid overwrite by hook return with value='.$hookmanager->resArray['bankaccountid'], LOG_DEBUG, 0, '_payment'); + $bankaccountid = $hookmanager->resArray['bankaccountid']; + } + } if ($bankaccountid > 0) { $label = '(CustomerInvoicePayment)'; if ($object->type == Facture::TYPE_CREDIT_NOTE) { @@ -1484,6 +1540,17 @@ if ($ispaymentok) { $bankaccountid = getDolGlobalString('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS'); } + //Get bank account for a specific paymentmedthod + $parameters = [ + 'paymentmethod' => $paymentmethod, + ]; + $reshook = $hookmanager->executeHooks('getBankAccountPaymentMethod', $parameters, $object, $action); + if ($reshook >= 0) { + if (isset($hookmanager->resArray['bankaccountid'])) { + dol_syslog('bankaccountid overwrite by hook return with value='.$hookmanager->resArray['bankaccountid'], LOG_DEBUG, 0, '_payment'); + $bankaccountid = $hookmanager->resArray['bankaccountid']; + } + } if ($bankaccountid > 0) { $label = '(CustomerInvoicePayment)'; if ($object->type == Facture::TYPE_CREDIT_NOTE) { @@ -1684,6 +1751,17 @@ if ($ispaymentok) { $bankaccountid = getDolGlobalString('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS'); } + //Get bank account for a specific paymentmedthod + $parameters = [ + 'paymentmethod' => $paymentmethod, + ]; + $reshook = $hookmanager->executeHooks('getBankAccountPaymentMethod', $parameters, $object, $action); + if ($reshook >= 0) { + if (isset($hookmanager->resArray['bankaccountid'])) { + dol_syslog('bankaccountid overwrite by hook return with value='.$hookmanager->resArray['bankaccountid'], LOG_DEBUG, 0, '_payment'); + $bankaccountid = $hookmanager->resArray['bankaccountid']; + } + } if ($bankaccountid > 0) { $label = '(CustomerInvoicePayment)'; if ($object->type == Facture::TYPE_CREDIT_NOTE) { diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 96835b53dc5..3d6d597db21 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -733,6 +733,7 @@ if (empty($reshook)) { $triggersendname = 'RECEPTION_SENTBYMAIL'; $paramname = 'id'; $mode = 'emailfromreception'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_RECEPTION_TO'; $trackid = 'rec'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; } diff --git a/htdocs/reception/dispatch.php b/htdocs/reception/dispatch.php index 1e9170f0235..e9984004bc4 100644 --- a/htdocs/reception/dispatch.php +++ b/htdocs/reception/dispatch.php @@ -193,7 +193,7 @@ if ($action == 'updatelines' && $permissiontoreceive) { } else { $qtystart = $supplierorderdispatch->qty; $supplierorderdispatch->qty = GETPOST($qty); - $supplierorderdispatch->fk_entrepot = GETPOST($ent, 'int'); + $supplierorderdispatch->fk_entrepot = GETPOSTINT($ent); if ($modebatch == "batch") { $supplierorderdispatch->eatby = $dDLUO; $supplierorderdispatch->sellby = $dDLC; diff --git a/htdocs/recruitment/admin/setup_candidatures.php b/htdocs/recruitment/admin/setup_candidatures.php index 487f39dad84..c8ca0c09a42 100644 --- a/htdocs/recruitment/admin/setup_candidatures.php +++ b/htdocs/recruitment/admin/setup_candidatures.php @@ -22,35 +22,9 @@ */ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; - $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../../main.inc.php'; -global $langs, $user; +global $conf, $langs, $user; // Libraries require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 3783f0de394..f3ad06e06ed 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 William Mead * * 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 @@ -39,10 +40,14 @@ $id = GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); $ref = GETPOST('ref', 'alpha'); +$address = GETPOST('address', 'alpha'); +$zip = GETPOST('zipcode', 'alpha'); +$town = GETPOST('town', 'alpha'); $description = GETPOST('description', 'restricthtml'); $confirm = GETPOST('confirm', 'aZ09'); -$fk_code_type_resource = GETPOST('fk_code_type_resource', 'alpha'); -$country_id = GETPOST('country_id', 'int'); +$fk_code_type_resource = GETPOSTINT('fk_code_type_resource'); +$country_id = GETPOSTINT('country_id'); +$state_id = GETPOSTINT('state_id'); // Protection if external user if ($user->socid > 0) { @@ -98,9 +103,13 @@ if (empty($reshook)) { $action = 'create'; } else { $object->ref = $ref; + $object->address = $address; + $object->zip = $zip; + $object->town = $town; $object->description = $description; $object->fk_code_type_resource = $fk_code_type_resource; $object->country_id = $country_id; + $object->state_id = $state_id; // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); @@ -138,9 +147,13 @@ if (empty($reshook)) { $res = $object->fetch($id); if ($res > 0) { $object->ref = $ref; + $object->address = $address; + $object->zip = $zip; + $object->town = $town; $object->description = $description; $object->fk_code_type_resource = $fk_code_type_resource; $object->country_id = $country_id; + $object->state_id = $state_id; // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); @@ -222,6 +235,51 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) { print '
'; print ''; + // Address + print ''; + print ''; + + // Zip / Town + print 'browser->layout == 'phone' ? ' colspan="3"': '').'>'; + print $formresource->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 0, '', 'maxwidth100'); + print ''; + if ($conf->browser->layout == 'phone') { + print ''; + } + print 'browser->layout == 'phone' ? ' colspan="3"': '').'>'; + print $formresource->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); + print $form->widgetForTranslation("town", $object, $permissiontoadd, 'string', 'alphanohtml', 'maxwidth100 quatrevingtpercent'); + print ''; + + // Origin country + print ''; + + // State + if (empty($conf->global->SOCIETE_DISABLE_STATE)) { + if ((getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 1 || getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 2)) { + print ''; + } + // Type print ''; print ''; - // Origin country - print ''; - // Other attributes $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -276,12 +326,7 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) { $linkback = ''.$langs->trans("BackToList").''; - - $morehtmlref = '
'; - $morehtmlref .= '
'; - - - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref'); print '
'; diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index ccebbb2f12c..29b00cf4262 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 William Mead * * 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 @@ -23,12 +24,14 @@ require_once DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"; require_once DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php"; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonpeople.class.php'; /** * DAO Resource object */ class Dolresource extends CommonObject { + use CommonPeople; /** * @var string ID to identify managed object */ @@ -44,6 +47,20 @@ class Dolresource extends CommonObject */ public $picto = 'resource'; + /** + * @var string address variables + */ + public $address; + + /** + * @var string zip of town + */ + public $zip; + + /** + * @var string yown + */ + public $town; /** * @var int ID @@ -57,8 +74,15 @@ class Dolresource extends CommonObject */ public $description; + /** + * @var int ID country + */ public $fk_country; + /** + * @var int ID state + */ + public $fk_state; // Variable for a link of resource @@ -77,7 +101,7 @@ class Dolresource extends CommonObject * @var int ID */ public $fk_user_create; - public $tms = ''; + public $tms; /** * Used by fetch_element_resource() to return an object @@ -87,7 +111,7 @@ class Dolresource extends CommonObject /** * @var array Cache of type of resources. TODO Use $conf->cache['type_of_resources'] instead */ - public $cache_code_type_resource = array(); + public $cache_code_type_resource; /** * @var Dolresource Clone of object before changing it @@ -100,67 +124,60 @@ class Dolresource extends CommonObject * * @param DoliDB $db Database handler */ - public function __construct($db) + public function __construct(DoliDb $db) { $this->db = $db; + $this->tms = ''; + $this->cache_code_type_resource = array(); } /** - * Create object into database + * Create object in database * - * @param User $user User that creates - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int Return integer <0 if KO, Id of created object if OK + * @param User $user User that creates + * @param int $no_trigger 0=launch triggers after, 1=disable triggers + * @return int Return integer if KO: <0, if OK: Id of created object */ - public function create($user, $notrigger = 0) + public function create(User $user, int $no_trigger = 0): int { - global $conf, $langs, $hookmanager; $error = 0; // Clean parameters - - if (isset($this->ref)) { - $this->ref = trim($this->ref); + $new_resource_values = [$this->ref, $this->address, $this->zip, $this->town, $this->description, $this->country_id, $this->state_id, $this->fk_code_type_resource, $this->note_public, $this->note_private]; + foreach ($new_resource_values as $key => $value) { + if (isset($value)) { + $new_resource_values[$key] = trim($value); + } } - if (isset($this->description)) { - $this->description = trim($this->description); - } - if (!is_numeric($this->country_id)) { - $this->country_id = 0; - } - if (isset($this->fk_code_type_resource)) { - $this->fk_code_type_resource = trim($this->fk_code_type_resource); - } - if (isset($this->note_public)) { - $this->note_public = trim($this->note_public); - } - if (isset($this->note_private)) { - $this->note_private = trim($this->note_private); - } - // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."("; $sql .= "entity,"; $sql .= "ref,"; + $sql .= "address,"; + $sql .= "zip,"; + $sql .= "town,"; $sql .= "description,"; $sql .= "fk_country,"; + $sql .= "fk_state,"; $sql .= "fk_code_type_resource,"; $sql .= "note_public,"; $sql .= "note_private"; $sql .= ") VALUES ("; - $sql .= $conf->entity.", "; - $sql .= " ".(!isset($this->ref) ? 'NULL' : "'".$this->db->escape($this->ref)."'").","; - $sql .= " ".(!isset($this->description) ? 'NULL' : "'".$this->db->escape($this->description)."'").","; - $sql .= " ".($this->country_id > 0 ? $this->country_id : 'null').","; - $sql .= " ".(!isset($this->fk_code_type_resource) ? 'NULL' : "'".$this->db->escape($this->fk_code_type_resource)."'").","; - $sql .= " ".(!isset($this->note_public) ? 'NULL' : "'".$this->db->escape($this->note_public)."'").","; - $sql .= " ".(!isset($this->note_private) ? 'NULL' : "'".$this->db->escape($this->note_private)."'"); + $sql .= getEntity('resource') . ", "; + foreach ($new_resource_values as $value) { + $sql .= " " . ((isset($value) && $value > 0) ? "'" . $this->db->escape($value) . "'" : 'NULL') . ","; + } + $sql = rtrim($sql, ","); $sql .= ")"; + // Database session $this->db->begin(); - - dol_syslog(get_class($this)."::create", LOG_DEBUG); + try { + dol_syslog(get_class($this) . "::create", LOG_DEBUG); + } catch (Exception $exception) { + error_log('dol_syslog error: ' . $exception->getMessage()); + } $resql = $this->db->query($sql); if (!$resql) { $error++; @@ -169,37 +186,31 @@ class Dolresource extends CommonObject if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); - } - - if (!$error) { - $action = 'create'; - - // Actions on extra fields - if (!$error) { - $result = $this->insertExtraFields(); - if ($result < 0) { - $error++; - } + $result = $this->insertExtraFields(); + if ($result < 0) { + $error=-1; } } - if (!$error && !$notrigger) { - // Call trigger + if (!$error && !$no_trigger) { $result = $this->call_trigger('RESOURCE_CREATE', $user); if ($result < 0) { - $error++; + $error=-1; } - // End call triggers } // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + try { + dol_syslog(get_class($this) . "::create " . $errmsg, LOG_ERR); + } catch (Exception $exception) { + error_log('dol_syslog error: ' . $exception->getMessage()); + } $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1 * $error; + return $error; } else { $this->db->commit(); return $this->id; @@ -207,11 +218,11 @@ class Dolresource extends CommonObject } /** - * Load object in memory from database + * Load object into memory from database * - * @param int $id Id of object - * @param string $ref Ref of object - * @return int Return integer <0 if KO, >0 if OK + * @param int $id Id of object + * @param string $ref Ref of object + * @return int Return integer if KO: <0 , if OK: >0 */ public function fetch($id, $ref = '') { @@ -220,8 +231,12 @@ class Dolresource extends CommonObject $sql .= " t.rowid,"; $sql .= " t.entity,"; $sql .= " t.ref,"; + $sql .= " t.address,"; + $sql .= " t.zip,"; + $sql .= " t.town,"; $sql .= " t.description,"; $sql .= " t.fk_country,"; + $sql .= " t.fk_state,"; $sql .= " t.fk_code_type_resource,"; $sql .= " t.note_public,"; $sql .= " t.note_private,"; @@ -244,8 +259,12 @@ class Dolresource extends CommonObject $this->id = $obj->rowid; $this->entity = $obj->entity; $this->ref = $obj->ref; + $this->address = $obj->address; + $this->zip = $obj->zip; + $this->town = $obj->town; $this->description = $obj->description; $this->country_id = $obj->fk_country; + $this->state_id = $obj->fk_state; $this->fk_code_type_resource = $obj->fk_code_type_resource; $this->note_public = $obj->note_public; $this->note_private = $obj->note_private; @@ -267,11 +286,11 @@ class Dolresource extends CommonObject /** - * Update object into database + * Update object in database * - * @param User $user User that modifies - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int Return integer <0 if KO, >0 if OK + * @param User $user User that modifies + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int Return integer if KO: <0 , if OK: >0 */ public function update($user = null, $notrigger = 0) { @@ -282,6 +301,15 @@ class Dolresource extends CommonObject if (isset($this->ref)) { $this->ref = trim($this->ref); } + if (isset($this->address)) { + $this->address = trim($this->address); + } + if (isset($this->zip)) { + $this->zip = trim($this->zip); + } + if (isset($this->town)) { + $this->town = trim($this->town); + } if (isset($this->fk_code_type_resource)) { $this->fk_code_type_resource = trim($this->fk_code_type_resource); } @@ -291,6 +319,9 @@ class Dolresource extends CommonObject if (!is_numeric($this->country_id)) { $this->country_id = 0; } + if (!is_numeric($this->state_id)) { + $this->state_id = 0; + } // $this->oldcopy should have been set by the caller of update (here properties were already modified) if (empty($this->oldcopy)) { @@ -300,8 +331,12 @@ class Dolresource extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET"; $sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "null").","; + $sql .= " address=".(isset($this->address) ? "'".$this->db->escape($this->address)."'" : "null").","; + $sql .= " zip=".(isset($this->zip) ? "'".$this->db->escape($this->zip)."'" : "null").","; + $sql .= " town=".(isset($this->town) ? "'".$this->db->escape($this->town)."'" : "null").","; $sql .= " description=".(isset($this->description) ? "'".$this->db->escape($this->description)."'" : "null").","; $sql .= " fk_country=".($this->country_id > 0 ? $this->country_id : "null").","; + $sql .= " fk_state=".($this->state_id > 0 ? $this->state_id : "null").","; $sql .= " fk_code_type_resource=".(isset($this->fk_code_type_resource) ? "'".$this->db->escape($this->fk_code_type_resource)."'" : "null").","; $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null'); $sql .= " WHERE rowid=".((int) $this->id); @@ -368,16 +403,14 @@ class Dolresource extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Load data of resource links in memory from database + * Load data of resource links into memory from database * - * @param int $id Id of link element_resources - * @return int Return integer <0 if KO, >0 if OK + * @param int $id Id of link element_resources + * @return int Return integer if KO: <0, if OK: >0 */ - public function fetch_element_resource($id) + public function fetchElementResource($id) { - // phpcs:enable $sql = "SELECT"; $sql .= " t.rowid,"; $sql .= " t.resource_id,"; @@ -423,11 +456,11 @@ class Dolresource extends CommonObject } /** - * Delete a resource object + * Delete a resource object * - * @param int $rowid Id of resource line to delete - * @param int $notrigger Disable all triggers - * @return int >0 if OK, <0 if KO + * @param int $rowid Id of resource line to delete + * @param int $notrigger Disable all triggers + * @return int Return integer if OK: >0, if KO: <0 */ public function delete($rowid, $notrigger = 0) { @@ -498,20 +531,18 @@ class Dolresource extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Load resource objects into $this->lines + * Load resource objects into $this->lines * - * @param string $sortorder sort order - * @param string $sortfield sort field - * @param int $limit limit page - * @param int $offset page - * @param array $filter filter output - * @return int Return integer <0 if KO, Number of lines loaded if OK + * @param string $sortorder sort order + * @param string $sortfield sort field + * @param int $limit limit page + * @param int $offset page + * @param array $filter filter output + * @return int Return integer if KO: <0, if OK number of lines loaded */ public function fetchAll($sortorder, $sortfield, $limit, $offset, $filter = []) { - // phpcs:enable require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); @@ -519,8 +550,12 @@ class Dolresource extends CommonObject $sql .= " t.rowid,"; $sql .= " t.entity,"; $sql .= " t.ref,"; + $sql .= " t.address,"; + $sql .= " t.zip,"; + $sql .= " t.town,"; $sql .= " t.description,"; $sql .= " t.fk_country,"; + $sql .= " t.fk_state,"; $sql .= " t.fk_code_type_resource,"; $sql .= " t.tms,"; // Add fields from extrafields @@ -562,8 +597,12 @@ class Dolresource extends CommonObject $line = new Dolresource($this->db); $line->id = $obj->rowid; $line->ref = $obj->ref; + $line->address = $obj->address; + $line->zip = $obj->zip; + $line->town = $obj->town; $line->description = $obj->description; $line->country_id = $obj->fk_country; + $line->state_id = $obj->fk_state; $line->fk_code_type_resource = $obj->fk_code_type_resource; $line->type_label = $obj->type_label; @@ -582,17 +621,15 @@ class Dolresource extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Update element resource into database + * Update element resource in database * - * @param User $user User that modifies - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int Return integer <0 if KO, >0 if OK + * @param User $user User that modifies + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int Return integer if KO: <0, if OK: >0 */ - public function update_element_resource($user = null, $notrigger = 0) + public function updateElementResource($user = null, $notrigger = 0) { - // phpcs:enable global $conf, $langs; $error = 0; @@ -711,9 +748,9 @@ class Dolresource extends CommonObject /** * Return an int number of resources linked to the element * - * @param string $element Element type - * @param int $element_id Element id - * @return int Nb of resources loaded + * @param string $element Element type + * @param int $element_id Element id + * @return int Nb of resources loaded */ public function fetchElementResources($element, $element_id) { @@ -726,16 +763,13 @@ class Dolresource extends CommonObject return $i; } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Load in cache resource type code (setup in dictionary) + * Load in cache resource type code (setup in dictionary) * - * @return int Number of lines loaded, 0 if already loaded, <0 if KO + * @return int Number of lines loaded, if already loaded: 0, if KO: <0 */ - public function load_cache_code_type_resource() + public function loadCacheCodeTypeResource() { - // phpcs:enable global $langs; if (is_array($this->cache_code_type_resource) && count($this->cache_code_type_resource)) { @@ -770,9 +804,9 @@ class Dolresource extends CommonObject /** * getTooltipContentArray * - * @param array $params ex option, infologin - * @since v18 - * @return array + * @param array $params ex option, infologin + * @since v18 + * @return array */ public function getTooltipContentArray($params) { @@ -795,7 +829,7 @@ class Dolresource extends CommonObject } /** - * Return clicable link of object (with eventually picto) + * Return clickable link of object (with optional picto) * * @param int $withpicto Add picto into link * @param string $option Where point the link ('compta', 'expedition', 'document', ...) @@ -878,39 +912,35 @@ class Dolresource extends CommonObject /** - * Return the label of the status + * Get status label * - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label of status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function getLibStatut($mode = 0) { - return $this->LibStatut($this->status, $mode); + return $this->getLibStatusLabel($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Return the status + * Get status * - * @param int $status Id status - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto - * @return string Label of status + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto + * @return string Label of status */ - public static function LibStatut($status, $mode = 0) + public static function getLibStatusLabel($status, $mode = 0) { - // phpcs:enable return ''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators this->nb for state board * - * @return int Return integer <0 if KO, >0 if OK + * @return int Return integer if KO: <0, if OK: >0 */ - public function load_state_board() + public function loadStateBoard() { - // phpcs:enable $this->nb = array(); $sql = "SELECT count(r.rowid) as nb"; diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index 03941f84573..888e3aa91c7 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -2,6 +2,7 @@ /* Copyright (C) - 2013-2015 Jean-François FERRY * Copyright (C) 2019 Frédéric France * Copyright (C) 2022 Ferran Marcet + * Copyright (C) 2023 William Mead * * 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 @@ -65,21 +66,21 @@ class FormResource /** * Output html form to select a resource * - * @param int $selected Preselected resource id - * @param string $htmlname Name of field in form - * @param string $filter Optional filters criteras (example: 's.rowid <> x') + * @param int $selected Preselected resource id + * @param string $htmlname Name of field in form + * @param array $filter Optional filters criteria (example: 's.rowid <> x') * @param int $showempty Add an empty field - * @param int $showtype Show third party type in combolist (customer, prospect or supplier) + * @param int $showtype Show third party type in combo list (customer, prospect or supplier) * @param int $forcecombo Force to use combo box * @param array $event Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) - * @param string $filterkey Filter on key value + * @param array $filterkey Filter on key value * @param int $outputmode 0=HTML select string, 1=Array, 2=without form tag * @param int $limit Limit number of answers * @param string $morecss More css - * @param bool $multiple add [] in the name of element and add 'multiple' attribute + * @param bool $multiple add [] in the name of element and add 'multiple' attribute * @return string|array HTML string with */ - public function select_resource_list($selected = '', $htmlname = 'fk_resource', $filter = '', $showempty = 0, $showtype = 0, $forcecombo = 0, $event = array(), $filterkey = '', $outputmode = 0, $limit = 20, $morecss = '', $multiple = false) + public function select_resource_list($selected = 0, $htmlname = 'fk_resource', $filter = [], $showempty = 0, $showtype = 0, $forcecombo = 0, $event = array(), $filterkey = '', $outputmode = 0, $limit = 20, $morecss = '', $multiple = false) { // phpcs:enable global $conf, $user, $langs; @@ -190,7 +191,7 @@ class FormResource $filterarray = explode(',', $filtertype); } - $resourcestat->load_cache_code_type_resource(); + $resourcestat->loadCacheCodeTypeResource(); print '' . "\n"; + + return $out; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Returns the drop-down list of departments/provinces/cantons for all countries or for a given country. + * In the case of an all-country list, the display breaks on the country. + * The key of the list is the code (there can be several entries for a given code but in this case, the country field differs). + * Thus the links with the departments are done on a department independently of its name. + * + * @param int $selected Code state preselected (mus be state id) + * @param integer $country_codeid Country code or id: 0=list for all countries, otherwise country code or country rowid to show + * @param string $htmlname Id of department. If '', we want only the string with
'; print dol_get_fiche_end(); +$objUser = $object; +$objcon = new stdClass(); + +$out = ''; +$permok = $user->hasRight('agenda', 'myactions', 'create'); +if ((!empty($objUser->id) || !empty($objcon->id)) && $permok) { + if (is_object($objUser) && get_class($objUser) == 'User') { + $out .= '&originid='.$objUser->id.($objUser->id > 0 ? '&userid='.$objUser->id : '').'&backtopage='.urlencode($_SERVER['PHP_SELF'].($objUser->id > 0 ? '?userid='.$objUser->id : '')); + } + $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : ''); + $out .= '&datep='.dol_print_date(dol_now(), 'dayhourlog', 'tzuserrel'); +} + +$morehtmlright = ''; + +$messagingUrl = DOL_URL_ROOT.'/societe/messaging.php?userid='.$object->id; +$morehtmlright .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 1); +$messagingUrl = DOL_URL_ROOT.'/user/info.php?id='.$object->id; +$morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 2); + +if (isModEnabled('agenda')) { + if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) { + $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out); + } +} + +if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allaactions', 'read'))) { + print '
'; + $param = '&id='.urlencode($id); + + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.((int) $limit); + } + + + // Try to know count of actioncomm from cache + require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; + $cachekey = 'count_events_user_'.$object->id; + $nbEvent = dol_getcache($cachekey); + + $titlelist = $langs->trans("ActionsOnCompany").(is_numeric($nbEvent) ? '('.$nbEvent.')' : ''); + if (!empty($conf->dol_optimize_smallscreen)) { + $titlelist = $langs->trans("Actions").(is_numeric($nbEvent) ? '('.$nbEvent.')' : ''); + } + + print_barre_liste($titlelist, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 0); + + // List of all actions + $filters = array(); + $filters['search_agenda_label'] = $search_agenda_label; + $filters['search_rowid'] = $search_rowid; + + // TODO Replace this with same code than into list.php + show_actions_done_user($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module); +} + // End of page llxFooter(); $db->close(); diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index e3e11b96f6f..1ebbd5652a5 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -175,8 +175,8 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST( $sanit_features[$explode[0]] = $explode[1]; $tmp = new ProductCombination2ValuePair($db); - $tmp->fk_prod_attr = $explode[0]; - $tmp->fk_prod_attr_val = $explode[1]; + $tmp->fk_prod_attr = (int) $explode[0]; + $tmp->fk_prod_attr_val = (int) $explode[1]; $productCombination2ValuePairs1[] = $tmp; } @@ -277,19 +277,19 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST( exit(); } - $prodcomb->variation_weight = price2num($weight_impact); + $prodcomb->variation_weight = (float) price2num($weight_impact); // for conf PRODUIT_MULTIPRICES if (getDolGlobalString('PRODUIT_MULTIPRICES')) { $level_price_impact = array_map('price2num', $level_price_impact); - $prodcomb->variation_price = $level_price_impact[1]; + $prodcomb->variation_price = (float) $level_price_impact[1]; $prodcomb->variation_price_percentage = (bool) $level_price_impact_percent[1]; } else { $level_price_impact = array(1 => $price_impact); $level_price_impact_percent = array(1 => $price_impact_percent); - $prodcomb->variation_price = $price_impact; + $prodcomb->variation_price = (float) $price_impact; $prodcomb->variation_price_percentage = $price_impact_percent; } @@ -299,7 +299,7 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST( $productCombinationLevel = new ProductCombinationLevel($db); $productCombinationLevel->fk_product_attribute_combination = $prodcomb->id; $productCombinationLevel->fk_price_level = $i; - $productCombinationLevel->variation_price = $level_price_impact[$i]; + $productCombinationLevel->variation_price = (float) $level_price_impact[$i]; $productCombinationLevel->variation_price_percentage = (bool) $level_price_impact_percent[$i]; $prodcomb->combination_price_levels[$i] = $productCombinationLevel; } diff --git a/htdocs/webhook/class/target.class.php b/htdocs/webhook/class/target.class.php index 0ee668af87f..9ae8dc6ee45 100644 --- a/htdocs/webhook/class/target.class.php +++ b/htdocs/webhook/class/target.class.php @@ -223,7 +223,7 @@ class Target extends CommonObject public function create(User $user, $notrigger = 0) { $resultcreate = $this->createCommon($user, $notrigger); - $this->ref = $this->id; + $this->ref = (string) $this->id; if ($resultcreate <= 0) { return $resultcreate; @@ -341,7 +341,7 @@ class Target extends CommonObject { $result = $this->fetchCommon($id, $ref); if (empty($this->ref)) { - $this->ref = $this->id; + $this->ref = (string) $this->id; } return $result; diff --git a/phpstan.neon b/phpstan.neon index cc4562d57b2..103812c4ed2 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,9 +1,9 @@ parameters: tmpDir: ./.github/tmp parallel: - jobSize: 20 + jobSize: 8 processTimeout: 600.0 - maximumNumberOfProcesses: 8 + maximumNumberOfProcesses: 20 minimumNumberOfJobsPerProcess: 2 buffer: 134217728 # 128 MB customRulesetUsed: true diff --git a/pyproject.toml b/pyproject.toml index 810261cad54..8f8cc6f74b1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,13 +3,26 @@ requires = ["setuptools>=61.2"] build-backend = "setuptools.build_meta" [tool.codespell] +# The configuration must be kept here to ensure that +# `codespell` can be run as a standalone program from the CLI +# with the appropriate default options. + skip = "*/langs/*,*/build/exe/*,**.log,*.pdf,*dev/resources/*,*.phar,*.z,*.gz,*.sql,*htdocs/includes/*,*/textiso.txt,*.js,*README-*,*build/rpm/*spec,*build/pad/*ml,*htdocs/includes/phpoffice/*,*htdocs/includes/tecnickcom/*,*dev/initdemo/removeconfdemo.sh,*dev/tools/codespell/*,*pyproject.toml,*build/exe/*,*fontawe*,*htdocs/theme/*/flags-sprite.inc.php,*dev/setup/codetemplates/codetemplates.xml,*/php.ini,*/html_cerfafr.*,*/lessc.class.php,*.asciidoc,*.xml,*opensurvey/css/style.css" quiet-level=2 ignore-regex = '\\[fnrstv]' builtin = "clear,rare,informal,usage,code,names" -#D = "-" -#dictionary = "dev/tools/codespell/codespell-dict.txt" + +ignore-words = "dev/tools/codespell/codespell-ignore.txt" +exclude-file = "dev/tools/codespell/codespell-lines-ignore.txt" +uri-ignore-words-list="ned" + +# For future reference: it is not currently possible to specify +# the standard dictionnary and the custom dictionnary in the configuration +# file +# D = "-" +# dictionary = "dev/tools/codespell/codespell-dict.txt" + [tool.setuptools] include-package-data = false
'.$langs->trans("ActivityOnProjectThisYear").': '.strftime("%Y", $now).''.$langs->trans("ActivityOnProjectThisYear").': '.dol_print_date($now, "%Y").''.$langs->trans("Time").'
'.$langs->trans("ResourceFormLabel_ref").'
'.$form->editfieldkey('Address', 'address', '', $object, 0).''; + print $form->widgetForTranslation("address", $object, $permissiontoadd, 'textarea', 'alphanohtml', 'quatrevingtpercent'); + print '
'.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).'
'.$form->editfieldkey('Town', 'town', '', $object, 0).'
'.$langs->trans("CountryOrigin").''; + print $form->select_country($object->country_id, 'country_id'); + if ($user->admin) { + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + } + print '
'.$form->editfieldkey('Region-State', 'state_id', '', $object, 0).''; + } else { + print '
'.$form->editfieldkey('State', 'state_id', '', $object, 0).''; + } + + if ($object->country_id) { + print img_picto('', 'state', 'class="pictofixedwidth"'); + print $formresource->select_state($object->state_id, $object->country_code); + } else { + print $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; + } + print '
'.$langs->trans("ResourceType").''; @@ -236,14 +294,6 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) { $doleditor->Create(); print '
'.$langs->trans("CountryOrigin").''; - print $form->select_country($object->country_id, 'country_id'); - if ($user->admin) { - print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - } - print '