3333define ('GLPI_KEEP_CSRF_TOKEN ' , true ); // 0.90
3434$ token = (isset ($ _POST ['_glpi_csrf_token ' ]) ? $ _POST ['_glpi_csrf_token ' ] : false );
3535
36- include ( " ../../../inc/includes.php " );
36+ include ( ' ../../../inc/includes.php ' );
3737
3838/* 0.85 Hack to allow multiple exports, yes this is an hack, yes an awful one */
3939if (!isset ($ _SESSION ['glpicsrftokens ' ][$ token ])) {
40- $ _SESSION ['glpicsrftokens ' ][$ token ] = time () + GLPI_CSRF_EXPIRES ;
40+ $ _SESSION ['glpicsrftokens ' ][$ token ] = time () + GLPI_CSRF_EXPIRES ;
4141}
4242
4343Plugin::load ('pdf ' , true );
4444
4545$ dbu = new DbUtils ();
4646
47- if (isset ($ _POST ["plugin_pdf_inventory_type " ])
48- && ($ item = $ dbu ->getItemForItemtype ($ _POST ["plugin_pdf_inventory_type " ]))
49- && isset ($ _POST ["itemID " ])) {
47+ if (isset ($ _POST ['plugin_pdf_inventory_type ' ])
48+ && ($ item = $ dbu ->getItemForItemtype ($ _POST ['plugin_pdf_inventory_type ' ]))
49+ && isset ($ _POST ['itemID ' ])) {
50+ $ type = $ _POST ['plugin_pdf_inventory_type ' ];
51+ $ item ->check ($ _POST ['itemID ' ], READ );
5052
51- $ type = $ _POST ["plugin_pdf_inventory_type " ];
52- $ item ->check ($ _POST ["itemID " ], READ );
53+ if (isset ($ _SESSION ['plugin_pdf ' ][$ type ])) {
54+ unset($ _SESSION ['plugin_pdf ' ][$ type ]);
55+ }
5356
54- if (isset ($ _SESSION ["plugin_pdf " ][$ type ])) {
55- unset($ _SESSION ["plugin_pdf " ][$ type ]);
56- }
57+ $ tab = [];
5758
58- $ tab = [];
59+ if (isset ($ _POST ['item ' ])) {
60+ foreach ($ _POST ['item ' ] as $ key => $ val ) {
61+ if (!in_array ($ key , $ tab )) {
62+ $ tab [] = $ _SESSION ['plugin_pdf ' ][$ type ][] = $ key ;
63+ }
64+ }
65+ }
66+ if (empty ($ tab )) {
67+ $ tab [] = $ type . '$main ' ;
68+ }
5969
60- if (isset ($ _POST ['item ' ])) {
61- foreach ($ _POST ['item ' ] as $ key => $ val ) {
62- if (!in_array ($ key , $ tab )) {
63- $ tab [] = $ _SESSION ["plugin_pdf " ][$ type ][] = $ key ;
64- }
65- }
66- }
67- if (empty ($ tab )) {
68- $ tab [] = $ type .'$main ' ;
69- }
70-
71- if (isset ($ PLUGIN_HOOKS ['plugin_pdf ' ][$ type ])
72- && class_exists ($ PLUGIN_HOOKS ['plugin_pdf ' ][$ type ])) {
73-
74- $ itempdf = new $ PLUGIN_HOOKS ['plugin_pdf ' ][$ type ]($ item );
75- $ itempdf ->generatePDF ([$ _POST ["itemID " ]], $ tab , (isset ($ _POST ["page " ]) ? $ _POST ["page " ] : 0 ));
76- } else {
77- die ("Missing hook " );
78- }
70+ if (isset ($ PLUGIN_HOOKS ['plugin_pdf ' ][$ type ])
71+ && class_exists ($ PLUGIN_HOOKS ['plugin_pdf ' ][$ type ])) {
72+ $ itempdf = new $ PLUGIN_HOOKS ['plugin_pdf ' ][$ type ]($ item );
73+ $ itempdf ->generatePDF ([$ _POST ['itemID ' ]], $ tab , (isset ($ _POST ['page ' ]) ? $ _POST ['page ' ] : 0 ));
74+ } else {
75+ die ('Missing hook ' );
76+ }
7977} else {
80- die (" Missing context " );
81- }
78+ die (' Missing context ' );
79+ }
0 commit comments