Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic Object plugins and Fields #512

Closed
Wolvverine opened this issue May 9, 2022 · 10 comments
Closed

Generic Object plugins and Fields #512

Wolvverine opened this issue May 9, 2022 · 10 comments

Comments

@Wolvverine
Copy link

It is not possible to add fields in Asset created with the Generic Object plugin.

Only for some dropdowns: Models, Types, Category.

@tomolimo
Copy link
Collaborator

Hello @Wolvverine
Could you detail your issue?
I.E. give more infos?
In order to reproduce your issue
Thank you,
Regards,
Tomolimo

@Giudy
Copy link

Giudy commented Sep 27, 2022

Hello,
I guess the point is that this plugin is not compatible, if I'm not wrong, with Generic object. So If a new object is created in the inventory, it is not possible to customize the fields for that object.

davide

@tomolimo
Copy link
Collaborator

Hello @Giudy
I don't understand your issue, as I'm able to do what your proposed:
I've created a new Object type, and I'm able to add "additionnal fileds" to it.
So be kind enough to detail your issue step by step, so that I'll be able to help you.
Thank you,
Regards,
Tomolimo

@Giudy
Copy link

Giudy commented Sep 27, 2022

SOrry Tomolino, you're right I was trying on a 9.5.x version and it wasn't working. on the 10 it is working fine thank you

@tomolimo
Copy link
Collaborator

tomolimo commented Sep 28, 2022

Hello @Wolvverine and @Giudy
I've done a backport of this feature (#546) to be available for GLPI 9.5, would you like to have it for GLPI 9.5?
Thank you,
Regards,
Tomolimo

@Wolvverine
Copy link
Author

@tomolimo
I am currently personally migrating my installations slowly to 10.0.x.
But I think some people will be happy, of those who won't be able to migrate for a while yet.

@trasher
Copy link
Contributor

trasher commented Sep 28, 2022

Hi, we do not plan to maintain any feature for GLPI 9.5; it's officially no longer maintained. Of course, any of you is free to provide any backport patch, but that will stay unofficial and not merged :)

@trasher trasher closed this as completed Sep 28, 2022
@tomolimo
Copy link
Collaborator

Hello @Wolvverine
Here it is:

Just mofify the following source file: plugins/fields/inc/container.class.php in the PluginFieldsContainer::getItemtypes() method:

Add the following block of code:

      $plugin = new Plugin();
      if ($plugin->isActivated('genericobject') && method_exists('PluginGenericobjectType', 'getTypes')) {
         $go_itemtypes = [];
         foreach (array_keys(PluginGenericobjectType::getTypes()) as $go_itemtype) {
            if (!class_exists($go_itemtype)) {
               continue;
            }
            $go_itemtypes[$go_itemtype] = $plugin->getInfo('genericobject', 'name').' - '.$go_itemtype::getTypeName(2); ;
         }
         if (count($go_itemtypes) > 0) {
            $tabs[$plugin->getInfo('genericobject', 'name')] = $go_itemtypes;
         }
      }

Like below:

      $tabs[__('Administration')] = [
         'User'    => User::getTypeName(2),
         'Group'   => Group::getTypeName(2),
         'Entity'  => Entity::getTypeName(2),
         'Profile' => Profile::getTypeName(2)
      ];

      $plugin = new Plugin();
      if ($plugin->isActivated('genericobject') && method_exists('PluginGenericobjectType', 'getTypes')) {
         $go_itemtypes = [];
         foreach (array_keys(PluginGenericobjectType::getTypes()) as $go_itemtype) {
            if (!class_exists($go_itemtype)) {
               continue;
            }
            $go_itemtypes[$go_itemtype] = $plugin->getInfo('genericobject', 'name').' - '.$go_itemtype::getTypeName(2); ;
         }
         if (count($go_itemtypes) > 0) {
            $tabs[$plugin->getInfo('genericobject', 'name')] = $go_itemtypes;
         }
      }


      foreach ($PLUGIN_HOOKS['plugin_fields'] as $itemtype) {
         $isPlugin = isPluginItemType($itemtype);
         if ($isPlugin) {
            $plugin_name = Plugin::getInfo($isPlugin['plugin'], 'name');

            $tabs[__("Plugins")][$itemtype] = $plugin_name.' - '.$itemtype::getTypeName(2);
         }
      }

Regards,
Tomolimo

@Wolvverine
Copy link
Author

THX @tomolimo

@Giudy
Copy link

Giudy commented Sep 28, 2022

Thank you!!! @tomolimo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants