setup.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. define('PLUGIN_SINGLESIGNON_VERSION', '1.0.0');
  3. // Init the hooks of the plugins -Needed
  4. function plugin_init_singlesignon() {
  5. global $PLUGIN_HOOKS, $CFG_GLPI, $CFG_SSO;
  6. $autoload = __DIR__ . '/vendor/autoload.php';
  7. if (file_exists($autoload)) {
  8. include_once $autoload;
  9. }
  10. $PLUGIN_HOOKS['csrf_compliant']['singlesignon'] = true;
  11. $CFG_SSO = Config::getConfigurationValues('singlesignon');
  12. $PLUGIN_HOOKS['display_login']['singlesignon'] = "plugin_singlesignon_display_login";
  13. $PLUGIN_HOOKS['menu_toadd']['singlesignon'] = array(
  14. 'config' => 'PluginSinglesignonProvider',
  15. );
  16. }
  17. // Get the name and the version of the plugin - Needed
  18. function plugin_version_singlesignon() {
  19. return array(
  20. 'name' => __sso('Single Sign-on'),
  21. 'version' => PLUGIN_SINGLESIGNON_VERSION,
  22. 'author' => 'Edgard Lorraine Messias',
  23. 'homepage' => 'https://github.com/edgardmessias/glpi-singlesignon',
  24. 'minGlpiVersion' => '0.85'
  25. );
  26. }
  27. // Optional : check prerequisites before install : may print errors or add to message after redirect
  28. function plugin_singlesignon_check_prerequisites() {
  29. $autoload = __DIR__ . '/vendor/autoload.php';
  30. if (!file_exists($autoload)) {
  31. echo __sso("Run first: composer install");
  32. return false;
  33. }
  34. if (version_compare(GLPI_VERSION, '0.85', 'lt')) {
  35. echo __sso("This plugin requires GLPI >= 0.85");
  36. return false;
  37. } else {
  38. return true;
  39. }
  40. }
  41. function plugin_singlesignon_check_config() {
  42. return true;
  43. }
  44. function __sso($str) {
  45. return __($str, 'singlesignon');
  46. }
  47. function sso_TableExists($table) {
  48. if (function_exists("TableExists")) {
  49. return TableExists($table);
  50. }
  51. global $DB;
  52. return $DB->TableExists($table);
  53. }
  54. function sso_FieldExists($table, $field, $usecache = true) {
  55. if (function_exists("FieldExists")) {
  56. return FieldExists($table);
  57. }
  58. global $DB;
  59. return $DB->FieldExists($table, $field, $usecache);
  60. }