@@ -49,7 +49,6 @@ public static function getTypeName($nb = 0) {
4949 return __ ('Tree view ' , 'treeview ' );
5050 }
5151
52-
5352 /**
5453 * Configuration form
5554 **/
@@ -156,7 +155,6 @@ function showForm($id, $options=array()) {
156155 Html::closeForm ();
157156 }
158157
159-
160158 /**
161159 * For other plugins, add a type to the linkable types
162160 *
@@ -197,10 +195,9 @@ static function getTypes($all=false) {
197195 }
198196 return $ types ;
199197 }
200-
198+
201199 static function getPicbyType ($ type ) {
202200 global $ PLUGIN_HOOKS ;
203-
204201 $ pic = '' ;
205202 switch ($ type ) {
206203 case 'Computer ' :
@@ -226,14 +223,11 @@ static function getPicbyType($type) {
226223 break ;
227224 }
228225 //Like $PLUGIN_HOOKS['treeview']['PluginExampleExample'] = '../example/pics/mypic.png';
229- if (in_array ($ type , self ::$ types )
230- && isPluginItemtype ($ type )) {
231- if (isset ($ PLUGIN_HOOKS ['treeview ' ][$ type ])) {
232- return $ PLUGIN_HOOKS ['treeview ' ][$ type ];
233- }
234-
226+ if (in_array ($ type , self ::$ types ) && isPluginItemtype ($ type )) {
227+ if (isset ($ PLUGIN_HOOKS ['treeview ' ][$ type ])) {
228+ return $ PLUGIN_HOOKS ['treeview ' ][$ type ];
229+ }
235230 }
236-
237231 return $ pic ;
238232 }
239233
@@ -296,7 +290,7 @@ function hideTreeview() {
296290 function buildTreeview () {
297291 global $ CFG_GLPI ;
298292
299- # necessary files needed for the tree to work.
293+ // necessary files needed for the tree to work.
300294 echo "<link rel='stylesheet' type='text/css' href=' " .
301295 $ CFG_GLPI ["root_doc " ]."/plugins/treeview/dtree.css' type= \"text/css \" > \n" ;
302296 echo "<script type='text/javascript' src=' " .$ CFG_GLPI ["root_doc " ].
@@ -327,15 +321,13 @@ function getNodesFromDb() {
327321
328322 $ itemName = $ this ->fields ["itemName " ];
329323 $ locationName = $ this ->fields ["locationName " ];
330-
331324 $ target = $ this ->fields ["target " ];
332325 $ folderLinks = $ this ->fields ["folderLinks " ];
333326 $ useSelection = $ this ->fields ["useSelection " ];
334327 $ useLines = $ this ->fields ["useLines " ];
335328 $ useIcons = $ this ->fields ["useIcons " ];
336329 $ closeSameLevel = $ this ->fields ["closeSameLevel " ];
337330
338-
339331 // Load the settings in JavaSript so that dTree script can apply them
340332 echo "d.config.target = ' " .$ target . "'; \n" ;
341333 echo "d.config.folderLinks = " .$ folderLinks . "; \n" ;
@@ -350,9 +342,9 @@ function getNodesFromDb() {
350342 $ query = " SELECT MAX(`id`) AS `max_id`,
351343 MAX(`level`) AS `max_level`
352344 FROM `glpi_locations` " ;
353-
354- $ query .= getEntitiesRestrictRequest (" WHERE " ,"glpi_locations " ,'' ,'' ,true );
355-
345+
346+ $ query .= getEntitiesRestrictRequest (" WHERE " , "glpi_locations " , '' , '' , true );
347+
356348 $ result = $ DB ->query ($ query );
357349
358350 $ max_level = $ DB ->result ($ result , 0 , "max_level " );
@@ -380,16 +372,16 @@ function getNodesFromDb() {
380372 "\r" =>" " ,
381373 "\n" =>" " );
382374
383- for ($ n =1 ; $ n <=count ($ nodes ) ; $ n ++) {
375+ for ($ n =1 ; $ n <=count ($ nodes ); $ n ++) {
384376 if ($ nodes [$ n -1 ] <= $ max_id && $ n <= $ max_level ) {
385377 $ query = "SELECT *
386378 FROM `glpi_locations`
387379 WHERE `level` = ' $ n'
388380 AND `locations_id` = ' " . $ nodes [$ n -1 ] ."' " ;
389-
390- $ query .= getEntitiesRestrictRequest (" AND " ,"glpi_locations " ,'' ,'' ,true );
381+
382+ $ query .= getEntitiesRestrictRequest (" AND " , "glpi_locations " , '' , '' , true );
391383 $ query .= "ORDER BY `completename` ASC " ;
392-
384+
393385 $ result = $ DB ->query ($ query );
394386
395387 while ($ r = $ DB ->fetch_assoc ($ result )) {
@@ -415,7 +407,7 @@ function getNodesFromDb() {
415407
416408 // Is this location requested by the user to be opened
417409 if (in_array ($ r ['id ' ], $ nodes )) {
418- echo "d.add( " .$ r ['id ' ].", " .$ r ['locations_id ' ].", \"" .strtr ($ l_name ,$ trans ).
410+ echo "d.add( " .$ r ['id ' ].", " .$ r ['locations_id ' ].", \"" .strtr ($ l_name , $ trans ).
419411 "\", true, -1,''); \n" ;
420412 $ dontLoad = 'true ' ;
421413 // Then add aloso its items
@@ -426,20 +418,20 @@ function getNodesFromDb() {
426418 $ query = "SELECT *
427419 FROM ` $ itemtable`
428420 WHERE `locations_id` = ' " .$ r ['id ' ]."' " ;
429-
421+
430422 if ($ item ->maybeTemplate ()) {
431423 $ query .= " AND ` $ itemtable`.`is_template` = '0' " ;
432424 }
433425 if ($ item ->maybeDeleted ()) {
434426 $ query .= " AND ` $ itemtable`.`is_deleted` = '0' " ;
435427 }
436-
428+
437429 if ($ this ->isEntityAssign ()) {
438430 $ query .= " AND ` $ itemtable`.`entities_id` = ' " .$ _SESSION ["glpiactive_entity " ]."' " ;
439431 }
440-
432+
441433 $ query .= " ORDER BY ` $ itemtable`.`name` " ;
442-
434+
443435 $ result_1 = $ DB ->query ($ query );
444436 if ($ DB ->numrows ($ result_1 )) {
445437 $ pid = $ tv_id ;
@@ -497,32 +489,32 @@ function getNodesFromDb() {
497489 $ i_name = $ r_1 ['name ' ];
498490 }
499491 }
500-
492+
501493 $ url = Toolbox::getItemTypeFormURL ($ type ). "?id= " .$ r_1 ['id ' ];
502494 $ pic = "pics/node.gif " ;
503- $ name = strtr ($ i_name ,$ trans );
495+ $ name = strtr ($ i_name , $ trans );
504496 $ opt = array ('url ' => $ url ,
505497 'pic ' => $ pic ,
506498 'name ' => $ name );
507-
499+
508500 $ params = array ('itemtype ' => $ type ,
509501 'id ' => $ r_1 ['id ' ],
510502 'url ' => $ url ,
511503 'pic ' => $ pic ,
512504 'name ' => $ name );
513-
505+
514506 $ opt = Plugin::doHookFunction ('treeview_params ' , $ params );
515507
516508 // Add the item
517509 echo "d.add( " .$ tv_id ++.", $ pid, \"" . $ opt ['name ' ] . "\", true, -1, ' " .
518510 $ opt ['url ' ]."', '', '', ' " .$ opt ['pic ' ]."',' " .$ opt ['pic ' ]."'); \n" ;
519-
511+
520512 }
521513 }
522514
523- // Add only the location without its items
515+ // Add only the location without its items
524516 } else {
525- echo "d.add( " .$ r ['id ' ].", " .$ r ['locations_id ' ].", \"" .strtr ($ l_name ,$ trans ).
517+ echo "d.add( " .$ r ['id ' ].", " .$ r ['locations_id ' ].", \"" .strtr ($ l_name , $ trans ).
526518 "\", false, -1,'', '', '', '', '', false, true); \n" ;
527519 }
528520 }
@@ -539,5 +531,4 @@ function getNodesFromDb() {
539531 echo "d.openTo( " .$ nodes [count ($ nodes )-1 ]. "); \n" ;
540532 }
541533 }
542- }
543- ?>
534+ }
0 commit comments