Skip to content

Commit 702672c

Browse files
committed
Plugin: AzureActiveDirectory: Fix error when loading index file as standalone
1 parent 3740eec commit 702672c

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

plugin/azure_active_directory/index.php

+20-16
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,33 @@
66
* @package chamilo.plugin.azure_active_directory
77
*/
88

9-
/** @var AzureActiveDirectory $activeDirectoryPlugin */
10-
$activeDirectoryPlugin = AzureActiveDirectory::create();
9+
// Check if AzureActiveDirectory exists, since this is not loaded as a page.
10+
// index.php is shown as a block when showing the region to which the plugin is assigned
11+
if (class_exists(AzureActiveDirectory::class)) {
12+
/** @var AzureActiveDirectory $activeDirectoryPlugin */
13+
$activeDirectoryPlugin = AzureActiveDirectory::create();
1114

12-
if ($activeDirectoryPlugin->get(AzureActiveDirectory::SETTING_ENABLE) === 'true') {
13-
$_template['block_title'] = $activeDirectoryPlugin->get(AzureActiveDirectory::SETTING_BLOCK_NAME);
15+
if ($activeDirectoryPlugin->get(AzureActiveDirectory::SETTING_ENABLE) === 'true') {
16+
$_template['block_title'] = $activeDirectoryPlugin->get(AzureActiveDirectory::SETTING_BLOCK_NAME);
1417

15-
$_template['signin_url'] = $activeDirectoryPlugin->getUrl(AzureActiveDirectory::URL_TYPE_AUTHORIZE);
18+
$_template['signin_url'] = $activeDirectoryPlugin->getUrl(AzureActiveDirectory::URL_TYPE_AUTHORIZE);
1619

17-
if ('true' === $activeDirectoryPlugin->get(AzureActiveDirectory::SETTING_FORCE_LOGOUT_BUTTON)) {
18-
$_template['signout_url'] = $activeDirectoryPlugin->getUrl(AzureActiveDirectory::URL_TYPE_LOGOUT);
19-
}
20+
if ('true' === $activeDirectoryPlugin->get(AzureActiveDirectory::SETTING_FORCE_LOGOUT_BUTTON)) {
21+
$_template['signout_url'] = $activeDirectoryPlugin->getUrl(AzureActiveDirectory::URL_TYPE_LOGOUT);
22+
}
2023

21-
$managementLoginEnabled = 'true' === $activeDirectoryPlugin->get(AzureActiveDirectory::SETTING_MANAGEMENT_LOGIN_ENABLE);
24+
$managementLoginEnabled = 'true' === $activeDirectoryPlugin->get(AzureActiveDirectory::SETTING_MANAGEMENT_LOGIN_ENABLE);
2225

23-
$_template['management_login_enabled'] = $managementLoginEnabled;
26+
$_template['management_login_enabled'] = $managementLoginEnabled;
2427

25-
if ($managementLoginEnabled) {
26-
$managementLoginName = $activeDirectoryPlugin->get(AzureActiveDirectory::SETTING_MANAGEMENT_LOGIN_NAME);
28+
if ($managementLoginEnabled) {
29+
$managementLoginName = $activeDirectoryPlugin->get(AzureActiveDirectory::SETTING_MANAGEMENT_LOGIN_NAME);
2730

28-
if (empty($managementLoginName)) {
29-
$managementLoginName = $activeDirectoryPlugin->get_lang('ManagementLogin');
30-
}
31+
if (empty($managementLoginName)) {
32+
$managementLoginName = $activeDirectoryPlugin->get_lang('ManagementLogin');
33+
}
3134

32-
$_template['management_login_name'] = $managementLoginName;
35+
$_template['management_login_name'] = $managementLoginName;
36+
}
3337
}
3438
}

0 commit comments

Comments
 (0)