Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions assets/vue/components/layout/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@
</template>

<script setup>
defineOptions({
name: "AppSidebar",
})

import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue"
import ToggleButton from "primevue/togglebutton"
import { useI18n } from "vue-i18n"
Expand All @@ -71,18 +75,15 @@ import { useSecurityStore } from "../../store/securityStore"
import { useSidebarMenu } from "../../composables/sidebarMenu"
import { usePlatformConfig } from "../../store/platformConfig"
import PageList from "../page/PageList.vue"
import { useEnrolledStore } from "../../store/enrolledStore"
import BaseSidebarPanelMenu from "../basecomponents/BaseSidebarPanelMenu.vue"
import CategoryLinks from "../page/CategoryLinks.vue"

const { t } = useI18n()
const route = useRoute()
const securityStore = useSecurityStore()
const enrolledStore = useEnrolledStore()
const platformConfigStore = usePlatformConfig()

const { menuItemsBeforeMyCourse, menuItemMyCourse, menuItemsAfterMyCourse, hasOnlyOneItem, initialize } =
useSidebarMenu()
const { menuItemsBeforeMyCourse, menuItemMyCourse, menuItemsAfterMyCourse, initialize } = useSidebarMenu()

const MOBILE_BREAKPOINT = 640

Expand All @@ -99,6 +100,10 @@ if (!isMobile() && storedSidebarState === null) {
const expandingDueToPanelClick = ref(false)
const externalLogoutBehaviour = ref(null)

const externalLogoutPluginEnabled = computed(
() => platformConfigStore.plugins?.extauthchamilologoutbuttonbehaviour?.enabled === true,
)

const currentYear = new Date().getFullYear()

const hideLogoutButton = computed(() => {
Expand Down Expand Up @@ -274,7 +279,10 @@ onMounted(async () => {

if (securityStore.isAuthenticated && !isAnonymous.value) {
await initialize()
externalLogoutBehaviour.value = await fetchExternalLogoutBehaviour()

if (externalLogoutPluginEnabled.value) {
externalLogoutBehaviour.value = await fetchExternalLogoutBehaviour()
}
}
})

Expand Down
35 changes: 30 additions & 5 deletions assets/vue/composables/pluginRegion.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { computed, nextTick, onUnmounted, ref, watch } from "vue"
import { useRoute } from "vue-router"
import { useRoute, useRouter } from "vue-router"
import { useCidReqStore } from "../store/cidReq"
import pluginRegionService from "../services/pluginRegionService"

Expand All @@ -9,22 +9,35 @@ import pluginRegionService from "../services/pluginRegionService"
*/
export function usePluginRegion(region) {
const route = useRoute()
const router = useRouter()
const cidReqStore = useCidReqStore()

const blocks = ref([])
const injectedElements = ref([])
let abortController = null
let stopRequestWatcher = null
let isUnmounted = false

function normalizeContextId(value) {
if (value === null || value === undefined || value === "") {
return undefined
}

return String(value)
}

const resolvedParams = computed(() => ({
...route.query,
...route.params,
cid: cidReqStore.course?.id ?? undefined,
sid: cidReqStore.session?.id ?? undefined,
gid: cidReqStore.group?.id ?? undefined,
cid: normalizeContextId(cidReqStore.course?.id ?? route.query.cid),
sid: normalizeContextId(cidReqStore.session?.id ?? route.query.sid),
gid: normalizeContextId(cidReqStore.group?.id ?? route.query.gid),
_route: route.path,
_route_name: route.name ?? undefined,
}))

const requestKey = computed(() => JSON.stringify(resolvedParams.value))

async function fetchBlocks() {
if (abortController) {
abortController.abort()
Expand Down Expand Up @@ -118,9 +131,21 @@ export function usePluginRegion(region) {
injectedElements.value = []
}

watch(resolvedParams, fetchBlocks, { immediate: true })
router.isReady().then(() => {
if (isUnmounted) {
return
}

stopRequestWatcher = watch(requestKey, fetchBlocks, { immediate: true })
})

onUnmounted(() => {
isUnmounted = true

if (stopRequestWatcher) {
stopRequestWatcher()
}

if (abortController) {
abortController.abort()
}
Expand Down
13 changes: 10 additions & 3 deletions assets/vue/composables/useTopbarLoggedIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,10 @@ export function useTopbarLoggedIn(props) {
if (resolvedRoute?.href) {
return resolvedRoute.href
}
} catch {}
} catch {
return "/my-services"
}

return "/my-services"
})

Expand Down Expand Up @@ -363,6 +366,10 @@ export function useTopbarLoggedIn(props) {
})

const buyCoursesConfig = computed(() => platformConfigStore.plugins?.buycourses || {})
const externalLogoutPluginEnabled = computed(
() => platformConfigStore.plugins?.extauthchamilologoutbuttonbehaviour?.enabled === true,
)
const justificationPluginEnabled = computed(() => platformConfigStore.plugins?.justification?.enabled === true)

const showMyServicesLink = computed(() => normalizeBooleanFlag(buyCoursesConfig.value?.enabled))

Expand All @@ -375,7 +382,7 @@ export function useTopbarLoggedIn(props) {
const showMyJustificationsLink = computed(() => !isAnonymous.value && justificationMenu.value.enabled === true)

async function fetchJustificationMenu() {
if (isAnonymous.value) {
if (isAnonymous.value || !justificationPluginEnabled.value) {
justificationMenu.value.enabled = false

return
Expand Down Expand Up @@ -584,7 +591,7 @@ export function useTopbarLoggedIn(props) {
onMounted(async () => {
fetchJustificationMenu()

if (!isAnonymous.value) {
if (!isAnonymous.value && externalLogoutPluginEnabled.value) {
externalLogoutBehaviour.value = await fetchExternalLogoutBehaviour()
}
})
Expand Down
8 changes: 8 additions & 0 deletions src/CoreBundle/Controller/PlatformConfigurationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use BuyCoursesPlugin;
use Chamilo\CoreBundle\Helpers\AiFeatureAccessHelper;
use Chamilo\CoreBundle\Helpers\AuthenticationConfigHelper;
use Chamilo\CoreBundle\Helpers\PluginHelper;
use Chamilo\CoreBundle\Helpers\ThemeHelper;
use Chamilo\CoreBundle\Helpers\UserHelper;
use Chamilo\CoreBundle\Repository\Node\CourseRepository;
Expand Down Expand Up @@ -48,6 +49,7 @@ public function list(
AuthenticationConfigHelper $authenticationConfigHelper,
McpAccessPolicy $mcpAccessPolicy,
UrlGeneratorInterface $urlGenerator,
PluginHelper $pluginHelper,
): Response {
$requestSession = $this->getRequest()->getSession();

Expand Down Expand Up @@ -251,6 +253,12 @@ public function list(
];

$configuration['plugins']['onlyoffice'] = $this->getOnlyofficeFrontendConfig();
$configuration['plugins']['extauthchamilologoutbuttonbehaviour'] = [
'enabled' => $pluginHelper->isPluginEnabled('ExtAuthChamiloLogoutButtonBehaviour'),
];
$configuration['plugins']['justification'] = [
'enabled' => $pluginHelper->isPluginEnabled('Justification'),
];
} else {
$configuration['settings']['security.allow_captcha'] = $settingsManager->getSetting('security.allow_captcha', true);
}
Expand Down
Loading