Item_Item class¶
For the moment CommonDBRelation manage the connection between Phones, Printers and Peripherals to a computer.I propose to extend it to :
- connect peripherals and simcards to phones and peripherals
- manage connections from an item to another (several simcards on a phone)
- manage connections of several items to one (a simcard can be connected to a computer, a phone or a peripheral)
MoYo : CommonDBRelation is a standard class to manage link between 2 objects... Not only phones / printers... Maybe you want to speak about Computer_Item ?
Walid : I was thinking of a way to factorize and extends treatments made in Computer_Item in CommonDBRelation. Maybe the best would be a new classe CommonDBConnection for example, which extends CommonDBRelation.
MoYo : maybe... the migration to a item_item class and table (as networkport) managing all direct connection may be the easiest solution...
Wald : you mean having for example Computer_Peripheral, Computer_Phone and so on ? do I understand it right ?
MoYo : no Item_Item with 2 couple itemtype / items_id
This feature can be linked to #2225 (filter connection by status)
Item_Item class¶
Add a new class Item_Item extends CommonDBRelation.
Computer_Item will be replaced by Item_Item.
Connections definitions¶
Describe possible connections between items : add a new global array in define.php
For each itemtype, there's the list of all other itemtypes that can be connected.
$CFG_GLPI["directconnections_types"] = array ('Computer' => array('Peripheral', 'Phone', 'Printer', 'Monitor'), 'Peripheral' => array('Computer', 'Phone'), 'Phone' => array('Peripheral', 'Computer'), 'Printer' => array('Computer'), 'Monitor' => array('Computer'));
Tab management¶
Count all connections for all types. Filter count depending on the rights :- if user has no right to see monitors, do not show monitors count
Connections display¶
Change display to a list, like network ports and connections.
There will be only one method to display all connections : Item_Item::showRelations
Add a new connection by using Dropdown::showItemType()
Front directory changes¶
Add an item_item.form.php which handles :- connection
- deconnection
- unglobalization
Remove actions "connect", "disconnect" and "unglobalize" from monitor.form.php, computer.form.php, printer.form.php, phone.form.php and peripheral.form.phph.
Database changes¶
Rename glpi_computers_items table in glpi_items_items. The table has the following prototype :
REATE TABLE IF NOT EXISTS `glpi_items_items` ( `id` int(11) NOT NULL AUTO_INCREMENT, `itemtype_1` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `itemtype_2` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `items_id_1` int(11) NOT NULL DEFAULT '0', `items_id_2` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `itemtype_1` (`itemtype_1`) KEY `itemtype_2` (`itemtype_2`) KEY `items_id_1` (`items_id_1`), KEY `items_id_2` (`items_id_2`), KEY `item1` (`itemtype_1`,`items_id_1`), KEY `item2` (`itemtype_2`,`items_id_2`), ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;