Skip to content
Permalink
Browse files

Add config value admin_chamilo_announcements_disable #2796

Disable Chamilo.org announcements at the top of the admin page
  • Loading branch information...
AngelFQC committed Feb 6, 2019
1 parent 5cac117 commit 8a21d41da8c63f4ec2943f3ce53f2385d594430c
@@ -3,6 +3,7 @@
use Chamilo\CoreBundle\Entity\BranchSync;
use Chamilo\CoreBundle\Entity\Repository\BranchSyncRepository;
use GuzzleHttp\Client;
/**
* Responses to AJAX calls.
@@ -72,6 +73,16 @@
echo file_get_contents("{$newUrlDir}{$blockName}_extra.html");
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>';
}
/**
* Display the latest news from the Chamilo Association for admins
*
* @throws \GuzzleHttp\Exception\GuzzleException
*
* @return string|void
*/
function getLatestNews()
{
global $language_interface;

This comment has been minimized.

Copy link
@jmontoyaa

jmontoyaa Feb 13, 2019

Member

No usar globals. Usar la función para obtener el idioma:

api_get_interface_language();

This comment has been minimized.

Copy link
@AngelFQC

AngelFQC Feb 13, 2019

Author Member

Fixed 6be9f6e

$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 @@
// Default selected row in jqgrid/sortable tables
//$_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)
// 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
@@ -1,3 +1,5 @@
{% set admin_chamilo_announcements_disable = 'admin_chamilo_announcements_disable'|api_get_configuration_value %}

<script>
$(document).ready(function () {
$.ajax({
@@ -35,10 +37,34 @@
});
});
})(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 %}
});
</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">
{% set columns = 2 %}
{% for block_item in blocks %}

0 comments on commit 8a21d41

Please sign in to comment.
You can’t perform that action at this time.