diff --git a/assets/vue/composables/admin/indexBlocks.js b/assets/vue/composables/admin/indexBlocks.js
index 9b1ac9a3b0a..eeafc458cca 100644
--- a/assets/vue/composables/admin/indexBlocks.js
+++ b/assets/vue/composables/admin/indexBlocks.js
@@ -80,6 +80,7 @@ export function useIndexBlocks() {
const blockChamilo = ref(null)
const blockSecurity = ref(null)
const blockPlugins = ref(null)
+ const blockHealthCheck = ref(null)
async function loadBlocks() {
const blocks = await adminService.findBlocks()
@@ -95,6 +96,7 @@ export function useIndexBlocks() {
blockChamilo.value = blocks.chamilo || null
blockSecurity.value = blocks.security || null
blockPlugins.value = blocks.plugins || null
+ blockHealthCheck.value = blocks.health_check || null
}
return {
@@ -116,5 +118,6 @@ export function useIndexBlocks() {
blockSupportStatusEl,
loadSupport,
blockPlugins,
+ blockHealthCheck,
}
}
diff --git a/assets/vue/views/admin/AdminIndex.vue b/assets/vue/views/admin/AdminIndex.vue
index fff7a6692ee..76322653e50 100644
--- a/assets/vue/views/admin/AdminIndex.vue
+++ b/assets/vue/views/admin/AdminIndex.vue
@@ -100,6 +100,14 @@
icon="settings"
/>
+
+
getId(), $my_user_url_list)) {
- $url_string .= $u->getUrl() . '
';
+if (!api_is_admin_in_all_active_urls()) {
+ // Get the list of unregistered urls
+ $url_string = '';
+ foreach ($url_list as $u) {
+ if (!in_array($u->getId(), $my_user_url_list)) {
+ $url_string .= $u->getUrl() . '
';
+ }
}
-}
-if (!empty($url_string)) {
echo Display::return_message(
get_lang('Admin user should be registered here') . '
' . $url_string,
'warning',
diff --git a/public/main/inc/lib/api.lib.php b/public/main/inc/lib/api.lib.php
index 8e06d13d7be..13b0cdce8db 100644
--- a/public/main/inc/lib/api.lib.php
+++ b/public/main/inc/lib/api.lib.php
@@ -5259,6 +5259,43 @@ function api_get_access_url_from_user($user_id)
return $list;
}
+/**
+ * Checks whether the current admin user in in all access urls.
+ *
+ * @return bool
+ */
+function api_is_admin_in_all_active_urls()
+{
+ if (api_is_platform_admin()) {
+ $urls = api_get_active_urls();
+ $user_url_list = api_get_access_url_from_user(api_get_user_id());
+ foreach ($urls as $url) {
+ if (!in_array($url['id'], $user_url_list)) {
+ return false;
+ }
+ }
+ return true;
+ }
+}
+
+/**
+ * Gets all the access urls in the database.
+ *
+ * @return array
+ */
+function api_get_active_urls()
+{
+ $table = Database::get_main_table(TABLE_MAIN_ACCESS_URL);
+ $sql = "SELECT * FROM $table WHERE active = 1";
+ $result = Database::query($sql);
+ // Fetch all rows as associative arrays
+ $urls = [];
+ while ($row = Database::fetch_assoc($result)) {
+ $urls[] = $row;
+ }
+ return $urls;
+}
+
/**
* Checks whether the curent user is in a group or not.
*
diff --git a/src/CoreBundle/Controller/Admin/IndexBlocksController.php b/src/CoreBundle/Controller/Admin/IndexBlocksController.php
index 5b969496fb2..a5603a9c62d 100644
--- a/src/CoreBundle/Controller/Admin/IndexBlocksController.php
+++ b/src/CoreBundle/Controller/Admin/IndexBlocksController.php
@@ -15,6 +15,7 @@
use Chamilo\CoreBundle\Event\AdminBlockDisplayedEvent;
use Chamilo\CoreBundle\Event\Events;
use Chamilo\CoreBundle\Helpers\AccessUrlHelper;
+use Chamilo\CoreBundle\Repository\Node\AccessUrlRepository;
use Chamilo\CoreBundle\Repository\PageCategoryRepository;
use Chamilo\CoreBundle\Repository\PageRepository;
use Chamilo\CoreBundle\Repository\PluginRepository;
@@ -44,6 +45,7 @@ public function __construct(
private readonly EventDispatcherInterface $eventDispatcher,
private readonly PluginRepository $pluginRepository,
private readonly AccessUrlHelper $accessUrlHelper,
+ private readonly AccessUrlRepository $accessUrlRepository,
) {
$this->extAuthSource = [
'extldap' => [],
@@ -146,6 +148,13 @@ public function __invoke(): JsonResponse
'editable' => false,
'items' => $this->getItemsPlugins(),
];
+
+ /* Health check */
+ $json['health_check'] = [
+ 'id' => 'block-admin-health-check',
+ 'editable' => false,
+ 'items' => $this->getItemsHealthCheck(),
+ ];
}
/* Sessions */
@@ -907,4 +916,43 @@ private function getItemsPlugins(): array
return $items;
}
+
+ private function getItemsHealthCheck(): array
+ {
+ $items = [];
+
+ // Check if dsn or email is defined :
+ $mailDsn = $this->settingsManager->getSetting('mail.mailer_dsn', true);
+ $mailSender = $this->settingsManager->getSetting('mail.mailer_from_email', true);
+ if ((empty($mailDsn) || 'null://null' == $mailDsn) && empty($mailSender)) {
+ $items[] = [
+ 'className' => 'item-health-check-mail-settings text-error',
+ 'url' => '/admin/settings/mail',
+ 'label' => $this->translator->trans('E-mail settings need to be configured'),
+ ];
+ } else {
+ $items[] = [
+ 'className' => 'item-health-check-mail-settings text-success',
+ 'url' => '/admin/settings/mail',
+ 'label' => $this->translator->trans('E-mail settings are OK'),
+ ];
+ }
+
+ // Check if the admin user has access to all URLs
+ if (api_is_admin_in_all_active_urls()) {
+ $items[] = [
+ 'className' => 'item-health-check-admin-urls text-success',
+ 'url' => '/main/admin/access_urls.php',
+ 'label' => $this->translator->trans('Admin has access to all active URLs'),
+ ];
+ } else {
+ $items[] = [
+ 'className' => 'item-health-check-admin-urls text-error',
+ 'url' => '/main/admin/access_url_edit_users_to_url.php',
+ 'label' => $this->translator->trans('Admin does not have access to all active URLs'),
+ ];
+ }
+
+ return $items;
+ }
}