diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 5e5c4fc0cb5..e96c5ef4ba0 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -14,6 +14,17 @@ jobs: - name: Install required tools run: sudo apt-get update && sudo apt-get install cppcheck if: false + + # The next uses the git API because there is no clone yet. + # This is faster for a big repo. + - name: Get all changed php files (if PR) + id: changed-php + uses: tj-actions/changed-files@v42 + if: github.event_name == 'pull_request' + with: + files: | + **.php + # Checkout git sources to analyze - uses: actions/checkout@v4 # Action setup-python needs a requirements.txt or pyproject.toml @@ -42,6 +53,24 @@ jobs: set -o pipefail pre-commit gc pre-commit run --show-diff-on-failure --color=always --all-files | tee ${RAW_LOG} + + # The next uses git, which is slow for a bit repo. + # - name: Get all changed php files (if PR) + # id: changed-php + # uses: tj-actions/changed-files@v42 + # if: github.event_name == 'pull_request' + # with: + # files: | + # **.php + + - name: Run some pre-commit hooks on selected changed files only + if: steps.changed-php.outputs.any_changed == 'true' + env: + ALL_CHANGED_FILES: ${{ steps.changed-php.outputs.all_changed_files }} + run: | + set -o pipefail + pre-commit run php-cs ${ALL_CHANGED_FILES} | tee -a ${RAW_LOG} + # If error, we convert log in the checkstyle format - name: Convert Raw Log to CheckStyle format if: ${{ failure() }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 49d115a2355..81159f37bed 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ exclude: (?x)^( htdocs/includes/ckeditor/.* ) repos: # Several miscellaneous checks and fix (on yaml files, end of files fix) - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: no-commit-to-branch args: [--branch, develop, --pattern, \d+.0] @@ -87,7 +87,7 @@ repos: # Check format of yaml files - repo: https://github.com/adrienverge/yamllint.git - rev: v1.32.0 + rev: v1.33.0 hooks: - id: yamllint args: @@ -97,7 +97,7 @@ repos: # Execute codespell to fix typo errors (setup of codespell into dev/tools/codespell/) - repo: https://github.com/codespell-project/codespell - rev: v2.2.5 + rev: v2.2.6 hooks: - id: codespell # Due to a current limitation of configuration files, @@ -142,7 +142,7 @@ repos: # Check some shell scripts - repo: https://github.com/shellcheck-py/shellcheck-py - rev: v0.9.0.5 + rev: v0.9.0.6 hooks: - id: shellcheck args: [-W, '100'] diff --git a/ChangeLog b/ChangeLog index 4de2b1fc745..9b9664a1cf6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -28,7 +28,6 @@ The following changes may create regressions for some external modules, but were For users: ---------- NEW: Compatibility with PHP 8.2 -NEW: Module for Advanced stock transfer is now stable (#26594) NEW: Module Workstation (used to enhance the module BOM and Manufacturing Order) is now stable NEW: Add a confirmation popup when deleting extrafields NEW: Add type 'icon' type for extrafields @@ -188,10 +187,15 @@ NEW: updating for display Help title when try to delete Don (issue #25314) NEW: Upgrade in module builder in menu section NEW: use account address in sepa mandate (#23642) NEW: VAT rate - Add entity +<<<<<<< HEAD NEW: webportal site account NEW: When an user unset the batch management of products, transformation of each batch stock movement in global stock movement FIX: #25828 wrong odt style naming +======= +NEW: When an user unset the batch management of products, transformation of each batch stock mouvement in global stock mouvement +NEW: PDF Generation for each Human Resource Evaluations. +>>>>>>> branch '19.0' of git@github.com:Dolibarr/dolibarr.git SEC: #25512 applicative anti bruteforce - security on too many login attempts (#25520) SEC: Add action confirm_... as sensitive to need a CSRF token @@ -264,6 +268,8 @@ WARNING: -------- The following changes may create regressions for some external modules, but were necessary to make Dolibarr better: +* Recheck the setup of your module Workflow to see if you need to enable the new setting to have shipment set to billed automatically when + an invoice from a shipment is validated (and if your process is to make invoice on shipment and not on order), because this setup has changed. * The hook changeHelpURL is replaced by llxHeader * The property ->brouillon has been removed from all classes. It was not reliable and was a duplicate of ->status == self::STATUS_DRAFT. * The duplicated and deprecated property ->date_livraison that was renamed into ->delivery_date has been completely removed. @@ -272,19 +278,18 @@ The following changes may create regressions for some external modules, but were * The property ->user_creation to store ID of user of creation has been renamed into ->user_creation_id. * The property ->user_modification to store ID of user of modification has been renamed into ->user_modification_id. * The private array ->status_short, ->statuts and ->status_long are now array ->labelStatusShort and ->labelStatus everywhere. -* The duplicate property ->user_creat, ->date_creat, ->date_valid has been removed (use instead user_creation, date_creation, date_validation). +* The duplicate property ->user_creat, ->date_creat, ->date_valid have been removed (use instead user_creation, date_creation, date_validation). * The method get_substitutionarray_shipment_lines() has been removed. Use the generic get_substitutionarray_lines() instead. * The method ProductcustomerPrice->fetch_all_log() has been renamed into camel case ->fetchAllLog() -* Recheck the setup of your module Workflow to see if you need to enable the new setting to have shipment set to billed automatically when - an invoice from a shipment is validated (and if your process is to make invoice on shipment and not on order), because this setup has changed. * It was possible to use a variable $soc or $right inside a PHP code condition of some extrafields properties, this is no more true (this 2 variables are no more global variables). * New hook files of modules actions_mymodule.class.php should now "extends CommonHookActions" * Endpoint for API /partnershipapi and /recruitment has been renamed into /partnerships and /recruitments to follow name conventions. -* Hidden option ACCOUNTANCY_AUTOFIX_MISSING_LINK_TO_USEr_ON_SALARY_BANK_PAYMENT has been renamed into ACCOUNTANCY_AUTOFIX_MISSING_LINK_TO_USER_ON_SALARY_BANK_PAYMENT +* Hidden option ACCOUNTANCY_AUTOFIX_MISSING_LINK_TO_USER_ON_SALARY_BANK_PAYMENT has been renamed into ACCOUNTANCY_AUTOFIX_MISSING_LINK_TO_USER_ON_SALARY_BANK_PAYMENT * The delete() method of AdherentType, Contact, Delivery, MultiCurrency, CurrencyRate now need $user as first parameter. * A very high number of class properties (with old name in french) are now deprecated in favor of the property name in english. * The load of hook context productdao has been removed before calling loadvirtualstock. Modules must use the context of main parent page or 'all' for all cases. + ***** ChangeLog for 18.0.4 compared to 18.0.3 ***** FIX: $this->newref already exists and could have been modified by trigger but we still use a local variable for the filesystem-based renaming FIX: 16.0 only, backport fix for SQL error on global search product diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 6bcae9c5d48..b2aff1082f2 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -1595,17 +1595,17 @@ if ($action == 'create') { print ''; print ''; - // Status of generated invoices + // Status of auto generated invoices print ''; if ($action == 'auto_validate' || $object->frequency > 0) { - print $form->editfieldkey($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->hasRight('facture', 'creer')); + print $form->editfieldkey($langs->trans("StatusOfAutoGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->hasRight('facture', 'creer')); } else { - print $langs->trans("StatusOfGeneratedInvoices"); + print $langs->trans("StatusOfAutoGeneratedInvoices"); } print ''; $select = 'select;0:'.$langs->trans('BillStatusDraft').',1:'.$langs->trans('BillStatusValidated'); if ($action == 'auto_validate' || $object->frequency > 0) { - print $form->editfieldval($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->hasRight('facture', 'creer'), $select); + print $form->editfieldval($langs->trans("StatusOfAutoGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->hasRight('facture', 'creer'), $select); } print ''; // Auto generate documents diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f204c535089..2261e8ee70d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7314,10 +7314,8 @@ abstract class CommonObject $out .= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0); } - $out .= ''; + if ((!isset($this->fields[$key]['default'])) || ($this->fields[$key]['notnull'] != 1) || $nbchoice >= 2) { + $out .= ''; + } + $out .= $tmpselect; $out .= ''; } elseif ($type == 'sellist') { $out = ''; @@ -7814,7 +7819,7 @@ abstract class CommonObject $form = new Form($this->db); } - $label = empty($val['label']) ? '' : $val['label']; + //$label = empty($val['label']) ? '' : $val['label']; $type = empty($val['type']) ? '' : $val['type']; $size = empty($val['css']) ? '' : $val['css']; $reg = array(); @@ -8217,7 +8222,8 @@ abstract class CommonObject $value = ''; } } elseif ($type == 'password') { - $value = preg_replace('/./i', '*', $value); + $value = ''.$langs->trans("Encrypted").''; + //$value = preg_replace('/./i', '*', $value); } elseif ($type == 'array') { $value = implode('
', $value); } else { // text|html|varchar diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 285e37edbf4..9592ed0a291 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -889,7 +889,7 @@ class FormMail extends Form //input prompt AI require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; - if (isModEnabled('ai') && getDolGlobalConst('AI_CHATGPT_API_KEY')) { + if (isModEnabled('ai') && getDolGlobalString('AI_CHATGPT_API_KEY')) { $out .= $this->getHtmlForInstruction(); } // Message diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index b0a7768d919..96cf95ceb6a 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -497,8 +497,8 @@ class Menubase $this->module = 'specimen'; $this->type = 'top'; $this->mainmenu = ''; - $this->fk_menu = '0'; - $this->position = ''; + $this->fk_menu = 0; + $this->position = 0; $this->url = 'http://dummy'; $this->target = ''; $this->title = 'Specimen menu'; @@ -506,8 +506,8 @@ class Menubase $this->leftmenu = ''; $this->perms = ''; $this->enabled = ''; - $this->user = ''; - $this->tms = ''; + $this->user = 0; + $this->tms = dol_now(); } diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 6ef05ecb79b..20849f92ec4 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -647,7 +647,7 @@ function dol_get_last_hour($date, $gm = 'tzserver') * @param int $date Date GMT * @param mixed $gm False or 0 or 'tzserver' = Return date to compare with server TZ, * 'gmt' to compare with GMT date. - * @return int Date for last hour of a given date + * @return int Date for first hour of a given date */ function dol_get_first_hour($date, $gm = 'tzserver') { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 6dabfe46290..cff1b5b85aa 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -966,6 +966,7 @@ function GETPOSTINT($paramname, $method = 0) * @param string $paramname Name of the $_GET or $_POST parameter * @param string|int $rounding Type of rounding ('', 'MU', 'MT, 'MS', 'CU', 'CT', integer) {@see price2num()} * @return float Value converted into float + * @since Dolibarr V20 */ function GETPOSTFLOAT($paramname, $rounding = '') { diff --git a/htdocs/core/lib/profid.lib.php b/htdocs/core/lib/profid.lib.php index f1f5d805a0f..4523c8ee2f6 100644 --- a/htdocs/core/lib/profid.lib.php +++ b/htdocs/core/lib/profid.lib.php @@ -155,7 +155,7 @@ function isValidTinForBE($str) $str = trim($str); $str = preg_replace('/(\s)/', '', $str); - if (preg_match('/(^[0-9]{4}\.[0-9]{3}\.[0-9]{3}$)/', $str)) { + if (preg_match('/(^[0-1]{1}[0-9]{3}\.[0-9]{3}\.[0-9]{3}$)/', $str)) { return true; } else { return false; diff --git a/htdocs/core/modules/modOpenSurvey.class.php b/htdocs/core/modules/modOpenSurvey.class.php index 6030f23cbd4..237e5086a30 100644 --- a/htdocs/core/modules/modOpenSurvey.class.php +++ b/htdocs/core/modules/modOpenSurvey.class.php @@ -38,8 +38,6 @@ class modOpenSurvey extends DolibarrModules */ public function __construct($db) { - global $langs, $conf; - $this->db = $db; // Id for module (must be unique). @@ -181,8 +179,6 @@ class modOpenSurvey extends DolibarrModules */ public function init($options = '') { - global $conf, $langs; - $result = $this->_load_tables('/install/mysql/', 'opensurvey'); 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') diff --git a/htdocs/core/modules/modTakePos.class.php b/htdocs/core/modules/modTakePos.class.php index 383996d4345..ed237feadf6 100644 --- a/htdocs/core/modules/modTakePos.class.php +++ b/htdocs/core/modules/modTakePos.class.php @@ -40,7 +40,7 @@ class modTakePos extends DolibarrModules */ public function __construct($db) { - global $langs, $conf; + global $conf; $this->db = $db; @@ -54,7 +54,7 @@ class modTakePos extends DolibarrModules // It is used to group modules by family in module setup page $this->family = "portal"; // Module position in the family on 2 digits ('01', '10', '20', ...) - $this->module_position = '60'; + $this->module_position = '45'; // Gives the possibility to 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"))); @@ -120,8 +120,8 @@ class modTakePos extends DolibarrModules //1=>array('TAKEPOS_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1) ); - - if (!isset($conf->takepos) || !isset($conf->takepos->enabled)) { + // To avoid warning + if (!isModEnabled('takepos')) { $conf->takepos = new stdClass(); $conf->takepos->enabled = 0; } diff --git a/htdocs/webportal/core/modules/modWebPortal.class.php b/htdocs/core/modules/modWebPortal.class.php similarity index 94% rename from htdocs/webportal/core/modules/modWebPortal.class.php rename to htdocs/core/modules/modWebPortal.class.php index dd088dcd2e8..6bd2885f31a 100644 --- a/htdocs/webportal/core/modules/modWebPortal.class.php +++ b/htdocs/core/modules/modWebPortal.class.php @@ -53,7 +53,7 @@ class modWebPortal extends DolibarrModules $this->family = "portal"; // Module position in the family on 2 digits ('01', '10', '20', ...) - $this->module_position = '80'; + $this->module_position = '47'; // 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"))); @@ -139,7 +139,7 @@ class modWebPortal extends DolibarrModules $this->conflictwith = array(); // The language file dedicated to your module - $this->langfiles = array("webportal@webportal"); + $this->langfiles = array("website"); // Prerequisites $this->phpmin = array(7, 0); // Minimum version of PHP required by module @@ -165,7 +165,8 @@ class modWebPortal extends DolibarrModules 'fr_FR:ParentCompany'=>'Maison mère ou revendeur' )*/ - if (!isset($conf->webportal) || !isset($conf->webportal->enabled)) { + // To avoid warnings + if (isModEnabled('webportal')) { $conf->webportal = new stdClass(); $conf->webportal->enabled = 0; } @@ -202,7 +203,7 @@ class modWebPortal extends DolibarrModules $this->dictionaries = array(); /* Example: $this->dictionaries=array( - 'langs'=>'webportal@webportal', + 'langs'=>'website', // List of tables we want to see into dictonnary editor 'tabname'=>array("table1", "table2", "table3"), // Label of tables @@ -287,7 +288,7 @@ class modWebPortal extends DolibarrModules 'mainmenu' => 'webportal', 'leftmenu' => '', 'url' => getDolGlobalString('WEBPORTAL_ROOT_URL', '/public/webportal/index.php'), - 'langs' => 'webportal@webportal', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'langs' => 'website', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position' => 1000 + $r, 'enabled' => 'isModEnabled("webportal")', // Define condition to show or hide menu entry. Use 'isModEnabled("webportal")' if entry must be visible if module is enabled. 'perms' => '1', // Use 'perms'=>'$user->hasRight("webportal", "webportalpropal", "read")' if you want your menu with a permission rules @@ -302,7 +303,7 @@ class modWebPortal extends DolibarrModules 'mainmenu'=>'webportal', 'leftmenu'=>'webportalpropal', 'url'=>'/webportal/webportalindex.php', - 'langs'=>'webportal@webportal', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'langs'=>'website', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>1000+$r, 'enabled'=>'isModEnabled("webportal")', // Define condition to show or hide menu entry. Use 'isModEnabled("webportal")' if entry must be visible if module is enabled. 'perms'=>'$user->hasRight("webportal", "webportalpropal", "read")', @@ -316,7 +317,7 @@ class modWebPortal extends DolibarrModules 'mainmenu'=>'webportal', 'leftmenu'=>'webportal_webportalpropal_list', 'url'=>'/webportal/webportalpropal_list.php', - 'langs'=>'webportal@webportal', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'langs'=>'website', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>1000+$r, 'enabled'=>'isModEnabled("webportal")', // Define condition to show or hide menu entry. Use 'isModEnabled("webportal")' if entry must be visible if module is enabled. 'perms'=>'$user->hasRight("webportal", "webportalpropal", "read")' @@ -330,7 +331,7 @@ class modWebPortal extends DolibarrModules 'mainmenu'=>'webportal', 'leftmenu'=>'webportal_webportalpropal_new', 'url'=>'/webportal/webportalpropal_card.php?action=create', - 'langs'=>'webportal@webportal', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'langs'=>'website', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>1000+$r, 'enabled'=>'isModEnabled("webportal")', // Define condition to show or hide menu entry. Use 'isModEnabled("webportal")' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 'perms'=>'$user->hasRight("webportal", "webportalpropal", "write")' @@ -349,7 +350,7 @@ class modWebPortal extends DolibarrModules */ public function init($options = '') { - global $conf, $langs; + //global $conf, $langs; //$result = $this->_load_tables('/install/mysql/', 'webportal'); $result = $this->_load_tables('/webportal/sql/'); @@ -360,11 +361,11 @@ class modWebPortal extends DolibarrModules // Create extrafields during init //include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; //$extrafields = new ExtraFields($this->db); - //$result1=$extrafields->addExtraField('webportal_myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'webportal@webportal', 'isModEnabled("webportal")'); - //$result2=$extrafields->addExtraField('webportal_myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'webportal@webportal', 'isModEnabled("webportal")'); - //$result3=$extrafields->addExtraField('webportal_myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'webportal@webportal', 'isModEnabled("webportal")'); - //$result4=$extrafields->addExtraField('webportal_myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'webportal@webportal', 'isModEnabled("webportal")'); - //$result5=$extrafields->addExtraField('webportal_myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'webportal@webportal', 'isModEnabled("webportal")'); + //$result1=$extrafields->addExtraField('webportal_myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'website', 'isModEnabled("webportal")'); + //$result2=$extrafields->addExtraField('webportal_myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'website', 'isModEnabled("webportal")'); + //$result3=$extrafields->addExtraField('webportal_myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'website', 'isModEnabled("webportal")'); + //$result4=$extrafields->addExtraField('webportal_myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'website', 'isModEnabled("webportal")'); + //$result5=$extrafields->addExtraField('webportal_myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'website', 'isModEnabled("webportal")'); // Permissions $this->remove($options); diff --git a/htdocs/core/modules/modWebsite.class.php b/htdocs/core/modules/modWebsite.class.php index 6a21435b489..a1a573553b3 100644 --- a/htdocs/core/modules/modWebsite.class.php +++ b/htdocs/core/modules/modWebsite.class.php @@ -37,8 +37,6 @@ class modWebsite extends DolibarrModules */ public function __construct($db) { - global $langs, $conf; - $this->db = $db; $this->numero = 10000; diff --git a/htdocs/cron/card.php b/htdocs/cron/card.php index 3a1298f271f..2e6e53aab5f 100644 --- a/htdocs/cron/card.php +++ b/htdocs/cron/card.php @@ -482,7 +482,7 @@ if (($action == "create") || ($action == "edit")) { } else { $input .= ' />'; } - $input .= ""; + $input .= ""; print $input; print ""; diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index ff917cc2634..3d7e31b3f26 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -184,6 +184,11 @@ class Cronjob extends CommonObject */ public $autodelete; + /** + * @var array Cronjob + */ + public $lines; + const STATUS_DISABLED = 0; const STATUS_ENABLED = 1; @@ -512,7 +517,6 @@ class Cronjob extends CommonObject /** * Load list of cron jobs in a memory array from the database - * @TODO Use object CronJob and not CronJobLine. * * @param string $sortorder sort order * @param string $sortfield sort field diff --git a/htdocs/datapolicy/class/actions_datapolicy.class.php b/htdocs/datapolicy/class/actions_datapolicy.class.php index 805cc537f38..b36608a32c6 100644 --- a/htdocs/datapolicy/class/actions_datapolicy.class.php +++ b/htdocs/datapolicy/class/actions_datapolicy.class.php @@ -115,9 +115,9 @@ class ActionsDatapolicy extends CommonHookActions $object->fax = ''; $object->state = ''; $object->country = ''; - $object->state_id = ''; + $object->state_id = 0; $object->socialnetworks = ''; - $object->country_id = ''; + $object->country_id = 0; $object->note_private = dol_concatdesc($object->note_private, $langs->trans('ANONYMISER_AT', dol_print_date(dol_now()))); if ($object->update($object->id, $user, 0)) { diff --git a/htdocs/delivery/card.php b/htdocs/delivery/card.php index 54e1cb1e07f..f87ac1bada3 100644 --- a/htdocs/delivery/card.php +++ b/htdocs/delivery/card.php @@ -102,7 +102,7 @@ if ($action == 'add') { $object->note = GETPOST("note", 'restricthtml'); $object->note_private = GETPOST("note", 'restricthtml'); $object->commande_id = GETPOST("commande_id", 'int'); - $object->fk_incoterms = GETPOST('incoterm_id', 'int'); + $object->fk_incoterms = GETPOSTINT('incoterm_id'); /* ->entrepot_id seems to not exists if (!getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION') && isModEnabled('stock')) { diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 44e5b207156..3b39c59d52c 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -185,19 +185,19 @@ if (empty($reshook)) { if (!$error) { $object->fetch($id); - $object->firstname = (string) GETPOST("firstname", 'alpha'); - $object->lastname = (string) GETPOST("lastname", 'alpha'); - $object->societe = (string) GETPOST("societe", 'alpha'); - $object->address = (string) GETPOST("address", 'alpha'); - $object->amount = price2num(GETPOST("amount", 'alpha'), '', 2); - $object->town = (string) GETPOST("town", 'alpha'); - $object->zip = (string) GETPOST("zipcode", 'alpha'); - $object->country_id = (int) GETPOST('country_id', 'int'); - $object->email = (string) GETPOST("email", 'alpha'); + $object->firstname = GETPOST("firstname", 'alpha'); + $object->lastname = GETPOST("lastname", 'alpha'); + $object->societe = GETPOST("societe", 'alpha'); + $object->address = GETPOST("address", 'alpha'); + $object->amount = GETPOSTFLOAT("amount"); + $object->town = GETPOST("town", 'alpha'); + $object->zip = GETPOST("zipcode", 'alpha'); + $object->country_id = GETPOSTINT('country_id'); + $object->email = GETPOST("email", 'alpha'); $object->date = $donation_date; $object->public = $public_donation; - $object->fk_project = (int) GETPOST("fk_project", 'int'); - $object->modepaymentid = (int) GETPOST('modepayment', 'int'); + $object->fk_project = GETPOSTINT("fk_project"); + $object->modepaymentid = GETPOSTINT('modepayment'); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); diff --git a/htdocs/fourn/facture/card-rec.php b/htdocs/fourn/facture/card-rec.php index b9c746af4fc..a29f1f9dfff 100644 --- a/htdocs/fourn/facture/card-rec.php +++ b/htdocs/fourn/facture/card-rec.php @@ -1053,14 +1053,14 @@ if ($action == 'create') { print ""; // Auto validate the invoice - print "" . $langs->trans("StatusOfGeneratedInvoices") . ""; + print "" . $langs->trans("StatusOfAutoGeneratedInvoices") . ""; $select = array('0' => $langs->trans('BillStatusDraft'), '1' => $langs->trans('BillStatusValidated')); print $form->selectarray('auto_validate', $select, GETPOST('auto_validate')); print ""; // Auto generate document if (getDolGlobalString('INVOICE_REC_CAN_DISABLE_DOCUMENT_FILE_GENERATION')) { - print "" . $langs->trans("StatusOfAutoGeneratedDocuments") . ""; + print "" . $langs->trans("StatusOfGeneratedDocuments") . ""; $select = array('0' => $langs->trans('DoNotGenerateDoc'), '1' => $langs->trans('AutoGenerateDoc')); print $form->selectarray('generate_pdf', $select, GETPOST('generate_pdf')); print ""; @@ -1484,14 +1484,14 @@ if ($action == 'create') { // Status of generated invoices print ''; if ($action == 'auto_validate' || $object->frequency > 0) { - print $form->editfieldkey($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $usercancreate); + print $form->editfieldkey($langs->trans("StatusOfAutoGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $usercancreate); } else { - print $langs->trans("StatusOfGeneratedInvoices"); + print $langs->trans("StatusOfAutoGeneratedInvoices"); } print ''; $select = 'select;0:' . $langs->trans('BillStatusDraft') . ',1:' . $langs->trans('BillStatusValidated'); if ($action == 'auto_validate' || $object->frequency > 0) { - print $form->editfieldval($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $usercancreate, $select); + print $form->editfieldval($langs->trans("StatusOfAutoGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $usercancreate, $select); } print ''; // Auto generate documents 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 3b287fbcf3e..6a136fdfc4b 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 @@ -147,6 +147,7 @@ UPDATE llx_product set stockable_product = 0 WHERE type = 1; ALTER TABLE llx_prelevement_lignes ADD COLUMN fk_user integer NULL; +ALTER TABLE llx_hrm_evaluation ADD COLUMN last_main_doc varchar(255); ALTER TABLE llx_hrm_evaluationdet ADD COLUMN comment TEXT; ALTER TABLE llx_resource ADD COLUMN address varchar(255) DEFAULT NULL AFTER fk_code_type_resource; 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 6a3f61a22d2..d1f6998aa2e 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 @@ -208,3 +208,6 @@ ALTER TABLE llx_categorie ADD COLUMN position integer DEFAULT 0 AFTER color; ALTER TABLE llx_product DROP COLUMN onportal; ALTER TABLE llx_knowledgemanagement_knowledgerecord MODIFY COLUMN answer longtext; + +-- Rename const to add customer categories on not customer/prospect third-party if enabled +UPDATE llx_const SET name = 'THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT' WHERE name = 'THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER'; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 79272f0b6f5..fac5f950a30 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -685,7 +685,7 @@ Module5000Desc=Allows you to manage multiple companies Module6000Name=Inter-modules Workflow Module6000Desc=Workflow management between different modules (automatic creation of object and/or automatic status change) Module10000Name=Websites -Module10000Desc=Create websites (public) with a WYSIWYG editor. This is a webmaster or developer oriented CMS (it is better to know HTML and CSS language). Just setup your web server (Apache, Nginx, ...) to point to the dedicated Dolibarr directory to have it online on the internet with your own domain name. +Module10000Desc=CMS to create websites with a WYSIWYG editor. This is a webmaster or developer oriented Content Management System (it is better to know HTML and CSS language). Just setup your web server (Apache, Nginx, ...) to point to the dedicated Dolibarr directory to have it online on the internet with your own domain name. Module20000Name=Leave Request Management Module20000Desc=Define and track employee leave requests Module39000Name=Product Lots diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index cb2f8bedde5..8c144fbae3e 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1260,4 +1260,4 @@ AmountSalary=Salary amount InvoiceSubtype=Invoice subtype ConfirmMassReverse=Bulk Reverse confirmation ConfirmMassReverseQuestion=Are you sure you want to reverse the %s selected record(s)? - +Encrypted=Encrypted diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 58d285b577d..1b076f689b4 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -161,5 +161,76 @@ Visibility=Visibility Everyone=Everyone AssignedContacts=Assigned contacts WebsiteTypeLabel=Type of Web site -WebsiteTypeDolibarrWebsite=Web site (CMS Dolibarr) -WebsiteTypeDolibarrPortal=Native Dolibarr portal +WebsiteTypeDolibarrWebsite=Web site (Module WebSites CMS) +WebsiteTypeDolibarrPortal=Native and ready to use web portal (Module Web Portal) +WebPortalURL=Web portal URL +NewWebsiteAccount=New accounts for websites + + +ModuleWebPortalName = Web portal +ModuleWebPortalDesc = A ready to use native web portal for customers, suppliers, partners or members +WebPortalDescription = Public web portal module for membership and partnership +WebPortalSetup = WebPortal setup +WebPortalCSS=Web portal CSS +Settings = Settings +WebPortalSetupPage = WebPortal setup page +WEBPORTAL_ROOT_URL = Alternative virtual host URL +WebPortalRootUrlHelp = Public access url (http or https) if you have a virtual host or keep empty +WEBPORTAL_TITLE = Brand name on header of public page +UserAccountForWebPortalAreInThirdPartyTabHelp = Users accounts for WebPortal can be set on each third party card in Website accounts tab +WebPortalAccessHidden = Hidden +WebPortalAccessVisible = Visible +WebPortalAccessEdit = Editable +WEBPORTAL_MEMBER_CARD_ACCESS = Enable access to the membership record +WebPortalMemberCardAccessHelp = Enable access to the membership record (Hidden / Visible or Editable) +WEBPORTAL_PARTNERSHIP_CARD_ACCESS = Enable access to the partnership record +WebPortalPartnerShipCardAccessHelp = Enable access to the partnership record (Hidden / Visible or Editable) +WEBPORTAL_PROPAL_LIST_ACCESS = Enable access to the proposals +WEBPORTAL_ORDER_LIST_ACCESS = Enable access to the orders +WEBPORTAL_INVOICE_LIST_ACCESS = Enable access to the invoices +WEBPORTAL_USER_LOGGED = Select an anonymous user +WebPortalUserLoggedHelp = This user is used to update cards +WebPortalHomeTitle = Welcome +WebPortalHomeDesc = Welcome to the public interface +WebPortalPropalListMenu = Proposals +WebPortalPropalListTitle = List of proposals +WebPortalPropalListDesc = List of proposals +WebPortalPropalListNothing = Proposals not found +WebPortalOrderListMenu = Orders +WebPortalOrderListTitle = List of orders +WebPortalOrderListDesc = List of orders +WebPortalOrderListNothing = Orders not found +WebPortalInvoiceListMenu = Invoices +WebPortalInvoiceListTitle = List of invoices +WebPortalInvoiceListDesc = List of invoices +WebPortalInvoiceListNothing = Invoices not found +WebPortalMemberCardMenu = Member +WebPortalMemberCardTitle = Member card +WebPortalMemberCardDesc = Member card +WebPortalPartnershipCardMenu = Partnership +WebPortalPartnershipCardTitle = Partnership card +WebPortalPartnershipCardDesc = Partnership card +loginWebportalUserName = User name / email +loginWebportalPassword = Password +LoginNow = Login now +RemoveSearchFilters = Remove search filters +WEBPORTAL_PRIMARY_COLOR = Primary color +WEBPORTAL_SECONDARY_COLOR = Secondary color +WEBPORTAL_LOGIN_LOGO_URL = Login logo image URL +WEBPORTAL_MENU_LOGO_URL = Menu logo image URL +WEBPORTAL_MENU_LOGO_URLTooltip = Leave empty to use login logo +WEBPORTAL_LOGIN_BACKGROUND = Background login image URL +WEBPORTAL_BANNER_BACKGROUND = Background for banner +WEBPORTAL_BANNER_BACKGROUND_IS_DARK = Use dark theme for banner +AriaPrevPage = Previous page +AriaNextPage = Next page +AriaPageX = Page %s +WebPortalError404 = Page not found +WebPortalErrorPageNotExist = Page not exist +WebPortalErrorFetchThirdPartyAccountFromLogin = Error when loading third-party account (login : %s) +WebPortalErrorAuthentication = Authentication error +WebPortalErrorFetchLoggedThirdPartyAccount = Error when loading third-party account (login : %s) +WebPortalErrorFetchLoggedUser = Error when loading user (Id : %s) +WebPortalErrorFetchLoggedThirdParty = Error when loading third-party (Id : %s) +WebPortalErrorFetchLoggedMember = Error when loading member (Id : %s) +WebPortalErrorFetchLoggedPartnership = Error when loading partnership (Third-party Id : %s, Member Id : %s) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 5b995486664..53eeeba0274 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -342,18 +342,18 @@ if (!empty($php_session_save_handler) && $php_session_save_handler == 'db') { require_once 'core/lib/phpsessionin'.$php_session_save_handler.'.lib.php'; } -// Init session. Name of session is specific to Dolibarr instance. -// Must be done after the include of filefunc.inc.php so global variables of conf file are defined (like $dolibarr_main_instance_unique_id or $dolibarr_main_force_https). -// Note: the function dol_getprefix() is defined into functions.lib.php but may have been defined to return a different key to manage another area to protect. -$prefix = dol_getprefix(''); -$sessionname = 'DOLSESSID_'.$prefix; -$sessiontimeout = 'DOLSESSTIMEOUT_'.$prefix; + // Init session. Name of session is specific to Dolibarr instance. + // Must be done after the include of filefunc.inc.php so global variables of conf file are defined (like $dolibarr_main_instance_unique_id or $dolibarr_main_force_https). + // Note: the function dol_getprefix() is defined into functions.lib.php but may have been defined to return a different key to manage another area to protect. + $prefix = dol_getprefix(''); + $sessionname = 'DOLSESSID_'.$prefix; + $sessiontimeout = 'DOLSESSTIMEOUT_'.$prefix; if (!empty($_COOKIE[$sessiontimeout])) { ini_set('session.gc_maxlifetime', $_COOKIE[$sessiontimeout]); } -// This create lock, released by session_write_close() or end of page. -// We need this lock as long as we read/write $_SESSION ['vars']. We can remove lock when finished. + // This create lock, released by session_write_close() or end of page. + // We need this lock as long as we read/write $_SESSION ['vars']. We can remove lock when finished. if (!defined('NOSESSION')) { if (PHP_VERSION_ID < 70300) { session_set_cookie_params(0, '/', null, ((empty($dolibarr_main_force_https) && isHTTPS() === false) ? false : true), true); // Add tag secure and httponly on session cookie (same as setting session.cookie_httponly into php.ini). Must be called before the session_start. @@ -375,13 +375,13 @@ if (!defined('NOSESSION')) { } -// Init the 6 global objects, this include will make the 'new Xxx()' and set properties for: $conf, $db, $langs, $user, $mysoc, $hookmanager -require_once 'master.inc.php'; + // Init the 6 global objects, this include will make the 'new Xxx()' and set properties for: $conf, $db, $langs, $user, $mysoc, $hookmanager + require_once 'master.inc.php'; -// Uncomment this and set session.save_handler = user to use local session storing -// include DOL_DOCUMENT_ROOT.'/core/lib/phpsessionindb.inc.php + // Uncomment this and set session.save_handler = user to use local session storing + // include DOL_DOCUMENT_ROOT.'/core/lib/phpsessionindb.inc.php -// If software has been locked. Only login $conf->global->MAIN_ONLY_LOGIN_ALLOWED is allowed. + // If software has been locked. Only login $conf->global->MAIN_ONLY_LOGIN_ALLOWED is allowed. if (getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED')) { $ok = 0; if ((!session_id() || !isset($_SESSION["dol_login"])) && !isset($_POST["username"]) && !empty($_SERVER["GATEWAY_INTERFACE"])) { @@ -411,10 +411,10 @@ if (getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED')) { } -// Activate end of page function -register_shutdown_function('dol_shutdown'); + // Activate end of page function + register_shutdown_function('dol_shutdown'); -// Load debugbar + // Load debugbar if (isModEnabled('debugbar') && !GETPOST('dol_use_jmobile') && empty($_SESSION['dol_use_jmobile'])) { global $debugbar; include_once DOL_DOCUMENT_ROOT.'/debugbar/class/DebugBar.php'; @@ -428,7 +428,7 @@ if (isModEnabled('debugbar') && !GETPOST('dol_use_jmobile') && empty($_SESSION[' $debugbar['time']->startMeasure('pageaftermaster', 'Page generation (after environment init)'); } -// Detection browser + // Detection browser if (isset($_SERVER["HTTP_USER_AGENT"])) { $tmp = getBrowserInfo($_SERVER["HTTP_USER_AGENT"]); $conf->browser->name = $tmp['browsername']; @@ -443,13 +443,13 @@ if (isset($_SERVER["HTTP_USER_AGENT"])) { } } -// If theme is forced + // If theme is forced if (GETPOST('theme', 'aZ09')) { $conf->theme = GETPOST('theme', 'aZ09'); $conf->css = "/theme/".$conf->theme."/style.css.php"; } -// Set global MAIN_OPTIMIZEFORTEXTBROWSER (must be before login part) + // Set global MAIN_OPTIMIZEFORTEXTBROWSER (must be before login part) if (GETPOST('textbrowser', 'int') || (!empty($conf->browser->name) && $conf->browser->name == 'lynxlinks')) { // If we must enable text browser $conf->global->MAIN_OPTIMIZEFORTEXTBROWSER = 1; } @@ -498,7 +498,7 @@ if (!defined('NOLOGIN') && !defined('NOIPCHECK') && !empty($dolibarr_main_restri } } -// Loading of additional presentation includes + // Loading of additional presentation includes if (!defined('NOREQUIREHTML')) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; // Need 660ko memory (800ko in 2.2) } @@ -506,13 +506,13 @@ if (!defined('NOREQUIREAJAX')) { require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; // Need 22ko memory } -// If install or upgrade process not done or not completely finished, we call the install page. + // If install or upgrade process not done or not completely finished, we call the install page. if (getDolGlobalString('MAIN_NOT_INSTALLED') || getDolGlobalString('MAIN_NOT_UPGRADED')) { dol_syslog("main.inc: A previous install or upgrade was not complete. Redirect to install page.", LOG_WARNING); header("Location: ".DOL_URL_ROOT."/install/index.php"); exit; } -// If an upgrade process is required, we call the install page. + // If an upgrade process is required, we call the install page. if ((getDolGlobalString('MAIN_VERSION_LAST_UPGRADE') && ($conf->global->MAIN_VERSION_LAST_UPGRADE != DOL_VERSION)) || (!getDolGlobalString('MAIN_VERSION_LAST_UPGRADE') && getDolGlobalString('MAIN_VERSION_LAST_INSTALL') && ($conf->global->MAIN_VERSION_LAST_INSTALL != DOL_VERSION))) { $versiontocompare = !getDolGlobalString('MAIN_VERSION_LAST_UPGRADE') ? $conf->global->MAIN_VERSION_LAST_INSTALL : $conf->global->MAIN_VERSION_LAST_UPGRADE; @@ -530,7 +530,7 @@ if ((getDolGlobalString('MAIN_VERSION_LAST_UPGRADE') && ($conf->global->MAIN_VER } } -// Creation of a token against CSRF vulnerabilities + // Creation of a token against CSRF vulnerabilities if (!defined('NOTOKENRENEWAL') && !defined('NOSESSION')) { // No token renewal on .css.php, .js.php and .json.php (even if the NOTOKENRENEWAL was not provided) if (!preg_match('/\.(css|js|json)\.php$/', $_SERVER["PHP_SELF"])) { @@ -550,9 +550,9 @@ if (!defined('NOTOKENRENEWAL') && !defined('NOSESSION')) { } } -//dol_syslog("CSRF info: ".defined('NOCSRFCHECK')." - ".$dolibarr_nocsrfcheck." - ".$conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN." - ".$_SERVER['REQUEST_METHOD']." - ".GETPOST('token', 'alpha')); + //dol_syslog("CSRF info: ".defined('NOCSRFCHECK')." - ".$dolibarr_nocsrfcheck." - ".$conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN." - ".$_SERVER['REQUEST_METHOD']." - ".GETPOST('token', 'alpha')); -// Check validity of token, only if option MAIN_SECURITY_CSRF_WITH_TOKEN enabled or if constant CSRFCHECK_WITH_TOKEN is set into page + // Check validity of token, only if option MAIN_SECURITY_CSRF_WITH_TOKEN enabled or if constant CSRFCHECK_WITH_TOKEN is set into page if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && getDolGlobalInt('MAIN_SECURITY_CSRF_WITH_TOKEN')) || defined('CSRFCHECK_WITH_TOKEN')) { // Array of action code where CSRFCHECK with token will be forced (so token must be provided on url request) $sensitiveget = false; @@ -609,12 +609,12 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && getDolGlobalInt( print " into setup).\n"; } } - die; + die; } } - $sessiontokenforthisurl = (empty($_SESSION['token']) ? '' : $_SESSION['token']); - // TODO Get the sessiontokenforthisurl into an array of session token (one array per base URL so we can use the CSRF per page and we keep ability for several tabs per url in a browser) + $sessiontokenforthisurl = (empty($_SESSION['token']) ? '' : $_SESSION['token']); + // TODO Get the sessiontokenforthisurl into an array of session token (one array per base URL so we can use the CSRF per page and we keep ability for several tabs per url in a browser) if (GETPOSTISSET('token') && GETPOST('token') != 'notrequired' && GETPOST('token', 'alpha') != $sessiontokenforthisurl) { dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"]) ? '' : $_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused by CSRF protection (invalid token), so we disable POST and some GET parameters - referrer=".(empty($_SERVER['HTTP_REFERER'])?'':$_SERVER['HTTP_REFERER']).", action=".GETPOST('action', 'aZ09').", _GET|POST['token']=".GETPOST('token', 'alpha'), LOG_WARNING); //dol_syslog("_SESSION['token']=".$sessiontokenforthisurl, LOG_DEBUG); @@ -643,7 +643,7 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && getDolGlobalInt( // Note: There is another CSRF protection into the filefunc.inc.php } -// Disable modules (this must be after session_start and after conf has been loaded) + // Disable modules (this must be after session_start and after conf has been loaded) if (GETPOSTISSET('disablemodules')) { $_SESSION["disablemodules"] = GETPOST('disablemodules', 'alpha'); } @@ -668,8 +668,8 @@ if (!empty($_SESSION["disablemodules"])) { } } -// Set current modulepart -$modulepart = explode("/", $_SERVER["PHP_SELF"]); + // Set current modulepart + $modulepart = explode("/", $_SERVER["PHP_SELF"]); if (is_array($modulepart) && count($modulepart) > 0) { foreach ($conf->modules as $module) { if (in_array($module, $modulepart)) { @@ -683,10 +683,10 @@ if (is_array($modulepart)) { } -/* - * Phase authentication / login - */ -$login = ''; + /* + * Phase authentication / login + */ + $login = ''; if (!defined('NOLOGIN')) { // $authmode lists the different method of identification to be tested in order of preference. // Example: 'http', 'dolibarr', 'ldap', 'http,forceuser', '...' @@ -1017,10 +1017,10 @@ if (!defined('NOLOGIN')) { // User validity dates are no more valid dol_syslog("The user login has a validity between [".$user->datestartvalidity." and ".$user->dateendvalidity."], current date is ".dol_now()); } - session_destroy(); - session_set_cookie_params(0, '/', null, (empty($dolibarr_main_force_https) ? false : true), true); // Add tag secure and httponly on session cookie - session_name($sessionname); - session_start(); + session_destroy(); + session_set_cookie_params(0, '/', null, (empty($dolibarr_main_force_https) ? false : true), true); // Add tag secure and httponly on session cookie + session_name($sessionname); + session_start(); if ($resultFetchUser == 0) { $langs->loadLangs(array('main', 'errors')); @@ -1040,23 +1040,23 @@ if (!defined('NOLOGIN')) { $user->context['audit'] = 'ErrorUserSessionWasInvalidated - login='.$login; } - // Call trigger - $result = $user->call_trigger('USER_LOGIN_FAILED', $user); + // Call trigger + $result = $user->call_trigger('USER_LOGIN_FAILED', $user); if ($result < 0) { $error++; } - // End call triggers + // End call triggers - // Hooks on failed login - $action = ''; - $hookmanager->initHooks(array('login')); - $parameters = array('dol_authmode' => (isset($dol_authmode) ? $dol_authmode : ''), 'dol_loginmesg' => $_SESSION["dol_loginmesg"]); - $reshook = $hookmanager->executeHooks('afterLoginFailed', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks + // Hooks on failed login + $action = ''; + $hookmanager->initHooks(array('login')); + $parameters = array('dol_authmode' => (isset($dol_authmode) ? $dol_authmode : ''), 'dol_loginmesg' => $_SESSION["dol_loginmesg"]); + $reshook = $hookmanager->executeHooks('afterLoginFailed', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { $error++; } - $paramsurl = array(); + $paramsurl = array(); if (GETPOST('textbrowser', 'int')) { $paramsurl[] = 'textbrowser='.GETPOST('textbrowser', 'int'); } @@ -1067,8 +1067,8 @@ if (!defined('NOLOGIN')) { $paramsurl[] = 'lang='.GETPOST('lang', 'aZ09'); } - header('Location: '.DOL_URL_ROOT.'/index.php'.(count($paramsurl) ? '?'.implode('&', $paramsurl) : '')); - exit; + header('Location: '.DOL_URL_ROOT.'/index.php'.(count($paramsurl) ? '?'.implode('&', $paramsurl) : '')); + exit; } else { // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('main')); @@ -1273,13 +1273,13 @@ if (!defined('NOLOGIN')) { } -// Case forcing style from url + // Case forcing style from url if (GETPOST('theme', 'aZ09')) { $conf->theme = GETPOST('theme', 'aZ09', 1); $conf->css = "/theme/".$conf->theme."/style.css.php"; } -// Set javascript option + // Set javascript option if (GETPOST('nojs', 'int')) { // If javascript was not disabled on URL $conf->use_javascript_ajax = 0; } else { @@ -1288,15 +1288,15 @@ if (GETPOST('nojs', 'int')) { // If javascript was not disabled on URL } } -// Set MAIN_OPTIMIZEFORTEXTBROWSER for user (must be after login part) + // Set MAIN_OPTIMIZEFORTEXTBROWSER for user (must be after login part) if (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') && !empty($user->conf->MAIN_OPTIMIZEFORTEXTBROWSER)) { $conf->global->MAIN_OPTIMIZEFORTEXTBROWSER = $user->conf->MAIN_OPTIMIZEFORTEXTBROWSER; } -// set MAIN_OPTIMIZEFORCOLORBLIND for user -$conf->global->MAIN_OPTIMIZEFORCOLORBLIND = empty($user->conf->MAIN_OPTIMIZEFORCOLORBLIND) ? '' : $user->conf->MAIN_OPTIMIZEFORCOLORBLIND; + // set MAIN_OPTIMIZEFORCOLORBLIND for user + $conf->global->MAIN_OPTIMIZEFORCOLORBLIND = empty($user->conf->MAIN_OPTIMIZEFORCOLORBLIND) ? '' : $user->conf->MAIN_OPTIMIZEFORCOLORBLIND; -// Set terminal output option according to conf->browser. + // Set terminal output option according to conf->browser. if (GETPOST('dol_hide_leftmenu', 'int') || !empty($_SESSION['dol_hide_leftmenu'])) { $conf->dol_hide_leftmenu = 1; } @@ -1312,7 +1312,7 @@ if (GETPOST('dol_no_mouse_hover', 'int') || !empty($_SESSION['dol_no_mouse_hover if (GETPOST('dol_use_jmobile', 'int') || !empty($_SESSION['dol_use_jmobile'])) { $conf->dol_use_jmobile = 1; } -// If not on Desktop + // If not on Desktop if (!empty($conf->browser->layout) && $conf->browser->layout != 'classic') { $conf->dol_no_mouse_hover = 1; } @@ -1329,7 +1329,7 @@ if ((!empty($conf->browser->layout) && $conf->browser->layout == 'phone') $conf->global->PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE = 0; } } -// Replace themes bugged with jmobile with eldy + // Replace themes bugged with jmobile with eldy if (!empty($conf->dol_use_jmobile) && in_array($conf->theme, array('bureau2crea', 'cameleo', 'amarok'))) { $conf->theme = 'eldy'; $conf->css = "/theme/".$conf->theme."/style.css.php"; @@ -1411,9 +1411,9 @@ if (empty($conf->browser->firefox)) { define('ROWS_9', 8); } -$heightforframes = 50; + $heightforframes = 50; -// Init menu manager + // Init menu manager if (!defined('NOREQUIREMENU')) { if (empty($user->socid)) { // If internal user or not defined $conf->standard_menu = (!getDolGlobalString('MAIN_MENU_STANDARD_FORCED') ? (!getDolGlobalString('MAIN_MENU_STANDARD') ? 'eldy_menu.php' : $conf->global->MAIN_MENU_STANDARD) : $conf->global->MAIN_MENU_STANDARD_FORCED); @@ -1455,7 +1455,7 @@ if (!empty(GETPOST('seteventmessages', 'alpha'))) { } } -// Functions + // Functions if (!function_exists("llxHeader")) { /** @@ -1541,13 +1541,13 @@ if (!function_exists("llxHeader")) { } -/** - * Show HTTP header. Called by top_htmlhead(). - * - * @param string $contenttype Content type. For example, 'text/html' - * @param int $forcenocache Force disabling of cache for the page - * @return void - */ + /** + * Show HTTP header. Called by top_htmlhead(). + * + * @param string $contenttype Content type. For example, 'text/html' + * @param int $forcenocache Force disabling of cache for the page + * @return void + */ function top_httphead($contenttype = 'text/html', $forcenocache = 0) { global $db, $conf, $hookmanager; @@ -2084,22 +2084,22 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr } -/** - * Show an HTML header + a BODY + The top menu bar - * - * @param string $head Lines in the HEAD - * @param string $title Title of web page - * @param string $target Target to use in menu links (Example: '' or '_top') - * @param int $disablejs Do not output links to js (Ex: qd fonction utilisee par sous formulaire Ajax) - * @param int $disablehead Do not output head section - * @param array $arrayofjs Array of js files to add in header - * @param array $arrayofcss Array of css files to add in header - * @param string $morequerystring Query string to add to the link "print" to get same parameters (use only if autodetect fails) - * @param string $helppagename Name of wiki page for help ('' by default). - * Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage|DE:GermanPage - * For other external page: http://server/url - * @return void - */ + /** + * Show an HTML header + a BODY + The top menu bar + * + * @param string $head Lines in the HEAD + * @param string $title Title of web page + * @param string $target Target to use in menu links (Example: '' or '_top') + * @param int $disablejs Do not output links to js (Ex: qd fonction utilisee par sous formulaire Ajax) + * @param int $disablehead Do not output head section + * @param array $arrayofjs Array of js files to add in header + * @param array $arrayofcss Array of css files to add in header + * @param string $morequerystring Query string to add to the link "print" to get same parameters (use only if autodetect fails) + * @param string $helppagename Name of wiki page for help ('' by default). + * Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage|DE:GermanPage + * For other external page: http://server/url + * @return void + */ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead = 0, $arrayofjs = array(), $arrayofcss = array(), $morequerystring = '', $helppagename = '') { global $user, $conf, $langs, $db, $form; @@ -2347,13 +2347,13 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead } -/** - * Build the tooltip on user login - * - * @param int $hideloginname Hide login name. Show only the image. - * @param string $urllogout URL for logout (Will use DOL_URL_ROOT.'/user/logout.php?token=...' if empty) - * @return string HTML content - */ + /** + * Build the tooltip on user login + * + * @param int $hideloginname Hide login name. Show only the image. + * @param string $urllogout URL for logout (Will use DOL_URL_ROOT.'/user/logout.php?token=...' if empty) + * @return string HTML content + */ function top_menu_user($hideloginname = 0, $urllogout = '') { global $langs, $conf, $db, $hookmanager, $user, $mysoc; @@ -2615,11 +2615,11 @@ function top_menu_user($hideloginname = 0, $urllogout = '') return $btnUser; } -/** - * Build the tooltip on top menu quick add - * - * @return string HTML content - */ + /** + * Build the tooltip on top menu quick add + * + * @return string HTML content + */ function top_menu_quickadd() { global $conf, $langs; @@ -2642,8 +2642,9 @@ function top_menu_quickadd() '; - $html .= ' - + if (!defined('JS_JQUERY_DISABLE_DROPDOWN') && !empty($conf->use_javascript_ajax)) { // This may be set by some pages that use different jquery version to avoid errors + $html .= ' + '; + } return $html; } -/** - * Generate list of quickadd items - * - * @return string HTML output - */ + /** + * Generate list of quickadd items + * + * @return string HTML output + */ function printDropdownQuickadd() { global $conf, $user, $langs, $hookmanager; @@ -2855,11 +2857,11 @@ function printDropdownQuickadd() return $dropDownQuickAddHtml; } -/** - * Build the tooltip on top menu bookmark - * - * @return string HTML content - */ + /** + * Build the tooltip on top menu bookmark + * + * @return string HTML content + */ function top_menu_bookmark() { global $langs, $conf, $db, $user; @@ -2938,11 +2940,11 @@ function top_menu_bookmark() return $html; } -/** - * Build the tooltip on top menu tsearch - * - * @return string HTML content - */ + /** + * Build the tooltip on top menu tsearch + * + * @return string HTML content + */ function top_menu_search() { global $langs, $conf, $db, $user, $hookmanager; @@ -3363,12 +3365,12 @@ function left_menu($menu_array_before, $helppagename = '', $notused = '', $menu_ } -/** - * Begin main area - * - * @param string $title Title - * @return void - */ + /** + * Begin main area + * + * @param string $title Title + * @return void + */ function main_area($title = '') { global $conf, $langs, $hookmanager; @@ -3424,13 +3426,13 @@ function main_area($title = '') } -/** - * Return helpbaseurl, helppage and mode - * - * @param string $helppagename Page name ('EN:xxx,ES:eee,FR:fff,DE:ddd...' or 'http://localpage') - * @param Translate $langs Language - * @return array Array of help urls - */ + /** + * Return helpbaseurl, helppage and mode + * + * @param string $helppagename Page name ('EN:xxx,ES:eee,FR:fff,DE:ddd...' or 'http://localpage') + * @param Translate $langs Language + * @return array Array of help urls + */ function getHelpParamFor($helppagename, $langs) { $helpbaseurl = ''; @@ -3475,22 +3477,22 @@ function getHelpParamFor($helppagename, $langs) } -/** - * Show a search area. - * Used when the javascript quick search is not used. - * - * @param string $urlaction Url post - * @param string $urlobject Url of the link under the search box - * @param string $title Title search area - * @param string $htmlmorecss Add more css - * @param string $htmlinputname Field Name input form - * @param string $accesskey Accesskey - * @param string $prefhtmlinputname Complement for id to avoid multiple same id in the page - * @param string $img Image to use - * @param int $showtitlebefore Show title before input text instead of into placeholder. This can be set when output is dedicated for text browsers. - * @param int $autofocus Set autofocus on field - * @return string - */ + /** + * Show a search area. + * Used when the javascript quick search is not used. + * + * @param string $urlaction Url post + * @param string $urlobject Url of the link under the search box + * @param string $title Title search area + * @param string $htmlmorecss Add more css + * @param string $htmlinputname Field Name input form + * @param string $accesskey Accesskey + * @param string $prefhtmlinputname Complement for id to avoid multiple same id in the page + * @param string $img Image to use + * @param int $showtitlebefore Show title before input text instead of into placeholder. This can be set when output is dedicated for text browsers. + * @param int $autofocus Set autofocus on field + * @return string + */ function printSearchForm($urlaction, $urlobject, $title, $htmlmorecss, $htmlinputname, $accesskey = '', $prefhtmlinputname = '', $img = '', $showtitlebefore = 0, $autofocus = 0) { global $langs, $user; diff --git a/htdocs/modulebuilder/README.md b/htdocs/modulebuilder/README.md index 26b0ecf717b..fa3752f7ceb 100644 --- a/htdocs/modulebuilder/README.md +++ b/htdocs/modulebuilder/README.md @@ -2,7 +2,7 @@ Module Builder ============== This is a module to provide embedded tools to develop your own application/features inside Dolibarr ERP CRM software. -It provide tools for module developers to kickstart their project and give an hands-on sample of which features Dolibarr +It provides tools for module developers to kickstart their project and give an hands-on sample of which features Dolibarr has to offer for module development. If you don't need to develop your own module/application, you just don't need this. diff --git a/htdocs/modulebuilder/template/core/modules/mailings/mailing_mymodule_selector1.modules.php b/htdocs/modulebuilder/template/core/modules/mailings/mailing_mymodule_selector1.modules.php index 8f242f3fd2e..c96228a00b4 100644 --- a/htdocs/modulebuilder/template/core/modules/mailings/mailing_mymodule_selector1.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mailings/mailing_mymodule_selector1.modules.php @@ -61,8 +61,6 @@ class mailing_mailing_mymodule_selector1 extends MailingTargets global $langs; $langs->load("members"); - $form = new Form($this->db); - $arraystatus = array(1=>'Option 1', 2=>'Option 2'); $s = ''; @@ -104,9 +102,9 @@ class mailing_mailing_mymodule_selector1 extends MailingTargets $target = array(); $j = 0; - $sql = " select rowid as id, label, firstname, lastname"; - $sql .= " from ".MAIN_DB_PREFIX."myobject"; - $sql .= " where email IS NOT NULL AND email <> ''"; + $sql = "SELECT rowid as id, firstname, lastname, email"; + $sql .= " FROM ".MAIN_DB_PREFIX."myobject"; + $sql .= " WHERE email IS NOT NULL AND email <> ''"; if (GETPOSTISSET('filter') && GETPOST('filter', 'alphanohtml') != 'none') { $sql .= " AND status = '".$this->db->escape(GETPOST('filter', 'alphanohtml'))."'"; } @@ -118,7 +116,7 @@ class mailing_mailing_mymodule_selector1 extends MailingTargets $num = $this->db->num_rows($result); $i = 0; - dol_syslog("mailinglist_mymodule_myobject.modules.php: mailing ".$num." targets found"); + dol_syslog(__METHOD__.":add_to_target ".$num." targets found"); $old = ''; while ($i < $num) { @@ -126,10 +124,10 @@ class mailing_mailing_mymodule_selector1 extends MailingTargets if ($old != $obj->email) { $target[$j] = array( 'email' => $obj->email, - 'name' => $obj->lastname, 'id' => $obj->id, 'firstname' => $obj->firstname, - 'other' => $obj->label, + 'lastname' => $obj->lastname, + //'other' => $obj->label, 'source_url' => $this->url($obj->id), 'source_id' => $obj->id, 'source_type' => 'myobject@mymodule' @@ -188,7 +186,9 @@ class mailing_mailing_mymodule_selector1 extends MailingTargets */ public function getNbOfRecipients($sql = '') { - $sql = "select count(distinct(email)) as nb from ".MAIN_DB_PREFIX."myobject as p where email IS NOT NULL AND email != ''"; + $sql = "SELECT COUNT(DISTINCT(email)) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."myobject as p"; + $sql .= " WHERE email IS NOT NULL AND email <> ''"; $a = parent::getNbOfRecipients($sql); diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index b2bcfa2eeb1..17c832df13b 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -169,7 +169,7 @@ class modMyModule extends DolibarrModules 'fr_FR:ParentCompany'=>'Maison mère ou revendeur' )*/ - if (!isset($conf->mymodule) || !isset($conf->mymodule->enabled)) { + if (!isModEnabled("mymodule")) { $conf->mymodule = new stdClass(); $conf->mymodule->enabled = 0; } diff --git a/htdocs/public/test/test_forms.php b/htdocs/public/test/test_forms.php index 29e726c9ae3..d21967404d7 100644 --- a/htdocs/public/test/test_forms.php +++ b/htdocs/public/test/test_forms.php @@ -23,14 +23,12 @@ llxHeader(); ?> -

This page is a sample of page using Dolibarr HTML widget methods. It is designed to make test with
- css (add parameter &theme=newtheme to test another theme or edit css of current theme)
- jmobile (add parameter ">dol_use_jmobile=1&dol_optimize_smallscreen=1 and switch to small screen < 570 to enable with emulated jmobile)
- no javascript / usage for bind people (add parameter ">nojs=1 to force disable javascript)
- use with a text browser (add parameter ">textbrowser=1 to force detection of a text browser)
-

-
+

selectDate('', 'test1b', 1, 1, 0); print '

'."\n"; // Test2: form->selectDate using tzuser date -print "Test 2: We must have here 1970-01-01 00:00:00 selected (fields can be empty)
\n"; +print "Test 2: We must have here 1970-01-01 selected (fields can be empty)
\n"; print $form->selectDate(dol_get_first_day(1970, 1, false), 'test2', 1, 1, 1); print '

'."\n"; @@ -120,7 +118,7 @@ if (is_file(DOL_DOCUMENT_ROOT.'/includes/flowjs/flow.js')) { print '