3333// Purpose of file:
3434// ----------------------------------------------------------------------
3535
36+ use GlpiPlugin \Example \Dropdown ;
37+ use GlpiPlugin \Example \Example ;
38+ use Dropdown as GlpiDropdown ;
39+
3640// Hook called on profile change
3741// Good place to evaluate the user right on this plugin
3842// And to save it in the session
@@ -59,7 +63,7 @@ function plugin_example_getDatabaseRelations() {
5963// Define Dropdown tables to be manage in GLPI :
6064function plugin_example_getDropdown () {
6165 // Table => Name
62- return [' PluginExampleDropdown ' => __ ("Plugin Example Dropdown " , 'example ' )];
66+ return [Dropdown::class => __ ("Plugin Example Dropdown " , 'example ' )];
6367}
6468
6569
@@ -94,15 +98,15 @@ function plugin_example_getAddSearchOptionsNew($itemtype) {
9498 return $ options ;
9599}
96100
97- // See also PluginExampleExample ::getSpecificValueToDisplay()
101+ // See also GlpiPlugin\Example\Example ::getSpecificValueToDisplay()
98102function plugin_example_giveItem ($ type , $ ID , $ data , $ num ) {
99103 $ searchopt = &Search::getOptions ($ type );
100104 $ table = $ searchopt [$ ID ]["table " ];
101105 $ field = $ searchopt [$ ID ]["field " ];
102106
103107 switch ($ table .'. ' .$ field ) {
104108 case "glpi_plugin_example_examples.name " :
105- $ out = "<a href=' " .Toolbox::getItemTypeFormURL (' PluginExampleExample ' )."?id= " .$ data ['id ' ]."'> " ;
109+ $ out = "<a href=' " .Toolbox::getItemTypeFormURL (Example::class )."?id= " .$ data ['id ' ]."'> " ;
106110 $ out .= $ data [$ num ][0 ]['name ' ];
107111 if ($ _SESSION ["glpiis_ids_visible " ] || empty ($ data [$ num ][0 ]['name ' ])) {
108112 $ out .= " ( " .$ data ["id " ].") " ;
@@ -133,7 +137,7 @@ function plugin_example_addDefaultJoin($type, $ref_table, &$already_link_tables)
133137 // Example of default JOIN clause
134138 // No need of the function if you do not have specific cases
135139 switch ($ type ) {
136- // case "PluginExampleExample" :
140+ // case Example::class :
137141 case "MyType " :
138142 return Search::addLeftJoin ($ type , $ ref_table , $ already_link_tables ,
139143 "newtable " , "linkfield " );
@@ -146,7 +150,7 @@ function plugin_example_addDefaultSelect($type) {
146150 // Example of default SELECT item to be added
147151 // No need of the function if you do not have specific cases
148152 switch ($ type ) {
149- // case "PluginExampleExample" :
153+ // case Example::class :
150154 case "MyType " :
151155 return "`mytable`.`myfield` = 'myvalue' AS MYNAME, " ;
152156 }
@@ -158,7 +162,7 @@ function plugin_example_addDefaultWhere($type) {
158162 // Example of default WHERE item to be added
159163 // No need of the function if you do not have specific cases
160164 switch ($ type ) {
161- // case "PluginExampleExample" :
165+ // case Example::class :
162166 case "MyType " :
163167 return " `mytable`.`myfield` = 'myvalue' " ;
164168 }
@@ -179,7 +183,7 @@ function plugin_example_addLeftJoin($type, $ref_table, $new_table, $linkfield) {
179183
180184function plugin_example_forceGroupBy ($ type ) {
181185 switch ($ type ) {
182- case ' PluginExampleExample ' :
186+ case Example::class :
183187 // Force add GROUP BY IN REQUEST
184188 return true ;
185189 }
@@ -272,7 +276,7 @@ function plugin_example_MassiveActions($type) {
272276 switch ($ type ) {
273277 // New action for core and other plugin types : name = plugin_PLUGINNAME_actionname
274278 case 'Computer ' :
275- return [' PluginExampleExample ' . MassiveAction::CLASS_ACTION_SEPARATOR . 'DoIt ' =>
279+ return [Example::class . MassiveAction::CLASS_ACTION_SEPARATOR . 'DoIt ' =>
276280 __ ("plugin_example_DoIt " , 'example ' )];
277281
278282 // Actions for types provided by the plugin are included inside the classes
@@ -325,7 +329,7 @@ function plugin_example_searchOptionsValues($options = []) {
325329 switch ($ table .". " .$ field ) {
326330 case "glpi_plugin_example_examples.serial " :
327331 echo __ ("Not really specific - Use your own dropdown - Just for example " , 'example ' );
328- Dropdown ::show (getItemTypeForTable ($ options ['searchoption ' ]['table ' ]),
332+ GlpiDropdown ::show (getItemTypeForTable ($ options ['searchoption ' ]['table ' ]),
329333 ['value ' => $ options ['value ' ],
330334 'name ' => $ options ['name ' ],
331335 'comments ' => 0 ]);
@@ -427,7 +431,7 @@ function plugin_item_transfer_example($parm) {
427431
428432// Do special actions for dynamic report
429433function plugin_example_dynamicReport ($ parm ) {
430- if ($ parm ["item_type " ] == ' PluginExampleExample ' ) {
434+ if ($ parm ["item_type " ] == Example::class ) {
431435 // Do all what you want for export depending on $parm
432436 echo "Personalized export for type " .$ parm ["display_type " ];
433437 echo 'with additional datas : <br> ' ;
@@ -445,7 +449,7 @@ function plugin_example_dynamicReport($parm) {
445449
446450// Add parameters to Html::printPager in search system
447451function plugin_example_addParamFordynamicReport ($ itemtype ) {
448- if ($ itemtype == ' PluginExampleExample ' ) {
452+ if ($ itemtype == Example::class ) {
449453 // Return array data containing all params to add : may be single data or array data
450454 // Search config are available from session variable
451455 return ['add1 ' => $ _SESSION ['glpisearch ' ][$ itemtype ]['order ' ],
@@ -551,7 +555,7 @@ function plugin_example_install() {
551555
552556 // To be called for each task the plugin manage
553557 // task in class
554- CronTask::Register (' PluginExampleExample ' , 'Sample ' , DAY_TIMESTAMP , ['param ' => 50 ]);
558+ CronTask::Register (Example::class , 'Sample ' , DAY_TIMESTAMP , ['param ' => 50 ]);
555559 return true ;
556560}
557561
@@ -607,7 +611,7 @@ function plugin_example_uninstall() {
607611
608612
609613function plugin_example_AssignToTicket ($ types ) {
610- $ types [' PluginExampleExample ' ] = "Example " ;
614+ $ types [Example::class ] = "Example " ;
611615 return $ types ;
612616}
613617
0 commit comments