diff --git a/Makefile b/Makefile index 9ad840336..6d46c1ee4 100644 --- a/Makefile +++ b/Makefile @@ -34,9 +34,9 @@ OBJS = swad_account.o swad_account_database.o swad_action.o swad_agenda.o \ swad_button.o \ swad_calendar.o swad_call_for_exam.o swad_center.o \ swad_center_config.o swad_chat.o swad_chat_database.o swad_config.o \ - swad_connected.o swad_connected_database.o swad_cookie.o swad_country.o \ - swad_country_config.o swad_course.o swad_course_config.o \ - swad_cryptography.o \ + swad_connected.o swad_connected_database.o swad_cookie.o \ + swad_cookie_database.o swad_country.o swad_country_config.o \ + swad_course.o swad_course_config.o swad_cryptography.o \ swad_database.o swad_date.o swad_degree.o swad_degree_config.o \ swad_degree_type.o swad_department.o swad_duplicate.o \ swad_enrolment.o swad_error.o swad_exam.o swad_exam_log.o \ diff --git a/swad_changelog.h b/swad_changelog.h index f12169cba..0bce838ef 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -602,13 +602,14 @@ TODO: FIX BUG, URGENT! En las fechas como par TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo. */ -#define Log_PLATFORM_VERSION "SWAD 20.79 (2021-05-20)" +#define Log_PLATFORM_VERSION "SWAD 20.80 (2021-05-20)" #define CSS_FILE "swad20.45.css" #define JS_FILE "swad20.69.1.js" /* TODO: Rename CENTRE to CENTER in help wiki. TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams + Version 20.80: May 20, 2021 New module swad_cookie_database for database queries related to cookies. (? lines) Version 20.79: May 20, 2021 New module swad_connected_database for database queries related to connected users. (311415 lines) Version 20.78.2: May 20, 2021 Code formatting in games and matches. (311326 lines) Version 20.78.1: May 20, 2021 Fixed bug in matches. Reported by Jesús Garrido Alcázar. (311317 lines) diff --git a/swad_cookie.c b/swad_cookie.c index 818f6218a..b8b1d954f 100644 --- a/swad_cookie.c +++ b/swad_cookie.c @@ -27,6 +27,7 @@ #include "swad_box.h" #include "swad_cookie.h" +#include "swad_cookie_database.h" #include "swad_database.h" #include "swad_figure.h" #include "swad_form.h" @@ -68,32 +69,36 @@ void Coo_EditMyPrefsOnCookies (void) /***** Begin section with preferences about cookies *****/ HTM_SECTION_Begin (Coo_COOKIES_ID); - /***** Begin box and table *****/ - Box_BoxTableBegin (NULL,Txt_Cookies, - Coo_PutIconsCookies,NULL, - Hlp_PROFILE_Settings_cookies,Box_NOT_CLOSABLE,2); + /***** Begin box and table *****/ + Box_BoxTableBegin (NULL,Txt_Cookies, + Coo_PutIconsCookies,NULL, + Hlp_PROFILE_Settings_cookies,Box_NOT_CLOSABLE,2); - /***** Edit my preference about cookies *****/ - /* Begin form */ - Frm_StartFormAnchor (ActChgCooPrf,Coo_COOKIES_ID); + /***** Edit my preference about cookies *****/ + /* Begin form */ + Frm_StartFormAnchor (ActChgCooPrf,Coo_COOKIES_ID); - /* Begin container */ - HTM_DIV_Begin ("class=\"%s\"", - (Gbl.Usrs.Me.UsrDat.Prefs.AcceptThirdPartyCookies) ? "DAT_N LIGHT_BLUE" : - "DAT"); - /* Check box */ - HTM_LABEL_Begin (NULL); - HTM_INPUT_CHECKBOX ("cookies",HTM_SUBMIT_ON_CHANGE, - "value=\"Y\"%s", - Gbl.Usrs.Me.UsrDat.Prefs.AcceptThirdPartyCookies ? " checked=\"checked\"" : ""); - HTM_Txt (Txt_Accept_third_party_cookies_to_view_multimedia_content_from_other_websites); - HTM_LABEL_End (); + /* Begin container */ + HTM_DIV_Begin ("class=\"%s\"", + (Gbl.Usrs.Me.UsrDat.Prefs.AcceptThirdPartyCookies) ? "DAT_N LIGHT_BLUE" : + "DAT"); + /* Check box */ + HTM_LABEL_Begin (NULL); + HTM_INPUT_CHECKBOX ("cookies",HTM_SUBMIT_ON_CHANGE, + "value=\"Y\"%s", + Gbl.Usrs.Me.UsrDat.Prefs.AcceptThirdPartyCookies ? " checked=\"checked\"" : + ""); + HTM_Txt (Txt_Accept_third_party_cookies_to_view_multimedia_content_from_other_websites); + HTM_LABEL_End (); - /* End container */ - HTM_DIV_End (); + /* End container */ + HTM_DIV_End (); - /***** End table and box *****/ - Box_BoxTableEnd (); + /* End form */ + Frm_EndForm (); + + /***** End table and box *****/ + Box_BoxTableEnd (); /***** End section with preferences about cookies *****/ HTM_SECTION_End (); @@ -120,13 +125,7 @@ void Coo_ChangeMyPrefsCookies (void) /***** Store preference in database *****/ if (Gbl.Usrs.Me.Logged) - DB_QueryUPDATE ("can not update your preference about cookies", - "UPDATE usr_data" - " SET ThirdPartyCookies='%c'" - " WHERE UsrCod=%ld", - Gbl.Usrs.Me.UsrDat.Prefs.AcceptThirdPartyCookies ? 'Y' : - 'N', - Gbl.Usrs.Me.UsrDat.UsrCod); + Coo_DB_UpdateMyPrefsCookies (); /***** Show forms again *****/ Set_EditSettings (); diff --git a/swad_cookie_database.c b/swad_cookie_database.c new file mode 100644 index 000000000..f670cf302 --- /dev/null +++ b/swad_cookie_database.c @@ -0,0 +1,66 @@ +// swad_cookie_database.c: user's preferences about cookies (operations with database) + +// swad_cookies.c: user's preferences about cookies + +/* + SWAD (Shared Workspace At a Distance), + is a web platform developed at the University of Granada (Spain), + and used to support university teaching. + + This file is part of SWAD core. + Copyright (C) 1999-2021 Antonio Cañas Vargas + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ +/*****************************************************************************/ +/********************************* Headers ***********************************/ +/*****************************************************************************/ + +#include "swad_cookie.h" +#include "swad_cookie_database.h" +#include "swad_database.h" +#include "swad_global.h" + +/*****************************************************************************/ +/************** External global variables from others modules ****************/ +/*****************************************************************************/ + +extern struct Globals Gbl; + +/*****************************************************************************/ +/****************************** Public constants *****************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/***************************** Private constants *****************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/***************************** Private prototypes ****************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/************** Update my settings about third party cookies *****************/ +/*****************************************************************************/ + +void Coo_DB_UpdateMyPrefsCookies (void) + { + DB_QueryUPDATE ("can not update your preference about cookies", + "UPDATE usr_data" + " SET ThirdPartyCookies='%c'" + " WHERE UsrCod=%ld", + Gbl.Usrs.Me.UsrDat.Prefs.AcceptThirdPartyCookies ? 'Y' : + 'N', + Gbl.Usrs.Me.UsrDat.UsrCod); + } diff --git a/swad_cookie_database.h b/swad_cookie_database.h new file mode 100644 index 000000000..0ed574a54 --- /dev/null +++ b/swad_cookie_database.h @@ -0,0 +1,40 @@ +// swad_cookie_database.h: user's preferences about cookies (operations with database) + +#ifndef _SWAD_COO_DB +#define _SWAD_COO_DB +/* + SWAD (Shared Workspace At a Distance in Spanish), + is a web platform developed at the University of Granada (Spain), + and used to support university teaching. + + This file is part of SWAD core. + Copyright (C) 1999-2021 Antonio Cañas Vargas + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ +/*****************************************************************************/ +/********************************* Headers ***********************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/************************* Public types and constants ************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/***************************** Public prototypes *****************************/ +/*****************************************************************************/ + +void Coo_DB_UpdateMyPrefsCookies (void); + +#endif