Skip to content

Commit

Permalink
Add config value admin_chamilo_announcements_disable #2796
Browse files Browse the repository at this point in the history
Disable Chamilo.org announcements at the top of the admin page
  • Loading branch information
AngelFQC committed Feb 6, 2019
1 parent 5cac117 commit 8a21d41
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
42 changes: 42 additions & 0 deletions main/inc/ajax/admin.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use Chamilo\CoreBundle\Entity\BranchSync;
use Chamilo\CoreBundle\Entity\Repository\BranchSyncRepository;
use GuzzleHttp\Client;

/**
* Responses to AJAX calls.
Expand Down Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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();
}
3 changes: 3 additions & 0 deletions main/install/configuration.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions main/template/default/admin/settings_index.tpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{% set admin_chamilo_announcements_disable = 'admin_chamilo_announcements_disable'|api_get_configuration_value %}

<script>
$(document).ready(function () {
$.ajax({
Expand Down Expand Up @@ -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 %}
Expand Down

0 comments on commit 8a21d41

Please sign in to comment.