3434class PluginAddressingReserveip extends CommonDBTM
3535{
3636 const COMPUTER = 'Computer ' ;
37- const NETWORK = 'NetworkEquipment ' ;
38- const PRINTER = 'Printer ' ;
37+ const NETWORK = 'NetworkEquipment ' ;
38+ const PRINTER = 'Printer ' ;
3939
4040 static $ rightname = 'plugin_addressing ' ;
4141
@@ -64,58 +64,58 @@ function reserveip($input = array())
6464
6565 // Find computer
6666 $ item = new $ input ['type ' ]();
67- $ id = 0 ;
67+ $ id = 0 ;
6868 if (!$ item ->getFromDBByQuery ("WHERE `name`=' " . $ input ["name " ] . "' AND `entities_id`= " . $ input ['entities_id ' ] . " LIMIT 1 " )) {
6969 // Add computer
70- $ id = $ item ->add (array ("name " => $ input ["name " ],
71- "entities_id " => $ input ['entities_id ' ],
72- 'states_id ' => $ input ["states_id " ],
73- "comment " => $ input ['comment ' ]));
70+ $ id = $ item ->add (array ("name " => $ input ["name " ],
71+ "entities_id " => $ input ['entities_id ' ],
72+ 'states_id ' => $ input ["states_id " ],
73+ "comment " => $ input ['comment ' ]));
7474 } else {
7575 $ id = $ item ->getID ();
7676 //update item
77- $ item ->update (array ("id " => $ id ,
78- "entities_id " => $ input ['entities_id ' ],
79- 'states_id ' => $ input ["states_id " ],
80- "comment " => $ input ['comment ' ]));
77+ $ item ->update (array ("id " => $ id ,
78+ "entities_id " => $ input ['entities_id ' ],
79+ 'states_id ' => $ input ["states_id " ],
80+ "comment " => $ input ['comment ' ]));
8181 }
8282
8383 // Add a new port
8484 if ($ id ) {
8585 switch ($ input ['type ' ]) {
8686 case 'NetworkEquipment ' :
8787 $ newinput = array (
88- "itemtype " => $ input ['type ' ],
89- "items_id " => $ id ,
90- "entities_id " => $ _SESSION ["glpiactive_entity " ],
91- "name " => self ::getPortName ($ input ["ip " ]),
92- "instantiation_type " => "NetworkPortAggregate " ,
93- "_create_children " => 1 ,
88+ "itemtype " => $ input ['type ' ],
89+ "items_id " => $ id ,
90+ "entities_id " => $ _SESSION ["glpiactive_entity " ],
91+ "name " => self ::getPortName ($ input ["ip " ]),
92+ "instantiation_type " => "NetworkPortAggregate " ,
93+ "_create_children " => 1 ,
9494 "NetworkName__ipaddresses " => array ("-100 " => $ input ["ip " ]),
95- "mac " => $ input ["mac " ],
95+ "mac " => $ input ["mac " ],
9696 );
9797 break ;
9898 case 'Computer ' :
9999 case 'Printer ' :
100100 $ newinput = array (
101- "itemtype " => $ input ['type ' ],
102- "items_id " => $ id ,
103- "entities_id " => $ _SESSION ["glpiactive_entity " ],
104- "name " => self ::getPortName ($ input ["ip " ]),
105- "instantiation_type " => "NetworkPortEthernet " ,
106- "_create_children " => 1 ,
101+ "itemtype " => $ input ['type ' ],
102+ "items_id " => $ id ,
103+ "entities_id " => $ _SESSION ["glpiactive_entity " ],
104+ "name " => self ::getPortName ($ input ["ip " ]),
105+ "instantiation_type " => "NetworkPortEthernet " ,
106+ "_create_children " => 1 ,
107107 "NetworkName__ipaddresses " => array ("-100 " => $ input ["ip " ]),
108- "mac " => $ input ["mac " ],
108+ "mac " => $ input ["mac " ],
109109 );
110110 break ;
111111 }
112112
113- $ np = new NetworkPort ();
113+ $ np = new NetworkPort ();
114114 $ newID = $ np ->add ($ newinput );
115115
116116 Event::log ($ newID , "networkport " , 5 , "inventory " ,
117117 //TRANS: %s is the user login
118- sprintf (__ ('%s adds an item ' ), $ _SESSION ["glpiname " ]));
118+ sprintf (__ ('%s adds an item ' ), $ _SESSION ["glpiname " ]));
119119 }
120120 }
121121
@@ -127,17 +127,17 @@ function reserveip($input = array())
127127 */
128128 function checkMandatoryFields ($ input )
129129 {
130- $ msg = array ();
130+ $ msg = array ();
131131 $ checkKo = false ;
132132
133133 $ mandatory_fields = array ('name ' => __ ("Object's name " , 'addressing ' ),
134- 'ip ' => _n ("IP address " , "IP addresses " , 1 ));
134+ 'ip ' => _n ("IP address " , "IP addresses " , 1 ));
135135
136136 foreach ($ input as $ key => $ value ) {
137137 if (isset ($ mandatory_fields [$ key ])) {
138138 if ((isset ($ value ) && empty ($ value )) || !isset ($ value )) {
139139 $ msg [$ key ] = $ mandatory_fields [$ key ];
140- $ checkKo = true ;
140+ $ checkKo = true ;
141141 }
142142 }
143143 }
@@ -201,8 +201,8 @@ function showForm($ip, $id_addressing, $randmodal)
201201 <td> " . __ ("Type " ) . "</td>
202202 <td> " ;
203203 Dropdown::showFromArray ('type ' , array (PluginAddressingReserveip::COMPUTER => Computer::getTypeName (),
204- PluginAddressingReserveip::NETWORK => NetworkEquipment::getTypeName (),
205- PluginAddressingReserveip::PRINTER => Printer::getTypeName ()), array ('on_change ' => "nameIsThere( \"" . $ CFG_GLPI ['root_doc ' ] . "\"); " ));
204+ PluginAddressingReserveip::NETWORK => NetworkEquipment::getTypeName (),
205+ PluginAddressingReserveip::PRINTER => Printer::getTypeName ()), array ('on_change ' => "nameIsThere( \"" . $ CFG_GLPI ['root_doc ' ] . "\"); " ));
206206 echo "</td><td></td> " ;
207207 echo "</tr> " ;
208208 echo "<tr class='tab_bg_1'>
@@ -239,7 +239,7 @@ function showForm($ip, $id_addressing, $randmodal)
239239 echo "<tr class='tab_bg_1'>
240240 <td colspan='4' class='center'>
241241 <input type='submit' name='add' class='submit' value=' " . __ ("Validate the reservation " , 'addressing ' ) . "' "
242- . "onclick= \"" . Html::jsGetElementbyID ("reserveip " . $ randmodal ) . ".dialog('close');window.location.reload();return true; \"/>
242+ . "onclick= \"" . Html::jsGetElementbyID ("reserveip " . $ randmodal ) . ".dialog('close');window.location.reload();return true; \"/>
243243 </td>
244244 </tr>
245245 </table> " ;
0 commit comments