Add config value admin_chamilo_announcements_disable #2796

Disable Chamilo.org announcements at the top of the admin page
pull/2808/head
Angel Fernando Quiroz Campos 7 years ago
parent 5cac117674
commit 8a21d41da8
  1. 42
      main/inc/ajax/admin.ajax.php
  2. 3
      main/install/configuration.dist.php
  3. 26
      main/template/default/admin/settings_index.tpl

@ -3,6 +3,7 @@
use Chamilo\CoreBundle\Entity\BranchSync; use Chamilo\CoreBundle\Entity\BranchSync;
use Chamilo\CoreBundle\Entity\Repository\BranchSyncRepository; use Chamilo\CoreBundle\Entity\Repository\BranchSyncRepository;
use GuzzleHttp\Client;
/** /**
* Responses to AJAX calls. * Responses to AJAX calls.
@ -72,6 +73,16 @@ switch ($action) {
echo file_get_contents("{$newUrlDir}{$blockName}_extra.html"); echo file_get_contents("{$newUrlDir}{$blockName}_extra.html");
break; break;
case 'get_latest_news':
if (api_get_configuration_value('admin_chamilo_announcements_disable') === true) {
break;
}
$latestNews = getLatestNews();
$latestNews = json_decode($latestNews, true);
echo Security::remove_XSS($latestNews['text'], COURSEMANAGER);
break;
} }
/** /**
@ -225,3 +236,34 @@ function check_system_version()
return '<span style="color:red">'.get_lang('ImpossibleToContactVersionServerPleaseTryAgain').'</span>'; return '<span style="color:red">'.get_lang('ImpossibleToContactVersionServerPleaseTryAgain').'</span>';
} }
/**
* Display the latest news from the Chamilo Association for admins
*
* @throws \GuzzleHttp\Exception\GuzzleException
*
* @return string|void
*/
function getLatestNews()
{
global $language_interface;
$url = 'https://version.chamilo.org/news/latest.php';
$client = new Client();
$response = $client->request(
'GET',
$url,
[
'query' => [
'language' => $language_interface,
],
]
);
if ($response->getStatusCode() !== 200) {
return;
}
return $response->getBody()->getContents();
}

@ -1093,6 +1093,9 @@ VALUES (2, 13, 'session_courses_read_only_mode', 'Lock Course In Session', 1, 1,
// Default selected row in jqgrid/sortable tables // Default selected row in jqgrid/sortable tables
//$_configuration['table_default_row'] = 50; //$_configuration['table_default_row'] = 50;
// Disable Chamilo.org announcements at the top of the admin page
//$_configuration['admin_chamilo_announcements_disable'] = false;
// ------ Custom DB changes (keep this at the end) // ------ Custom DB changes (keep this at the end)
// Add user activation by confirmation email // Add user activation by confirmation email
// This option prevents the new user to login in the platform if your account is not confirmed via email // This option prevents the new user to login in the platform if your account is not confirmed via email

@ -1,3 +1,5 @@
{% set admin_chamilo_announcements_disable = 'admin_chamilo_announcements_disable'|api_get_configuration_value %}
<script> <script>
$(document).ready(function () { $(document).ready(function () {
$.ajax({ $.ajax({
@ -35,10 +37,34 @@
}); });
}); });
})(window.CKEDITOR); })(window.CKEDITOR);
{% if not admin_chamilo_announcements_disable %}
$
.ajax('{{ web_admin_ajax_url }}?a=get_latest_news')
.then(function (response) {
$('#chamilo-news').removeClass('hidden');
$('#chamilo-news-content').html(response);
});
{% endif %}
{% endif %} {% endif %}
}); });
</script> </script>
{% if not admin_chamilo_announcements_disable %}
<section id="chamilo-news" class="row hidden">
<div class="col-xs-12">
<div class="alert alert-info">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<div id="chamilo-news-content">
</div>
</div>
</div>
</section>
{% endif %}
<section id="settings" class="row"> <section id="settings" class="row">
{% set columns = 2 %} {% set columns = 2 %}
{% for block_item in blocks %} {% for block_item in blocks %}

Loading…
Cancel
Save