provider.form.php 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**
  3. * ---------------------------------------------------------------------
  4. * SingleSignOn is a plugin which allows to use SSO for auth
  5. * ---------------------------------------------------------------------
  6. * Copyright (C) 2022 Edgard
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. * ---------------------------------------------------------------------
  21. * @copyright Copyright © 2021 - 2022 Edgard
  22. * @license http://www.gnu.org/licenses/gpl.txt GPLv3+
  23. * @link https://github.com/edgardmessias/glpi-singlesignon/
  24. * ---------------------------------------------------------------------
  25. */
  26. use Glpi\Event;
  27. include ('../../../inc/includes.php');
  28. Session::checkRight("config", UPDATE);
  29. if (!isset($_GET["id"])) {
  30. $_GET["id"] = "";
  31. }
  32. $provider = new PluginSinglesignonProvider();
  33. if (isset($_POST["add"])) {
  34. $provider->check(-1, CREATE, $_POST);
  35. if ($newID = $provider->add($_POST)) {
  36. Event::log($newID, "singlesignon", 4, "provider",
  37. sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["name"]));
  38. if ($_SESSION['glpibackcreated']) {
  39. Html::redirect($provider->getLinkURL());
  40. }
  41. }
  42. Html::back();
  43. } else if (isset($_POST["delete"])) {
  44. $provider->check($_POST["id"], DELETE);
  45. $provider->delete($_POST);
  46. Event::log($_POST["id"], "singlesignon", 4, "provider",
  47. //TRANS: %s is the user login
  48. sprintf(__('%s deletes an item'), $_SESSION["glpiname"]));
  49. $provider->redirectToList();
  50. } else if (isset($_POST["restore"])) {
  51. $provider->check($_POST["id"], DELETE);
  52. $provider->restore($_POST);
  53. Event::log($_POST["id"], "singlesignon", 4, "provider",
  54. //TRANS: %s is the user login
  55. sprintf(__('%s restores an item'), $_SESSION["glpiname"]));
  56. $provider->redirectToList();
  57. } else if (isset($_POST["purge"])) {
  58. $provider->check($_POST["id"], PURGE);
  59. $provider->delete($_POST, 1);
  60. Event::log($_POST["id"], "singlesignon", 4, "provider",
  61. //TRANS: %s is the user login
  62. sprintf(__('%s purges an item'), $_SESSION["glpiname"]));
  63. $provider->redirectToList();
  64. } else if (isset($_POST["update"])) {
  65. $provider->check($_POST["id"], UPDATE);
  66. $provider->update($_POST);
  67. Event::log($_POST["id"], "singlesignon", 4, "provider",
  68. //TRANS: %s is the user login
  69. sprintf(__('%s updates an item'), $_SESSION["glpiname"]));
  70. Html::back();
  71. } else {
  72. if ($_SESSION["glpiactiveprofile"]["interface"] == "central") {
  73. Html::header(__sso('Single Sign-on'), $_SERVER['PHP_SELF'], "config", "pluginsinglesignonprovider", "");
  74. } else {
  75. Html::helpHeader(__sso('Single Sign-on'), $_SERVER['PHP_SELF']);
  76. }
  77. $provider->display($_GET);
  78. }
  79. Html::footer();