From c3a525f9309396ba498690c9899e68b111500cbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Wed, 15 Jun 2016 20:04:15 +0200 Subject: [PATCH] Version 15.225.9 --- swad_changelog.h | 3 +- swad_user.c | 184 +++-------------------------------------------- swad_user.h | 2 +- 3 files changed, 11 insertions(+), 178 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index d12e4c3e1..5c08910ea 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -128,13 +128,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.225.8 (2016-06-15)" +#define Log_PLATFORM_VERSION "SWAD 15.225.9 (2016-06-15)" #define CSS_FILE "swad15.224.3.css" #define JS_FILE "swad15.216.js" // Number of lines (includes comments but not blank lines) has been got with the following command: // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1 /* + Version 15.225.9: Jun 15, 2016 Code refactoring in list of students and teachers. (202636 lines) Version 15.225.8: Jun 15, 2016 Code refactoring in list of students and teachers. (202779 lines) Version 15.225.7: Jun 15, 2016 Listing possible duplicate users. (202775 lines) Version 15.225.6: Jun 15, 2016 Listing possible duplicate users. (202761 lines) diff --git a/swad_user.c b/swad_user.c index c77e89fd6..5c920f518 100644 --- a/swad_user.c +++ b/swad_user.c @@ -128,9 +128,6 @@ static void Usr_SetUsrRoleAndPrefs (void); static void Usr_InsertMyLastData (void); -static void Usr_WriteRowGstMainData (unsigned NumUsr,struct UsrData *UsrDat); -static void Usr_WriteRowTchMainData (unsigned NumUsr,struct UsrData *UsrDat, - bool PutCheckBoxToSelectUsr); static void Usr_WriteRowGstAllData (struct UsrData *UsrDat); static void Usr_RestrictLengthUsrName (struct UsrData *UsrDat); static void Usr_WriteMainUsrDataExceptUsrID (struct UsrData *UsrDat, @@ -2707,79 +2704,10 @@ static void Usr_InsertMyLastData (void) } /*****************************************************************************/ -/************* Write a row of a table with the data of a guest ***************/ +/*********** Write a row of a table with the main data of a user *************/ /*****************************************************************************/ -static void Usr_WriteRowGstMainData (unsigned NumUsr,struct UsrData *UsrDat) - { - char PhotoURL[PATH_MAX+1]; - bool ShowPhoto; - struct Institution Ins; - - /***** Start row *****/ - fprintf (Gbl.F.Out,""); - - /***** Checkbox to select user *****/ - // Two colors are used alternatively to better distinguish the rows - fprintf (Gbl.F.Out,"", - Gbl.RowEvenOdd); - Usr_PutCheckboxToSelectUser (UsrDat,false); - fprintf (Gbl.F.Out,""); - - /***** Guest has accepted enrollment in current course? *****/ - fprintf (Gbl.F.Out,"" - "\"\"" - "", - Gbl.RowEvenOdd, - Gbl.Prefs.IconsURL); - - /***** Write number of user in the list *****/ - fprintf (Gbl.F.Out,"" - " %u " - "", - Gbl.RowEvenOdd,NumUsr); - - if (Gbl.Usrs.Listing.WithPhotos) - { - /***** Show guest's photo *****/ - fprintf (Gbl.F.Out,"", - Gbl.RowEvenOdd); - ShowPhoto = Pho_ShowUsrPhotoIsAllowed (UsrDat,PhotoURL); - Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO21x28",Pho_ZOOM,false); - fprintf (Gbl.F.Out,""); - } - - /****** Write user's IDs ******/ - fprintf (Gbl.F.Out,"", - UsrDat->Accepted ? "DAT_SMALL_N" : - "DAT_SMALL", - Gbl.RowEvenOdd); - ID_WriteUsrIDs (UsrDat); - fprintf (Gbl.F.Out,""); - - /***** Write rest of main guest's data *****/ - Ins.InsCod = UsrDat->InsCod; - Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA); - Usr_RestrictLengthUsrName (UsrDat); - Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd], - Ins.ShortName,Ins.WWW[0] ? Ins.WWW : - NULL); - - /***** End row *****/ - fprintf (Gbl.F.Out,""); - - Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd; - } - -/*****************************************************************************/ -/************ Write a row of a table with the data of a student **************/ -/*****************************************************************************/ - -void Usr_WriteRowStdMainData (unsigned NumUsr,struct UsrData *UsrDat, +void Usr_WriteRowUsrMainData (unsigned NumUsr,struct UsrData *UsrDat, bool PutCheckBoxToSelectUsr) { extern const char *Txt_Enrollment_confirmed; @@ -3082,99 +3010,6 @@ void Usr_WriteRowStdAllData (struct UsrData *UsrDat,char *GroupNames) Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd; } -/*****************************************************************************/ -/************* Write a row of a table with the data of a teacher *************/ -/*****************************************************************************/ - -static void Usr_WriteRowTchMainData (unsigned NumUsr,struct UsrData *UsrDat, - bool PutCheckBoxToSelectUsr) - { - extern const char *Txt_Enrollment_confirmed; - extern const char *Txt_Enrollment_not_confirmed; - const char *BgColor; - char PhotoURL[PATH_MAX+1]; - bool ShowPhoto; - bool UsrIsTheMsgSender = PutCheckBoxToSelectUsr && - (UsrDat->UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod); - struct Institution Ins; - - /***** Start row *****/ - fprintf (Gbl.F.Out,""); - - /***** Checkbox to select user *****/ - // Two colors are used alternatively to better distinguish the rows - BgColor = UsrIsTheMsgSender ? "LIGHT_GREEN" : - Gbl.ColorRows[Gbl.RowEvenOdd]; - if (PutCheckBoxToSelectUsr) - { - fprintf (Gbl.F.Out,"",BgColor); - - Usr_PutCheckboxToSelectUser (UsrDat,UsrIsTheMsgSender); - - fprintf (Gbl.F.Out,""); - } - - /***** User has accepted enrollment? *****/ - fprintf (Gbl.F.Out,"" - "\"%s\"" - "", - Gbl.Prefs.IconsURL, - UsrDat->Accepted ? "ok_on" : - "tr", - UsrDat->Accepted ? Txt_Enrollment_confirmed : - Txt_Enrollment_not_confirmed, - UsrDat->Accepted ? Txt_Enrollment_confirmed : - Txt_Enrollment_not_confirmed); - - /***** Write number of user in the list *****/ - fprintf (Gbl.F.Out,"" - " %u " - "", - UsrDat->Accepted ? "DAT_SMALL_N" : - "DAT_SMALL", - BgColor, - NumUsr); - - if (Gbl.Usrs.Listing.WithPhotos) - { - /***** Show user's photo *****/ - fprintf (Gbl.F.Out,"",BgColor); - ShowPhoto = Pho_ShowUsrPhotoIsAllowed (UsrDat,PhotoURL); - Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO21x28",Pho_ZOOM,false); - fprintf (Gbl.F.Out,""); - } - - /****** Write user's IDs ******/ - fprintf (Gbl.F.Out,"", - UsrDat->Accepted ? "DAT_SMALL_N" : - "DAT_SMALL", - BgColor); - ID_WriteUsrIDs (UsrDat); - fprintf (Gbl.F.Out,""); - - /***** Write rest of main user's data *****/ - Ins.InsCod = UsrDat->InsCod; - Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA); - Usr_RestrictLengthUsrName (UsrDat); - Usr_WriteMainUsrDataExceptUsrID (UsrDat,BgColor, - Ins.ShortName,Ins.WWW[0] ? Ins.WWW : - NULL); - - /***** End row *****/ - fprintf (Gbl.F.Out,""); - - Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd; - } - /*****************************************************************************/ /*** Write a row of a table with the data of a teacher or an administrator ***/ /*****************************************************************************/ @@ -5318,7 +5153,7 @@ static void Usr_ListMainDataGsts (bool PutCheckBoxToSelectUsr) UsrDat.Accepted = false; // Guests have no courses,... // ...so they have not accepted... // ...inscription in any course - Usr_WriteRowGstMainData (++NumUsr,&UsrDat); + Usr_WriteRowUsrMainData (++NumUsr,&UsrDat,true); } } @@ -5399,7 +5234,7 @@ static void Usr_ListMainDataStds (bool PutCheckBoxToSelectUsr) if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // If user's data exist... { UsrDat.Accepted = Gbl.Usrs.LstStds.Lst[NumUsr].Accepted; - Usr_WriteRowStdMainData (++NumUsr,&UsrDat,PutCheckBoxToSelectUsr); + Usr_WriteRowUsrMainData (++NumUsr,&UsrDat,PutCheckBoxToSelectUsr); } } @@ -5470,7 +5305,7 @@ static void Usr_ListMainDataTchs (bool PutCheckBoxToSelectUsr) if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // If user's data exist... { UsrDat.Accepted = Gbl.Usrs.LstTchs.Lst[NumUsr].Accepted; - Usr_WriteRowTchMainData (++NumUsr,&UsrDat,PutCheckBoxToSelectUsr); + Usr_WriteRowUsrMainData (++NumUsr,&UsrDat,PutCheckBoxToSelectUsr); } } @@ -5841,7 +5676,7 @@ void Usr_ListUsrsForSelection (Rol_Role_t Role) if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // If user's data exist... { UsrDat.Accepted = Gbl.Usrs.LstStds.Lst[NumUsr].Accepted; - Usr_WriteRowStdMainData (++NumUsr,&UsrDat,true); + Usr_WriteRowUsrMainData (++NumUsr,&UsrDat,true); } } break; @@ -5853,7 +5688,7 @@ void Usr_ListUsrsForSelection (Rol_Role_t Role) if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // If user's data exist... { UsrDat.Accepted = Gbl.Usrs.LstTchs.Lst[NumUsr].Accepted; - Usr_WriteRowTchMainData (++NumUsr,&UsrDat,true); + Usr_WriteRowUsrMainData (++NumUsr,&UsrDat,true); } } break; @@ -6035,10 +5870,7 @@ unsigned Usr_ListUsrsFound (Rol_Role_t Role,const char *UsrQuery) UsrDat.Accepted = LstUsrs->Lst[NumUsr].Accepted; /* Write data of this user */ - if (Role == Rol_STUDENT) - Usr_WriteRowStdMainData (NumUsr + 1,&UsrDat,false); - else // Role == Rol_ROLE_TEACHER - Usr_WriteRowTchMainData (NumUsr + 1,&UsrDat,false); + Usr_WriteRowUsrMainData (NumUsr + 1,&UsrDat,false); /* Write all the courses this user belongs to */ if (Role != Rol__GUEST_) diff --git a/swad_user.h b/swad_user.h index 0957b8062..1e8e57426 100644 --- a/swad_user.h +++ b/swad_user.h @@ -277,7 +277,7 @@ bool Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (struct UsrData *UsrDat); void Usr_UpdateMyLastData (void); void Usr_InsertMyLastCrsTabAndTime (void); -void Usr_WriteRowStdMainData (unsigned NumUsr,struct UsrData *UsrDat, +void Usr_WriteRowUsrMainData (unsigned NumUsr,struct UsrData *UsrDat, bool PutCheckboxToSelectUsr); void Usr_WriteRowStdAllData (struct UsrData *UsrDat,char *GrpNames); void Usr_WriteRowTchAllData (struct UsrData *UsrDat);