diff --git a/swad_API.c b/swad_API.c index d448a771..590a79d6 100644 --- a/swad_API.c +++ b/swad_API.c @@ -639,8 +639,7 @@ int swad__createAccount (struct soap *soap, sizeof (Gbl.Usrs.Me.UsrDat.Password) - 1); /***** User does not exist in the platform, so create him/her! *****/ - Acc_CreateNewUsr (&Gbl.Usrs.Me.UsrDat, - true); // I am creating my own account + Acc_CreateNewUsr (&Gbl.Usrs.Me.UsrDat,Usr_ME); /***** Save nickname *****/ Nck_DB_UpdateNick (Gbl.Usrs.Me.UsrDat.UsrCod,NewNickWithoutArr); diff --git a/swad_account.c b/swad_account.c index ca0f461b..f3987db8 100644 --- a/swad_account.c +++ b/swad_account.c @@ -610,8 +610,7 @@ bool Acc_CreateMyNewAccountAndLogIn (void) sizeof (Gbl.Usrs.Me.UsrDat.Password) - 1); /***** User does not exist in the platform, so create him/her! *****/ - Acc_CreateNewUsr (&Gbl.Usrs.Me.UsrDat, - true); // I am creating my own account + Acc_CreateNewUsr (&Gbl.Usrs.Me.UsrDat,Usr_ME); /***** Save nickname *****/ Nck_DB_UpdateNick (Gbl.Usrs.Me.UsrDat.UsrCod,NewNickWithoutArr); @@ -723,7 +722,7 @@ static bool Acc_GetParsNewAccount (char NewNickWithoutArr[Nck_MAX_BYTES_NICK_WIT // UsrDat->UsrCod must be <= 0 // UsrDat->UsrDat.IDs must contain a list of IDs for the new user -void Acc_CreateNewUsr (struct Usr_Data *UsrDat,bool CreatingMyOwnAccount) +void Acc_CreateNewUsr (struct Usr_Data *UsrDat,Usr_MeOrOther_t MeOrOther) { char PathRelUsr[PATH_MAX + 1]; unsigned NumID; @@ -758,7 +757,7 @@ void Acc_CreateNewUsr (struct Usr_Data *UsrDat,bool CreatingMyOwnAccount) Fil_CreateDirIfNotExists (PathRelUsr); /***** Create user's figures *****/ - Prf_CreateNewUsrFigures (UsrDat->UsrCod,CreatingMyOwnAccount); + Prf_CreateNewUsrFigures (UsrDat->UsrCod,MeOrOther); } /*****************************************************************************/ diff --git a/swad_account.h b/swad_account.h index 8a2a2468..edff1282 100644 --- a/swad_account.h +++ b/swad_account.h @@ -56,7 +56,7 @@ void Acc_ShowFormChgMyAccount (void); void Acc_ShowFormChgOtherUsrAccount (void); void Acc_PutLinkToRemoveMyAccount (__attribute__((unused)) void *Args); bool Acc_CreateMyNewAccountAndLogIn (void); -void Acc_CreateNewUsr (struct Usr_Data *UsrDat,bool CreatingMyOwnAccount); +void Acc_CreateNewUsr (struct Usr_Data *UsrDat,Usr_MeOrOther_t MeOrOther); void Acc_AfterCreationNewAccount (void); void Acc_GetUsrCodAndRemUsrGbl (void); diff --git a/swad_changelog.h b/swad_changelog.h index 5e68b46f..fdf6c498 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -629,11 +629,12 @@ 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. */ -#define Log_PLATFORM_VERSION "SWAD 22.118.8 (2023-05-30)" +#define Log_PLATFORM_VERSION "SWAD 22.118.9 (2023-05-30)" #define CSS_FILE "swad22.118.5.css" #define JS_FILE "swad22.49.js" /* - Version 22.118.8: May 30, 2023 Fixed bugs users. (337361 lines) + Version 22.118.9: May 30, 2023 Code refactoring in user account. (337363 lines) + Version 22.118.8: May 30, 2023 Fixed bugs in users. (337361 lines) Version 22.118.7: May 30, 2023 Fixed bug in photo processing. Reported by Emilio Alemán Carmona. (337364 lines) Version 22.118.6: May 24, 2023 Fixed bug in rubrics. (337363 lines) Version 22.118.5: May 23, 2023 Changes in comments in surveys. (337360 lines) diff --git a/swad_enrolment.c b/swad_enrolment.c index 05d44ea9..8e873b64 100644 --- a/swad_enrolment.c +++ b/swad_enrolment.c @@ -1663,8 +1663,7 @@ static void Enr_RegisterUsr (struct Usr_Data *UsrDat,Rol_Role_t RegRemRole, /* User does not exist in database; list of IDs is initialized */ UsrDat->IDs.List[0].Confirmed = true; // If he/she is a new user ==> his/her ID will be stored as confirmed in database - Acc_CreateNewUsr (UsrDat, - false); // I am NOT creating my own account + Acc_CreateNewUsr (UsrDat,Usr_OTHER); } /***** Register user in current course in database *****/ @@ -2793,8 +2792,7 @@ void Enr_CreateNewUsr1 (void) /***** Create user *****/ Gbl.Usrs.Other.UsrDat.IDs.List[0].Confirmed = true; // User's ID will be stored as confirmed - Acc_CreateNewUsr (&Gbl.Usrs.Other.UsrDat, - false); // I am NOT creating my own account + Acc_CreateNewUsr (&Gbl.Usrs.Other.UsrDat,Usr_OTHER); /***** Register user in current course in database *****/ if (Gbl.Hierarchy.Level == HieLvl_CRS) // Course selected diff --git a/swad_profile.c b/swad_profile.c index 72263a76..7468a595 100644 --- a/swad_profile.c +++ b/swad_profile.c @@ -1100,7 +1100,7 @@ static void Prf_GetNumMessagesSentAndStoreAsUsrFigure (long UsrCod) /******************* Create user's figures for a new user ********************/ /*****************************************************************************/ -void Prf_CreateNewUsrFigures (long UsrCod,bool CreatingMyOwnAccount) +void Prf_CreateNewUsrFigures (long UsrCod,Usr_MeOrOther_t MeOrOther) { struct Prf_UsrFigures UsrFigures; @@ -1113,7 +1113,7 @@ void Prf_CreateNewUsrFigures (long UsrCod,bool CreatingMyOwnAccount) UsrFigures.NumMessagesSent = 0; // set number of messages sent to 0 /***** Create user's figures *****/ - Prf_DB_CreateUsrFigures (UsrCod,&UsrFigures,CreatingMyOwnAccount); + Prf_DB_CreateUsrFigures (UsrCod,&UsrFigures,MeOrOther); } /*****************************************************************************/ diff --git a/swad_profile.h b/swad_profile.h index a14f9766..37d22643 100644 --- a/swad_profile.h +++ b/swad_profile.h @@ -68,7 +68,7 @@ void Prf_GetUsrFigures (long UsrCod,struct Prf_UsrFigures *UsrFigures); void Prf_CalculateFigures (void); bool Prf_GetAndStoreAllUsrFigures (long UsrCod,struct Prf_UsrFigures *UsrFigures); -void Prf_CreateNewUsrFigures (long UsrCod,bool CreatingMyOwnAccount); +void Prf_CreateNewUsrFigures (long UsrCod,Usr_MeOrOther_t MeOrOther); void Prf_GetAndShowRankingClicks (void); void Prf_GetAndShowRankingTimelinePubs (void); diff --git a/swad_profile_database.c b/swad_profile_database.c index a8f9c430..4a26c145 100644 --- a/swad_profile_database.c +++ b/swad_profile_database.c @@ -41,17 +41,22 @@ extern struct Globals Gbl; /*****************************************************************************/ void Prf_DB_CreateUsrFigures (long UsrCod,const struct Prf_UsrFigures *UsrFigures, - bool CreatingMyOwnAccount) + Usr_MeOrOther_t MeOrOther) { char SubQueryFirstClickTime[64]; - if (CreatingMyOwnAccount) - // This is the first click - Str_Copy (SubQueryFirstClickTime,"NOW()",sizeof (SubQueryFirstClickTime) - 1); - else - snprintf (SubQueryFirstClickTime,sizeof (SubQueryFirstClickTime), - "FROM_UNIXTIME(%ld)", - (long) UsrFigures->FirstClickTimeUTC); // 0 ==> unknown first click time or user never logged + switch (MeOrOther) + { + case Usr_ME: + // This is the first click + Str_Copy (SubQueryFirstClickTime,"NOW()",sizeof (SubQueryFirstClickTime) - 1); + break; + case Usr_OTHER: + snprintf (SubQueryFirstClickTime,sizeof (SubQueryFirstClickTime), + "FROM_UNIXTIME(%ld)", + (long) UsrFigures->FirstClickTimeUTC); // 0 ==> unknown first click time or user never logged + break; + } DB_QueryINSERT ("can not create user's figures", "INSERT INTO usr_figures" diff --git a/swad_profile_database.h b/swad_profile_database.h index 1220a2cd..fb77d311 100644 --- a/swad_profile_database.h +++ b/swad_profile_database.h @@ -34,7 +34,7 @@ /*****************************************************************************/ void Prf_DB_CreateUsrFigures (long UsrCod,const struct Prf_UsrFigures *UsrFigures, - bool CreatingMyOwnAccount); + Usr_MeOrOther_t MeOrOther); void Prf_DB_UpdateFirstClickTimeUsr (long UsrCod,time_t FirstClickTimeUTC); void Prf_DB_UpdateNumClicksUsr (long UsrCod,int NumClicks); void Prf_DB_UpdateNumTimelinePubsUsr (long UsrCod,int NumTimelinePubs);