Merge pull request #29013 from frederic34/box_member_phpstan
clean code for phpstan
This commit is contained in:
commit
19fbfb9444
16 changed files with 69 additions and 50 deletions
|
|
@ -3,6 +3,7 @@
|
|||
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* 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
|
||||
|
|
@ -112,11 +113,16 @@ if ($action == 'set') {
|
|||
|
||||
dolibarr_del_const($db, 'SYSLOG_HANDLERS', -1); // To be sure there is not a setup into another entity
|
||||
dolibarr_set_const($db, 'SYSLOG_HANDLERS', json_encode($activeModules), 'chaine', 0, '', 0);
|
||||
|
||||
$error = 0;
|
||||
$errors = [];
|
||||
// Check configuration
|
||||
foreach ($activeModules as $modulename) {
|
||||
$module = new $modulename();
|
||||
$error = $module->checkConfiguration();
|
||||
$res = $module->checkConfiguration();
|
||||
if (!$res) {
|
||||
$error++;
|
||||
$errors = array_merge($errors, $module->errors);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -125,7 +131,7 @@ if ($action == 'set') {
|
|||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
$db->rollback();
|
||||
setEventMessages($error, $errors, 'errors');
|
||||
setEventMessages('', $errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* 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
|
||||
|
|
@ -68,7 +69,7 @@ class box_graph_invoices_permonth extends ModeleBoxes
|
|||
//include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
//$facturestatic=new Facture($this->db);
|
||||
|
||||
$startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
|
||||
$startmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
|
||||
if (!getDolGlobalString('GRAPH_USE_FISCAL_YEAR')) {
|
||||
$startmonth = 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* 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,7 +66,7 @@ class box_graph_invoices_peryear extends ModeleBoxes
|
|||
//include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
//$facturestatic=new Facture($this->db);
|
||||
|
||||
$startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
|
||||
$startmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
|
||||
if (!getDolGlobalString('GRAPH_USE_FISCAL_YEAR')) {
|
||||
$startmonth = 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* 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
|
||||
|
|
@ -66,7 +67,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
|
|||
|
||||
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
||||
|
||||
$startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
|
||||
$startmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
|
||||
if (!getDolGlobalString('GRAPH_USE_FISCAL_YEAR')) {
|
||||
$startmonth = 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* 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
|
||||
|
|
@ -67,7 +68,7 @@ class box_graph_orders_permonth extends ModeleBoxes
|
|||
//include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
|
||||
//$commandestatic=new Commande($this->db);
|
||||
|
||||
$startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
|
||||
$startmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
|
||||
if (!getDolGlobalString('GRAPH_USE_FISCAL_YEAR')) {
|
||||
$startmonth = 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* 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
|
||||
|
|
@ -66,7 +67,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
|
|||
|
||||
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
|
||||
|
||||
$startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
|
||||
$startmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
|
||||
if (!getDolGlobalString('GRAPH_USE_FISCAL_YEAR')) {
|
||||
$startmonth = 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* 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
|
||||
|
|
@ -67,7 +68,7 @@ class box_graph_propales_permonth extends ModeleBoxes
|
|||
//include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
|
||||
//$propalstatic=new Propal($this->db);
|
||||
|
||||
$startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
|
||||
$startmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
|
||||
if (!getDolGlobalString('GRAPH_USE_FISCAL_YEAR')) {
|
||||
$startmonth = 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2015-2023 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2021-2023 Waël Almoman <info@almoman.com>
|
||||
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2015-2024 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2021-2023 Waël Almoman <info@almoman.com>
|
||||
*
|
||||
* 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
|
||||
|
|
@ -140,12 +140,11 @@ class box_members_by_tags extends ModeleBoxes
|
|||
$line++;
|
||||
$AdherentTag = array();
|
||||
foreach ($sumMembers as $key => $data) {
|
||||
$adhtag = new Categorie($this->db);
|
||||
$adhtag->id = $key;
|
||||
|
||||
if ($key == 'total') {
|
||||
break;
|
||||
}
|
||||
$adhtag = new Categorie($this->db);
|
||||
$adhtag->id = (int) $key;
|
||||
$adhtag->label = $data['label'];
|
||||
$AdherentTag[$key] = $adhtag;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2015-2023 Frederic France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2021-2023 Waël Almoman <info@almoman.com>
|
||||
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2015-2024 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2021-2023 Waël Almoman <info@almoman.com>
|
||||
*
|
||||
* 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
|
||||
|
|
@ -140,12 +140,11 @@ class box_members_by_type extends ModeleBoxes
|
|||
$line++;
|
||||
$AdherentType = array();
|
||||
foreach ($sumMembers as $key => $data) {
|
||||
$adhtype = new AdherentType($this->db);
|
||||
$adhtype->id = $key;
|
||||
|
||||
if ($key == 'total') {
|
||||
break;
|
||||
}
|
||||
$adhtype = new AdherentType($this->db);
|
||||
$adhtype->id = (int) $key;
|
||||
$adhtype->label = $data['label'];
|
||||
$AdherentType[$key] = $adhtype;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2015-2020 Frederic France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2015-2024 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* 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
|
||||
|
|
@ -110,7 +110,7 @@ class box_members_last_modified extends ModeleBoxes
|
|||
$memberstatic->email = $objp->email;
|
||||
$memberstatic->morphy = $objp->morphy;
|
||||
$memberstatic->company = $objp->company;
|
||||
$memberstatic->statut = $objp->status;
|
||||
$memberstatic->status = $objp->status;
|
||||
$memberstatic->date_creation = $datec;
|
||||
$memberstatic->date_modification = $datem;
|
||||
$memberstatic->need_subscription = $objp->subscription;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2015-2020 Frederic France <frederic.france@netlogic.fr>
|
||||
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2015-2024 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* 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
|
||||
|
|
@ -110,7 +110,7 @@ class box_members_last_subscriptions extends ModeleBoxes
|
|||
$staticmember->email = $obj->email;
|
||||
$staticmember->photo = $obj->photo;
|
||||
$staticmember->morphy = $obj->morphy;
|
||||
$staticmember->statut = $obj->status;
|
||||
$staticmember->status = $obj->status;
|
||||
$staticmember->need_subscription = $obj->need_subscription;
|
||||
$staticmember->datefin = $this->db->jdate($obj->date_end_subscription);
|
||||
if (!empty($obj->fk_soc)) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/* Copyright (C) 2012-2018 Charlene BENKE <charlie@patas-monkey.com>
|
||||
* Copyright (C) 2015-2021 Frederic France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2015-2024 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* 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
|
||||
|
|
@ -174,7 +174,7 @@ class box_task extends ModeleBoxes
|
|||
$taskstatic->ref = $objp->ref;
|
||||
$taskstatic->label = $objp->label;
|
||||
$taskstatic->progress = $objp->progress;
|
||||
$taskstatic->fk_statut = $objp->fk_statut;
|
||||
$taskstatic->status = $objp->fk_statut;
|
||||
$taskstatic->date_end = $this->db->jdate($objp->datee);
|
||||
$taskstatic->planned_workload = $objp->planned_workload;
|
||||
$taskstatic->duration_effective = $objp->duration_effective;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
/* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
*/
|
||||
/*
|
||||
* 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
|
||||
|
|
@ -24,6 +26,11 @@ class LogHandler
|
|||
{
|
||||
protected $ident = 0;
|
||||
|
||||
/**
|
||||
* @var string[] Array of errors messages
|
||||
*/
|
||||
public $errors = [];
|
||||
|
||||
|
||||
/**
|
||||
* Content of the info tooltip.
|
||||
|
|
@ -80,11 +87,11 @@ class LogHandler
|
|||
* It will be called after setting the configuration.
|
||||
* The function returns an array with error messages
|
||||
*
|
||||
* @return array
|
||||
* @return bool
|
||||
*/
|
||||
public function checkConfiguration()
|
||||
{
|
||||
return array();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
/* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
*/
|
||||
/*
|
||||
* 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
|
||||
|
|
@ -79,7 +81,7 @@ interface LogHandlerInterface
|
|||
/**
|
||||
* Output log content
|
||||
*
|
||||
* @param string $content Content to log
|
||||
* @param array $content Content to log
|
||||
* @return void
|
||||
*/
|
||||
public function export($content);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
/* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/syslog/logHandler.php';
|
||||
|
|
@ -78,23 +79,21 @@ class mod_syslog_file extends LogHandler implements LogHandlerInterface
|
|||
/**
|
||||
* Return if configuration is valid
|
||||
*
|
||||
* @return array Array of errors. Empty array if ok.
|
||||
* @return bool true if ok
|
||||
*/
|
||||
public function checkConfiguration()
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$errors = array();
|
||||
|
||||
$filename = $this->getFilename();
|
||||
|
||||
if (file_exists($filename) && is_writable($filename)) {
|
||||
dol_syslog('admin/syslog: file '.$filename);
|
||||
return true;
|
||||
} else {
|
||||
$errors[] = $langs->trans("ErrorFailedToOpenFile", $filename);
|
||||
$this->errors[] = $langs->trans("ErrorFailedToOpenFile", $filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
/* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/syslog/logHandler.php';
|
||||
|
||||
|
|
@ -77,15 +79,14 @@ class mod_syslog_syslog extends LogHandler implements LogHandlerInterface
|
|||
/**
|
||||
* Return if configuration is valid
|
||||
*
|
||||
* @return array Array of errors. Empty array if ok.
|
||||
* @return bool True if ok.
|
||||
*/
|
||||
public function checkConfiguration()
|
||||
{
|
||||
global $conf, $langs;
|
||||
global $langs;
|
||||
|
||||
$errors = array();
|
||||
$facility = constant(getDolGlobalString('SYSLOG_FACILITY'));
|
||||
|
||||
$facility = constant($conf->global->SYSLOG_FACILITY);
|
||||
if ($facility) {
|
||||
// Only LOG_USER supported on Windows
|
||||
if (!empty($_SERVER["WINDIR"])) {
|
||||
|
|
@ -93,11 +94,11 @@ class mod_syslog_syslog extends LogHandler implements LogHandlerInterface
|
|||
}
|
||||
|
||||
dol_syslog("admin/syslog: facility ".$facility);
|
||||
return true;
|
||||
} else {
|
||||
$errors[] = $langs->trans("ErrorUnknownSyslogConstant", $facility);
|
||||
$this->errors[] = $langs->trans("ErrorUnknownSyslogConstant", $facility);
|
||||
return false;
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue