Miglioramento gestione ID
This commit is contained in:
parent
5b0d7ca7ad
commit
bb01b1bff0
3
core.php
3
core.php
|
@ -207,6 +207,9 @@ if (!API::isAPIRequest()) {
|
|||
$id_plugin = filter('id_plugin');
|
||||
$id_parent = filter('id_parent');
|
||||
|
||||
Modules::setCurrent($id_module);
|
||||
Plugins::setCurrent($id_plugin);
|
||||
|
||||
// Periodo di visualizzazione dei record
|
||||
// Personalizzato
|
||||
if (!empty($_GET['period_start'])) {
|
||||
|
|
|
@ -4,7 +4,7 @@ function submodules($list, $depth = 1)
|
|||
{
|
||||
$osm_version = Update::getVersion();
|
||||
|
||||
$id_module = App::getCurrentModule()['id'];
|
||||
$id_module = Modules::getCurrent()['id'];
|
||||
|
||||
$result = '';
|
||||
|
||||
|
|
33
src/App.php
33
src/App.php
|
@ -43,35 +43,6 @@ class App
|
|||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Restituisce il modulo attualmente in utilizzo.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getCurrentModule()
|
||||
{
|
||||
$id = filter('id_module');
|
||||
|
||||
if (empty(self::$current_module) && !empty($id)) {
|
||||
self::$current_module = Modules::get($id);
|
||||
}
|
||||
|
||||
return self::$current_module;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce l'identificativo dell'elemento attualmente in utilizzo.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getCurrentElement()
|
||||
{
|
||||
if (empty(self::$current_element)) {
|
||||
self::$current_element = intval(filter('id_record'));
|
||||
}
|
||||
|
||||
return self::$current_element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce la configurazione di default del progetto.
|
||||
|
@ -470,9 +441,9 @@ class App
|
|||
*/
|
||||
protected static function internalLoad($file, $result, $options, $directory = null)
|
||||
{
|
||||
$module = self::getCurrentModule();
|
||||
$module = Modules::getCurrent();
|
||||
|
||||
$id_module = filter('id_module');
|
||||
$id_module = $module['id'];
|
||||
$id_record = filter('id_record');
|
||||
|
||||
$directory = empty($directory) ? 'include|custom|/common/' : $directory;
|
||||
|
|
|
@ -231,7 +231,7 @@ class Mail extends PHPMailer\PHPMailer\PHPMailer
|
|||
*/
|
||||
public function attach($prints, $files)
|
||||
{
|
||||
$id_module = App::getCurrentModule()['id'];
|
||||
$id_module = Modules::getCurrent()['id'];
|
||||
$id_record = App::getCurrentElement();
|
||||
|
||||
// Elenco degli allegati
|
||||
|
|
|
@ -67,6 +67,26 @@ class Modules
|
|||
return Module::get($module);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce il modulo attualmente in utilizzo.
|
||||
*
|
||||
* @return Module
|
||||
*/
|
||||
public static function getCurrent()
|
||||
{
|
||||
return Module::getCurrent($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Imposta il modulo attualmente in utilizzo.
|
||||
*
|
||||
* @param int $id
|
||||
*/
|
||||
public static function setCurrent($id)
|
||||
{
|
||||
Module::setCurrent($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce i permessi accordati all'utente in relazione al modulo specificato.
|
||||
*
|
||||
|
@ -210,7 +230,7 @@ class Modules
|
|||
{
|
||||
$menus = self::getHierarchy();
|
||||
|
||||
$module = App::getCurrentModule();
|
||||
$module = Modules::getCurrent();
|
||||
$module_name = isset($module) ? $module->name : '';
|
||||
|
||||
$result = '';
|
||||
|
|
|
@ -42,7 +42,7 @@ class Plugins
|
|||
*
|
||||
* @param string|int $plugin
|
||||
*
|
||||
* @return array
|
||||
* @return Plugin
|
||||
*/
|
||||
public static function get($plugin)
|
||||
{
|
||||
|
@ -55,6 +55,29 @@ class Plugins
|
|||
return $plugins[$plugin];
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce il modulo attualmente in utilizzo.
|
||||
*
|
||||
* @return Plugin
|
||||
*/
|
||||
public static function getCurrent()
|
||||
{
|
||||
return Plugin::getCurrent($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Imposta il modulo attualmente in utilizzo.
|
||||
*
|
||||
* @param int $id
|
||||
*/
|
||||
public static function setCurrent($id)
|
||||
{
|
||||
Plugin::setCurrent($id);
|
||||
|
||||
// Fix modulo
|
||||
$plugin = self::getCurrent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Individua il percorso per il file.
|
||||
*
|
||||
|
|
|
@ -9,6 +9,9 @@ trait StoreTrait
|
|||
/** @var bool Controllo sul salvataggio globale */
|
||||
protected static $all = false;
|
||||
|
||||
/** @var int Identificatore dell'oggetto in utilizzo */
|
||||
protected static $current;
|
||||
|
||||
/** @var string Nome della colonna "id" (Primary Key) */
|
||||
protected static $id = 'id';
|
||||
/** @var string Nome della colonna "name" */
|
||||
|
@ -62,4 +65,24 @@ trait StoreTrait
|
|||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce l'oggetto attualmente impostato.
|
||||
*
|
||||
* @return StoreTrait
|
||||
*/
|
||||
public static function getCurrent()
|
||||
{
|
||||
return self::get(self::$current);
|
||||
}
|
||||
|
||||
/**
|
||||
* Imposta il modulo attualmente in utilizzo.
|
||||
*
|
||||
* @param int $id
|
||||
*/
|
||||
public static function setCurrent($id)
|
||||
{
|
||||
self::$current = $id;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue