|
|
|
@ -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 @@ switch ($action) { |
|
|
|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
|
|
$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(); |
|
|
|
|
} |
|
|
|
|