logoff.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. // Copyright (C) 2010-2013 Combodo SARL
  3. //
  4. // This file is part of iTop.
  5. //
  6. // iTop is free software; you can redistribute it and/or modify
  7. // it under the terms of the GNU Affero General Public License as published by
  8. // the Free Software Foundation, either version 3 of the License, or
  9. // (at your option) any later version.
  10. //
  11. // iTop is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. // GNU Affero General Public License for more details.
  15. //
  16. // You should have received a copy of the GNU Affero General Public License
  17. // along with iTop. If not, see <http://www.gnu.org/licenses/>
  18. require_once('../approot.inc.php');
  19. require_once(APPROOT.'/application/application.inc.php');
  20. require_once(APPROOT.'/application/itopwebpage.class.inc.php');
  21. require_once(APPROOT.'/application/wizardhelper.class.inc.php');
  22. require_once(APPROOT.'/application/startup.inc.php');
  23. $oAppContext = new ApplicationContext();
  24. $currentOrganization = utils::ReadParam('org_id', '');
  25. $operation = utils::ReadParam('operation', '');
  26. require_once(APPROOT.'/application/loginwebpage.class.inc.php');
  27. require_once(APPROOT.'/application/ajaxwebpage.class.inc.php');
  28. $bPortal = utils::ReadParam('portal', false);
  29. $sUrl = utils::GetAbsoluteUrlAppRoot();
  30. if ($operation == 'do_logoff')
  31. {
  32. // Reload the same dummy page to let the "calling" page execute its 'onunload' method before performing the actual logoff.
  33. // Note the redirection MUST NOT be made via an HTTP "header" since onunload is called only when the actual content of the DOM
  34. // is replaced by some other content. So the "bouncing" page must provide some content (in our case a script making the redirection).
  35. $oPage = new ajax_page('');
  36. $oPage->add_script("window.location.href='{$sUrl}pages/logoff.php?portal=$bPortal'");
  37. $oPage->output();
  38. exit;
  39. }
  40. if ($bPortal)
  41. {
  42. $sUrl .= 'portal/';
  43. }
  44. else
  45. {
  46. $sUrl .= 'pages/UI.php';
  47. }
  48. if (isset($_SESSION['auth_user']))
  49. {
  50. $sAuthUser = $_SESSION['auth_user'];
  51. UserRights::Login($sAuthUser); // Set the user's language
  52. }
  53. $sLoginMode = isset($_SESSION['login_mode']) ? $_SESSION['login_mode'] : '';
  54. LoginWebPage::ResetSession();
  55. switch($sLoginMode)
  56. {
  57. case 'cas':
  58. $sCASLogoutUrl = MetaModel::GetConfig()->Get('cas_logout_redirect_service');
  59. if (empty($sCASLogoutUrl))
  60. {
  61. $sCASLogoutUrl = $sUrl;
  62. }
  63. utils::InitCASClient();
  64. phpCAS::logoutWithRedirectService($sCASLogoutUrl); // Redirects to the CAS logout page
  65. break;
  66. }
  67. $oPage = LoginWebPage::NewLoginWebPage();
  68. $oPage->no_cache();
  69. $oPage->DisplayLoginHeader();
  70. $oPage->add("<div id=\"login\">\n");
  71. $oPage->add("<h1>".Dict::S('UI:LogOff:ThankYou')."</h1>\n");
  72. $oPage->add("<p><a href=\"$sUrl\">".Dict::S('UI:LogOff:ClickHereToLoginAgain')."</a></p>");
  73. $oPage->add("</div>\n");
  74. $oPage->output();
  75. ?>