Adds cookie warning message see #7478

A configuration option is required in configuration.php:

chamilo_use_cookie_warning_validation
1.9.x
baelmyhu 11 years ago committed by Julio Montoya
parent 1119b0de85
commit 5e8ae687fd
  1. 16
      index.php
  2. 16
      main/admin/index.php
  3. 13
      main/css/base.css
  4. 17
      main/inc/lib/main_api.lib.php
  5. 35
      main/inc/lib/template.lib.php
  6. 2
      main/install/configuration.dist.php
  7. 23
      main/template/default/layout/main_header.tpl
  8. 16
      user_portal.php

@ -149,6 +149,22 @@ if (!api_is_anonymous()) {
$hot_courses = null; $hot_courses = null;
$announcements_block = null; $announcements_block = null;
// Display the Site Use Cookie Warning Validation
$useCookieValidation = api_get_configuration_value('chamilo_use_cookie_warning_validation');
if ($useCookieValidation) {
if (isset($_POST['acceptCookies'])) {
api_set_site_use_cookie_warning_cookie();
} else if (!api_site_use_cookie_warning_cookie_exist()) {
if (Template::isToolBarDisplayedForUser()) {
$controller->tpl->assign('toolBarDisplayed', true);
} else {
$controller->tpl->assign('toolBarDisplayed', false);
}
$controller->tpl->assign('displayCookieUsageWarning', true);
}
}
// When loading a chamilo page do not include the hot courses and news // When loading a chamilo page do not include the hot courses and news
if (!isset($_REQUEST['include'])) { if (!isset($_REQUEST['include'])) {

@ -338,6 +338,22 @@ if (api_is_platform_admin()) {
$admin_ajax_url = api_get_path(WEB_AJAX_PATH).'admin.ajax.php'; $admin_ajax_url = api_get_path(WEB_AJAX_PATH).'admin.ajax.php';
$tpl = new Template(); $tpl = new Template();
// Display the Site Use Cookie Warning Validation
$useCookieValidation = api_get_configuration_value('chamilo_use_cookie_warning_validation');
if ($useCookieValidation) {
if (isset($_POST['acceptCookies'])) {
api_set_site_use_cookie_warning_cookie();
} else if (!api_site_use_cookie_warning_cookie_exist()) {
if (Template::isToolBarDisplayedForUser()) {
$tpl->assign('toolBarDisplayed', true);
} else {
$tpl->assign('toolBarDisplayed', false);
}
$tpl->assign('displayCookieUsageWarning', true);
}
}
$tpl->assign('web_admin_ajax_url', $admin_ajax_url); $tpl->assign('web_admin_ajax_url', $admin_ajax_url);
$tpl->assign('blocks', $blocks); $tpl->assign('blocks', $blocks);
// The template contains the call to the AJAX version checker // The template contains the call to the AJAX version checker

@ -5291,3 +5291,16 @@ i.size-32.icon-new-work{
margin-right: auto; margin-right: auto;
max-width: 100%; max-width: 100%;
} }
/* display the cookie usage warning validation */
.cookieUsageValidation {
padding: 5px;
background-color: #333333;
color:#E0E0E0;
text-align:center;
}
.displayUnderToolbar
{
height: 52px;
}

@ -7496,3 +7496,20 @@ function api_register_campus($listCampus = true) {
} }
// Reload the settings. // Reload the settings.
} }
/**
* Set the Site Use Cookie Warning for 1 year
*/
function api_set_site_use_cookie_warning_cookie()
{
setcookie("ChamiloUsesCookies", "ok", time()+31556926);
}
/**
* Return true if the Site Use Cookie Warning Cookie warning exists
* @return bool
*/
function api_site_use_cookie_warning_cookie_exist()
{
return isset($_COOKIE['ChamiloUsesCookies']);
}

@ -301,35 +301,50 @@ class Template
} }
/** /**
* Sets the header visibility * return true if toolbar has to be displayed for user
* @param bool true if we show the header * @return bool
*/ */
public function set_header($status) public static function isToolBarDisplayedForUser()
{ {
$this->show_header = $status;
$this->assign('show_header', $status);
//Toolbar //Toolbar
$show_admin_toolbar = api_get_setting('show_admin_toolbar'); $show_admin_toolbar = api_get_setting('show_admin_toolbar');
$show_toolbar = 0; $show_toolbar = false;
switch ($show_admin_toolbar) { switch ($show_admin_toolbar) {
case 'do_not_show': case 'do_not_show':
break; break;
case 'show_to_admin': case 'show_to_admin':
if (api_is_platform_admin()) { if (api_is_platform_admin()) {
$show_toolbar = 1; $show_toolbar = true;
} }
break; break;
case 'show_to_admin_and_teachers': case 'show_to_admin_and_teachers':
if (api_is_platform_admin() || api_is_allowed_to_edit()) { if (api_is_platform_admin() || api_is_allowed_to_edit()) {
$show_toolbar = 1; $show_toolbar = true;
} }
break; break;
case 'show_to_all': case 'show_to_all':
$show_toolbar = 1; $show_toolbar = true;
break; break;
} }
return $show_toolbar;
}
/**
* Sets the header visibility
* @param bool true if we show the header
*/
public function set_header($status)
{
$this->show_header = $status;
$this->assign('show_header', $status);
$show_toolbar = 0;
if (self::isToolBarDisplayedForUser()) {
$show_toolbar = 1;
}
$this->assign('show_toolbar', $show_toolbar); $this->assign('show_toolbar', $show_toolbar);
//Only if course is available //Only if course is available

@ -282,3 +282,5 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
//$_configuration['name_order_conventions'] = array( //$_configuration['name_order_conventions'] = array(
// 'french' => array('format' => 'title last_name first_name', 'sort_by' => 'last_name') // 'french' => array('format' => 'title last_name first_name', 'sort_by' => 'last_name')
//); //);
// Shows a warning message that the site use cookies
//$_configuration['chamilo_use_cookie_warning_validation'] = false;

@ -11,6 +11,29 @@
<body dir="{{ text_direction }}" class="{{ section_name }} {{ login_class }}"> <body dir="{{ text_direction }}" class="{{ section_name }} {{ login_class }}">
<noscript>{{ "NoJavascript"|get_lang }}</noscript> <noscript>{{ "NoJavascript"|get_lang }}</noscript>
<!-- Display the Chamilo Uses Cookies Warning Validation if needed -->
{% if displayCookieUsageWarning == true %}
<!-- If toolbar is displayed, we have to display this block bellow it -->
{% if toolBarDisplayed == true %}
<div class="displayUnderToolbar" >&nbsp;</div>
{% endif %}
<form onSubmit="$(this).toggle('slow')" action="" method="post">
<input value=1 type="hidden" name="acceptCookies"/>
<div class="cookieUsageValidation">
{{ "youDeclareToAcceptCookies" | get_lang }}
<span style="margin-left:20px;" onclick="$(this).next().toggle('slow'); $(this).toggle('slow')">
({{"More" | get_lang }})
</span>
<div style="display:none; margin:20px 0;">
{{ "helpCookieUsageValidation" | get_lang}}
</div>
<span style="margin-left:20px;" onclick="$(this).parent().parent().submit()">
({{"Accept" | get_lang }})
</span>
</div>
</form>
{% endif %}
{% if show_header == true %} {% if show_header == true %}
<div class="skip"> <div class="skip">
<ul> <ul>

@ -164,6 +164,22 @@ if (api_get_setting('allow_browser_sniffer') == 'true') {
} }
} }
// Display the Site Use Cookie Warning Validation
$useCookieValidation = api_get_configuration_value('chamilo_use_cookie_warning_validation');
if ($useCookieValidation) {
if (isset($_POST['acceptCookies'])) {
api_set_site_use_cookie_warning_cookie();
} else if (!api_site_use_cookie_warning_cookie_exist()) {
if (Template::isToolBarDisplayedForUser()) {
$controller->tpl->assign('toolBarDisplayed', true);
} else {
$controller->tpl->assign('toolBarDisplayed', false);
}
$controller->tpl->assign('displayCookieUsageWarning', true);
}
}
//check for flash and message //check for flash and message
$sniff_notification = ''; $sniff_notification = '';
$some_activex = isset($_SESSION['sniff_check_some_activex']) ? $_SESSION['sniff_check_some_activex'] : null; $some_activex = isset($_SESSION['sniff_check_some_activex']) ? $_SESSION['sniff_check_some_activex'] : null;

Loading…
Cancel
Save