Aggiunto controllo plugin duplicati per i moduli

This commit is contained in:
Luca 2022-12-05 18:51:41 +01:00
parent d775541f75
commit 5f85920013
3 changed files with 75 additions and 4 deletions

View File

@ -221,8 +221,19 @@ foreach ($db as $name => $values) {
} else{
$type = tr('Impostazione');
$inc = str_replace(['k', 'M'], ['000', '000000'], App::getConfig()['db_options'][$name]);
//Vedo se riesco a recuperare l'impostazione dalle variabili di sessione o globali di mysql
$rs_session_variabile = $dbo->fetchArray('SHOW SESSION VARIABLES LIKE '.prepare($name));
$rs_global_variabile = $dbo->fetchArray('SHOW GLOBAL VARIABLES LIKE '.prepare($name));
if (!empty($rs_session_variabile[0]['Value']))
$inc = \Util\FileSystem::formatBytes($rs_session_variabile[0]['Value']);
else if (!empty($rs_global_variabile[0]['Value']))
$inc = \Util\FileSystem::formatBytes($rs_global_variabile[0]['Value']);
else
$inc = str_replace(['k', 'M'], ['000', '000000'], App::getConfig()['db_options'][$name]);
$real = str_replace(['k', 'M'], ['000', '000000'], $description);
if (string_starts_with($real, '>')) {
@ -240,9 +251,9 @@ foreach ($db as $name => $values) {
}
$description = tr('Valore consigliato: _VALUE_ (Valore attuale: _INI_)', [
$description = tr('Valore consigliato: _VALUE_ (Valore attuale: _INC_)', [
'_VALUE_' => $description,
'_INI_' => App::getConfig()['db_options'][$name],
'_INC_' => $inc,
]);
}

View File

@ -21,6 +21,7 @@ include_once __DIR__.'/../../core.php';
use Models\Cache;
use Modules\Aggiornamenti\Controlli\ColonneDuplicateViste;
use Modules\Aggiornamenti\Controlli\PluginDuplicati;
use Modules\Aggiornamenti\Controlli\Controllo;
use Modules\Aggiornamenti\Controlli\DatiFattureElettroniche;
use Modules\Aggiornamenti\Controlli\PianoConti;
@ -57,6 +58,7 @@ switch (filter('op')) {
PianoConti::class,
DatiFattureElettroniche::class,
ColonneDuplicateViste::class,
PluginDuplicati::class,
];
$results = [];

View File

@ -0,0 +1,58 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace Modules\Aggiornamenti\Controlli;
use Models\Module;
class PluginDuplicati extends Controllo
{
public function getName()
{
return tr('Plugin duplicati per i Moduli');
}
public function getType($record)
{
return 'warning';
}
public function check()
{
$duplicati = database()->fetchArray('SELECT `idmodule_to`, `name` FROM `zz_plugins` GROUP BY `idmodule_to`, `name` HAVING COUNT(`name`) > 1');
foreach ($duplicati as $plugin) {
$modulo = Module::pool($plugin['idmodule_to']);
$this->addResult([
'id' => $plugin['name'],
'nome' => $modulo->title.': '.$plugin['name'],
'descrizione' => tr('Il plugin _NAME_ del modulo _MODULE_ esiste più volte', [
'_NAME_' => $plugin['name'],
'_MODULE_' => $modulo->title,
]),
]);
}
}
public function execute($record, $params = [])
{
return false;
}
}