From 7dfa9b7d33d2f9fb7f84051ca2711d53e162bf3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 28 Oct 2024 19:49:01 +0100 Subject: [PATCH] remove unused code (#31610) * remove unused code * remove unused code * fix typo * fix * fix * fix --- htdocs/asset/class/asset.class.php | 37 +--------- htdocs/asset/class/assetmodel.class.php | 74 ++----------------- .../facture/class/api_invoices.class.php | 10 +-- htdocs/core/class/conf.class.php | 23 ++++-- htdocs/core/class/link.class.php | 23 +++++- htdocs/core/lib/ecm.lib.php | 2 +- htdocs/webportal/class/context.class.php | 3 + 7 files changed, 52 insertions(+), 120 deletions(-) diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 1026fd092bb..88088e6f26a 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -256,7 +256,7 @@ class Asset extends CommonObject */ public function __construct(DoliDB $db) { - global $conf, $langs; + global $langs; $this->db = $db; @@ -343,13 +343,7 @@ class Asset extends CommonObject // // // Load source object // $result = $object->fetchCommon($fromid); - // if ($result > 0 && !empty($object->table_element_line)) { - // $object->fetchLines(); - // } // - // // get lines so they will be clone - // //foreach($this->lines as $line) - // // $line->fetch_optionals(); // // // Reset some properties // unset($object->id); @@ -420,6 +414,7 @@ class Asset extends CommonObject // $this->db->rollback(); // return -1; // } + return -1; } @@ -434,10 +429,6 @@ class Asset extends CommonObject { $result = $this->fetchCommon($id, $ref); if ($result > 0) { - if (!empty($this->table_element_line)) { - $this->fetchLines(); - } - $res = $this->hasDepreciationLinesInBookkeeping(); if ($res < 0) { return -1; @@ -454,18 +445,6 @@ class Asset extends CommonObject return $result; } - /** - * Load object lines in memory from the database - * - * @return int Return integer <0 if KO, 0 if not found, >0 if OK - */ - public function fetchLines() - { - $this->lines = array(); - - return 1; - } - /** * Load list of objects in memory from the database. @@ -1591,18 +1570,6 @@ class Asset extends CommonObject return $this->initAsSpecimenCommon(); } - /** - * Create an array of lines - * - * @return array|int array of lines if OK, <0 if KO - */ - public function getLinesArray() - { - $this->lines = array(); - - return $this->lines; - } - /** * Returns the reference to the following non used object depending on the active numbering module. * diff --git a/htdocs/asset/class/assetmodel.class.php b/htdocs/asset/class/assetmodel.class.php index ac9dc8c778c..c39d6eb47f5 100644 --- a/htdocs/asset/class/assetmodel.class.php +++ b/htdocs/asset/class/assetmodel.class.php @@ -1,8 +1,8 @@ - * Copyright (C) 2021 Open-Dsi - * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW +/* Copyright (C) 2017 Laurent Destailleur + * Copyright (C) 2021 Open-Dsi + * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * 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 @@ -263,13 +263,6 @@ class AssetModel extends CommonObject // Load source object $result = $object->fetchCommon($fromid); - if ($result > 0 && !empty($object->table_element_line)) { - $object->fetchLines(); - } - - // get lines so they will be clone - //foreach($this->lines as $line) - // $line->fetch_optionals(); // Reset some properties unset($object->id); @@ -354,25 +347,10 @@ class AssetModel extends CommonObject public function fetch($id, $ref = null) { $result = $this->fetchCommon($id, $ref); - if ($result > 0 && !empty($this->table_element_line)) { - $this->fetchLines(); - } + return $result; } - /** - * Load object lines in memory from the database - * - * @return int Return integer <0 if KO, 0 if not found, >0 if OK - */ - public function fetchLines() - { - $this->lines = array(); - - return 1; - } - - /** * Load list of objects in memory from the database. * @@ -810,46 +788,4 @@ class AssetModel extends CommonObject return $this->initAsSpecimenCommon(); } - - /** - * Create an array of lines - * - * @return array|int array of lines if OK, <0 if KO - */ - public function getLinesArray() - { - $this->lines = array(); - - return $this->lines; - } - - /** - * Action executed by scheduler - * CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters' - * Use public function doScheduledJob($param1, $param2, ...) to get parameters - * - * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) - */ - public function doScheduledJob() - { - //global $conf, $langs; - - //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log'; - - $error = 0; - $this->output = ''; - $this->error = ''; - - dol_syslog(__METHOD__, LOG_DEBUG); - - $now = dol_now(); - - $this->db->begin(); - - // ... - - $this->db->commit(); - - return $error; - } } diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index db5378949d1..ef5939be02f 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -1,9 +1,9 @@ - * Copyright (C) 2020 Thibault FOUCART - * Copyright (C) 2023 Joachim Kueter +/* Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2020 Thibault FOUCART + * Copyright (C) 2023 Joachim Kueter * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024 MDW * * 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 @@ -47,7 +47,7 @@ class Invoices extends DolibarrApi private $invoice; /** - * @var FactureRec $templte_invoice {@type FactureRec} + * @var FactureRec $template_invoice {@type FactureRec} */ private $template_invoice; diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 9e926c1c054..0d3e7184e6b 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -1,9 +1,10 @@ - * Copyright (C) 2003 Xavier Dutoit - * Copyright (C) 2004-2020 Laurent Destailleur - * Copyright (C) 2005-2017 Regis Houssin - * Copyright (C) 2006 Jean Heimburger +/* Copyright (C) 2003-2007 Rodolphe Quiedeville + * Copyright (C) 2003 Xavier Dutoit + * Copyright (C) 2004-2020 Laurent Destailleur + * Copyright (C) 2005-2017 Regis Houssin + * Copyright (C) 2006 Jean Heimburger + * 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 @@ -141,10 +142,20 @@ class Conf extends stdClass public $format_date_hour_text_short; public $format_date_hour_text; + /** + * @var int limit for list + */ public $liste_limit; + + /** + * @var int checkboxes are on left column if 1 + */ public $main_checkbox_left_column; - public $tzuserinputkey = 'tzserver'; // Use 'tzuserrel' to always store date in GMT and show date in time zone of user. + /** + * @var string Use 'tzuserrel' to always store date in GMT and show date in time zone of user. + */ + public $tzuserinputkey = 'tzserver'; // TODO Remove this part. diff --git a/htdocs/core/class/link.class.php b/htdocs/core/class/link.class.php index 8ea08e7d52a..53e7614701d 100644 --- a/htdocs/core/class/link.class.php +++ b/htdocs/core/class/link.class.php @@ -1,6 +1,7 @@ - * Copyright (C) 2024 MDW +/* Copyright (C) 2013 Cédric Salvador + * Copyright (C) 2024 MDW + * 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 @@ -44,7 +45,14 @@ class Link extends CommonObject */ public $entity; + /** + * @var int|'' date add + */ public $datea; + + /** + * @var string Object url + */ public $url; /** @@ -52,7 +60,14 @@ class Link extends CommonObject */ public $label; + /** + * @var string Object type + */ public $objecttype; + + /** + * @var int Object ID + */ public $objectid; @@ -167,11 +182,11 @@ class Link extends CommonObject } // Clean parameters - $this->url = clean_url($this->url, 1); + $this->url = clean_url($this->url, 1); if (empty($this->label)) { $this->label = basename($this->url); } - $this->label = trim($this->label); + $this->label = trim($this->label); $this->db->begin(); diff --git a/htdocs/core/lib/ecm.lib.php b/htdocs/core/lib/ecm.lib.php index 8c421b7c26f..20f8b91125f 100644 --- a/htdocs/core/lib/ecm.lib.php +++ b/htdocs/core/lib/ecm.lib.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2008-2014 Laurent Destailleur * Copyright (C) 2022-2024 Frédéric France * Copyright (C) 2024 MDW * diff --git a/htdocs/webportal/class/context.class.php b/htdocs/webportal/class/context.class.php index 82503fb5530..0bd07a2ffed 100644 --- a/htdocs/webportal/class/context.class.php +++ b/htdocs/webportal/class/context.class.php @@ -125,6 +125,9 @@ class Context */ public $rootUrl; + /** + * @var string[] + */ public $menu_active = array(); /**