login.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /* For license terms, see /license.txt */
  3. require __DIR__.'/../../main/inc/global.inc.php';
  4. $plugin = AzureActiveDirectory::create();
  5. $pluginEnabled = $plugin->get(AzureActiveDirectory::SETTING_ENABLE);
  6. $managementLoginEnabled = $plugin->get(AzureActiveDirectory::SETTING_MANAGEMENT_LOGIN_ENABLE);
  7. if ('true' !== $pluginEnabled || 'true' !== $managementLoginEnabled) {
  8. header('Location: '.api_get_path(WEB_PATH));
  9. exit;
  10. }
  11. $userId = api_get_user_id();
  12. if (!($userId) || api_is_anonymous($userId)) {
  13. $managementLoginName = $plugin->get(AzureActiveDirectory::SETTING_MANAGEMENT_LOGIN_NAME);
  14. if (empty($managementLoginName)) {
  15. $managementLoginName = $plugin->get_lang('ManagementLogin');
  16. }
  17. $template = new Template($managementLoginName);
  18. // Only display if the user isn't logged in.
  19. $template->assign('login_language_form', api_display_language_form(true, true));
  20. $template->assign('login_form', $template->displayLoginForm());
  21. $content = $template->fetch('azure_active_directory/view/login.tpl');
  22. $template->assign('content', $content);
  23. $template->display_one_col_template();
  24. }