From bca5387cfea0faa7029fa746d0fbaefd950f3930 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Wed, 15 Jun 2016 20:35:49 +0200 Subject: [PATCH] Version 15.225.10 --- swad_changelog.h | 3 +- swad_course.c | 12 +++++ swad_user.c | 111 +++++++++++++++++++---------------------------- swad_user.h | 2 + 4 files changed, 61 insertions(+), 67 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 5c08910e..656edfcf 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -128,13 +128,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.225.9 (2016-06-15)" +#define Log_PLATFORM_VERSION "SWAD 15.225.10 (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.10:Jun 15, 2016 Listing possible duplicate users. (202626 lines) 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) diff --git a/swad_course.c b/swad_course.c index c4e015de..e3ffd241 100644 --- a/swad_course.c +++ b/swad_course.c @@ -2974,6 +2974,13 @@ void Crs_GetAndWriteCrssOfAUsr (long UsrCod,Rol_Role_t Role) /***** List the courses (one row per course) *****/ if ((NumCrss = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get courses of a user"))) { + /* Start frame and table */ + fprintf (Gbl.F.Out,"" + "" + "", + Usr_NUM_MAIN_FIELDS_DATA_USR-2); + Lay_StartRoundFrameTable (NULL,2,NULL); + /* Heading row */ fprintf (Gbl.F.Out,"" "" @@ -3011,6 +3018,11 @@ void Crs_GetAndWriteCrssOfAUsr (long UsrCod,Rol_Role_t Role) /* Write data of this course */ Crs_WriteRowCrsData (NumCrs,row,true); } + + /* End table and frame */ + Lay_EndRoundFrameTable (); + fprintf (Gbl.F.Out,"" + ""); } /***** Free structure that stores the query result *****/ diff --git a/swad_user.c b/swad_user.c index 5c920f51..5666cbb0 100644 --- a/swad_user.c +++ b/swad_user.c @@ -83,7 +83,6 @@ const char *Usr_IconsClassPhotoOrList[Usr_NUM_USR_LIST_TYPES] = "list64x64.gif" }; -#define Usr_NUM_MAIN_FIELDS_DATA_USR 9 #define Usr_NUM_MAIN_FIELDS_DATA_ADM 8 #define Usr_NUM_ALL_FIELDS_DATA_INV 17 #define Usr_NUM_ALL_FIELDS_DATA_STD 13 @@ -5874,17 +5873,7 @@ unsigned Usr_ListUsrsFound (Rol_Role_t Role,const char *UsrQuery) /* Write all the courses this user belongs to */ if (Role != Rol__GUEST_) - { - fprintf (Gbl.F.Out,"" - "" - "", - Usr_NUM_MAIN_FIELDS_DATA_USR-2); - Lay_StartRoundFrameTable (NULL,2,NULL); Crs_GetAndWriteCrssOfAUsr (UsrDat.UsrCod,Role); - Lay_EndRoundFrameTable (); - fprintf (Gbl.F.Out,"" - ""); - } } } @@ -7741,17 +7730,16 @@ void Usr_ListDuplicateUsrs (void) extern const char *Txt_Possibly_duplicate_users; extern const char *Txt_User[Usr_NUM_SEXS]; extern const char *Txt_Informants; - extern const char *Txt_Date; extern const char *Txt_No_users_found[Rol_NUM_ROLES]; char Query[1024]; MYSQL_RES *mysql_res; MYSQL_ROW row; + unsigned NumCol; unsigned NumUsrs; unsigned NumUsr; struct UsrData UsrDat; - unsigned NumInformers; - bool ShowPhoto = false; - char PhotoURL[PATH_MAX+1]; + unsigned NumInformants; + Rol_Role_t Role; /***** Start frame with list of possible duplicate users *****/ Lay_StartRoundFrame (NULL,Txt_Possibly_duplicate_users,NULL); @@ -7765,29 +7753,31 @@ void Usr_ListDuplicateUsrs (void) /***** List possible duplicated users *****/ if (NumUsrs) - { - /* Initialize structure with user's data */ + { + /***** Initialize field names *****/ + Usr_SetUsrDatMainFieldNames (); + + /***** Initialize structure with user's data *****/ Usr_UsrDataConstructor (&UsrDat); - /* Start table */ - fprintf (Gbl.F.Out,"" - "" - "" - "" - "" - "", - Txt_User[Usr_SEX_UNKNOWN], - Txt_Informants, - Txt_Date); + /***** Start table *****/ + fprintf (Gbl.F.Out,"
" - "%s" - "" - "%s" - "" - "%s" - "
"); - /* List users */ + /***** Heading row with column names *****/ + /* Start row */ + fprintf (Gbl.F.Out,""); + for (NumCol = 0; + NumCol < Usr_NUM_MAIN_FIELDS_DATA_USR; + NumCol++) + fprintf (Gbl.F.Out,"", + Usr_UsrDatMainFieldNames[NumCol]); + + /* End row */ + fprintf (Gbl.F.Out,""); + + /***** List users *****/ for (NumUsr = 0; NumUsr < NumUsrs; NumUsr++) @@ -7798,49 +7788,38 @@ void Usr_ListDuplicateUsrs (void) UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]); if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) { - /***** Number *****/ - fprintf (Gbl.F.Out,"" - "", - NumUsrs - NumUsr); + UsrDat.Accepted = false; // TODO: Get this from database - /***** User photo *****/ - fprintf (Gbl.F.Out,""); + /* Write data of this user */ + Usr_WriteRowUsrMainData (NumUsrs - NumUsr,&UsrDat,false); - /***** User name *****/ - fprintf (Gbl.F.Out,""); - - /***** Number of informers (row[1]) *****/ - if (sscanf (row[1],"%u",&NumInformers) != 1) + /* Write number of informants (row[1]) if greater than 1 */ + if (sscanf (row[1],"%u",&NumInformants) != 1) Lay_ShowErrorAndExit ("Wrong number of informers."); - fprintf (Gbl.F.Out,"", - NumInformers); + if (NumInformants > 1) + fprintf (Gbl.F.Out,"" + "" + "" + "", + Usr_NUM_MAIN_FIELDS_DATA_USR-2, + Txt_Informants, + NumInformants); - /***** Inform time (row[2]) *****/ - Msg_WriteMsgDate (Dat_GetUNIXTimeFromStr (row[2]),"DAT"); - - fprintf (Gbl.F.Out,""); + /* Write all the courses this user belongs to */ + for (Role = Rol_STUDENT; + Role <= Rol_TEACHER; + Role++) + Crs_GetAndWriteCrssOfAUsr (UsrDat.UsrCod,Role); } else // User does not exists ==> // remove user from table of possible duplicate users Usr_RemoveUsrFromDuplicated (UsrDat.UsrCod); } - /* End table */ + /***** End table *****/ fprintf (Gbl.F.Out,"
" + "%s " + "
" - "%u" - ""); - ShowPhoto = Pho_ShowUsrPhotoIsAllowed (&UsrDat,PhotoURL); - Pho_ShowUsrPhoto (&UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO21x28",Pho_ZOOM,false); - fprintf (Gbl.F.Out,""); - Usr_RestrictLengthAndWriteName (&UsrDat,20); - fprintf (Gbl.F.Out,"" - "%u" - "
%s: %u
"); - /* Free memory used for user's data */ + /***** Free memory used for user's data *****/ Usr_UsrDataDestructor (&UsrDat); } else // There are no users diff --git a/swad_user.h b/swad_user.h index 1e8e5742..51584159 100644 --- a/swad_user.h +++ b/swad_user.h @@ -73,6 +73,8 @@ #define Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS (Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64*Cfg_MAX_USRS_IN_LIST) +#define Usr_NUM_MAIN_FIELDS_DATA_USR 9 + /*****************************************************************************/ /******************************** Public types *******************************/ /*****************************************************************************/