Version 20.51.49: Mar 26, 2021 User IDs database table renamed.

This commit is contained in:
acanas 2021-03-26 00:23:33 +01:00
parent 6e17eabcd5
commit bad9767bd1
8 changed files with 106 additions and 71 deletions

View File

@ -1690,9 +1690,9 @@ CREATE TABLE IF NOT EXISTS usr_follow (
UNIQUE INDEX (FollowedCod,FollowerCod),
INDEX (FollowTime));
--
-- Table usr_IDs: stores the users' IDs
-- Table usr_ids: stores the users' IDs
--
CREATE TABLE IF NOT EXISTS usr_IDs (
CREATE TABLE IF NOT EXISTS usr_ids (
UsrCod INT NOT NULL,
UsrID CHAR(16) NOT NULL,
CreatTime DATETIME NOT NULL,

View File

@ -952,12 +952,14 @@ int swad__loginByUserPasswordKey (struct soap *soap,
// TODO: Get only if ID confirmed?
NumRows =
(unsigned) DB_QuerySELECT (&mysql_res,"can not get user's data",
"SELECT usr_IDs.UsrCod"
" FROM usr_IDs,usr_data"
" WHERE usr_IDs.UsrID='%s'"
" AND usr_IDs.UsrCod=usr_data.UsrCod"
" AND usr_data.Password='%s'",
UsrIDNickOrEmail,userPassword);
"SELECT usr_ids.UsrCod"
" FROM usr_ids,"
"usr_data"
" WHERE usr_ids.UsrID='%s'"
" AND usr_ids.UsrCod=usr_data.UsrCod"
" AND usr_data.Password='%s'",
UsrIDNickOrEmail,
userPassword);
}
else // String is not a valid user's nickname, email or ID
return soap_receiver_fault (soap,
@ -1307,7 +1309,8 @@ int swad__getNewPassword (struct soap *soap,
// TODO: Get only if ID confirmed?
NumRows =
(unsigned) DB_QuerySELECT (&mysql_res,"can not get user's data",
"SELECT UsrCod FROM usr_IDs"
"SELECT UsrCod"
" FROM usr_ids"
" WHERE UsrID='%s'",
UsrIDNickOrEmail);
}

View File

@ -103,9 +103,12 @@ void ID_GetListIDsFromUsrCod (struct UsrData *UsrDat)
// First the confirmed (Confirmed == 'Y')
// Then the unconfirmed (Confirmed == 'N')
NumIDs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get user's IDs",
"SELECT UsrID,Confirmed FROM usr_IDs"
"SELECT UsrID," // row[0]
"Confirmed" // row[1]
" FROM usr_ids"
" WHERE UsrCod=%ld"
" ORDER BY Confirmed DESC,UsrID",
" ORDER BY Confirmed DESC,"
"UsrID",
UsrDat->UsrCod);
if (NumIDs)
{
@ -215,22 +218,26 @@ unsigned ID_GetListUsrCodsFromUsrID (struct UsrData *UsrDat,
// or if password in database is empty (new user)
ListUsrCods->NumUsrs =
(unsigned) DB_QuerySELECT (&mysql_res,"can not get user's codes",
"SELECT DISTINCT(usr_IDs.UsrCod) FROM usr_IDs,usr_data"
" WHERE usr_IDs.UsrID IN (%s)"
"%s"
" AND usr_IDs.UsrCod=usr_data.UsrCod"
" AND (usr_data.Password='%s' OR usr_data.Password='')",
"SELECT DISTINCT(usr_ids.UsrCod)"
" FROM usr_ids,"
"usr_data"
" WHERE usr_ids.UsrID IN (%s)"
"%s"
" AND usr_ids.UsrCod=usr_data.UsrCod"
" AND (usr_data.Password='%s'"
" OR usr_data.Password='')",
SubQueryAllUsrs,
OnlyConfirmedIDs ? " AND usr_IDs.Confirmed='Y'" :
OnlyConfirmedIDs ? " AND usr_ids.Confirmed='Y'" :
"",
EncryptedPassword);
}
else
ListUsrCods->NumUsrs =
(unsigned) DB_QuerySELECT (&mysql_res,"can not get user's codes",
"SELECT DISTINCT(UsrCod) FROM usr_IDs"
"SELECT DISTINCT(UsrCod)"
" FROM usr_ids"
" WHERE UsrID IN (%s)"
"%s",
"%s",
SubQueryAllUsrs,
OnlyConfirmedIDs ? " AND Confirmed='Y'" :
"");
@ -832,9 +839,13 @@ static bool ID_CheckIfConfirmed (long UsrCod,const char *UsrID)
{
/***** Get if ID is confirmed from database *****/
return (DB_QueryCOUNT ("can not check if ID is confirmed",
"SELECT COUNT(*) FROM usr_IDs"
" WHERE UsrCod=%ld AND UsrID='%s' AND Confirmed='Y'",
UsrCod,UsrID) != 0);
"SELECT COUNT(*)"
" FROM usr_ids"
" WHERE UsrCod=%ld"
" AND UsrID='%s'"
" AND Confirmed='Y'",
UsrCod,
UsrID) != 0);
}
/*****************************************************************************/
@ -845,8 +856,9 @@ static void ID_RemoveUsrIDFromDB (long UsrCod,const char *UsrID)
{
/***** Remove one of my user's IDs *****/
DB_QueryREPLACE ("can not remove a user's ID",
"DELETE FROM usr_IDs"
" WHERE UsrCod=%ld AND UsrID='%s'",
"DELETE FROM usr_ids"
" WHERE UsrCod=%ld"
" AND UsrID='%s'",
UsrCod,UsrID);
}
@ -982,7 +994,7 @@ static void ID_InsertANewUsrIDInDB (long UsrCod,const char *NewID,bool Confirmed
{
/***** Update my nickname in database *****/
DB_QueryINSERT ("can not insert a new ID",
"INSERT INTO usr_IDs"
"INSERT INTO usr_ids"
" (UsrCod,UsrID,CreatTime,Confirmed)"
" VALUES"
" (%ld,'%s',NOW(),'%c')",
@ -1106,7 +1118,11 @@ void ID_ConfirmUsrID (const struct UsrData *UsrDat,const char *UsrID)
{
/***** Update database *****/
DB_QueryINSERT ("can not confirm a user's ID",
"UPDATE usr_IDs SET Confirmed='Y'"
" WHERE UsrCod=%ld AND UsrID='%s' AND Confirmed<>'Y'",
UsrDat->UsrCod,UsrID);
"UPDATE usr_ids"
" SET Confirmed='Y'"
" WHERE UsrCod=%ld"
" AND UsrID='%s'"
" AND Confirmed<>'Y'",
UsrDat->UsrCod,
UsrID);
}

View File

@ -212,11 +212,12 @@ void Acc_CheckIfEmptyAccountExists (void)
if (ID_CheckIfUsrIDIsValid (ID))
{
NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get user's codes",
"SELECT usr_IDs.UsrCod"
" FROM usr_IDs,usr_data"
" WHERE usr_IDs.UsrID='%s'"
" AND usr_IDs.UsrCod=usr_data.UsrCod"
" AND usr_data.Password=''",
"SELECT usr_ids.UsrCod"
" FROM usr_ids,"
"usr_data"
" WHERE usr_ids.UsrID='%s'"
" AND usr_ids.UsrCod=usr_data.UsrCod"
" AND usr_data.Password=''",
ID);
if (NumUsrs)
{
@ -797,7 +798,7 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount)
{
Str_ConvertToUpperText (UsrDat->IDs.List[NumID].ID);
DB_QueryINSERT ("can not store user's ID when creating user",
"INSERT INTO usr_IDs"
"INSERT INTO usr_ids"
" (UsrCod,UsrID,CreatTime,Confirmed)"
" VALUES"
" (%ld,'%s',NOW(),'%c')",
@ -1193,7 +1194,7 @@ static void Acc_RemoveUsr (struct UsrData *UsrDat)
/***** Remove user's IDs *****/
DB_QueryDELETE ("can not remove user's IDs",
"DELETE FROM usr_IDs"
"DELETE FROM usr_ids"
" WHERE UsrCod=%ld",
UsrDat->UsrCod);

View File

@ -600,13 +600,17 @@ TODO: Salvador Romero Cort
TODO: FIX BUG, URGENT! En las fechas como parámetro Dat_WriteParamsIniEndDates(), por ejemplo al cambiar el color de la gráfica de accesos por día y hora, no se respeta la zona horaria.
*/
#define Log_PLATFORM_VERSION "SWAD 20.51.48 (2021-03-26)"
#define Log_PLATFORM_VERSION "SWAD 20.51.49 (2021-03-26)"
#define CSS_FILE "swad20.45.css"
#define JS_FILE "swad20.6.2.js"
/*
TODO: Rename CENTRE to CENTER in help wiki.
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
Version 20.51.49: Mar 26, 2021 User IDs database table renamed. (308816 lines)
1 change necessary in database:
RENAME TABLE usr_IDs TO usr_ids;
Version 20.51.48: Mar 26, 2021 Room MAC addresses database table renamed. (308782 lines)
1 change necessary in database:
RENAME TABLE roo_MACs TO roo_macs;

View File

@ -3283,27 +3283,6 @@ mysql> DESCRIBE tst_tags;
"UNIQUE INDEX(TagCod),"
"INDEX(CrsCod,ChangeTime))");
/***** Table usr_IDs *****/
/*
mysql> DESCRIBE usr_IDs;
+-----------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+---------------+------+-----+---------+-------+
| UsrCod | int(11) | NO | PRI | NULL | |
| UsrID | char(16) | NO | PRI | NULL | |
| CreatTime | datetime | NO | | NULL | |
| Confirmed | enum('N','Y') | NO | | N | |
+-----------+---------------+------+-----+---------+-------+
4 rows in set (0.01 sec)
*/
DB_CreateTable ("CREATE TABLE IF NOT EXISTS usr_IDs ("
"UsrCod INT NOT NULL,"
"UsrID CHAR(16) NOT NULL," // ID_MAX_BYTES_USR_ID
"CreatTime DATETIME NOT NULL,"
"Confirmed ENUM('N','Y') NOT NULL DEFAULT 'N',"
"UNIQUE INDEX(UsrCod,UsrID),"
"INDEX(UsrID))");
/***** Table usr_admins *****/
/*
mysql> DESCRIBE usr_admins;
@ -3565,6 +3544,27 @@ mysql> DESCRIBE usr_follow;
"UNIQUE INDEX (FollowedCod,FollowerCod),"
"INDEX (FollowTime))");
/***** Table usr_ids *****/
/*
mysql> DESCRIBE usr_ids;
+-----------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+---------------+------+-----+---------+-------+
| UsrCod | int(11) | NO | PRI | NULL | |
| UsrID | char(16) | NO | PRI | NULL | |
| CreatTime | datetime | NO | | NULL | |
| Confirmed | enum('N','Y') | NO | | N | |
+-----------+---------------+------+-----+---------+-------+
4 rows in set (0.01 sec)
*/
DB_CreateTable ("CREATE TABLE IF NOT EXISTS usr_ids ("
"UsrCod INT NOT NULL,"
"UsrID CHAR(16) NOT NULL," // ID_MAX_BYTES_USR_ID
"CreatTime DATETIME NOT NULL,"
"Confirmed ENUM('N','Y') NOT NULL DEFAULT 'N',"
"UNIQUE INDEX(UsrCod,UsrID),"
"INDEX(UsrID))");
/***** Table usr_last *****/
/*
mysql> DESCRIBE usr_last;

View File

@ -273,21 +273,28 @@ static void Dup_ListSimilarUsrs (void)
if (Gbl.Usrs.Other.UsrDat.Surname1[0] &&
Gbl.Usrs.Other.UsrDat.FrstName[0]) // Name and surname 1 not empty
NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get similar users",
"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",
"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.FrstName);
else
NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get similar users",
"SELECT DISTINCT UsrCod FROM usr_IDs"
" WHERE UsrID IN (SELECT UsrID FROM usr_IDs WHERE UsrCod=%ld)",
"SELECT DISTINCT UsrCod FROM usr_ids"
" WHERE UsrID IN (SELECT UsrID FROM usr_ids WHERE UsrCod=%ld)",
Gbl.Usrs.Other.UsrDat.UsrCod);
/***** List possible similar users *****/

View File

@ -552,7 +552,8 @@ static bool Pwd_CheckIfPasswdIsUsrIDorName (const char *PlainPassword)
/***** Get if password is found in user's ID from database *****/
Found = (DB_QueryCOUNT ("can not check if a password matches a user's ID",
"SELECT COUNT(*) FROM usr_IDs"
"SELECT COUNT(*)"
" FROM usr_ids"
" WHERE UsrID='%s'",
PlainPassword) != 0);
@ -560,11 +561,14 @@ static bool Pwd_CheckIfPasswdIsUsrIDorName (const char *PlainPassword)
if (!Found)
Found = (DB_QueryCOUNT ("can not check if a password matches"
" a first name or a surname",
"SELECT COUNT(*) FROM usr_data"
"SELECT COUNT(*)"
" FROM usr_data"
" WHERE FirstName='%s'"
" OR Surname1='%s'"
" OR Surname2='%s'",
PlainPassword,PlainPassword,PlainPassword) != 0);
" OR Surname1='%s'"
" OR Surname2='%s'",
PlainPassword,
PlainPassword,
PlainPassword) != 0);
return Found;
}