Admin: Remove notification modal about Official providers and add "Support" and "News" blocks, that can be disabled through the "admin.admin_chamilo_announcements_disable" setting

pull/5312/head
Yannick Warnier 8 months ago
parent 3da7f59d1e
commit 514a9d1d3d
  1. 26
      assets/vue/composables/admin/indexBlocks.js
  2. 9
      assets/vue/services/adminService.js
  3. 56
      assets/vue/views/admin/AdminIndex.vue
  4. 42
      public/main/inc/ajax/admin.ajax.php

@ -14,21 +14,23 @@ export function useIndexBlocks() {
const securityStore = useSecurityStore()
const blockVersionStatusEl = ref()
const blockNewsStatusEl = ref()
const blockSupportStatusEl = ref()
onMounted(() => {
if (!securityStore.isAdmin) {
return
}
if ("false" === platformConfigStore.getSetting("admin.admin_chamilo_announcements_disable")) {
adminService.findAnnouncements().then((announcement) => toast.add({ severity: "info", detail: announcement }))
}
if ("false" === platformConfigStore.getSetting("platform.registered")) {
blockVersionStatusEl.value = null
} else {
loadVersion()
}
if ("false" === platformConfigStore.getSetting("admin.admin_chamilo_announcements_disable")) {
loadSupport()
loadNews()
}
})
/**
@ -51,6 +53,18 @@ export function useIndexBlocks() {
blockVersionStatusEl.value = await adminService.findVersion()
}
async function loadNews() {
blockVersionStatusEl.value = t("Loading")
blockNewsStatusEl.value = await adminService.findAnnouncements()
}
async function loadSupport() {
blockSupportStatusEl.value = t("Loading")
blockSupportStatusEl.value = await adminService.findSupport()
}
const blockUsers = ref(null)
const blockCourses = ref(null)
const blockSessions = ref(null)
@ -88,5 +102,9 @@ export function useIndexBlocks() {
blockPlatform,
blockChamilo,
loadBlocks,
blockNewsStatusEl,
loadNews,
blockSupportStatusEl,
loadSupport,
}
}

@ -29,6 +29,15 @@ export default {
return data
},
/**
* @returns {Promise<string>}
*/
findSupport: async () => {
const { data } = await axios.get("/main/inc/ajax/admin.ajax.php?a=get_support")
return data
},
/**
* @returns {Promise<Object>}
*/

@ -179,6 +179,60 @@
icon="admin-settings"
title="Chamilo.org"
/>
<div
v-if="securityStore.isAdmin"
class="admin-index__block-container block-admin-support"
>
<div class="admin-index__block">
<h4 v-t="'Professional support'" />
<div
v-if="blockSupportStatusEl"
class="block-admin-support__status"
v-html="blockSupportStatusEl"
/>
<div
v-else
class="block-admin-news__status"
>
<i18n-t
class="mb-3"
keypath="Disabled"
tag="p"
>
</i18n-t>
</div>
</div>
</div>
<div
v-if="securityStore.isAdmin"
class="admin-index__block-container block-admin-news"
>
<div class="admin-index__block">
<h4 v-t="'News from Chamilo'" />
<div
v-if="blockNewsStatusEl"
class="block-admin-news__status"
v-html="blockNewsStatusEl"
/>
<div
v-else
class="block-admin-news__status"
>
<i18n-t
class="mb-3"
keypath="Disabled"
tag="p"
>
</i18n-t>
</div>
</div>
</div>
</div>
</template>
@ -213,6 +267,8 @@ const {
blockPlatform,
blockChamilo,
loadBlocks,
blockNewsStatusEl,
blockSupportStatusEl,
} = useIndexBlocks()
function checkVersionOnSubmit() {

@ -67,12 +67,18 @@ switch ($action) {
break;
case 'get_latest_news':
if ('true' === api_get_setting('admin.admin_chamilo_announcements_disable')) {
try {
$latestNews = getLatestNews();
$latestNews = json_decode($latestNews, true);
echo Security::remove_XSS($latestNews['text'], COURSEMANAGER);
break;
} catch (Exception $e) {
break;
}
case 'get_support':
try {
$latestNews = getLatestNews();
$latestNews = getProSupport();
$latestNews = json_decode($latestNews, true);
echo Security::remove_XSS($latestNews['text'], COURSEMANAGER);
@ -280,3 +286,33 @@ function getLatestNews()
return $response->getBody()->getContents();
}
/**
* Display the latest support services block.
*
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws Exception
*
* @return string|void
*/
function getProSupport()
{
$url = 'https://version.chamilo.org/support/latest.php';
$client = new Client();
$response = $client->request(
'GET',
$url,
[
'query' => [
'language' => api_get_language_isocode(),
],
]
);
if (200 !== $response->getStatusCode()) {
throw new Exception(get_lang('Deny access'));
}
return $response->getBody()->getContents();
}

Loading…
Cancel
Save