action.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. //Sauvegarde des configurations de glpi
  3. Action::register('glpi_setting_save',function(&$response){
  4. global $myUser,$_,$conf;
  5. User::check_access('glpi','configure');
  6. //Si input file "multiple", possibilité de normlaiser le
  7. //tableau $_FILES récupéré avec la fonction => normalize_php_files();
  8. foreach(Configuration::setting('glpi') as $key=>$value){
  9. if(!is_array($value)) continue;
  10. $allowed[] = $key;
  11. }
  12. foreach ($_['fields'] as $key => $value) {
  13. if(in_array($key, $allowed))
  14. $conf->put($key,$value);
  15. }
  16. });
  17. Action::register('glpi_widget_load',function(&$response){
  18. global $myUser;
  19. require_once(PLUGIN_PATH.'dashboard'.SLASH.'DashboardWidget.class.php');
  20. User::check_access('glpi','read');
  21. $widget = DashboardWidget::current();
  22. $widget->title = 'Widget Glpi';
  23. ob_start();
  24. require_once(__DIR__.SLASH.'widget.php');
  25. $widget->content = ob_get_clean();
  26. echo json_encode($widget);
  27. exit();
  28. });
  29. Action::register('glpi_widget_glpi_configure',function(&$response){
  30. global $myUser;
  31. User::check_access('glpi','configure');
  32. require_once(PLUGIN_PATH.'dashboard'.SLASH.'DashboardWidget.class.php');
  33. $widget = DashboardWidget::current();
  34. ob_start();
  35. require_once(__DIR__.SLASH.'widget.configure.php');
  36. $content = ob_get_clean();
  37. echo $content ;
  38. exit();
  39. });
  40. Action::register('glpi_widget_glpi_configure_save',function(&$response){
  41. global $myUser,$_;
  42. User::check_access('glpi','configure');
  43. require_once(PLUGIN_PATH.'dashboard'.SLASH.'DashboardWidget.class.php');
  44. $widget = DashboardWidget::getById($_['id']);
  45. $widget->data('service',$_['widget-glpi-service']);
  46. $widget->data('newHours',$_['widget-glpi-new-hours']);
  47. $widget->save();
  48. });
  49. ?>