From 2cb2070d618a252a73e874a3deb679b11c5dc8ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Sat, 18 Jun 2016 01:01:26 +0200 Subject: [PATCH] Version 15.226.6 --- sql/cambios.sql | 2 ++ swad_changelog.h | 3 ++- swad_duplicate.c | 23 ++++++++++++++++++----- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/sql/cambios.sql b/sql/cambios.sql index b395e4475..5822b139e 100644 --- a/sql/cambios.sql +++ b/sql/cambios.sql @@ -11595,3 +11595,5 @@ UPDATE notif SET NotifyEvent=3 WHERE NotifyEvent=2; CREATE TABLE IF NOT EXISTS usr_duplicated (UsrCod INT NOT NULL,InformerCod INT NOT NULL,InformTime DATETIME NOT NULL,UNIQUE INDEX(UsrCod,InformerCod),INDEX(UsrCod)); +SELECT DISTINCT UsrCod FROM (SELECT DISTINCT UsrCod FROM usr_IDs WHERE UsrID IN (SELECT UsrID FROM usr_IDs WHERE UsrCod='1') UNION SELECT UsrCod FROM usr_data WHERE Surname1='' AND Surname2='' AND FirstName='') AS I; + diff --git a/swad_changelog.h b/swad_changelog.h index 12242bd93..ef9a13058 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -129,13 +129,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.226.5 (2016-06-18)" +#define Log_PLATFORM_VERSION "SWAD 15.226.6 (2016-06-18)" #define CSS_FILE "swad15.226.css" #define JS_FILE "swad15.226.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.226.6: Jun 18, 2016 Changes in query about similar users. (202962 lines) Version 15.226.5: Jun 18, 2016 Code refactoring in duplicate users. (202948 lines) Version 15.226.4: Jun 17, 2016 Translation of buttons in list of similar users. (202934 lines) Version 15.226.3: Jun 17, 2016 Request the removal of a user account from list of similar users. (202912 lines) diff --git a/swad_duplicate.c b/swad_duplicate.c index ccdc6ee8c..2a294dbfa 100644 --- a/swad_duplicate.c +++ b/swad_duplicate.c @@ -245,7 +245,7 @@ static void Dup_ListSimilarUsrs (void) extern const char *Txt_Possibly_duplicate_users; extern const char *Txt_No_users_found[Rol_NUM_ROLES]; struct UsrData UsrDat; - char Query[256]; + char Query[512]; MYSQL_RES *mysql_res; MYSQL_ROW row; unsigned NumUsrs; @@ -255,10 +255,23 @@ static void Dup_ListSimilarUsrs (void) Lay_StartRoundFrame (NULL,Txt_Possibly_duplicate_users,NULL); /***** Build query *****/ - sprintf (Query,"SELECT DISTINCT UsrCod FROM usr_IDs" - " WHERE usr_IDs.UsrID IN" - " (SELECT UsrID FROM usr_IDs WHERE UsrCod='%ld')", - Gbl.Usrs.Other.UsrDat.UsrCod); + if (Gbl.Usrs.Other.UsrDat.Surname1[0] && + Gbl.Usrs.Other.UsrDat.FirstName[0]) // Name and surname 1 not empty + sprintf (Query,"SELECT DISTINCT UsrCod FROM" + "(SELECT DISTINCT UsrCod FROM usr_IDs" + " WHERE UsrID IN (SELECT UsrID FROM usr_IDs WHERE UsrCod='%ld')" + " UNION" + " SELECT UsrCod FROM usr_data" + " WHERE Surname1='%s' AND Surname2='%s' AND FirstName='%s')" + " AS U", + Gbl.Usrs.Other.UsrDat.UsrCod, + Gbl.Usrs.Other.UsrDat.Surname1, + Gbl.Usrs.Other.UsrDat.Surname2, + Gbl.Usrs.Other.UsrDat.FirstName); + else + sprintf (Query,"SELECT DISTINCT UsrCod FROM usr_IDs" + " WHERE UsrID IN (SELECT UsrID FROM usr_IDs WHERE UsrCod='%ld')", + Gbl.Usrs.Other.UsrDat.UsrCod); NumUsrs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get similar users"); /***** List possible duplicated users *****/