diff --git a/plugin/azure_active_directory/index.php b/plugin/azure_active_directory/index.php index a63dfce7fa..2f9183f341 100644 --- a/plugin/azure_active_directory/index.php +++ b/plugin/azure_active_directory/index.php @@ -17,4 +17,18 @@ if ($activeDirectoryPlugin->get(AzureActiveDirectory::SETTING_ENABLE) === 'true' if ('true' === $activeDirectoryPlugin->get(AzureActiveDirectory::SETTING_FORCE_LOGOUT_BUTTON)) { $_template['signout_url'] = $activeDirectoryPlugin->getUrl(AzureActiveDirectory::URL_TYPE_LOGOUT); } + + $managementLoginEnabled = 'true' === $activeDirectoryPlugin->get(AzureActiveDirectory::SETTING_MANAGEMENT_LOGIN_ENABLE); + + $_template['management_login_enabled'] = $managementLoginEnabled; + + if ($managementLoginEnabled) { + $managementLoginName = $activeDirectoryPlugin->get(AzureActiveDirectory::SETTING_MANAGEMENT_LOGIN_NAME); + + if (empty($managementLoginName)) { + $managementLoginName = $activeDirectoryPlugin->get_lang('ManagementLogin'); + } + + $_template['management_login_name'] = $managementLoginName; + } } diff --git a/plugin/azure_active_directory/lang/english.php b/plugin/azure_active_directory/lang/english.php index 77c2d83c09..3360e792c7 100644 --- a/plugin/azure_active_directory/lang/english.php +++ b/plugin/azure_active_directory/lang/english.php @@ -17,5 +17,11 @@ $strings['app_secret'] = 'Application secret'; $strings['force_logout'] = 'Force logout button'; $strings['force_logout_help'] = 'Show a button to force logout session from Azure.'; $strings['block_name'] = 'Block name'; +$strings['management_login_enable'] = 'Management login'; +$strings['management_login_enable_help'] = 'Disable the chamilo login and enable an alternative login page for users.
' + .'You will need copy the /plugin/azure_active_directory/layout/login_form.tpl file to /main/template/overrides/layout/ directory.'; +$strings['management_login_name'] = 'Name for the management login'; +$strings['management_login_name_help'] = 'By default is "Management Login".'; $strings['OrganisationEmail'] = 'Organisation e-mail'; $strings['AzureId'] = 'Azure ID (mailNickname)'; +$strings['ManagementLogin'] = 'Management Login'; diff --git a/plugin/azure_active_directory/layout/login_form.tpl b/plugin/azure_active_directory/layout/login_form.tpl new file mode 100644 index 0000000000..bed575acaf --- /dev/null +++ b/plugin/azure_active_directory/layout/login_form.tpl @@ -0,0 +1,44 @@ +{% if _u.logged == 0 %} + {% if login_form %} +
+
+ {{ login_language_form }} + {% if plugin_login_top is not null %} +
+ {{ plugin_login_top }} +
+ {% endif %} + + {{ login_failed }} + + {% set azure_plugin_enabled = 'azure_active_directory'|api_get_plugin_setting('enable') %} + {% set azure_plugin_manage_login = 'azure_active_directory'|api_get_plugin_setting('manage_login_enable') %} + + {% if 'false' == azure_plugin_enabled or 'false' == azure_plugin_manage_login %} + {{ login_form }} + + {% if "allow_lostpassword" | api_get_setting == 'true' or "allow_registration"|api_get_setting == 'true' %} + + {% endif %} + + {% endif %} + + {% if plugin_login_bottom is not null %} +
+ {{ plugin_login_bottom }} +
+ {% endif %} +
+
+ {% endif %} +{% endif %} diff --git a/plugin/azure_active_directory/login.php b/plugin/azure_active_directory/login.php new file mode 100644 index 0000000000..a6f790f4bb --- /dev/null +++ b/plugin/azure_active_directory/login.php @@ -0,0 +1,35 @@ +get(AzureActiveDirectory::SETTING_ENABLE); +$managementLoginEnabled = $plugin->get(AzureActiveDirectory::SETTING_MANAGEMENT_LOGIN_ENABLE); + +if ('true' !== $pluginEnabled || 'true' !== $managementLoginEnabled) { + header('Location: '.api_get_path(WEB_PATH)); + + exit; +} + +$userId = api_get_user_id(); + +if (!($userId) || api_is_anonymous($userId)) { + $managementLoginName = $plugin->get(AzureActiveDirectory::SETTING_MANAGEMENT_LOGIN_NAME); + + if (empty($managementLoginName)) { + $managementLoginName = $plugin->get_lang('ManagementLogin'); + } + + $template = new Template($managementLoginName); + // Only display if the user isn't logged in. + $template->assign('login_language_form', api_display_language_form(true, true)); + $template->assign('login_form', $template->displayLoginForm()); + + $content = $template->fetch('azure_active_directory/view/login.tpl'); + + $template->assign('content', $content); + $template->display_one_col_template(); +} diff --git a/plugin/azure_active_directory/src/AzureActiveDirectory.php b/plugin/azure_active_directory/src/AzureActiveDirectory.php index f2566c1317..bd310912a1 100644 --- a/plugin/azure_active_directory/src/AzureActiveDirectory.php +++ b/plugin/azure_active_directory/src/AzureActiveDirectory.php @@ -17,6 +17,8 @@ class AzureActiveDirectory extends Plugin const SETTING_APP_SECRET = 'app_secret'; const SETTING_BLOCK_NAME = 'block_name'; const SETTING_FORCE_LOGOUT_BUTTON = 'force_logout'; + const SETTING_MANAGEMENT_LOGIN_ENABLE = 'management_login_enable'; + const SETTING_MANAGEMENT_LOGIN_NAME = 'management_login_name'; const URL_TYPE_AUTHORIZE = 'login'; const URL_TYPE_LOGOUT = 'logout'; @@ -35,6 +37,8 @@ class AzureActiveDirectory extends Plugin self::SETTING_APP_SECRET => 'text', self::SETTING_BLOCK_NAME => 'text', self::SETTING_FORCE_LOGOUT_BUTTON => 'boolean', + self::SETTING_MANAGEMENT_LOGIN_ENABLE => 'boolean', + self::SETTING_MANAGEMENT_LOGIN_NAME => 'text', ]; parent::__construct('2.0', 'Angel Fernando Quiroz Campos', $settings); diff --git a/plugin/azure_active_directory/view/block.tpl b/plugin/azure_active_directory/view/block.tpl index b8b53638dc..af7928256b 100644 --- a/plugin/azure_active_directory/view/block.tpl +++ b/plugin/azure_active_directory/view/block.tpl @@ -11,5 +11,12 @@ {% if not azure_active_directory.signout_url is empty %} {{ 'Logout'|get_lang }} {% endif %} + + {% if azure_active_directory.management_login_enabled %} +
+ + {{ azure_active_directory.management_login_name }} + + {% endif %} {% endif %} diff --git a/plugin/azure_active_directory/view/login.tpl b/plugin/azure_active_directory/view/login.tpl new file mode 100644 index 0000000000..fc86f27e20 --- /dev/null +++ b/plugin/azure_active_directory/view/login.tpl @@ -0,0 +1,19 @@ +
+
+ {{ login_language_form }} + + {{ login_form }} + + {% if "allow_lostpassword"|api_get_setting == 'true' or "allow_registration"|api_get_setting == 'true' %} + + {% endif %} +
+