File tree Expand file tree Collapse file tree 6 files changed +50
-50
lines changed Expand file tree Collapse file tree 6 files changed +50
-50
lines changed Original file line number Diff line number Diff line change 126
126
$ useCookieValidation = api_get_setting ('cookie_warning ' );
127
127
128
128
if ($ useCookieValidation === 'true ' ) {
129
- if (isset ($ _POST ['acceptCookies ' ])) {
130
- api_set_site_use_cookie_warning_cookie ();
131
- } elseif (!api_site_use_cookie_warning_cookie_exist ()) {
129
+ if (!api_site_use_cookie_warning_cookie_exist ()) {
132
130
if (Template::isToolBarDisplayedForUser ()) {
133
131
$ controller ->tpl ->assign ('toolBarDisplayed ' , true );
134
132
} else {
135
133
$ controller ->tpl ->assign ('toolBarDisplayed ' , false );
136
134
}
137
- $ controller ->tpl ->assign ( ' displayCookieUsageWarning ' , true );
135
+ $ controller ->tpl ->enableCookieUsageWarning ( );
138
136
}
139
137
}
140
138
// When loading a chamilo page do not include the hot courses and news
Original file line number Diff line number Diff line change 1018
1018
// Display the Site Use Cookie Warning Validation
1019
1019
$ useCookieValidation = api_get_setting ('cookie_warning ' );
1020
1020
if ($ useCookieValidation === 'true ' ) {
1021
- if (isset ($ _POST ['acceptCookies ' ])) {
1022
- api_set_site_use_cookie_warning_cookie ();
1023
- } elseif (!api_site_use_cookie_warning_cookie_exist ()) {
1021
+ if (!api_site_use_cookie_warning_cookie_exist ()) {
1024
1022
if (Template::isToolBarDisplayedForUser ()) {
1025
1023
$ tpl ->assign ('toolBarDisplayed ' , true );
1026
1024
} else {
1027
1025
$ tpl ->assign ('toolBarDisplayed ' , false );
1028
1026
}
1029
- $ tpl ->assign ( ' displayCookieUsageWarning ' , true );
1027
+ $ tpl ->enableCookieUsageWarning ( );
1030
1028
}
1031
1029
}
1032
1030
Original file line number Diff line number Diff line change @@ -1317,6 +1317,42 @@ public static function displayLoginForm()
1317
1317
return $ html ;
1318
1318
}
1319
1319
1320
+ public function enableCookieUsageWarning ()
1321
+ {
1322
+ $ form = new FormValidator (
1323
+ 'cookiewarning ' ,
1324
+ 'post ' ,
1325
+ '' ,
1326
+ '' ,
1327
+ [
1328
+ //'onsubmit' => "$(this).toggle('show')",
1329
+ ],
1330
+ FormValidator::LAYOUT_BOX_NO_LABEL
1331
+ );
1332
+ $ form ->addHidden ('acceptCookies ' , '1 ' );
1333
+ $ form ->addHtml (
1334
+ '<div class="cookieUsageValidation">
1335
+ ' .get_lang ('YouAcceptCookies ' ).'
1336
+ <button class="btn btn-link" onclick="$(this).next().toggle( \'slow \'); $(this).toggle( \'slow \')" type="button">
1337
+ ( ' .get_lang ('More ' ).')
1338
+ </button>
1339
+ <div style="display:none; margin:20px 0;">
1340
+ ' .get_lang ('HelpCookieUsageValidation ' ).'
1341
+ </div>
1342
+ <button class="btn btn-link" onclick="$(this).parents( \'form \').submit()" type="button">
1343
+ ( ' .get_lang ('Accept ' ).')
1344
+ </button>
1345
+ </div> '
1346
+ );
1347
+
1348
+ if ($ form ->validate ()) {
1349
+ api_set_site_use_cookie_warning_cookie ();
1350
+ } else {
1351
+ $ form ->protect ();
1352
+ $ this ->assign ('frmDisplayCookieUsageWarning ' , $ form ->returnForm ());
1353
+ }
1354
+ }
1355
+
1320
1356
/**
1321
1357
* Returns the tutors names for the current course in session
1322
1358
* Function to use in Twig templates.
Original file line number Diff line number Diff line change 14
14
<main id =" main" dir =" { { text_direction } } " class =" { { section_name } } { { login_class } } " >
15
15
<noscript >{ { " NoJavascript" |get_lang } }</noscript >
16
16
17
- {% if displayCookieUsageWarning == true %}
17
+ {% if frmDisplayCookieUsageWarning %}
18
18
<!-- START DISPLAY COOKIES VALIDATION -->
19
19
<div class =" toolbar-cookie alert-warning" >
20
- <form onSubmit =" $(this).toggle('slow')" action =" " method =" post" >
21
- <input value =1 type =" hidden" name =" acceptCookies" />
22
- <div class =" cookieUsageValidation" >
23
- { { ' YouAcceptCookies' | get_lang } }
24
- <span style =" margin-left :20px ;" onclick =" $(this).next().toggle('slow'); $(this).toggle('slow')" >
25
- ({ {" More" | get_lang } })
26
- </span >
27
- <div style =" display :none ; margin :20px 0 ;" >
28
- { { " HelpCookieUsageValidation" | get_lang} }
29
- </div >
30
- <span style =" margin-left :20px ;" onclick =" $(this).parent().parent().submit()" >
31
- ({ {" Accept" | get_lang } })
32
- </span >
33
- </div >
34
- </form >
20
+ { { frmDisplayCookieUsageWarning } }
35
21
</div >
36
22
<!-- END DISPLAY COOKIES VALIDATION -->
37
23
{% endif %}
Original file line number Diff line number Diff line change 14
14
<!-- START MAIN -->
15
15
<main id =" main" dir =" { { text_direction } } " class =" { { section_name } } { { login_class } } " >
16
16
<noscript >{ { " NoJavascript" |get_lang } }</noscript >
17
- {% if displayCookieUsageWarning == true %}
17
+ {% if frmDisplayCookieUsageWarning %}
18
18
<!-- START DISPLAY COOKIES VALIDATION -->
19
19
<div class =" toolbar-cookie alert-warning" >
20
- <form onSubmit =" $(this).toggle('slow')" action =" " method =" post" >
21
- <input value =1 type =" hidden" name =" acceptCookies" />
22
- <div class =" cookieUsageValidation" >
23
- { { ' YouAcceptCookies' | get_lang } }
24
- <span style =" margin-left :20px ;" onclick =" $(this).next().toggle('slow'); $(this).toggle('slow')" >
25
- ({ {" More" | get_lang } })
26
- </span >
27
- <div style =" display :none ; margin :20px 0 ;" >
28
- { { " HelpCookieUsageValidation" | get_lang} }
29
- </div >
30
- <span style =" margin-left :20px ;" onclick =" $(this).parent().parent().submit()" >
31
- ({ {" Accept" | get_lang } })
32
- </span >
33
- </div >
34
- </form >
20
+ { { frmDisplayCookieUsageWarning } }
35
21
</div >
36
22
<!-- END DISPLAY COOKIES VALIDATION -->
37
23
{% endif %}
Original file line number Diff line number Diff line change @@ -295,17 +295,13 @@ function changeMyCoursesView(inView) {
295
295
// Display the Site Use Cookie Warning Validation
296
296
$ useCookieValidation = api_get_setting ('cookie_warning ' );
297
297
if ($ useCookieValidation === 'true ' ) {
298
- if (isset ($ _POST ['acceptCookies ' ])) {
299
- api_set_site_use_cookie_warning_cookie ();
300
- } else {
301
- if (!api_site_use_cookie_warning_cookie_exist ()) {
302
- if (Template::isToolBarDisplayedForUser ()) {
303
- $ controller ->tpl ->assign ('toolBarDisplayed ' , true );
304
- } else {
305
- $ controller ->tpl ->assign ('toolBarDisplayed ' , false );
306
- }
307
- $ controller ->tpl ->assign ('displayCookieUsageWarning ' , true );
298
+ if (!api_site_use_cookie_warning_cookie_exist ()) {
299
+ if (Template::isToolBarDisplayedForUser ()) {
300
+ $ controller ->tpl ->assign ('toolBarDisplayed ' , true );
301
+ } else {
302
+ $ controller ->tpl ->assign ('toolBarDisplayed ' , false );
308
303
}
304
+ $ controller ->tpl ->enableCookieUsageWarning ();
309
305
}
310
306
}
311
307
You can’t perform that action at this time.
0 commit comments