diff --git a/dev/setup/pre-commit/README.md b/dev/setup/pre-commit/README.md index 1f3740144c2..c5c35e81829 100644 --- a/dev/setup/pre-commit/README.md +++ b/dev/setup/pre-commit/README.md @@ -23,16 +23,17 @@ the project: `pre-commit-config.yaml`. ### Installation in your git project -1. Install `pre-commit` tool.\ +1. Install pre-commit tool.\ 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 tool: `python -m pip install pre-commit`. + Then you can install pre-commit tool: + `python3 -m pip install pre-commit` -2. In your local git clone of the project, run `pre-commit install` to add the hooks.\ - or copy the file git/hooks/pre-commit manually. (recommended because this file differs - from the file installed with pre-commit install as it redirects output to the error - channel so your IDE will be able to catch the error. +2. In your local git clone of the project, run `pre-commit install` to add the hooks + or copy the file *dev/setup/git/hooks/pre-commit* manually into *.git/hooks/pre-commit* + (recommended because this file may differ from the file installed with the pre-commit install). + The good file redirects output to the error channel so your IDE will be able to catch the error. ### Tips diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index 6dba7fa0d93..ad1f0633c96 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -238,7 +238,7 @@ if ($user->hasRight('adherent', 'cotisation', 'creer') && $action == 'edit') { // Label print ''.$langs->trans("Label").''; print ''; - print ''; + print ''; // Bank line if (isModEnabled("bank") && (getDolGlobalString('ADHERENT_BANK_USE') || $object->fk_bank)) { @@ -334,7 +334,7 @@ if ($rowid && $action != 'edit') { print ''.$langs->trans("Amount").''.price($object->amount).''; // Label - print ''.$langs->trans("Label").''.dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note_private)).''; + print ''.$langs->trans("Label").''.dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note_public)).''; // Bank line if (isModEnabled("bank") && (getDolGlobalString('ADHERENT_BANK_USE') || $object->fk_bank)) { diff --git a/htdocs/comm/action/class/ical.class.php b/htdocs/comm/action/class/ical.class.php index 20b34678a5d..258539a8cd8 100644 --- a/htdocs/comm/action/class/ical.class.php +++ b/htdocs/comm/action/class/ical.class.php @@ -143,7 +143,7 @@ class ICal $this->cal = array(); // new empty array $this->event_count = -1; - $this->file_text = null; + $this->file_text = ''; // Save file into a cache if ($usecachefile) { @@ -168,10 +168,10 @@ class ICal } } - $this->file_text = preg_split("[\n]", $this->file_text); + $file_text_array = preg_split("[\n]", $this->file_text); // is this text vcalendar standard text ? on line 1 is BEGIN:VCALENDAR - if (!stristr($this->file_text[0], 'BEGIN:VCALENDAR')) { + if (!stristr($file_text_array[0], 'BEGIN:VCALENDAR')) { return 'error not VCALENDAR'; } @@ -179,7 +179,7 @@ class ICal $tmpkey = ''; $tmpvalue = ''; $type = ''; - foreach ($this->file_text as $text) { + foreach ($file_text_array as $text) { $text = trim($text); // trim one line if (!empty($text)) { // get Key and Value VCALENDAR:Begin -> Key = VCALENDAR, Value = begin diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 930c01db9fe..8102984f3b2 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -258,7 +258,7 @@ if ($sourcetype != 'salary') { $pricetowithdraw = $bprev->SommeAPrelever($type, 'salary'); } if ($nb < 0) { - dol_print_error($bprev->error); + dol_print_error($db, $bprev->error); } print ''; @@ -479,7 +479,7 @@ if ($resql) { } $title = $langs->trans("InvoiceWaitingWithdraw"); $picto = 'bill'; - if ($type =='bank-transfer') { + if ($type == 'bank-transfer') { if ($sourcetype != 'salary') { $title = $langs->trans("InvoiceWaitingPaymentByBankTransfer"); } else { diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index f6f14fdf863..97497ced70a 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -359,13 +359,14 @@ class ConferenceOrBooth extends ActionComm /** * Delete object in database * - * @param int $notrigger false=launch triggers after, true=disable triggers - * @return int Return integer <0 if KO, >0 if OK + * @param User $user User making the delete + * @param int $notrigger false=launch triggers after, true=disable triggers + * @return int Return integer <0 if KO, >0 if OK */ - public function delete($notrigger = 0) + public function delete($user, $notrigger = 0) { //TODO delete attendees and subscription - return parent::delete($notrigger); + return parent::delete($user, $notrigger); } /** diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 4fdefef202b..8c259b63e2a 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -506,7 +506,7 @@ if (empty($reshook)) { } } elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('expedition', 'supprimer')) { $also_update_stock = (GETPOST('alsoUpdateStock', 'alpha') ? 1 : 0); - $result = $object->delete(0, $also_update_stock); + $result = $object->delete($user, 0, $also_update_stock); if ($result > 0) { header("Location: ".DOL_URL_ROOT.'/expedition/index.php'); exit; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 1079f834024..b9b21899b28 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1242,7 +1242,7 @@ class Expedition extends CommonObject $mouvS = new MouvementStock($this->db); // we do not log origin because it will be deleted - $mouvS->origin = null; + $mouvS->origin = ''; // get lot/serial $lotArray = null; if (isModEnabled('productbatch')) { @@ -1440,7 +1440,7 @@ class Expedition extends CommonObject $mouvS = new MouvementStock($this->db); // we do not log origin because it will be deleted - $mouvS->origin = null; + $mouvS->origin = ''; // get lot/serial $lotArray = $shipmentlinebatch->fetchAll($obj->expeditiondet_id); if (!is_array($lotArray)) { diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index c5d1ad93933..a8301b48558 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -8,7 +8,7 @@ * Copyright (C) 2014-2022 Charlene Benke * Copyright (C) 2015-2016 Abbes Bahfir * Copyright (C) 2018-2022 Philippe Grand - * Copyright (C) 2020 Frédéric France + * Copyright (C) 2020-2024 Frédéric France * Copyright (C) 2023 Benjamin Grembi * Copyright (C) 2023-2024 William Mead * @@ -338,7 +338,7 @@ if (empty($reshook)) { if ($product_type == Product::TYPE_SERVICE || getDolGlobalString('FICHINTER_PRINT_PRODUCTS')) { //only services except if config includes products $duration = 3600; // Default to one hour - + $desc = ''; // Predefined products & services if ($lines[$i]->fk_product > 0) { $prod = new Product($db); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index b2a5140c9e1..7eff5f099d2 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2316,6 +2316,8 @@ class CommandeFournisseur extends CommonOrder */ public function deleteLine($idline, $notrigger = 0) { + global $user; + if ($this->statut == 0) { $line = new CommandeFournisseurLigne($this->db); @@ -2333,12 +2335,11 @@ class CommandeFournisseur extends CommonOrder } } - if ($line->delete($notrigger) > 0) { + if ($line->delete($user, $notrigger) > 0) { $this->update_price(1); return 1; } else { - $this->error = $line->error; - $this->errors = $line->errors; + $this->setErrorsFromObject($line); return -1; } } else { @@ -4162,9 +4163,11 @@ class CommandeFournisseurLigne extends CommonOrderLine * @param int $notrigger 1=Disable call to triggers * @return int Return integer <0 if KO, >0 if OK */ - public function delete($notrigger = 0) + public function delete($user, $notrigger = 0) { - global $user; + if (empty($user)) { + global $user; + } $error = 0; diff --git a/htdocs/hrm/class/establishment.class.php b/htdocs/hrm/class/establishment.class.php index 8acbb128987..37ab22b84a9 100644 --- a/htdocs/hrm/class/establishment.class.php +++ b/htdocs/hrm/class/establishment.class.php @@ -327,7 +327,6 @@ class Establishment extends CommonObject * Delete record * * @param User $user User making the change - * @param int $id Id of record to delete * @return int Return integer <0 if KO, >0 if OK */ public function delete($user) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index b7dd42c84e2..e632b93088a 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -655,7 +655,7 @@ Module2200Desc=Use maths expressions for auto-generation of prices Module2300Name=Scheduled jobs Module2300Desc=Scheduled jobs management (alias cron or chrono table) Module2400Name=Events/Agenda -Module2400Desc=Track events. Log automatic events for tracking purposes or record manual events or meetings. This is the principal module for good Customer or Vendor Relationship Management. +Module2400Desc=Manage manual and automatic events. Provide a calendar to record events manually. Log also events automatically for tracking purposes or record manual events or meetings. This is the principal module for good Customer or Vendor Relationship Management. Module2430Name=Online appointment scheduling Module2430Desc=Provides an online appointment booking system. This allow anyone to book rendez-vous, according to predefined ranges or availabilities. Module2500Name=DMS / ECM diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 2a40c0406c5..cce2244df42 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -530,6 +530,8 @@ class Dolresource extends CommonObject require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $rowid = $this->id; + $error = 0; $this->db->begin(); diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index d89decb1ac7..a9ed23f8d61 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 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 @@ -410,7 +411,7 @@ class Tickets extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if (!$this->ticket->delete($user)) { + if (!$this->ticket->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when deleting ticket'); }