diff --git a/hook.php b/hook.php index c28aae8f..7838a324 100644 --- a/hook.php +++ b/hook.php @@ -108,7 +108,8 @@ function plugin_uninstall_addUninstallTypes($uninstal_types = []) { function plugin_genericobject_install() { global $DB; - include_once(GLPI_ROOT."/plugins/genericobject/inc/object.class.php"); + include_once(GLPI_ROOT."/plugins/genericobject/inc/baseobject.class.php"); + include_once(GLPI_ROOT."/files/_plugins/genericobject/inc/object.class.php"); include_once(GLPI_ROOT."/plugins/genericobject/inc/type.class.php"); $migration = new Migration(PLUGIN_GENERICOBJECT_VERSION); @@ -155,7 +156,8 @@ function plugin_genericobject_install() { function plugin_genericobject_uninstall() { global $DB; - include_once(GLPI_ROOT."/plugins/genericobject/inc/object.class.php"); + include_once(GLPI_ROOT."/plugins/genericobject/inc/baseobject.class.php"); + include_once(GLPI_ROOT."/files/_plugins/genericobject/inc/object.class.php"); include_once(GLPI_ROOT."/plugins/genericobject/inc/type.class.php"); //For each type diff --git a/inc/object.class.php b/inc/baseobject.class.php similarity index 99% rename from inc/object.class.php rename to inc/baseobject.class.php index 92849865..8ed756e2 100644 --- a/inc/object.class.php +++ b/inc/baseobject.class.php @@ -25,7 +25,7 @@ @since 2009 ---------------------------------------------------------------------- */ -class PluginGenericobjectObject extends CommonDBTM { +class PluginGenericobjectBaseObject extends CommonDBTM { protected $objecttype; diff --git a/objects/object_child.class.tpl b/objects/object_child.class.tpl new file mode 100644 index 00000000..c0e3ed3e --- /dev/null +++ b/objects/object_child.class.tpl @@ -0,0 +1,34 @@ +. + -------------------------------------------------------------------------- + @package genericobject + @author the genericobject plugin team + @copyright Copyright (c) 2010-2011 Order plugin team + @license GPLv2+ + http://www.gnu.org/licenses/gpl.txt + @link https://forge.indepnet.n$/projects/genericobject + @link http://www.glpi-project.org/ + @since 2009 + ---------------------------------------------------------------------- */ +/** + * Users may customize this class at their own risk. No technical support for customizations. + */ +class PluginGenericobjectObject extends PluginGenericobjectBaseObject { + public function __construct() { + parent::__construct(); + } +} \ No newline at end of file diff --git a/setup.php b/setup.php index e2ac0506..14e7626e 100644 --- a/setup.php +++ b/setup.php @@ -99,6 +99,25 @@ if (file_exists(GENERICOBJECT_DIR . "/log_filter.settings.php")) { include_once(GENERICOBJECT_DIR . "/log_filter.settings.php"); } +// Backward compatible solution for allowing users to extend core plugin classes. +// All file paths are absolute. +// These are the only core classes that can be extended by users. +// REM: Should happen before autoloader initialization. +$child_classes = [ + [ + 'class_name' => 'PluginGenericobjectObject', + 'child_path' => GENERICOBJECT_CLASS_PATH.'/object.class.php', + 'template_path' => GENERICOBJECT_DIR.'/objects/object_child.class.tpl', + ], +]; +foreach ($child_classes as $config) { + if (! file_exists($config['child_path'])) { + file_put_contents( + $config['child_path'], + file_get_contents($config['template_path']) + ); + } +} $go_autoloader = new PluginGenericobjectAutoloader([ GENERICOBJECT_CLASS_PATH