mirror of https://github.com/acanas/swad-core.git
Version 22.120.2: Jun 07, 2023 Code refactoring related to cookies and hidden-visible.
This commit is contained in:
parent
b5cb69121e
commit
6408f2f54b
|
@ -629,10 +629,11 @@ TODO: Emilce Barrera Mesa: Podr
|
||||||
TODO: Emilce Barrera Mesa: Mis estudiantes presentan muchas dificultades a la hora de poner la foto porque la plataforma es muy exigente respecto al fondo de la imagen.
|
TODO: Emilce Barrera Mesa: Mis estudiantes presentan muchas dificultades a la hora de poner la foto porque la plataforma es muy exigente respecto al fondo de la imagen.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 22.120.1 (2023-06-06)"
|
#define Log_PLATFORM_VERSION "SWAD 22.120.2 (2023-06-07)"
|
||||||
#define CSS_FILE "swad22.120.css"
|
#define CSS_FILE "swad22.120.css"
|
||||||
#define JS_FILE "swad22.49.js"
|
#define JS_FILE "swad22.49.js"
|
||||||
/*
|
/*
|
||||||
|
Version 22.120.2: Jun 07, 2023 Code refactoring related to cookies and hidden-visible. (337640 lines)
|
||||||
Version 22.120.1: Jun 06, 2023 Translation of messages about cookies. (337620 lines)
|
Version 22.120.1: Jun 06, 2023 Translation of messages about cookies. (337620 lines)
|
||||||
Version 22.120: Jun 06, 2023 Code refactoring related to hidden-visible. (337561 lines)
|
Version 22.120: Jun 06, 2023 Code refactoring related to hidden-visible. (337561 lines)
|
||||||
Version 22.119: Jun 06, 2023 Code refactoring related to hidden-visible. (337588 lines)
|
Version 22.119: Jun 06, 2023 Code refactoring related to hidden-visible. (337588 lines)
|
||||||
|
|
|
@ -79,19 +79,24 @@ void Coo_EditMyPrefsOnCookies (void)
|
||||||
Frm_BeginFormAnchor (ActChgCooPrf,Coo_COOKIES_ID);
|
Frm_BeginFormAnchor (ActChgCooPrf,Coo_COOKIES_ID);
|
||||||
|
|
||||||
/* Begin container */
|
/* Begin container */
|
||||||
if (Gbl.Usrs.Me.UsrDat.Prefs.AcceptCookies)
|
switch (Gbl.Usrs.Me.UsrDat.Prefs.RefuseAcceptCookies)
|
||||||
HTM_DIV_Begin ("class=\"DAT_STRONG_%s BG_HIGHLIGHT\"",
|
{
|
||||||
The_GetSuffix ());
|
case Coo_REFUSE:
|
||||||
else
|
HTM_DIV_Begin ("class=\"DAT_%s\"",
|
||||||
HTM_DIV_Begin ("class=\"DAT_%s\"",
|
The_GetSuffix ());
|
||||||
The_GetSuffix ());
|
break;
|
||||||
|
case Coo_ACCEPT:
|
||||||
|
HTM_DIV_Begin ("class=\"DAT_STRONG_%s BG_HIGHLIGHT\"",
|
||||||
|
The_GetSuffix ());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check box */
|
/* Check box */
|
||||||
HTM_LABEL_Begin (NULL);
|
HTM_LABEL_Begin (NULL);
|
||||||
HTM_INPUT_CHECKBOX ("cookies",HTM_SUBMIT_ON_CHANGE,
|
HTM_INPUT_CHECKBOX ("cookies",HTM_SUBMIT_ON_CHANGE,
|
||||||
"value=\"Y\"%s",
|
"value=\"Y\"%s",
|
||||||
Gbl.Usrs.Me.UsrDat.Prefs.AcceptCookies ? " checked=\"checked\"" :
|
Gbl.Usrs.Me.UsrDat.Prefs.RefuseAcceptCookies == Coo_ACCEPT ? " checked=\"checked\"" :
|
||||||
"");
|
"");
|
||||||
HTM_Txt (Txt_Accept_third_party_cookies_to_view_multimedia_content_from_other_websites);
|
HTM_Txt (Txt_Accept_third_party_cookies_to_view_multimedia_content_from_other_websites);
|
||||||
HTM_LABEL_End ();
|
HTM_LABEL_End ();
|
||||||
|
|
||||||
|
@ -125,7 +130,8 @@ static void Coo_PutIconsCookies (__attribute__((unused)) void *Args)
|
||||||
void Coo_ChangeMyPrefsCookies (void)
|
void Coo_ChangeMyPrefsCookies (void)
|
||||||
{
|
{
|
||||||
/***** Get param with preference about third party cookies *****/
|
/***** Get param with preference about third party cookies *****/
|
||||||
Gbl.Usrs.Me.UsrDat.Prefs.AcceptCookies = Par_GetParBool ("cookies");
|
Gbl.Usrs.Me.UsrDat.Prefs.RefuseAcceptCookies = Par_GetParBool ("cookies") ? Coo_ACCEPT :
|
||||||
|
Coo_REFUSE;
|
||||||
|
|
||||||
/***** Store preference in database *****/
|
/***** Store preference in database *****/
|
||||||
if (Gbl.Usrs.Me.Logged)
|
if (Gbl.Usrs.Me.Logged)
|
||||||
|
@ -154,16 +160,16 @@ void Coo_GetAndShowNumUsrsPerCookies (void)
|
||||||
const char *Icon;
|
const char *Icon;
|
||||||
Ico_Color_t Color;
|
Ico_Color_t Color;
|
||||||
const char **Title;
|
const char **Title;
|
||||||
} Accepted[2] =
|
} Accepted[Coo_NUM_REFUSE_ACCEPT] =
|
||||||
{
|
{
|
||||||
[false] =
|
[Coo_REFUSE] =
|
||||||
{
|
{
|
||||||
.InDB = 'N',
|
.InDB = 'N',
|
||||||
.Icon = "times.svg",
|
.Icon = "times.svg",
|
||||||
.Color = Ico_RED,
|
.Color = Ico_RED,
|
||||||
.Title = &Txt_Do_not_accept_third_party_cookies
|
.Title = &Txt_Do_not_accept_third_party_cookies
|
||||||
},
|
},
|
||||||
[true ] =
|
[Coo_ACCEPT] =
|
||||||
{
|
{
|
||||||
.InDB = 'Y',
|
.InDB = 'Y',
|
||||||
.Icon = "check.svg",
|
.Icon = "check.svg",
|
||||||
|
@ -171,7 +177,7 @@ void Coo_GetAndShowNumUsrsPerCookies (void)
|
||||||
.Title = &Txt_Accept_third_party_cookies
|
.Title = &Txt_Accept_third_party_cookies
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
unsigned i;
|
Coo_RefuseAccept_t RefAcc;
|
||||||
char *SubQuery;
|
char *SubQuery;
|
||||||
unsigned NumUsrs[Mnu_NUM_MENUS];
|
unsigned NumUsrs[Mnu_NUM_MENUS];
|
||||||
unsigned NumUsrsTotal = 0;
|
unsigned NumUsrsTotal = 0;
|
||||||
|
@ -189,39 +195,39 @@ void Coo_GetAndShowNumUsrsPerCookies (void)
|
||||||
HTM_TR_End ();
|
HTM_TR_End ();
|
||||||
|
|
||||||
/***** For each option... *****/
|
/***** For each option... *****/
|
||||||
for (i = 0;
|
for (RefAcc = (Coo_RefuseAccept_t) 0;
|
||||||
i < 2;
|
RefAcc < (Coo_RefuseAccept_t) (Coo_NUM_REFUSE_ACCEPT - 1);
|
||||||
i++)
|
RefAcc++)
|
||||||
{
|
{
|
||||||
/* Get number of users who have chosen this menu from database */
|
/* Get number of users who have chosen this menu from database */
|
||||||
if (asprintf (&SubQuery,"usr_data.ThirdPartyCookies='%c'",
|
if (asprintf (&SubQuery,"usr_data.ThirdPartyCookies='%c'",
|
||||||
Accepted[i].InDB) < 0)
|
Accepted[RefAcc].InDB) < 0)
|
||||||
Err_NotEnoughMemoryExit ();
|
Err_NotEnoughMemoryExit ();
|
||||||
NumUsrs[i] = Usr_DB_GetNumUsrsWhoChoseAnOption (SubQuery);
|
NumUsrs[RefAcc] = Usr_DB_GetNumUsrsWhoChoseAnOption (SubQuery);
|
||||||
free (SubQuery);
|
free (SubQuery);
|
||||||
|
|
||||||
/* Update total number of users */
|
/* Update total number of users */
|
||||||
NumUsrsTotal += NumUsrs[i];
|
NumUsrsTotal += NumUsrs[RefAcc];
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Write number of users who have chosen each option *****/
|
/***** Write number of users who have chosen each option *****/
|
||||||
for (i = 0;
|
for (RefAcc = (Coo_RefuseAccept_t) 0;
|
||||||
i < 2;
|
RefAcc < (Coo_RefuseAccept_t) (Coo_NUM_REFUSE_ACCEPT - 1);
|
||||||
i++)
|
RefAcc++)
|
||||||
{
|
{
|
||||||
HTM_TR_Begin (NULL);
|
HTM_TR_Begin (NULL);
|
||||||
|
|
||||||
HTM_TD_Begin ("class=\"CM\"");
|
HTM_TD_Begin ("class=\"CM\"");
|
||||||
Ico_PutIcon (Accepted[i].Icon,Accepted[i].Color,
|
Ico_PutIcon (Accepted[RefAcc].Icon,Accepted[RefAcc].Color,
|
||||||
*Accepted[i].Title,"ICOx16");
|
*Accepted[RefAcc].Title,"ICOx16");
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
HTM_TD_Begin ("class=\"RM DAT_%s\"",The_GetSuffix ());
|
HTM_TD_Begin ("class=\"RM DAT_%s\"",The_GetSuffix ());
|
||||||
HTM_Unsigned (NumUsrs[i]);
|
HTM_Unsigned (NumUsrs[RefAcc]);
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
HTM_TD_Begin ("class=\"RM DAT_%s\"",The_GetSuffix ());
|
HTM_TD_Begin ("class=\"RM DAT_%s\"",The_GetSuffix ());
|
||||||
HTM_Percentage (NumUsrsTotal ? (double) NumUsrs[i] * 100.0 /
|
HTM_Percentage (NumUsrsTotal ? (double) NumUsrs[RefAcc] * 100.0 /
|
||||||
(double) NumUsrsTotal :
|
(double) NumUsrsTotal :
|
||||||
0.0);
|
0.0);
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
|
@ -29,6 +29,14 @@
|
||||||
|
|
||||||
#define Coo_COOKIES_ID "cookies"
|
#define Coo_COOKIES_ID "cookies"
|
||||||
|
|
||||||
|
#define Coo_NUM_REFUSE_ACCEPT 2
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
Coo_REFUSE,
|
||||||
|
Coo_ACCEPT,
|
||||||
|
} Coo_RefuseAccept_t;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/***************************** Public prototypes *****************************/
|
/***************************** Public prototypes *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -48,7 +48,7 @@ void Coo_DB_UpdateMyPrefsCookies (void)
|
||||||
"UPDATE usr_data"
|
"UPDATE usr_data"
|
||||||
" SET ThirdPartyCookies='%c'"
|
" SET ThirdPartyCookies='%c'"
|
||||||
" WHERE UsrCod=%ld",
|
" WHERE UsrCod=%ld",
|
||||||
Gbl.Usrs.Me.UsrDat.Prefs.AcceptCookies ? 'Y' :
|
Gbl.Usrs.Me.UsrDat.Prefs.RefuseAcceptCookies == Coo_ACCEPT ? 'Y' :
|
||||||
'N',
|
'N',
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ void TstVis_ShowVisibilityIcons (unsigned SelectedVisibility,
|
||||||
HidVis_HiddenOrVisible_t HiddenOrVisible)
|
HidVis_HiddenOrVisible_t HiddenOrVisible)
|
||||||
{
|
{
|
||||||
extern const char *Txt_TST_STR_VISIBILITY[TstVis_NUM_ITEMS_VISIBILITY];
|
extern const char *Txt_TST_STR_VISIBILITY[TstVis_NUM_ITEMS_VISIBILITY];
|
||||||
extern const char *Txt_TST_HIDDEN_VISIBLE[2];
|
extern const char *Txt_TST_HIDDEN_VISIBLE[HidVis_NUM_HIDDEN_VISIBLE];
|
||||||
static const char *Icons[TstVis_NUM_ITEMS_VISIBILITY] =
|
static const char *Icons[TstVis_NUM_ITEMS_VISIBILITY] =
|
||||||
{
|
{
|
||||||
[TstVis_VISIBLE_QST_ANS_TXT ] = "file-alt.svg",
|
[TstVis_VISIBLE_QST_ANS_TXT ] = "file-alt.svg",
|
||||||
|
@ -53,23 +53,27 @@ void TstVis_ShowVisibilityIcons (unsigned SelectedVisibility,
|
||||||
[TstVis_VISIBLE_EACH_QST_SCORE] = "tasks.svg",
|
[TstVis_VISIBLE_EACH_QST_SCORE] = "tasks.svg",
|
||||||
[TstVis_VISIBLE_TOTAL_SCORE ] = "check-circle-regular.svg",
|
[TstVis_VISIBLE_TOTAL_SCORE ] = "check-circle-regular.svg",
|
||||||
};
|
};
|
||||||
|
static Ico_Color_t Color[HidVis_NUM_HIDDEN_VISIBLE] =
|
||||||
|
{
|
||||||
|
[HidVis_HIDDEN ] = Ico_RED,
|
||||||
|
[HidVis_VISIBLE] = Ico_GREEN,
|
||||||
|
};
|
||||||
static void (*Ico_PutIcon[HidVis_NUM_HIDDEN_VISIBLE]) (const char *Icon,Ico_Color_t Color,const char *Title);
|
static void (*Ico_PutIcon[HidVis_NUM_HIDDEN_VISIBLE]) (const char *Icon,Ico_Color_t Color,const char *Title);
|
||||||
TstVis_Visibility_t Visibility;
|
TstVis_Visibility_t Visibility;
|
||||||
bool ItemVisible;
|
HidVis_HiddenOrVisible_t ItemHiddenOrVisible;
|
||||||
char *Title;
|
char *Title;
|
||||||
|
|
||||||
for (Visibility = (TstVis_Visibility_t) 0;
|
for (Visibility = (TstVis_Visibility_t) 0;
|
||||||
Visibility <= (TstVis_Visibility_t) (TstVis_NUM_ITEMS_VISIBILITY - 1);
|
Visibility <= (TstVis_Visibility_t) (TstVis_NUM_ITEMS_VISIBILITY - 1);
|
||||||
Visibility++)
|
Visibility++)
|
||||||
{
|
{
|
||||||
ItemVisible = (SelectedVisibility & (1 << Visibility)) != 0;
|
ItemHiddenOrVisible = ((SelectedVisibility & (1 << Visibility)) != 0) ? HidVis_VISIBLE :
|
||||||
|
HidVis_HIDDEN;
|
||||||
if (asprintf (&Title,"%s: %s",
|
if (asprintf (&Title,"%s: %s",
|
||||||
Txt_TST_STR_VISIBILITY[Visibility],
|
Txt_TST_STR_VISIBILITY[Visibility],
|
||||||
Txt_TST_HIDDEN_VISIBLE[ItemVisible]) < 0)
|
Txt_TST_HIDDEN_VISIBLE[ItemHiddenOrVisible]) < 0)
|
||||||
Err_NotEnoughMemoryExit ();
|
Err_NotEnoughMemoryExit ();
|
||||||
|
Ico_PutIcon[HiddenOrVisible] (Icons[Visibility],Color[ItemHiddenOrVisible],Title);
|
||||||
Ico_PutIcon[HiddenOrVisible] (Icons[Visibility],ItemVisible ? Ico_GREEN :
|
|
||||||
Ico_RED ,Title);
|
|
||||||
free (Title);
|
free (Title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54466,9 +54466,9 @@ const char *Txt_TST_Answer_given_by_the_user =
|
||||||
"Answer given by the user"; // Çeviri lazim!
|
"Answer given by the user"; // Çeviri lazim!
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char *Txt_TST_HIDDEN_VISIBLE[2] =
|
const char *Txt_TST_HIDDEN_VISIBLE[HidVis_NUM_HIDDEN_VISIBLE] =
|
||||||
{
|
{
|
||||||
[false] =
|
[HidVis_HIDDEN] =
|
||||||
#if L==1 // ca
|
#if L==1 // ca
|
||||||
"ocult"
|
"ocult"
|
||||||
#elif L==2 // de
|
#elif L==2 // de
|
||||||
|
@ -54491,7 +54491,7 @@ const char *Txt_TST_HIDDEN_VISIBLE[2] =
|
||||||
"hidden" // Çeviri lazim!
|
"hidden" // Çeviri lazim!
|
||||||
#endif
|
#endif
|
||||||
,
|
,
|
||||||
[true] =
|
[HidVis_VISIBLE] =
|
||||||
#if L==1 // ca
|
#if L==1 // ca
|
||||||
"visible"
|
"visible"
|
||||||
#elif L==2 // de
|
#elif L==2 // de
|
||||||
|
|
|
@ -349,8 +349,8 @@ void Usr_ResetUsrDataExceptUsrCodAndIDs (struct Usr_Data *UsrDat)
|
||||||
UsrDat->Prefs.Menu = Mnu_MENU_DEFAULT;
|
UsrDat->Prefs.Menu = Mnu_MENU_DEFAULT;
|
||||||
UsrDat->Prefs.SideCols = Cfg_DEFAULT_COLUMNS;
|
UsrDat->Prefs.SideCols = Cfg_DEFAULT_COLUMNS;
|
||||||
UsrDat->Prefs.PhotoShape = PhoSha_SHAPE_DEFAULT;
|
UsrDat->Prefs.PhotoShape = PhoSha_SHAPE_DEFAULT;
|
||||||
UsrDat->Prefs.AcceptCookies = false; // By default, don't accept third party cookies
|
UsrDat->Prefs.RefuseAcceptCookies = Coo_REFUSE; // By default, don't accept third party cookies
|
||||||
UsrDat->NtfEvents.SendEmail = 0; // By default, don't notify anything
|
UsrDat->NtfEvents.SendEmail = 0; // By default, don't notify anything
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -562,7 +562,8 @@ void Usr_GetUsrDataFromUsrCod (struct Usr_Data *UsrDat,
|
||||||
UsrDat->Prefs.Menu = Mnu_GetMenuFromStr (row[28]);
|
UsrDat->Prefs.Menu = Mnu_GetMenuFromStr (row[28]);
|
||||||
UsrDat->Prefs.SideCols = Set_GetSideColsFromStr (row[29]);
|
UsrDat->Prefs.SideCols = Set_GetSideColsFromStr (row[29]);
|
||||||
UsrDat->Prefs.PhotoShape = PhoSha_GetShapeFromStr (row[30]);
|
UsrDat->Prefs.PhotoShape = PhoSha_GetShapeFromStr (row[30]);
|
||||||
UsrDat->Prefs.AcceptCookies = (row[31][0] == 'Y');
|
UsrDat->Prefs.RefuseAcceptCookies = (row[31][0] == 'Y') ? Coo_ACCEPT :
|
||||||
|
Coo_REFUSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include "swad_action.h"
|
#include "swad_action.h"
|
||||||
#include "swad_constant.h"
|
#include "swad_constant.h"
|
||||||
|
#include "swad_cookie.h"
|
||||||
#include "swad_country.h"
|
#include "swad_country.h"
|
||||||
#include "swad_cryptography.h"
|
#include "swad_cryptography.h"
|
||||||
#include "swad_date.h"
|
#include "swad_date.h"
|
||||||
|
@ -217,7 +218,7 @@ struct Usr_Data
|
||||||
Mnu_Menu_t Menu;
|
Mnu_Menu_t Menu;
|
||||||
unsigned SideCols;
|
unsigned SideCols;
|
||||||
PhoSha_Shape_t PhotoShape;
|
PhoSha_Shape_t PhotoShape;
|
||||||
bool AcceptCookies; // User has accepted third party cookies
|
Coo_RefuseAccept_t RefuseAcceptCookies; // User has accepted third party cookies
|
||||||
} Prefs;
|
} Prefs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue