From 917d5198866d5e7d668d3eb1770edb4991dc90d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Thu, 16 Jun 2016 18:05:23 +0200 Subject: [PATCH] Version 15.225.13 --- swad_changelog.h | 4 +++- swad_duplicate.c | 5 ++++- swad_user.c | 35 +++++++++++++++++++++++++++++++++-- swad_user.h | 4 ++++ 4 files changed, 44 insertions(+), 4 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 8dea0fd5..6d87fe39 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -128,13 +128,15 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.225.12 (2016-06-16)" +#define Log_PLATFORM_VERSION "SWAD 15.225.14 (2016-06-16)" #define CSS_FILE "swad15.225.11.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.14:Jun 16, 2016 Button in possible duplicate user to show similar users. (? lines) + Version 15.225.13:Jun 16, 2016 Check if a user in listing of possible duplicate users has accepted all his/her courses. (? lines) Version 15.225.12:Jun 16, 2016 New module swad_duplicate for possible duplicate users. (202758 lines) Version 15.225.11:Jun 16, 2016 Listing possible duplicate users. (202667 lines) Version 15.225.10:Jun 15, 2016 Listing possible duplicate users. (202626 lines) diff --git a/swad_duplicate.c b/swad_duplicate.c index 63ac3061..30708ba5 100644 --- a/swad_duplicate.c +++ b/swad_duplicate.c @@ -180,7 +180,10 @@ void Dup_ListDuplicateUsrs (void) UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]); if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) { - UsrDat.Accepted = false; // TODO: Get this from database + if (Usr_GetNumCrssOfUsr (UsrDat.UsrCod) != 0) + UsrDat.Accepted = (Usr_GetNumCrssOfUsrNotAccepted (UsrDat.UsrCod) == 0); + else + UsrDat.Accepted = false; /* Write data of this user */ Usr_WriteRowUsrMainData (NumUsrs - NumUsr,&UsrDat,false); diff --git a/swad_user.c b/swad_user.c index e2592ab1..7a11beb2 100644 --- a/swad_user.c +++ b/swad_user.c @@ -786,6 +786,36 @@ bool Usr_CheckIfUsrIsSuperuser (long UsrCod) return (DB_QueryCOUNT (Query,"can not check if a user is superuser") != 0); } +/*****************************************************************************/ +/********************* Get number of courses of a user ***********************/ +/*****************************************************************************/ + +unsigned Usr_GetNumCrssOfUsr (long UsrCod) + { + char Query[128]; + + /***** Get the number of courses of a user from database ******/ + sprintf (Query,"SELECT COUNT(*) FROM crs_usr" + " WHERE UsrCod='%ld'", + UsrCod); + return (unsigned) DB_QueryCOUNT (Query,"can not get the number of courses of a user"); + } + +/*****************************************************************************/ +/*************** Get number of courses of a user not accepted ****************/ +/*****************************************************************************/ + +unsigned Usr_GetNumCrssOfUsrNotAccepted (long UsrCod) + { + char Query[256]; + + /***** Get the number of courses of a user not accepted from database ******/ + sprintf (Query,"SELECT COUNT(*) FROM crs_usr" + " WHERE UsrCod='%ld' AND Accepted='N'", + UsrCod); + return (unsigned) DB_QueryCOUNT (Query,"can not get the number of courses of a user not accepted"); + } + /*****************************************************************************/ /********* Get number of courses in with a user have a given role ************/ /*****************************************************************************/ @@ -794,7 +824,7 @@ unsigned Usr_GetNumCrssOfUsrWithARole (long UsrCod,Rol_Role_t Role) { char Query[128]; - /***** Get the number of teachers in a course from database ******/ + /***** Get the number of courses of a user with a role from database ******/ sprintf (Query,"SELECT COUNT(*) FROM crs_usr" " WHERE UsrCod='%ld' AND Role='%u'", UsrCod,(unsigned) Role); @@ -6117,7 +6147,8 @@ static void Usr_GetMyUsrListTypeFromDB (void) Usr_ShowUsrsType_t ListType; /***** Get type of listing of users from database *****/ - sprintf (Query,"SELECT UsrListType FROM crs_usr WHERE CrsCod='%ld' AND UsrCod='%ld'", + sprintf (Query,"SELECT UsrListType FROM crs_usr" + " WHERE CrsCod='%ld' AND UsrCod='%ld'", Gbl.CurrentCrs.Crs.CrsCod,Gbl.Usrs.Me.UsrDat.UsrCod); NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get type of listing of users"); diff --git a/swad_user.h b/swad_user.h index 803e0073..08529320 100644 --- a/swad_user.h +++ b/swad_user.h @@ -216,6 +216,9 @@ void Usr_RestrictLengthAndWriteName (const struct UsrData *UsrDat,unsigned MaxCh bool Usr_CheckIfUsrIsAdm (long UsrCod,Sco_Scope_t Scope,long Cod); bool Usr_CheckIfUsrIsSuperuser (long UsrCod); + +unsigned Usr_GetNumCrssOfUsr (long UsrCod); +unsigned Usr_GetNumCrssOfUsrNotAccepted (long UsrCod); unsigned Usr_GetNumCrssOfUsrWithARole (long UsrCod,Rol_Role_t Role); unsigned Usr_GetNumUsrsInCrssOfAUsr (long UsrCod,Rol_Role_t UsrRole, Rol_Role_t OthersRole); @@ -241,6 +244,7 @@ bool Usr_CheckIfIBelongToIns (long InsCod); bool Usr_CheckIfIBelongToCtr (long CtrCod); bool Usr_CheckIfIBelongToDeg (long DegCod); bool Usr_CheckIfIBelongToCrs (long CrsCod); + unsigned Usr_GetCtysFromUsr (long UsrCod,MYSQL_RES **mysql_res); unsigned long Usr_GetInssFromUsr (long UsrCod,long CtyCod,MYSQL_RES **mysql_res); unsigned long Usr_GetCtrsFromUsr (long UsrCod,long InsCod,MYSQL_RES **mysql_res);