Version 20.72: May 10, 2021 New module swad_account_database for database queries related to user's account.

This commit is contained in:
acanas 2021-05-10 21:10:06 +02:00
parent e61715a085
commit 39dc3d39a3
47 changed files with 735 additions and 414 deletions

View File

@ -26,8 +26,9 @@
# # # #
############################################################################### ###############################################################################
OBJS = swad_account.o swad_action.o swad_agenda.o swad_alert.o \ OBJS = swad_account.o swad_account_database.o swad_action.o swad_agenda.o \
swad_announcement.o swad_API.o swad_assignment.o swad_attendance.o \ swad_alert.o swad_announcement.o swad_API.o swad_assignment.o \
swad_attendance.o \
swad_banner.o swad_box.o swad_building.o swad_button.o \ swad_banner.o swad_box.o swad_building.o swad_button.o \
swad_calendar.o swad_call_for_exam.o swad_center.o \ swad_calendar.o swad_call_for_exam.o swad_center.o \
swad_center_config.o swad_chat.o swad_config.o swad_connected.o \ swad_center_config.o swad_chat.o swad_config.o swad_connected.o \

View File

@ -861,6 +861,18 @@ static void ID_RemoveUsrIDFromDB (long UsrCod,const char *UsrID)
UsrID); UsrID);
} }
/*****************************************************************************/
/****************************** Remove user's IDs ****************************/
/*****************************************************************************/
void ID_DB_RemoveUsrIDs (long UsrCod)
{
DB_QueryDELETE ("can not remove user's IDs",
"DELETE FROM usr_ids"
" WHERE UsrCod=%ld",
UsrCod);
}
/*****************************************************************************/ /*****************************************************************************/
/************************* New user's ID for me ******************************/ /************************* New user's ID for me ******************************/
/*****************************************************************************/ /*****************************************************************************/

View File

@ -77,6 +77,7 @@ void ID_ShowFormChangeOtherUsrID (void);
void ID_RemoveMyUsrID (void); void ID_RemoveMyUsrID (void);
void ID_RemoveOtherUsrID (void); void ID_RemoveOtherUsrID (void);
void ID_DB_RemoveUsrIDs (long UsrCod);
void ID_NewMyUsrID (void); void ID_NewMyUsrID (void);
void ID_NewOtherUsrID (void); void ID_NewOtherUsrID (void);

View File

@ -28,6 +28,7 @@
#include <string.h> // For string functions #include <string.h> // For string functions
#include "swad_account.h" #include "swad_account.h"
#include "swad_account_database.h"
#include "swad_agenda.h" #include "swad_agenda.h"
#include "swad_announcement.h" #include "swad_announcement.h"
#include "swad_attendance.h" #include "swad_attendance.h"
@ -47,12 +48,14 @@
#include "swad_language.h" #include "swad_language.h"
#include "swad_match.h" #include "swad_match.h"
#include "swad_message.h" #include "swad_message.h"
#include "swad_network.h"
#include "swad_nickname.h" #include "swad_nickname.h"
#include "swad_notification.h" #include "swad_notification.h"
#include "swad_parameter.h" #include "swad_parameter.h"
#include "swad_profile.h" #include "swad_profile.h"
#include "swad_project.h" #include "swad_project.h"
#include "swad_report.h" #include "swad_report.h"
#include "swad_setting.h"
#include "swad_test_print.h" #include "swad_test_print.h"
#include "swad_timeline.h" #include "swad_timeline.h"
@ -87,7 +90,7 @@ static void Acc_WriteRowEmptyAccount (unsigned NumUsr,const char *ID,struct UsrD
static void Acc_ShowFormRequestNewAccountWithParams (const char NewNickWithoutArr[Nck_MAX_BYTES_NICK_FROM_FORM + 1], static void Acc_ShowFormRequestNewAccountWithParams (const char NewNickWithoutArr[Nck_MAX_BYTES_NICK_FROM_FORM + 1],
const char *NewEmail); const char *NewEmail);
static bool Acc_GetParamsNewAccount (char NewNickWithoutArr[Nck_MAX_BYTES_NICK_FROM_FORM + 1], static bool Acc_GetParamsNewAccount (char NewNickWithoutArr[Nck_MAX_BYTES_NICK_FROM_FORM + 1],
char *NewEmail, char NewEmail[Cns_MAX_BYTES_EMAIL_ADDRESS + 1],
char *NewEncryptedPassword); char *NewEncryptedPassword);
static void Acc_CreateNewEncryptedUsrCod (struct UsrData *UsrDat); static void Acc_CreateNewEncryptedUsrCod (struct UsrData *UsrDat);
@ -97,7 +100,6 @@ static void Acc_AskIfRemoveUsrAccount (bool ItsMe);
static void Acc_AskIfRemoveOtherUsrAccount (void); static void Acc_AskIfRemoveOtherUsrAccount (void);
static void Acc_RemoveUsrBriefcase (struct UsrData *UsrDat); static void Acc_RemoveUsrBriefcase (struct UsrData *UsrDat);
static void Acc_RemoveUsr (struct UsrData *UsrDat);
/*****************************************************************************/ /*****************************************************************************/
/******************** Put link to create a new account ***********************/ /******************** Put link to create a new account ***********************/
@ -211,16 +213,7 @@ void Acc_CheckIfEmptyAccountExists (void)
/***** Check if there are users with this user's ID *****/ /***** Check if there are users with this user's ID *****/
if (ID_CheckIfUsrIDIsValid (ID)) if (ID_CheckIfUsrIDIsValid (ID))
{ {
NumUsrs = (unsigned) if ((NumUsrs = Acc_DB_GetUsrsWithID (&mysql_res,ID)))
DB_QuerySELECT (&mysql_res,"can not get user's codes",
"SELECT usr_ids.UsrCod" // row[0]
" FROM usr_ids,"
"usr_data"
" WHERE usr_ids.UsrID='%s'"
" AND usr_ids.UsrCod=usr_data.UsrCod"
" AND usr_data.Password=''",
ID);
if (NumUsrs)
{ {
/***** Begin box and table *****/ /***** Begin box and table *****/
Box_BoxTableBegin (NULL, Box_BoxTableBegin (NULL,
@ -233,7 +226,7 @@ void Acc_CheckIfEmptyAccountExists (void)
Usr_UsrDataConstructor (&UsrDat); Usr_UsrDataConstructor (&UsrDat);
/***** List users found *****/ /***** List users found *****/
for (NumUsr = 1, Gbl.RowEvenOdd = 0; for (NumUsr = 1, Gbl.RowEvenOdd = 0;
NumUsr <= NumUsrs; NumUsr <= NumUsrs;
NumUsr++, Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd) NumUsr++, Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd)
{ {
@ -286,51 +279,57 @@ static void Acc_WriteRowEmptyAccount (unsigned NumUsr,const char *ID,struct UsrD
extern const char *Txt_yet_unnamed; extern const char *Txt_yet_unnamed;
extern const char *Txt_Its_me; extern const char *Txt_Its_me;
/***** Write number of user in the list *****/ /***** Begin 1st table row *****/
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
HTM_TD_Begin ("rowspan=\"2\" class=\"USR_LIST_NUM_N RT COLOR%u\"",Gbl.RowEvenOdd); /***** Write number of user in the list *****/
HTM_Unsigned (NumUsr); HTM_TD_Begin ("rowspan=\"2\" class=\"USR_LIST_NUM_N RT COLOR%u\"",
HTM_TD_End (); Gbl.RowEvenOdd);
HTM_Unsigned (NumUsr);
HTM_TD_End ();
/***** Write user's ID and name *****/ /***** Write user's ID and name *****/
HTM_TD_Begin ("class=\"DAT_N LT COLOR%u\"",Gbl.RowEvenOdd); HTM_TD_Begin ("class=\"DAT_N LT COLOR%u\"",Gbl.RowEvenOdd);
HTM_TxtF ("%s:&nbsp;%s",Txt_ID,ID); HTM_TxtF ("%s:&nbsp;%s",Txt_ID,ID);
HTM_BR (); HTM_BR ();
HTM_TxtColonNBSP (Txt_Name); HTM_TxtColonNBSP (Txt_Name);
if (UsrDat->FullName[0]) if (UsrDat->FullName[0])
{ {
HTM_STRONG_Begin (); HTM_STRONG_Begin ();
HTM_Txt (UsrDat->FullName); HTM_Txt (UsrDat->FullName);
HTM_STRONG_End (); HTM_STRONG_End ();
} }
else else
{ {
HTM_EM_Begin (); HTM_EM_Begin ();
HTM_Txt (Txt_yet_unnamed); HTM_Txt (Txt_yet_unnamed);
HTM_EM_End (); HTM_EM_End ();
} }
HTM_TD_End (); HTM_TD_End ();
/***** Button to login with this account *****/ /***** Button to login with this account *****/
HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd); HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd);
Frm_BeginForm (ActLogInNew); Frm_BeginForm (ActLogInNew);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod); Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
Btn_PutCreateButtonInline (Txt_Its_me); Btn_PutCreateButtonInline (Txt_Its_me);
Frm_EndForm (); Frm_EndForm ();
HTM_TD_End (); HTM_TD_End ();
/***** End 1st table row *****/
HTM_TR_End (); HTM_TR_End ();
/***** Begin 2nd table row *****/
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
/***** Courses of this user *****/ /***** Courses of this user *****/
HTM_TD_Begin ("colspan=\"2\" class=\"LT COLOR%u\"",Gbl.RowEvenOdd); HTM_TD_Begin ("colspan=\"2\" class=\"LT COLOR%u\"",Gbl.RowEvenOdd);
UsrDat->Sex = Usr_SEX_UNKNOWN; UsrDat->Sex = Usr_SEX_UNKNOWN;
Crs_GetAndWriteCrssOfAUsr (UsrDat,Rol_TCH); Crs_GetAndWriteCrssOfAUsr (UsrDat,Rol_TCH);
Crs_GetAndWriteCrssOfAUsr (UsrDat,Rol_NET); Crs_GetAndWriteCrssOfAUsr (UsrDat,Rol_NET);
Crs_GetAndWriteCrssOfAUsr (UsrDat,Rol_STD); Crs_GetAndWriteCrssOfAUsr (UsrDat,Rol_STD);
HTM_TD_End (); HTM_TD_End ();
/***** End 2nd table row *****/
HTM_TR_End (); HTM_TR_End ();
} }
@ -370,52 +369,54 @@ static void Acc_ShowFormRequestNewAccountWithParams (const char NewNickWithoutAr
/***** Begin form to enter some data of the new user *****/ /***** Begin form to enter some data of the new user *****/
Frm_BeginForm (ActCreUsrAcc); Frm_BeginForm (ActCreUsrAcc);
/***** Begin box and table *****/ /***** Begin box and table *****/
Box_BoxTableBegin (NULL,Txt_Create_account, Box_BoxTableBegin (NULL,Txt_Create_account,
NULL,NULL, NULL,NULL,
Hlp_PROFILE_SignUp,Box_NOT_CLOSABLE,2); Hlp_PROFILE_SignUp,Box_NOT_CLOSABLE,2);
/***** Nickname *****/ /***** Nickname *****/
if (NewNickWithoutArr[0]) if (NewNickWithoutArr[0])
snprintf (NewNickWithArr,sizeof (NewNickWithArr),"@%s", snprintf (NewNickWithArr,sizeof (NewNickWithArr),"@%s",
NewNickWithoutArr); NewNickWithoutArr);
else else
NewNickWithArr[0] = '\0'; NewNickWithArr[0] = '\0';
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
/* Label */ /* Label */
Frm_LabelColumn ("RT","NewNick",Txt_Nickname); Frm_LabelColumn ("RT","NewNick",Txt_Nickname);
/* Data */ /* Data */
HTM_TD_Begin ("class=\"LT\""); HTM_TD_Begin ("class=\"LT\"");
HTM_INPUT_TEXT ("NewNick",1 + Nck_MAX_CHARS_NICK_WITHOUT_ARROBA, HTM_INPUT_TEXT ("NewNick",1 + Nck_MAX_CHARS_NICK_WITHOUT_ARROBA,
NewNickWithArr,HTM_DONT_SUBMIT_ON_CHANGE, NewNickWithArr,HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"NewNick\" size=\"18\" placeholder=\"%s\" required=\"required\"", "id=\"NewNick\" size=\"18\" placeholder=\"%s\""
Txt_HELP_nickname); " required=\"required\"",
HTM_TD_End (); Txt_HELP_nickname);
HTM_TD_End ();
HTM_TR_End (); HTM_TR_End ();
/***** Email *****/ /***** Email *****/
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
/* Label */ /* Label */
Frm_LabelColumn ("RT","NewEmail",Txt_Email); Frm_LabelColumn ("RT","NewEmail",Txt_Email);
/* Data */ /* Data */
HTM_TD_Begin ("class=\"LT\""); HTM_TD_Begin ("class=\"LT\"");
HTM_INPUT_EMAIL ("NewEmail",Cns_MAX_CHARS_EMAIL_ADDRESS,NewEmail, HTM_INPUT_EMAIL ("NewEmail",Cns_MAX_CHARS_EMAIL_ADDRESS,NewEmail,
"id=\"NewEmail\" size=\"18\" placeholder=\"%s\" required=\"required\"", "id=\"NewEmail\" size=\"18\" placeholder=\"%s\""
Txt_HELP_email); " required=\"required\"",
HTM_TD_End (); Txt_HELP_email);
HTM_TD_End ();
HTM_TR_End (); HTM_TR_End ();
/***** Password *****/ /***** Password *****/
Pwd_PutFormToGetNewPasswordOnce (); Pwd_PutFormToGetNewPasswordOnce ();
/***** End table, send button and end box *****/ /***** End table, send button and end box *****/
Box_BoxTableWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create_account); Box_BoxTableWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create_account);
/***** End form *****/ /***** End form *****/
Frm_EndForm (); Frm_EndForm ();
@ -440,7 +441,7 @@ void Acc_ShowFormGoToRequestNewAccount (void)
/***** Button to go to request the creation of a new account *****/ /***** Button to go to request the creation of a new account *****/
Frm_BeginForm (ActFrmMyAcc); Frm_BeginForm (ActFrmMyAcc);
Btn_PutCreateButton (Txt_Create_account); Btn_PutCreateButton (Txt_Create_account);
Frm_EndForm (); Frm_EndForm ();
/***** End box *****/ /***** End box *****/
@ -493,17 +494,17 @@ void Acc_ShowFormChgMyAccount (void)
/***** Begin container for this user *****/ /***** Begin container for this user *****/
HTM_DIV_Begin ("class=\"REC_USR\""); HTM_DIV_Begin ("class=\"REC_USR\"");
/***** Show form to change my password and my nickname ****/ /***** Show form to change my password and my nickname ****/
HTM_DIV_Begin ("class=\"REC_LEFT\""); HTM_DIV_Begin ("class=\"REC_LEFT\"");
Pwd_ShowFormChgMyPwd (); Pwd_ShowFormChgMyPwd ();
Nck_ShowFormChangeMyNickname (IMustCreateMyNicknameNow); Nck_ShowFormChangeMyNickname (IMustCreateMyNicknameNow);
HTM_DIV_End (); HTM_DIV_End ();
/***** Show form to change my email and my ID *****/ /***** Show form to change my email and my ID *****/
HTM_DIV_Begin ("class=\"REC_RIGHT\""); HTM_DIV_Begin ("class=\"REC_RIGHT\"");
Mai_ShowFormChangeMyEmail (IMustFillInMyEmailNow,IShouldConfirmMyEmailNow); Mai_ShowFormChangeMyEmail (IMustFillInMyEmailNow,IShouldConfirmMyEmailNow);
ID_ShowFormChangeMyID (IShouldFillInMyIDNow); ID_ShowFormChangeMyID (IShouldFillInMyIDNow);
HTM_DIV_End (); HTM_DIV_End ();
/***** Begin container for this user *****/ /***** Begin container for this user *****/
HTM_DIV_End (); HTM_DIV_End ();
@ -532,17 +533,17 @@ void Acc_ShowFormChgOtherUsrAccount (void)
/***** Begin container for this user *****/ /***** Begin container for this user *****/
HTM_DIV_Begin ("class=\"REC_USR\""); HTM_DIV_Begin ("class=\"REC_USR\"");
/***** Show form to change password and nickname *****/ /***** Show form to change password and nickname *****/
HTM_DIV_Begin ("class=\"REC_LEFT\""); HTM_DIV_Begin ("class=\"REC_LEFT\"");
Pwd_ShowFormChgOtherUsrPwd (); Pwd_ShowFormChgOtherUsrPwd ();
Nck_ShowFormChangeOtherUsrNickname (); Nck_ShowFormChangeOtherUsrNickname ();
HTM_DIV_End (); HTM_DIV_End ();
/***** Show form to change email and ID *****/ /***** Show form to change email and ID *****/
HTM_DIV_Begin ("class=\"REC_RIGHT\""); HTM_DIV_Begin ("class=\"REC_RIGHT\"");
Mai_ShowFormChangeOtherUsrEmail (); Mai_ShowFormChangeOtherUsrEmail ();
ID_ShowFormChangeOtherUsrID (); ID_ShowFormChangeOtherUsrID ();
HTM_DIV_End (); HTM_DIV_End ();
/***** Begin container for this user *****/ /***** Begin container for this user *****/
HTM_DIV_End (); HTM_DIV_End ();
@ -633,8 +634,8 @@ bool Acc_CreateMyNewAccountAndLogIn (void)
// Return false on error // Return false on error
static bool Acc_GetParamsNewAccount (char NewNickWithoutArr[Nck_MAX_BYTES_NICK_FROM_FORM + 1], static bool Acc_GetParamsNewAccount (char NewNickWithoutArr[Nck_MAX_BYTES_NICK_FROM_FORM + 1],
char *NewEmail, char NewEmail[Cns_MAX_BYTES_EMAIL_ADDRESS + 1],
char *NewEncryptedPassword) char NewEncryptedPassword[Pwd_BYTES_ENCRYPTED_PASSWORD + 1])
{ {
extern const char *Txt_The_nickname_X_had_been_registered_by_another_user; extern const char *Txt_The_nickname_X_had_been_registered_by_another_user;
extern const char *Txt_The_nickname_entered_X_is_not_valid_; extern const char *Txt_The_nickname_entered_X_is_not_valid_;
@ -659,13 +660,7 @@ static bool Acc_GetParamsNewAccount (char NewNickWithoutArr[Nck_MAX_BYTES_NICK_F
{ {
/* Check if the new nickname /* Check if the new nickname
matches any of the nicknames of other users */ matches any of the nicknames of other users */
if (DB_QueryCOUNT ("can not check if nickname already existed", if (Acc_DB_CheckIfNicknameAlreadyExists (NewNickWithoutArr))
"SELECT COUNT(*)"
" FROM usr_nicknames"
" WHERE Nickname='%s'"
" AND UsrCod<>%ld",
NewNickWithoutArr,
Gbl.Usrs.Me.UsrDat.UsrCod)) // A nickname of another user is the same that this nickname
{ {
Error = true; Error = true;
Ale_ShowAlert (Ale_WARNING,Txt_The_nickname_X_had_been_registered_by_another_user, Ale_ShowAlert (Ale_WARNING,Txt_The_nickname_X_had_been_registered_by_another_user,
@ -688,12 +683,7 @@ static bool Acc_GetParamsNewAccount (char NewNickWithoutArr[Nck_MAX_BYTES_NICK_F
{ {
/* Check if the new email matches /* Check if the new email matches
any of the confirmed emails of other users */ any of the confirmed emails of other users */
if (DB_QueryCOUNT ("can not check if email already existed", if (Acc_DB_CheckIfEmailAlreadyExists (NewEmail)) // An email of another user is the same that my email
"SELECT COUNT(*)"
" FROM usr_emails"
" WHERE E_mail='%s'"
" AND Confirmed='Y'",
NewEmail)) // An email of another user is the same that my email
{ {
Error = true; Error = true;
Ale_ShowAlert (Ale_WARNING,Txt_The_email_address_X_had_been_registered_by_another_user, Ale_ShowAlert (Ale_WARNING,Txt_The_email_address_X_had_been_registered_by_another_user,
@ -727,13 +717,6 @@ static bool Acc_GetParamsNewAccount (char NewNickWithoutArr[Nck_MAX_BYTES_NICK_F
void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount) void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount)
{ {
extern const char *The_ThemeId[The_NUM_THEMES];
extern const char *Ico_IconSetId[Ico_NUM_ICON_SETS];
extern const char *Pri_VisibilityDB[Pri_NUM_OPTIONS_PRIVACY];
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
extern const char *Usr_StringsSexDB[Usr_NUM_SEXS];
char BirthdayStrDB[Usr_BIRTHDAY_STR_DB_LENGTH + 1];
size_t CommentsLength;
char PathRelUsr[PATH_MAX + 1]; char PathRelUsr[PATH_MAX + 1];
unsigned NumID; unsigned NumID;
@ -749,54 +732,7 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount)
/***** Insert new user in database *****/ /***** Insert new user in database *****/
/* Insert user's data */ /* Insert user's data */
Usr_CreateBirthdayStrDB (UsrDat,BirthdayStrDB); // It can include start and ending apostrophes Acc_DB_CreateNewUsr (UsrDat);
if (UsrDat->Comments)
CommentsLength = strlen (UsrDat->Comments);
else
CommentsLength = 0;
UsrDat->UsrCod =
DB_QueryINSERTandReturnCode ("can not create user",
"INSERT INTO usr_data"
" (EncryptedUsrCod,Password,"
"Surname1,Surname2,FirstName,Sex,"
"Theme,IconSet,Language,FirstDayOfWeek,DateFormat,"
"PhotoVisibility,BaPrfVisibility,ExPrfVisibility,"
"CtyCod,"
"LocalPhone,FamilyPhone,"
"Birthday,Comments,"
"Menu,SideCols,NotifNtfEvents,EmailNtfEvents)"
" VALUES"
" ('%s','%s',"
"'%s','%s','%s','%s',"
"'%s','%s','%s',%u,%u,"
"'%s','%s','%s',"
"%ld,"
"'%s','%s',"
"%s,'%s',"
"%u,%u,-1,0)",
UsrDat->EnUsrCod,
UsrDat->Password,
UsrDat->Surname1,
UsrDat->Surname2,
UsrDat->FrstName,
Usr_StringsSexDB[UsrDat->Sex],
The_ThemeId[UsrDat->Prefs.Theme],
Ico_IconSetId[UsrDat->Prefs.IconSet],
Lan_STR_LANG_ID[UsrDat->Prefs.Language],
Cal_FIRST_DAY_OF_WEEK_DEFAULT,
(unsigned) Dat_FORMAT_DEFAULT,
Pri_VisibilityDB[UsrDat->PhotoVisibility],
Pri_VisibilityDB[UsrDat->BaPrfVisibility],
Pri_VisibilityDB[UsrDat->ExPrfVisibility],
UsrDat->CtyCod,
UsrDat->Phone[0],
UsrDat->Phone[1],
BirthdayStrDB,
CommentsLength ? UsrDat->Comments :
"",
(unsigned) Mnu_MENU_DEFAULT,
(unsigned) Cfg_DEFAULT_COLUMNS);
/* Insert user's IDs as confirmed */ /* Insert user's IDs as confirmed */
for (NumID = 0; for (NumID = 0;
@ -804,15 +740,9 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount)
NumID++) NumID++)
{ {
Str_ConvertToUpperText (UsrDat->IDs.List[NumID].ID); Str_ConvertToUpperText (UsrDat->IDs.List[NumID].ID);
DB_QueryINSERT ("can not store user's ID when creating user", Acc_DB_CreateNewUsrID (UsrDat->UsrCod,
"INSERT INTO usr_ids" UsrDat->IDs.List[NumID].ID,
" (UsrCod,UsrID,CreatTime,Confirmed)" UsrDat->IDs.List[NumID].Confirmed);
" VALUES"
" (%ld,'%s',NOW(),'%c')",
UsrDat->UsrCod,
UsrDat->IDs.List[NumID].ID,
UsrDat->IDs.List[NumID].Confirmed ? 'Y' :
'N');
} }
/***** Create directory for the user, if not exists *****/ /***** Create directory for the user, if not exists *****/
@ -1035,52 +965,40 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat,
Brw_RemoveUsrWorksInAllCrss (UsrDat); // Make this before of removing the user from the courses Brw_RemoveUsrWorksInAllCrss (UsrDat); // Make this before of removing the user from the courses
/***** Remove the fields of course record in all courses *****/ /***** Remove the fields of course record in all courses *****/
Rec_RemoveFieldsCrsRecordAll (UsrDat->UsrCod); Rec_DB_RemoveFieldsCrsRecordAll (UsrDat->UsrCod);
/***** Remove user from all his/her projects *****/ /***** Remove user from all his/her projects *****/
Prj_RemoveUsrFromProjects (UsrDat->UsrCod); Prj_RemoveUsrFromProjects (UsrDat->UsrCod);
/***** Remove user from all the attendance events *****/ /***** Remove user from all the attendance events *****/
Att_RemoveUsrFromAllAttEvents (UsrDat->UsrCod); Att_DB_RemoveUsrFromAllAttEvents (UsrDat->UsrCod);
/***** Remove user from all the groups of all courses *****/ /***** Remove user from all the groups of all courses *****/
Grp_RemUsrFromAllGrps (UsrDat->UsrCod); Grp_RemUsrFromAllGrps (UsrDat->UsrCod);
/***** Remove user's requests for inscription *****/ /***** Remove user's requests for enrolment *****/
DB_QueryDELETE ("can not remove user's requests for inscription", Enr_DB_RemUsrRequests (UsrDat->UsrCod);
"DELETE FROM crs_requests"
" WHERE UsrCod=%ld",
UsrDat->UsrCod);
/***** Remove user from possible duplicate users *****/ /***** Remove user from possible duplicate users *****/
Dup_RemoveUsrFromDuplicated (UsrDat->UsrCod); Dup_DB_RemoveUsrFromDuplicated (UsrDat->UsrCod);
/***** Remove user from the tables of courses and users *****/ /***** Remove user from the tables of courses and users *****/
DB_QueryDELETE ("can not remove a user from all courses", Set_DB_RemCrsUsrSettings (UsrDat->UsrCod);
"DELETE FROM crs_user_settings" Enr_DB_RemUsrFromAllCrss (UsrDat->UsrCod);
" WHERE UsrCod=%ld",
UsrDat->UsrCod);
DB_QueryDELETE ("can not remove a user from all courses",
"DELETE FROM crs_users"
" WHERE UsrCod=%ld",
UsrDat->UsrCod);
if (QuietOrVerbose == Cns_VERBOSE) if (QuietOrVerbose == Cns_VERBOSE)
Ale_ShowAlert (Ale_SUCCESS,Txt_THE_USER_X_has_been_removed_from_all_his_her_courses, Ale_ShowAlert (Ale_SUCCESS,Txt_THE_USER_X_has_been_removed_from_all_his_her_courses,
UsrDat->FullName); UsrDat->FullName);
/***** Remove user as administrator of any degree *****/ /***** Remove user as administrator of any degree/center/institution *****/
DB_QueryDELETE ("can not remove a user as administrator", Enr_DB_RemUsrAsAdmin (UsrDat->UsrCod);
"DELETE FROM usr_admins"
" WHERE UsrCod=%ld",
UsrDat->UsrCod);
if (QuietOrVerbose == Cns_VERBOSE) if (QuietOrVerbose == Cns_VERBOSE)
Ale_ShowAlert (Ale_SUCCESS,Txt_THE_USER_X_has_been_removed_as_administrator, Ale_ShowAlert (Ale_SUCCESS,Txt_THE_USER_X_has_been_removed_as_administrator,
UsrDat->FullName); UsrDat->FullName);
/***** Remove user's clipboard in forums *****/ /***** Remove user's clipboard in forums *****/
For_RemoveUsrFromThrClipboard (UsrDat->UsrCod); For_DB_RemoveUsrFromThrClipboard (UsrDat->UsrCod);
/***** Remove some files of the user's from database *****/ /***** Remove some files of the user's from database *****/
Brw_RemoveUsrFilesFromDB (UsrDat->UsrCod); Brw_RemoveUsrFilesFromDB (UsrDat->UsrCod);
@ -1097,7 +1015,7 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat,
Mch_RemoveMatchesMadeByUsrInAllCrss (UsrDat->UsrCod); Mch_RemoveMatchesMadeByUsrInAllCrss (UsrDat->UsrCod);
/***** Remove user's notifications *****/ /***** Remove user's notifications *****/
Ntf_RemoveUsrNtfs (UsrDat->UsrCod); Ntf_DB_RemoveUsrNtfs (UsrDat->UsrCod);
/***** Delete user's messages sent and received *****/ /***** Delete user's messages sent and received *****/
Msg_DelAllRecAndSntMsgsUsr (UsrDat->UsrCod); Msg_DelAllRecAndSntMsgsUsr (UsrDat->UsrCod);
@ -1106,32 +1024,26 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat,
UsrDat->FullName); UsrDat->FullName);
/***** Remove user from tables of banned users *****/ /***** Remove user from tables of banned users *****/
Usr_RemoveUsrFromUsrBanned (UsrDat->UsrCod); Usr_DB_RemoveUsrFromBanned (UsrDat->UsrCod);
Msg_RemoveUsrFromBanned (UsrDat->UsrCod); Msg_DB_RemoveUsrFromBanned (UsrDat->UsrCod);
/***** Delete thread read status for this user *****/ /***** Delete thread read status for this user *****/
For_RemoveUsrFromReadThrs (UsrDat->UsrCod); For_DB_RemoveUsrFromReadThrs (UsrDat->UsrCod);
/***** Remove user from table of seen announcements *****/ /***** Remove user from table of seen announcements *****/
Ann_RemoveUsrFromSeenAnnouncements (UsrDat->UsrCod); Ann_DB_RemoveUsrFromSeenAnnouncements (UsrDat->UsrCod);
/***** Remove user from table of connected users *****/ /***** Remove user from table of connected users *****/
DB_QueryDELETE ("can not remove a user from table of connected users", Con_DB_RemoveUsrFromConnected (UsrDat->UsrCod);
"DELETE FROM usr_connected"
" WHERE UsrCod=%ld",
UsrDat->UsrCod);
/***** Remove all sessions of this user *****/ /***** Remove all sessions of this user *****/
DB_QueryDELETE ("can not remove sessions of a user", Ses_DB_RemoveUsrSessions (UsrDat->UsrCod);
"DELETE FROM ses_sessions"
" WHERE UsrCod=%ld",
UsrDat->UsrCod);
/***** Remove social content associated to the user *****/ /***** Remove social content associated to the user *****/
Tml_Usr_RemoveUsrContent (UsrDat->UsrCod); Tml_Usr_RemoveUsrContent (UsrDat->UsrCod);
/***** Remove user's figures *****/ /***** Remove user's figures *****/
Prf_RemoveUsrFigures (UsrDat->UsrCod); Prf_DB_RemoveUsrFigures (UsrDat->UsrCod);
/***** Remove user from table of followers *****/ /***** Remove user from table of followers *****/
Fol_RemoveUsrFromUsrFollow (UsrDat->UsrCod); Fol_RemoveUsrFromUsrFollow (UsrDat->UsrCod);
@ -1140,10 +1052,10 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat,
Rep_RemoveUsrUsageReports (UsrDat->UsrCod); Rep_RemoveUsrUsageReports (UsrDat->UsrCod);
/***** Remove user's agenda *****/ /***** Remove user's agenda *****/
Agd_RemoveUsrEvents (UsrDat->UsrCod); Agd_DB_RemoveUsrEvents (UsrDat->UsrCod);
/***** Remove the user from the list of users without photo *****/ /***** Remove the user from the list of users without photo *****/
Pho_RemoveUsrFromTableClicksWithoutPhoto (UsrDat->UsrCod); Pho_DB_RemoveUsrFromTableClicksWithoutPhoto (UsrDat->UsrCod);
/***** Remove user's photo *****/ /***** Remove user's photo *****/
PhotoRemoved = Pho_RemovePhoto (UsrDat); PhotoRemoved = Pho_RemovePhoto (UsrDat);
@ -1151,8 +1063,25 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat,
Ale_ShowAlert (Ale_SUCCESS,Txt_Photo_of_THE_USER_X_has_been_removed, Ale_ShowAlert (Ale_SUCCESS,Txt_Photo_of_THE_USER_X_has_been_removed,
UsrDat->FullName); UsrDat->FullName);
/***** Remove user *****/ /***** Remove user's webs / social networks *****/
Acc_RemoveUsr (UsrDat); Net_DB_RemoveUsrWebs (UsrDat->UsrCod);
/***** Remove user's nicknames *****/
Nck_DB_RemoveUsrNicknames (UsrDat->UsrCod);
/***** Remove user's emails *****/
Mai_DB_RemoveUsrPendingEmails (UsrDat->UsrCod);
Mai_DB_RemoveUsrEmails (UsrDat->UsrCod);
/***** Remove user's IDs *****/
ID_DB_RemoveUsrIDs (UsrDat->UsrCod);
/***** Remove user's last data *****/
Usr_DB_RemoveUsrLastData (UsrDat->UsrCod);
/***** Remove user's data *****/
Usr_DB_RemoveUsrData (UsrDat->UsrCod);
if (QuietOrVerbose == Cns_VERBOSE) if (QuietOrVerbose == Cns_VERBOSE)
Ale_ShowAlert (Ale_SUCCESS,Txt_Record_card_of_THE_USER_X_has_been_removed, Ale_ShowAlert (Ale_SUCCESS,Txt_Record_card_of_THE_USER_X_has_been_removed,
UsrDat->FullName); UsrDat->FullName);
@ -1171,54 +1100,6 @@ static void Acc_RemoveUsrBriefcase (struct UsrData *UsrDat)
Fil_RemoveTree (PathRelUsr); Fil_RemoveTree (PathRelUsr);
} }
/*****************************************************************************/
/************************ Remove a user from database ************************/
/*****************************************************************************/
static void Acc_RemoveUsr (struct UsrData *UsrDat)
{
/***** Remove user's webs / social networks *****/
DB_QueryDELETE ("can not remove user's webs / social networks",
"DELETE FROM usr_webs"
" WHERE UsrCod=%ld",
UsrDat->UsrCod);
/***** Remove user's nicknames *****/
DB_QueryDELETE ("can not remove user's nicknames",
"DELETE FROM usr_nicknames"
" WHERE UsrCod=%ld",
UsrDat->UsrCod);
/***** Remove user's emails *****/
DB_QueryDELETE ("can not remove pending user's emails",
"DELETE FROM usr_pending_emails"
" WHERE UsrCod=%ld",
UsrDat->UsrCod);
DB_QueryDELETE ("can not remove user's emails",
"DELETE FROM usr_emails"
" WHERE UsrCod=%ld",
UsrDat->UsrCod);
/***** Remove user's IDs *****/
DB_QueryDELETE ("can not remove user's IDs",
"DELETE FROM usr_ids"
" WHERE UsrCod=%ld",
UsrDat->UsrCod);
/***** Remove user's last data *****/
DB_QueryDELETE ("can not remove user's last data",
"DELETE FROM usr_last"
" WHERE UsrCod=%ld",
UsrDat->UsrCod);
/***** Remove user's data *****/
DB_QueryDELETE ("can not remove user's data",
"DELETE FROM usr_data"
" WHERE UsrCod=%ld",
UsrDat->UsrCod);
}
/*****************************************************************************/ /*****************************************************************************/
/********* Put an icon to the action used to manage user's account ***********/ /********* Put an icon to the action used to manage user's account ***********/
/*****************************************************************************/ /*****************************************************************************/

214
swad_account_database.c Normal file
View File

@ -0,0 +1,214 @@
// swad_account_database.c: user's account operations with database
/*
SWAD (Shared Workspace At a Distance),
is a web platform developed at the University of Granada (Spain),
and used to support university teaching.
This file is part of SWAD core.
Copyright (C) 1999-2021 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General 3 License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*****************************************************************************/
/*********************************** Headers *********************************/
/*****************************************************************************/
// #include <string.h> // For string functions
#include "swad_account.h"
#include "swad_account_database.h"
// #include "swad_agenda.h"
// #include "swad_announcement.h"
// #include "swad_attendance.h"
// #include "swad_box.h"
#include "swad_calendar.h"
// #include "swad_database.h"
// #include "swad_duplicate.h"
// #include "swad_enrolment.h"
// #include "swad_error.h"
// #include "swad_exam_print.h"
// #include "swad_follow.h"
// #include "swad_form.h"
// #include "swad_forum.h"
#include "swad_global.h"
// #include "swad_HTML.h"
// #include "swad_ID.h"
// #include "swad_language.h"
// #include "swad_match.h"
// #include "swad_message.h"
// #include "swad_nickname.h"
// #include "swad_notification.h"
// #include "swad_parameter.h"
// #include "swad_profile.h"
// #include "swad_project.h"
// #include "swad_report.h"
// #include "swad_test_print.h"
// #include "swad_timeline.h"
/*****************************************************************************/
/****************************** Public constants *****************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private constants *****************************/
/*****************************************************************************/
/*****************************************************************************/
/****************************** Private types ********************************/
/*****************************************************************************/
/*****************************************************************************/
/************** External global variables from others modules ****************/
/*****************************************************************************/
extern struct Globals Gbl;
/*****************************************************************************/
/************************* Private global variables **************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private prototypes ****************************/
/*****************************************************************************/
/*****************************************************************************/
/*************** Check if there are users with this user's ID ****************/
/*****************************************************************************/
// Returns the number of users got
unsigned Acc_DB_GetUsrsWithID (MYSQL_RES **mysql_res,
const char ID[ID_MAX_BYTES_USR_ID + 1])
{
return (unsigned)
DB_QuerySELECT (mysql_res,"can not get user's codes",
"SELECT usr_ids.UsrCod" // row[0]
" FROM usr_ids,"
"usr_data"
" WHERE usr_ids.UsrID='%s'"
" AND usr_ids.UsrCod=usr_data.UsrCod"
" AND usr_data.Password=''",
ID);
}
/*****************************************************************************/
/****** Check if a nickname matches any of the nicknames of other users ******/
/*****************************************************************************/
bool Acc_DB_CheckIfNicknameAlreadyExists (const char NewNickWithoutArr[Nck_MAX_BYTES_NICK_FROM_FORM + 1])
{
return (DB_QueryCOUNT ("can not check if nickname already existed",
"SELECT COUNT(*)"
" FROM usr_nicknames"
" WHERE Nickname='%s'"
" AND UsrCod<>%ld",
NewNickWithoutArr,
Gbl.Usrs.Me.UsrDat.UsrCod) != 0); // A nickname of another user is the same that this nickname
}
/*****************************************************************************/
/******** Check if an email matches any of the emails of other users *********/
/*****************************************************************************/
bool Acc_DB_CheckIfEmailAlreadyExists (const char NewEmail[Cns_MAX_BYTES_EMAIL_ADDRESS + 1])
{
return (DB_QueryCOUNT ("can not check if email already existed",
"SELECT COUNT(*)"
" FROM usr_emails"
" WHERE E_mail='%s'"
" AND Confirmed='Y'",
NewEmail) != 0); // An email of another user is the same that my email
}
/*****************************************************************************/
/****************************** Create new user ******************************/
/*****************************************************************************/
void Acc_DB_CreateNewUsr (struct UsrData *UsrDat)
{
extern const char *The_ThemeId[The_NUM_THEMES];
extern const char *Ico_IconSetId[Ico_NUM_ICON_SETS];
extern const char *Pri_VisibilityDB[Pri_NUM_OPTIONS_PRIVACY];
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
extern const char *Usr_StringsSexDB[Usr_NUM_SEXS];
char BirthdayStrDB[Usr_BIRTHDAY_STR_DB_LENGTH + 1];
/***** Create birthday string *****/
Usr_CreateBirthdayStrDB (UsrDat,BirthdayStrDB); // It can include start and ending apostrophes
/***** Create new user *****/
UsrDat->UsrCod =
DB_QueryINSERTandReturnCode ("can not create user",
"INSERT INTO usr_data"
" (EncryptedUsrCod,Password,"
"Surname1,Surname2,FirstName,Sex,"
"Theme,IconSet,Language,FirstDayOfWeek,DateFormat,"
"PhotoVisibility,BaPrfVisibility,ExPrfVisibility,"
"CtyCod,"
"LocalPhone,FamilyPhone,"
"Birthday,Comments,"
"Menu,SideCols,NotifNtfEvents,EmailNtfEvents)"
" VALUES"
" ('%s','%s',"
"'%s','%s','%s','%s',"
"'%s','%s','%s',%u,%u,"
"'%s','%s','%s',"
"%ld,"
"'%s','%s',"
"%s,'%s',"
"%u,%u,-1,0)",
UsrDat->EnUsrCod,
UsrDat->Password,
UsrDat->Surname1,
UsrDat->Surname2,
UsrDat->FrstName,
Usr_StringsSexDB[UsrDat->Sex],
The_ThemeId[UsrDat->Prefs.Theme],
Ico_IconSetId[UsrDat->Prefs.IconSet],
Lan_STR_LANG_ID[UsrDat->Prefs.Language],
Cal_FIRST_DAY_OF_WEEK_DEFAULT,
(unsigned) Dat_FORMAT_DEFAULT,
Pri_VisibilityDB[UsrDat->PhotoVisibility],
Pri_VisibilityDB[UsrDat->BaPrfVisibility],
Pri_VisibilityDB[UsrDat->ExPrfVisibility],
UsrDat->CtyCod,
UsrDat->Phone[0],
UsrDat->Phone[1],
BirthdayStrDB,
UsrDat->Comments ? UsrDat->Comments :
"",
(unsigned) Mnu_MENU_DEFAULT,
(unsigned) Cfg_DEFAULT_COLUMNS);
}
/*****************************************************************************/
/*************************** Create new user's ID ****************************/
/*****************************************************************************/
void Acc_DB_CreateNewUsrID (long UsrCod,
const char ID[ID_MAX_BYTES_USR_ID + 1],
bool Confirmed)
{
DB_QueryINSERT ("can not store user's ID when creating user",
"INSERT INTO usr_ids"
" (UsrCod,UsrID,CreatTime,Confirmed)"
" VALUES"
" (%ld,'%s',NOW(),'%c')",
UsrCod,
ID,
Confirmed ? 'Y' :
'N');
}

60
swad_account_database.h Normal file
View File

@ -0,0 +1,60 @@
// swad_account_database.h: user's account operations with database
#ifndef _SWAD_ACC_DB
#define _SWAD_ACC_DB
/*
SWAD (Shared Workspace At a Distance in Spanish),
is a web platform developed at the University of Granada (Spain),
and used to support university teaching.
This file is part of SWAD core.
Copyright (C) 1999-2021 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*****************************************************************************/
/********************************** Headers **********************************/
/*****************************************************************************/
// #include <stdbool.h> // For boolean type
// #include "swad_constant.h"
#include "swad_database.h"
#include "swad_ID.h"
// #include "swad_user.h"
/*****************************************************************************/
/****************************** Public constants *****************************/
/*****************************************************************************/
/*****************************************************************************/
/******************************** Public types *******************************/
/*****************************************************************************/
/*****************************************************************************/
/****************************** Public prototypes ****************************/
/*****************************************************************************/
unsigned Acc_DB_GetUsrsWithID (MYSQL_RES **mysql_res,
const char ID[ID_MAX_BYTES_USR_ID + 1]);
bool Acc_DB_CheckIfNicknameAlreadyExists (const char NewNickWithoutArr[Nck_MAX_BYTES_NICK_FROM_FORM + 1]);
bool Acc_DB_CheckIfEmailAlreadyExists (const char NewEmail[Cns_MAX_BYTES_EMAIL_ADDRESS + 1]);
void Acc_DB_CreateNewUsr (struct UsrData *UsrDat);
void Acc_DB_CreateNewUsrID (long UsrCod,
const char ID[ID_MAX_BYTES_USR_ID + 1],
bool Confirmed);
#endif

View File

@ -1827,9 +1827,8 @@ static void Agd_UpdateEvent (struct Agd_Event *AgdEvent,const char *Txt)
/********************** Remove all the events of a user **********************/ /********************** Remove all the events of a user **********************/
/*****************************************************************************/ /*****************************************************************************/
void Agd_RemoveUsrEvents (long UsrCod) void Agd_DB_RemoveUsrEvents (long UsrCod)
{ {
/***** Remove events *****/
DB_QueryDELETE ("can not remove all the events of a user", DB_QueryDELETE ("can not remove all the events of a user",
"DELETE FROM agd_agendas" "DELETE FROM agd_agendas"
" WHERE UsrCod=%ld", " WHERE UsrCod=%ld",

View File

@ -125,7 +125,7 @@ void Agd_MakeEventPublic (void);
void Agd_ReceiveFormEvent (void); void Agd_ReceiveFormEvent (void);
void Agd_RemoveUsrEvents (long UsrCod); void Agd_DB_RemoveUsrEvents (long UsrCod);
unsigned Agd_GetNumEventsFromUsr (long UsrCod); unsigned Agd_GetNumEventsFromUsr (long UsrCod);
unsigned Agd_GetNumUsrsWithEvents (Hie_Lvl_Level_t Scope); unsigned Agd_GetNumUsrsWithEvents (Hie_Lvl_Level_t Scope);

View File

@ -630,9 +630,8 @@ void Ann_MarkAnnouncementAsSeen (void)
/******************** Remove user from seen announcements ********************/ /******************** Remove user from seen announcements ********************/
/*****************************************************************************/ /*****************************************************************************/
void Ann_RemoveUsrFromSeenAnnouncements (long UsrCod) void Ann_DB_RemoveUsrFromSeenAnnouncements (long UsrCod)
{ {
/***** Remove user from seen announcements *****/
DB_QueryDELETE ("can not remove user from seen announcements", DB_QueryDELETE ("can not remove user from seen announcements",
"DELETE FROM ann_seen" "DELETE FROM ann_seen"
" WHERE UsrCod=%ld", " WHERE UsrCod=%ld",

View File

@ -55,6 +55,6 @@ void Ann_HideActiveAnnouncement (void);
void Ann_RevealHiddenAnnouncement (void); void Ann_RevealHiddenAnnouncement (void);
void Ann_RemoveAnnouncement (void); void Ann_RemoveAnnouncement (void);
void Ann_MarkAnnouncementAsSeen (void); void Ann_MarkAnnouncementAsSeen (void);
void Ann_RemoveUsrFromSeenAnnouncements (long UsrCod); void Ann_DB_RemoveUsrFromSeenAnnouncements (long UsrCod);
#endif #endif

View File

@ -119,7 +119,7 @@ static void Att_CreateGrps (long AttCod);
static void Att_GetAndWriteNamesOfGrpsAssociatedToAttEvent (struct Att_Event *Event); static void Att_GetAndWriteNamesOfGrpsAssociatedToAttEvent (struct Att_Event *Event);
static void Att_RemoveAllUsrsFromAnAttEvent (long AttCod); static void Att_RemoveAllUsrsFromAnAttEvent (long AttCod);
static void Att_RemoveAttEventFromCurrentCrs (long AttCod); static void Att_DB_RemoveAttEventFromCurrentCrs (long AttCod);
static void Att_ShowEvent (struct Att_Events *Events); static void Att_ShowEvent (struct Att_Events *Events);
@ -986,7 +986,7 @@ void Att_RemoveAttEventFromDB (long AttCod)
Att_RemoveAllTheGrpsAssociatedToAnAttEvent (AttCod); Att_RemoveAllTheGrpsAssociatedToAnAttEvent (AttCod);
/***** Remove attendance event *****/ /***** Remove attendance event *****/
Att_RemoveAttEventFromCurrentCrs (AttCod); Att_DB_RemoveAttEventFromCurrentCrs (AttCod);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -1615,9 +1615,8 @@ static void Att_RemoveAllUsrsFromAnAttEvent (long AttCod)
/* Remove one user from all the attendance events where he/she is registered */ /* Remove one user from all the attendance events where he/she is registered */
/*****************************************************************************/ /*****************************************************************************/
void Att_RemoveUsrFromAllAttEvents (long UsrCod) void Att_DB_RemoveUsrFromAllAttEvents (long UsrCod)
{ {
/***** Remove group from all the attendance events *****/
DB_QueryDELETE ("can not remove user from all attendance events", DB_QueryDELETE ("can not remove user from all attendance events",
"DELETE FROM att_users" "DELETE FROM att_users"
" WHERE UsrCod=%ld", " WHERE UsrCod=%ld",
@ -1628,9 +1627,8 @@ void Att_RemoveUsrFromAllAttEvents (long UsrCod)
/*********** Remove one student from all the attendance events ***************/ /*********** Remove one student from all the attendance events ***************/
/*****************************************************************************/ /*****************************************************************************/
void Att_RemoveUsrFromCrsAttEvents (long UsrCod,long CrsCod) void Att_DB_RemoveUsrFromCrsAttEvents (long UsrCod,long CrsCod)
{ {
/***** Remove group from all the attendance events *****/
DB_QueryDELETE ("can not remove user from attendance events of a course", DB_QueryDELETE ("can not remove user from attendance events of a course",
"DELETE FROM att_users" "DELETE FROM att_users"
" USING att_events," " USING att_events,"
@ -1645,7 +1643,7 @@ void Att_RemoveUsrFromCrsAttEvents (long UsrCod,long CrsCod)
/*********************** Remove an attendance event **************************/ /*********************** Remove an attendance event **************************/
/*****************************************************************************/ /*****************************************************************************/
static void Att_RemoveAttEventFromCurrentCrs (long AttCod) static void Att_DB_RemoveAttEventFromCurrentCrs (long AttCod)
{ {
DB_QueryDELETE ("can not remove attendance event", DB_QueryDELETE ("can not remove attendance event",
"DELETE FROM att_events" "DELETE FROM att_events"
@ -1690,7 +1688,7 @@ void Att_RemoveCrsAttEvents (long CrsCod)
/*************** Get number of attendance events in a course *****************/ /*************** Get number of attendance events in a course *****************/
/*****************************************************************************/ /*****************************************************************************/
unsigned Att_GetNumAttEventsInCrs (long CrsCod) unsigned Att_DB_GetNumAttEventsInCrs (long CrsCod)
{ {
/***** Get number of attendance events in a course from database *****/ /***** Get number of attendance events in a course from database *****/
return (unsigned) return (unsigned)
@ -1707,7 +1705,7 @@ unsigned Att_GetNumAttEventsInCrs (long CrsCod)
// Returns the number of courses with attendance events // Returns the number of courses with attendance events
// in this location (all the platform, current degree or current course) // in this location (all the platform, current degree or current course)
unsigned Att_GetNumCoursesWithAttEvents (Hie_Lvl_Level_t Scope) unsigned Att_DB_GetNumCoursesWithAttEvents (Hie_Lvl_Level_t Scope)
{ {
/***** Get number of courses with attendance events from database *****/ /***** Get number of courses with attendance events from database *****/
switch (Scope) switch (Scope)
@ -1924,46 +1922,47 @@ static void Att_ListAttOnlyMeAsStudent (struct Att_Event *Event)
/***** Get my setting about photos in users' list for current course *****/ /***** Get my setting about photos in users' list for current course *****/
Usr_GetMyPrefAboutListWithPhotosFromDB (); Usr_GetMyPrefAboutListWithPhotosFromDB ();
/***** Begin form *****/
if (Event->Open)
{
Frm_BeginForm (ActRecAttMe);
Att_PutParamAttCod (Event->AttCod);
}
/***** List students (only me) *****/ /***** List students (only me) *****/
/* Begin box */ /* Begin box */
Box_BoxBegin (NULL,Txt_Attendance, Box_BoxBegin (NULL,Txt_Attendance,
NULL,NULL, NULL,NULL,
Hlp_USERS_Attendance,Box_NOT_CLOSABLE); Hlp_USERS_Attendance,Box_NOT_CLOSABLE);
/* Begin table */ /***** Begin form *****/
HTM_TABLE_BeginWideMarginPadding (2); if (Event->Open)
{
Frm_BeginForm (ActRecAttMe);
Att_PutParamAttCod (Event->AttCod);
}
/* Header */ /***** List students (only me) *****/
HTM_TR_Begin (NULL); /* Begin table */
HTM_TABLE_BeginWideMarginPadding (2);
HTM_TH_Empty (3); /* Header */
if (Gbl.Usrs.Listing.WithPhotos) HTM_TR_Begin (NULL);
HTM_TH_Empty (1);
HTM_TH (1,2,"TIT_TBL LM",Txt_ROLES_SINGUL_Abc[Rol_STD][Usr_SEX_UNKNOWN]);
HTM_TH (1,1,"LM",Txt_Student_comment);
HTM_TH (1,1,"LM",Txt_Teachers_comment);
HTM_TR_End (); HTM_TH_Empty (3);
if (Gbl.Usrs.Listing.WithPhotos)
HTM_TH_Empty (1);
HTM_TH (1,2,"TIT_TBL LM",Txt_ROLES_SINGUL_Abc[Rol_STD][Usr_SEX_UNKNOWN]);
HTM_TH (1,1,"LM",Txt_Student_comment);
HTM_TH (1,1,"LM",Txt_Teachers_comment);
/* List of students (only me) */ HTM_TR_End ();
Att_WriteRowUsrToCallTheRoll (1,&Gbl.Usrs.Me.UsrDat,Event);
/* End table */ /* List of students (only me) */
HTM_TABLE_End (); Att_WriteRowUsrToCallTheRoll (1,&Gbl.Usrs.Me.UsrDat,Event);
/* Send button */ /* End table */
if (Event->Open) HTM_TABLE_End ();
{
Btn_PutConfirmButton (Txt_Save_changes); /* Send button */
Frm_EndForm (); if (Event->Open)
} {
Btn_PutConfirmButton (Txt_Save_changes);
Frm_EndForm ();
}
/* End box */ /* End box */
Box_BoxEnd (); Box_BoxEnd ();

View File

@ -103,14 +103,14 @@ void Att_UpdateAttEvent (struct Att_Event *Event,const char *Description);
void Att_RemoveGroupsOfType (long GrpTypCod); void Att_RemoveGroupsOfType (long GrpTypCod);
void Att_RemoveGroup (long GrpCod); void Att_RemoveGroup (long GrpCod);
void Att_RemoveUsrFromAllAttEvents (long UsrCod); void Att_DB_RemoveUsrFromAllAttEvents (long UsrCod);
void Att_RemoveUsrFromCrsAttEvents (long UsrCod,long CrsCod); void Att_DB_RemoveUsrFromCrsAttEvents (long UsrCod,long CrsCod);
void Att_RemoveCrsAttEvents (long CrsCod); void Att_RemoveCrsAttEvents (long CrsCod);
unsigned Att_GetNumAttEventsInCrs(long CrsCod); unsigned Att_DB_GetNumAttEventsInCrs(long CrsCod);
unsigned Att_GetNumCoursesWithAttEvents (Hie_Lvl_Level_t Scope); unsigned Att_DB_GetNumCoursesWithAttEvents (Hie_Lvl_Level_t Scope);
unsigned Att_GetNumAttEvents (Hie_Lvl_Level_t Scope,unsigned *NumNotif); unsigned Att_GetNumAttEvents (Hie_Lvl_Level_t Scope,unsigned *NumNotif);
void Att_SeeOneAttEvent (void); void Att_SeeOneAttEvent (void);

View File

@ -600,13 +600,14 @@ 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. 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.71 (2021-05-10)" #define Log_PLATFORM_VERSION "SWAD 20.72 (2021-05-10)"
#define CSS_FILE "swad20.45.css" #define CSS_FILE "swad20.45.css"
#define JS_FILE "swad20.69.1.js" #define JS_FILE "swad20.69.1.js"
/* /*
TODO: Rename CENTRE to CENTER in help wiki. TODO: Rename CENTRE to CENTER in help wiki.
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
Version 20.72: May 10, 2021 New module swad_account_database for database queries related to user's account. (310328 lines)
Version 20.71: May 10, 2021 New module swad_media_database for database queries related to media. (310080 lines) Version 20.71: May 10, 2021 New module swad_media_database for database queries related to media. (310080 lines)
Version 20.70: May 07, 2021 New module swad_follow_database for database queries related to following/followers. (309943 lines) Version 20.70: May 07, 2021 New module swad_follow_database for database queries related to following/followers. (309943 lines)
Version 20.69.2: May 04, 2021 Fixed bug in removal of timeline favs. (309778 lines) Version 20.69.2: May 04, 2021 Fixed bug in removal of timeline favs. (309778 lines)

View File

@ -444,9 +444,8 @@ void Con_UpdateMeInConnectedList (void)
/************************** Remove old connected uses ************************/ /************************** Remove old connected uses ************************/
/*****************************************************************************/ /*****************************************************************************/
void Con_RemoveOldConnected (void) void Con_DB_RemoveOldConnected (void)
{ {
/***** Remove old users from connected list *****/
DB_QueryDELETE ("can not remove old users from list of connected users", DB_QueryDELETE ("can not remove old users from list of connected users",
"DELETE FROM usr_connected" "DELETE FROM usr_connected"
" WHERE UsrCod NOT IN" " WHERE UsrCod NOT IN"
@ -454,6 +453,18 @@ void Con_RemoveOldConnected (void)
" FROM ses_sessions)"); " FROM ses_sessions)");
} }
/*****************************************************************************/
/************* Remove a given user from list of connected users **************/
/*****************************************************************************/
void Con_DB_RemoveUsrFromConnected (long UsrCod)
{
DB_QueryDELETE ("can not remove a user from table of connected users",
"DELETE FROM usr_connected"
" WHERE UsrCod=%ld",
UsrCod);
}
/*****************************************************************************/ /*****************************************************************************/
/********************* Get connected users with a role ***********************/ /********************* Get connected users with a role ***********************/
/*****************************************************************************/ /*****************************************************************************/

View File

@ -55,7 +55,8 @@ void Con_ShowGlobalConnectedUsrs (void);
void Con_ComputeConnectedUsrsBelongingToCurrentCrs (void); void Con_ComputeConnectedUsrsBelongingToCurrentCrs (void);
void Con_ShowConnectedUsrsBelongingToCurrentCrs (void); void Con_ShowConnectedUsrsBelongingToCurrentCrs (void);
void Con_UpdateMeInConnectedList (void); void Con_UpdateMeInConnectedList (void);
void Con_RemoveOldConnected (void); void Con_DB_RemoveOldConnected (void);
void Con_DB_RemoveUsrFromConnected (long UsrCod);
void Con_WriteScriptClockConnected (void); void Con_WriteScriptClockConnected (void);

View File

@ -227,7 +227,7 @@ void Dup_ListDuplicateUsrs (void)
} }
else // User does not exists ==> else // User does not exists ==>
// remove user from table of possible duplicate users // remove user from table of possible duplicate users
Dup_RemoveUsrFromDuplicated (UsrDat.UsrCod); Dup_DB_RemoveUsrFromDuplicated (UsrDat.UsrCod);
} }
/***** End table *****/ /***** End table *****/
@ -471,7 +471,7 @@ void Dup_RemoveUsrFromListDupUsrs (void)
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ()) if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
{ {
/* Remove entry from database */ /* Remove entry from database */
Dup_RemoveUsrFromDuplicated (Gbl.Usrs.Other.UsrDat.UsrCod); Dup_DB_RemoveUsrFromDuplicated (Gbl.Usrs.Other.UsrDat.UsrCod);
/* Show list of similar users again */ /* Show list of similar users again */
// Dup_ListSimilarUsrsInternal (); // Dup_ListSimilarUsrsInternal ();
@ -487,9 +487,8 @@ void Dup_RemoveUsrFromListDupUsrs (void)
/******* Remove user from list of possible duplicate users in database *******/ /******* Remove user from list of possible duplicate users in database *******/
/*****************************************************************************/ /*****************************************************************************/
void Dup_RemoveUsrFromDuplicated (long UsrCod) void Dup_DB_RemoveUsrFromDuplicated (long UsrCod)
{ {
/***** Remove user from list of duplicated users *****/
DB_QueryDELETE ("can not remove a user from possible duplicates", DB_QueryDELETE ("can not remove a user from possible duplicates",
"DELETE FROM usr_duplicated" "DELETE FROM usr_duplicated"
" WHERE UsrCod=%ld", " WHERE UsrCod=%ld",

View File

@ -47,6 +47,6 @@ void Dup_ListDuplicateUsrs (void);
void Dup_GetUsrCodAndListSimilarUsrs (void); void Dup_GetUsrCodAndListSimilarUsrs (void);
void Dup_RemoveUsrFromListDupUsrs (void); void Dup_RemoveUsrFromListDupUsrs (void);
void Dup_RemoveUsrFromDuplicated (long UsrCod); void Dup_DB_RemoveUsrFromDuplicated (long UsrCod);
#endif #endif

View File

@ -4221,7 +4221,7 @@ static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat,
if (Usr_CheckIfUsrBelongsToCurrentCrs (UsrDat)) if (Usr_CheckIfUsrBelongsToCurrentCrs (UsrDat))
{ {
/***** Remove user from all the attendance events in course *****/ /***** Remove user from all the attendance events in course *****/
Att_RemoveUsrFromCrsAttEvents (UsrDat->UsrCod,Crs->CrsCod); Att_DB_RemoveUsrFromCrsAttEvents (UsrDat->UsrCod,Crs->CrsCod);
/***** Remove user from all the groups in course *****/ /***** Remove user from all the groups in course *****/
Grp_RemUsrFromAllGrpsInCrs (UsrDat->UsrCod,Crs->CrsCod); Grp_RemUsrFromAllGrpsInCrs (UsrDat->UsrCod,Crs->CrsCod);
@ -4242,7 +4242,7 @@ static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat,
} }
/***** Remove fields of this user in its course record *****/ /***** Remove fields of this user in its course record *****/
Rec_RemoveFieldsCrsRecordInCrs (UsrDat->UsrCod,Crs); Rec_DB_RemoveFieldsCrsRecordInCrs (UsrDat->UsrCod,Crs);
/***** Remove some information about files in course and groups *****/ /***** Remove some information about files in course and groups *****/
Brw_RemoveSomeInfoAboutCrsUsrFilesFromDB (UsrDat->UsrCod,Crs->CrsCod); Brw_RemoveSomeInfoAboutCrsUsrFilesFromDB (UsrDat->UsrCod,Crs->CrsCod);
@ -4308,6 +4308,30 @@ static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat,
Ale_CreateAlertUserNotFoundOrYouDoNotHavePermission (); Ale_CreateAlertUserNotFoundOrYouDoNotHavePermission ();
} }
/*****************************************************************************/
/************************ Remove a user from a course ************************/
/*****************************************************************************/
void Enr_DB_RemUsrRequests (long UsrCod)
{
DB_QueryDELETE ("can not remove user's requests for inscription",
"DELETE FROM crs_requests"
" WHERE UsrCod=%ld",
UsrCod);
}
/*****************************************************************************/
/************************ Remove a user from a course ************************/
/*****************************************************************************/
void Enr_DB_RemUsrFromAllCrss (long UsrCod)
{
DB_QueryDELETE ("can not remove a user from all courses",
"DELETE FROM crs_users"
" WHERE UsrCod=%ld",
UsrCod);
}
/*****************************************************************************/ /*****************************************************************************/
/** Ask if really wanted to remove an administrator from current institution */ /** Ask if really wanted to remove an administrator from current institution */
/*****************************************************************************/ /*****************************************************************************/
@ -4381,3 +4405,15 @@ static void Enr_EffectivelyRemAdm (struct UsrData *UsrDat,Hie_Lvl_Level_t Scope,
Ale_ShowAlert (Ale_ERROR,Txt_THE_USER_X_is_not_an_administrator_of_Y, Ale_ShowAlert (Ale_ERROR,Txt_THE_USER_X_is_not_an_administrator_of_Y,
UsrDat->FullName,InsCtrDegName); UsrDat->FullName,InsCtrDegName);
} }
/*****************************************************************************/
/******* Remove user as administrator of any degree/center/institution *******/
/*****************************************************************************/
void Enr_DB_RemUsrAsAdmin (long UsrCod)
{
DB_QueryDELETE ("can not remove a user as administrator",
"DELETE FROM usr_admins"
" WHERE UsrCod=%ld",
UsrCod);
}

View File

@ -145,4 +145,8 @@ void Enr_ModifyUsr2 (void);
void Enr_AcceptUsrInCrs (long UsrCod); void Enr_AcceptUsrInCrs (long UsrCod);
void Enr_DB_RemUsrRequests (long UsrCod);
void Enr_DB_RemUsrFromAllCrss (long UsrCod);
void Enr_DB_RemUsrAsAdmin (long UsrCod);
#endif #endif

View File

@ -402,17 +402,18 @@ static void For_RestrictAccess (const struct For_Forums *Forums);
static void For_WriteFormForumPst (struct For_Forums *Forums, static void For_WriteFormForumPst (struct For_Forums *Forums,
bool IsReply,const char *Subject); bool IsReply,const char *Subject);
static void For_UpdateNumUsrsNotifiedByEMailAboutPost (long PstCod,unsigned NumUsrsToBeNotifiedByEMail); static void For_DB_UpdateNumUsrsNotifiedByEMailAboutPost (long PstCod,
unsigned NumUsrsToBeNotifiedByEMail);
static void For_PutAllHiddenParamsRemThread (void *Forums); static void For_PutAllHiddenParamsRemThread (void *Forums);
static bool For_CheckIfICanMoveThreads (void); static bool For_CheckIfICanMoveThreads (void);
static long For_GetThrInMyClipboard (void); static long For_DB_GetThrInMyClipboard (void);
static bool For_CheckIfThrBelongsToForum (long ThrCod,const struct For_Forum *Forum); static bool For_DB_CheckIfThrBelongsToForum (long ThrCod,const struct For_Forum *Forum);
static void For_MoveThrToCurrentForum (const struct For_Forums *Forums); static void For_DB_MoveThrToCurrentForum (const struct For_Forums *Forums);
static void For_InsertThrInClipboard (long ThrCod); static void For_InsertThrInClipboard (long ThrCod);
static void For_RemoveExpiredThrsClipboards (void); static void For_DB_RemoveExpiredThrsClipboards (void);
static void For_RemoveThrCodFromThrClipboard (long ThrCod); static void For_DB_RemoveThrCodFromThrClipboard (long ThrCod);
/*****************************************************************************/ /*****************************************************************************/
/********************************** Reset forum ******************************/ /********************************** Reset forum ******************************/
@ -692,7 +693,7 @@ static void For_RemoveThreadOnly (long ThrCod)
For_DeleteThrFromReadThrs (ThrCod); For_DeleteThrFromReadThrs (ThrCod);
/***** Remove thread code from thread clipboard *****/ /***** Remove thread code from thread clipboard *****/
For_RemoveThrCodFromThrClipboard (ThrCod); For_DB_RemoveThrCodFromThrClipboard (ThrCod);
/***** Delete thread from forum thread table *****/ /***** Delete thread from forum thread table *****/
DB_QueryDELETE ("can not remove a thread from a forum", DB_QueryDELETE ("can not remove a thread from a forum",
@ -995,12 +996,11 @@ static void For_DeleteThrFromReadThrs (long ThrCod)
} }
/*****************************************************************************/ /*****************************************************************************/
/********************** Delete thread read status for an user ****************/ /********************** Remove thread read status for a user *****************/
/*****************************************************************************/ /*****************************************************************************/
void For_RemoveUsrFromReadThrs (long UsrCod) void For_DB_RemoveUsrFromReadThrs (long UsrCod)
{ {
/***** Delete pairs ThrCod-UsrCod in for_read for a user *****/
DB_QueryDELETE ("can not remove the status of reading by a user" DB_QueryDELETE ("can not remove the status of reading by a user"
" of all the threads of a forum", " of all the threads of a forum",
"DELETE FROM for_read" "DELETE FROM for_read"
@ -1039,7 +1039,7 @@ static void For_ShowPostsOfAThread (struct For_Forums *Forums,
/***** Get if there is a thread ready to be moved *****/ /***** Get if there is a thread ready to be moved *****/
if (For_CheckIfICanMoveThreads ()) if (For_CheckIfICanMoveThreads ())
Forums->Thread.ToMove = For_GetThrInMyClipboard (); Forums->Thread.ToMove = For_DB_GetThrInMyClipboard ();
/***** Get thread read time for the current user *****/ /***** Get thread read time for the current user *****/
ReadTimeUTC = For_GetThrReadTime (Thread.ThrCod); ReadTimeUTC = For_GetThrReadTime (Thread.ThrCod);
@ -1602,7 +1602,7 @@ static void For_ShowForumList (struct For_Forums *Forums)
/***** Get if there is a thread ready to be moved *****/ /***** Get if there is a thread ready to be moved *****/
if (For_CheckIfICanMoveThreads ()) if (For_CheckIfICanMoveThreads ())
Forums->Thread.ToMove = For_GetThrInMyClipboard (); Forums->Thread.ToMove = For_DB_GetThrInMyClipboard ();
/***** Fill the list with the institutions I belong to *****/ /***** Fill the list with the institutions I belong to *****/
Usr_GetMyInstits (); Usr_GetMyInstits ();
@ -2097,7 +2097,7 @@ static void For_WriteLinkToForum (const struct For_Forums *Forums,
if (Forums->Thread.ToMove >= 0) // If I have permission to paste threads and there is a thread ready to be pasted... if (Forums->Thread.ToMove >= 0) // If I have permission to paste threads and there is a thread ready to be pasted...
{ {
/* Check if thread to move is yet in current forum */ /* Check if thread to move is yet in current forum */
if (For_CheckIfThrBelongsToForum (Forums->Thread.ToMove,Forum)) if (For_DB_CheckIfThrBelongsToForum (Forums->Thread.ToMove,Forum))
Ico_PutIcon ("paste.svg",Txt_Copy_not_allowed,"CONTEXT_OPT ICO_HIDDEN ICO16x16"); Ico_PutIcon ("paste.svg",Txt_Copy_not_allowed,"CONTEXT_OPT ICO_HIDDEN ICO16x16");
else else
{ {
@ -3501,7 +3501,7 @@ static void For_ListForumThrs (struct For_Forums *Forums,
/***** Get if there is a thread ready to be moved *****/ /***** Get if there is a thread ready to be moved *****/
if ((ICanMoveThreads = For_CheckIfICanMoveThreads ())) if ((ICanMoveThreads = For_CheckIfICanMoveThreads ()))
ThreadInMyClipboard = For_GetThrInMyClipboard (); ThreadInMyClipboard = For_DB_GetThrInMyClipboard ();
/***** Initialize structure with user's data *****/ /***** Initialize structure with user's data *****/
Usr_UsrDataConstructor (&UsrDat); Usr_UsrDataConstructor (&UsrDat);
@ -4187,7 +4187,7 @@ void For_ReceiveForumPost (void)
case For_FORUM_COURSE_USRS: case For_FORUM_COURSE_USRS:
case For_FORUM_COURSE_TCHS: case For_FORUM_COURSE_TCHS:
if ((NumUsrsToBeNotifiedByEMail = Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_FORUM_POST_COURSE,PstCod))) if ((NumUsrsToBeNotifiedByEMail = Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_FORUM_POST_COURSE,PstCod)))
For_UpdateNumUsrsNotifiedByEMailAboutPost (PstCod,NumUsrsToBeNotifiedByEMail); For_DB_UpdateNumUsrsNotifiedByEMailAboutPost (PstCod,NumUsrsToBeNotifiedByEMail);
break; break;
default: default:
break; break;
@ -4196,7 +4196,7 @@ void For_ReceiveForumPost (void)
/***** Notify the new post to previous writers in this thread *****/ /***** Notify the new post to previous writers in this thread *****/
if (IsReply) if (IsReply)
if ((NumUsrsToBeNotifiedByEMail = Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_FORUM_REPLY,PstCod))) if ((NumUsrsToBeNotifiedByEMail = Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_FORUM_REPLY,PstCod)))
For_UpdateNumUsrsNotifiedByEMailAboutPost (PstCod,NumUsrsToBeNotifiedByEMail); For_DB_UpdateNumUsrsNotifiedByEMailAboutPost (PstCod,NumUsrsToBeNotifiedByEMail);
/***** Insert forum post into public social activity *****/ /***** Insert forum post into public social activity *****/
switch (Forums.Forum.Type) // Only if forum is public for any logged user switch (Forums.Forum.Type) // Only if forum is public for any logged user
@ -4223,9 +4223,9 @@ void For_ReceiveForumPost (void)
/********* Update number of users notified in table of forum posts **********/ /********* Update number of users notified in table of forum posts **********/
/*****************************************************************************/ /*****************************************************************************/
static void For_UpdateNumUsrsNotifiedByEMailAboutPost (long PstCod,unsigned NumUsrsToBeNotifiedByEMail) static void For_DB_UpdateNumUsrsNotifiedByEMailAboutPost (long PstCod,
unsigned NumUsrsToBeNotifiedByEMail)
{ {
/***** Update number of users notified *****/
DB_QueryUPDATE ("can not update the number of notifications of a post", DB_QueryUPDATE ("can not update the number of notifications of a post",
"UPDATE for_posts" "UPDATE for_posts"
" SET NumNotif=NumNotif+%u" " SET NumNotif=NumNotif+%u"
@ -4478,7 +4478,7 @@ void For_PasteThread (void)
For_GetThrSubject (Forums.Thread.Current,Subject); For_GetThrSubject (Forums.Thread.Current,Subject);
/***** Check if paste (move) the thread to current forum has sense *****/ /***** Check if paste (move) the thread to current forum has sense *****/
if (For_CheckIfThrBelongsToForum (Forums.Thread.Current,&Forums.Forum)) if (For_DB_CheckIfThrBelongsToForum (Forums.Thread.Current,&Forums.Forum))
{ {
/***** Show forum list again *****/ /***** Show forum list again *****/
For_ShowForumList (&Forums); For_ShowForumList (&Forums);
@ -4496,7 +4496,7 @@ void For_PasteThread (void)
else else
{ {
/***** Paste (move) the thread to current forum *****/ /***** Paste (move) the thread to current forum *****/
For_MoveThrToCurrentForum (&Forums); For_DB_MoveThrToCurrentForum (&Forums);
/***** Show forum list again *****/ /***** Show forum list again *****/
For_ShowForumList (&Forums); For_ShowForumList (&Forums);
@ -4526,9 +4526,8 @@ static bool For_CheckIfICanMoveThreads (void)
/**************** Get if there is a thread ready to be moved *****************/ /**************** Get if there is a thread ready to be moved *****************/
/*****************************************************************************/ /*****************************************************************************/
static long For_GetThrInMyClipboard (void) static long For_DB_GetThrInMyClipboard (void)
{ {
/***** Get if there is a thread ready to move in my clipboard from database *****/
return DB_QuerySELECTCode ("can not check if there is" return DB_QuerySELECTCode ("can not check if there is"
" any thread ready to be moved", " any thread ready to be moved",
"SELECT ThrCod" "SELECT ThrCod"
@ -4541,7 +4540,7 @@ static long For_GetThrInMyClipboard (void)
/***************** Get if a thread belongs to current forum ******************/ /***************** Get if a thread belongs to current forum ******************/
/*****************************************************************************/ /*****************************************************************************/
static bool For_CheckIfThrBelongsToForum (long ThrCod,const struct For_Forum *Forum) static bool For_DB_CheckIfThrBelongsToForum (long ThrCod,const struct For_Forum *Forum)
{ {
char SubQuery[256]; char SubQuery[256];
@ -4565,7 +4564,7 @@ static bool For_CheckIfThrBelongsToForum (long ThrCod,const struct For_Forum *Fo
/************************ Move a thread to current forum *********************/ /************************ Move a thread to current forum *********************/
/*****************************************************************************/ /*****************************************************************************/
static void For_MoveThrToCurrentForum (const struct For_Forums *Forums) static void For_DB_MoveThrToCurrentForum (const struct For_Forums *Forums)
{ {
/***** Move a thread to current forum *****/ /***** Move a thread to current forum *****/
switch (Forums->Forum.Type) switch (Forums->Forum.Type)
@ -4639,7 +4638,7 @@ static void For_MoveThrToCurrentForum (const struct For_Forums *Forums)
static void For_InsertThrInClipboard (long ThrCod) static void For_InsertThrInClipboard (long ThrCod)
{ {
/***** Remove expired thread clipboards *****/ /***** Remove expired thread clipboards *****/
For_RemoveExpiredThrsClipboards (); For_DB_RemoveExpiredThrsClipboards ();
/***** Add thread to my clipboard *****/ /***** Add thread to my clipboard *****/
DB_QueryREPLACE ("can not add thread to clipboard", DB_QueryREPLACE ("can not add thread to clipboard",
@ -4655,9 +4654,8 @@ static void For_InsertThrInClipboard (long ThrCod)
/************* Remove expired thread clipboards (from all users) *************/ /************* Remove expired thread clipboards (from all users) *************/
/*****************************************************************************/ /*****************************************************************************/
static void For_RemoveExpiredThrsClipboards (void) static void For_DB_RemoveExpiredThrsClipboards (void)
{ {
/***** Remove all expired clipboards *****/
DB_QueryDELETE ("can not remove old threads from clipboards", DB_QueryDELETE ("can not remove old threads from clipboards",
"DELETE LOW_PRIORITY FROM for_clipboards" "DELETE LOW_PRIORITY FROM for_clipboards"
" WHERE TimeInsert<FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)", " WHERE TimeInsert<FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)",
@ -4668,9 +4666,8 @@ static void For_RemoveExpiredThrsClipboards (void)
/**************** Remove thread code from thread clipboard *******************/ /**************** Remove thread code from thread clipboard *******************/
/*****************************************************************************/ /*****************************************************************************/
static void For_RemoveThrCodFromThrClipboard (long ThrCod) static void For_DB_RemoveThrCodFromThrClipboard (long ThrCod)
{ {
/***** Remove thread from thread clipboard *****/
DB_QueryDELETE ("can not remove a thread from clipboard", DB_QueryDELETE ("can not remove a thread from clipboard",
"DELETE FROM for_clipboards" "DELETE FROM for_clipboards"
" WHERE ThrCod=%ld", " WHERE ThrCod=%ld",
@ -4681,9 +4678,8 @@ static void For_RemoveThrCodFromThrClipboard (long ThrCod)
/********************* Remove thread clipboard of a user *********************/ /********************* Remove thread clipboard of a user *********************/
/*****************************************************************************/ /*****************************************************************************/
void For_RemoveUsrFromThrClipboard (long UsrCod) void For_DB_RemoveUsrFromThrClipboard (long UsrCod)
{ {
/***** Remove clipboard of specified user *****/
DB_QueryDELETE ("can not remove a thread from the clipboard of a user", DB_QueryDELETE ("can not remove a thread from the clipboard of a user",
"DELETE FROM for_clipboards" "DELETE FROM for_clipboards"
" WHERE UsrCod=%ld", " WHERE UsrCod=%ld",

View File

@ -123,7 +123,7 @@ void For_DisablePost (void);
void For_GetForumTypeAndLocationOfAPost (long PstCod,struct For_Forum *Forum); void For_GetForumTypeAndLocationOfAPost (long PstCod,struct For_Forum *Forum);
unsigned For_GetNumPostsUsr (long UsrCod); unsigned For_GetNumPostsUsr (long UsrCod);
void For_RemoveUsrFromReadThrs (long UsrCod); void For_DB_RemoveUsrFromReadThrs (long UsrCod);
void For_GetSummaryAndContentForumPst (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], void For_GetSummaryAndContentForumPst (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
char **ContentStr, char **ContentStr,
@ -157,7 +157,7 @@ void For_RequestRemoveThread (void);
void For_RemoveThread (void); void For_RemoveThread (void);
void For_CutThread (void); void For_CutThread (void);
void For_PasteThread (void); void For_PasteThread (void);
void For_RemoveUsrFromThrClipboard (long UsrCod); void For_DB_RemoveUsrFromThrClipboard (long UsrCod);
void For_RemoveForums (Hie_Lvl_Level_t Scope,long ForumLocation); void For_RemoveForums (Hie_Lvl_Level_t Scope,long ForumLocation);

View File

@ -1498,6 +1498,30 @@ static void Mai_RemoveEmailFromDB (long UsrCod,const char Email[Cns_MAX_BYTES_EM
Email); Email);
} }
/*****************************************************************************/
/**************************** Remove user's emails ***************************/
/*****************************************************************************/
void Mai_DB_RemoveUsrEmails (long UsrCod)
{
DB_QueryDELETE ("can not remove user's emails",
"DELETE FROM usr_emails"
" WHERE UsrCod=%ld",
UsrCod);
}
/*****************************************************************************/
/************** Remove a given user from list of pending emails **************/
/*****************************************************************************/
void Mai_DB_RemoveUsrPendingEmails (long UsrCod)
{
DB_QueryDELETE ("can not remove pending user's emails",
"DELETE FROM usr_pending_emails"
" WHERE UsrCod=%ld",
UsrCod);
}
/*****************************************************************************/ /*****************************************************************************/
/************************* New user's email for me ***************************/ /************************* New user's email for me ***************************/
/*****************************************************************************/ /*****************************************************************************/

View File

@ -84,10 +84,14 @@ void Mai_ShowFormChangeOtherUsrEmail (void);
void Mai_RemoveMyUsrEmail (void); void Mai_RemoveMyUsrEmail (void);
void Mai_RemoveOtherUsrEmail (void); void Mai_RemoveOtherUsrEmail (void);
void Mai_DB_RemoveUsrEmails (long UsrCod);
void Mai_DB_RemoveUsrPendingEmails (long UsrCod);
void May_NewMyUsrEmail (void); void May_NewMyUsrEmail (void);
void Mai_NewOtherUsrEmail (void); void Mai_NewOtherUsrEmail (void);
bool Mai_UpdateEmailInDB (const struct UsrData *UsrDat,const char NewEmail[Cns_MAX_BYTES_EMAIL_ADDRESS + 1]); bool Mai_UpdateEmailInDB (const struct UsrData *UsrDat,const char NewEmail[Cns_MAX_BYTES_EMAIL_ADDRESS + 1]);
bool Mai_SendMailMsgToConfirmEmail (void); bool Mai_SendMailMsgToConfirmEmail (void);
void Mai_ConfirmEmail (void); void Mai_ConfirmEmail (void);

View File

@ -131,7 +131,7 @@ int main (void)
Ses_RemoveExpiredSessions (); Ses_RemoveExpiredSessions ();
/***** Remove old users from connected list *****/ /***** Remove old users from connected list *****/
Con_RemoveOldConnected (); Con_DB_RemoveOldConnected ();
/***** Get number of sessions *****/ /***** Get number of sessions *****/
switch (Act_GetBrowserTab (Gbl.Action.Act)) switch (Act_GetBrowserTab (Gbl.Action.Act))

View File

@ -4148,10 +4148,8 @@ bool Msg_CheckIfUsrIsBanned (long FromUsrCod,long ToUsrCod)
/************************ Remove user from banned table **********************/ /************************ Remove user from banned table **********************/
/*****************************************************************************/ /*****************************************************************************/
void Msg_RemoveUsrFromBanned (long UsrCod) void Msg_DB_RemoveUsrFromBanned (long UsrCod)
{ {
/***** Remove pair (sender's code - my code)
from table of banned senders *****/
DB_QueryDELETE ("can not remove user from table of banned users", DB_QueryDELETE ("can not remove user from table of banned users",
"DELETE FROM msg_banned" "DELETE FROM msg_banned"
" WHERE FromUsrCod=%ld" " WHERE FromUsrCod=%ld"

View File

@ -129,7 +129,7 @@ void Msg_BanSenderWhenShowingMsgs (void);
void Msg_UnbanSenderWhenShowingMsgs (void); void Msg_UnbanSenderWhenShowingMsgs (void);
void Msg_UnbanSenderWhenListingUsrs (void); void Msg_UnbanSenderWhenListingUsrs (void);
bool Msg_CheckIfUsrIsBanned (long FromUsrCod,long ToUsrCod); bool Msg_CheckIfUsrIsBanned (long FromUsrCod,long ToUsrCod);
void Msg_RemoveUsrFromBanned (long UsrCod); void Msg_DB_RemoveUsrFromBanned (long UsrCod);
void Msg_ListBannedUsrs (void); void Msg_ListBannedUsrs (void);
#endif #endif

View File

@ -602,3 +602,15 @@ void Net_ShowWebAndSocialNetworksStats (void)
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res); DB_FreeMySQLResult (&mysql_res);
} }
/*****************************************************************************/
/******************* Remove user's webs / social networks ********************/
/*****************************************************************************/
void Net_DB_RemoveUsrWebs (long UsrCod)
{
DB_QueryDELETE ("can not remove user's webs / social networks",
"DELETE FROM usr_webs"
" WHERE UsrCod=%ld",
UsrCod);
}

View File

@ -45,4 +45,6 @@ void Net_ShowFormMyWebsAndSocialNets (void);
void Net_UpdateMyWebsAndSocialNets (void); void Net_UpdateMyWebsAndSocialNets (void);
void Net_ShowWebAndSocialNetworksStats (void); void Net_ShowWebAndSocialNetworksStats (void);
void Net_DB_RemoveUsrWebs (long UsrCod);
#endif #endif

View File

@ -485,6 +485,18 @@ static void Nck_RemoveNicknameFromDB (long UsrCod,const char *Nickname)
Nickname); Nickname);
} }
/*****************************************************************************/
/************************** Remove user's nicknames **************************/
/*****************************************************************************/
void Nck_DB_RemoveUsrNicknames (long UsrCod)
{
DB_QueryDELETE ("can not remove user's nicknames",
"DELETE FROM usr_nicknames"
" WHERE UsrCod=%ld",
UsrCod);
}
/*****************************************************************************/ /*****************************************************************************/
/***************************** Update my nickname ****************************/ /***************************** Update my nickname ****************************/
/*****************************************************************************/ /*****************************************************************************/

View File

@ -57,6 +57,7 @@ void Nck_ShowFormChangeOtherUsrNickname (void);
void Nck_RemoveMyNick (void); void Nck_RemoveMyNick (void);
void Nck_RemoveOtherUsrNick (void); void Nck_RemoveOtherUsrNick (void);
void Nck_DB_RemoveUsrNicknames (long UsrCod);
void Nck_UpdateMyNick (void); void Nck_UpdateMyNick (void);
void Nck_UpdateOtherUsrNick (void); void Nck_UpdateOtherUsrNick (void);

View File

@ -289,8 +289,8 @@ static void Ntf_UpdateNumNotifSent (long DegCod,long CrsCod,
unsigned NumEvents,unsigned NumMails); unsigned NumEvents,unsigned NumMails);
static void Ntf_GetParamsNotifyEvents (void); static void Ntf_GetParamsNotifyEvents (void);
static unsigned Ntf_GetNumberOfAllMyUnseenNtfs (void); static unsigned Ntf_DB_GetNumberOfAllMyUnseenNtfs (void);
static unsigned Ntf_GetNumberOfMyNewUnseenNtfs (void); static unsigned Ntf_DB_GetNumberOfMyNewUnseenNtfs (void);
/*****************************************************************************/ /*****************************************************************************/
/*************************** Show my notifications ***************************/ /*************************** Show my notifications ***************************/
@ -2141,8 +2141,8 @@ void Ntf_WriteNumberOfNewNtfs (void)
unsigned NumNewNtfs = 0; unsigned NumNewNtfs = 0;
/***** Get my number of unseen notifications *****/ /***** Get my number of unseen notifications *****/
if ((NumUnseenNtfs = Ntf_GetNumberOfAllMyUnseenNtfs ())) if ((NumUnseenNtfs = Ntf_DB_GetNumberOfAllMyUnseenNtfs ()))
NumNewNtfs = Ntf_GetNumberOfMyNewUnseenNtfs (); NumNewNtfs = Ntf_DB_GetNumberOfMyNewUnseenNtfs ();
/***** Begin form *****/ /***** Begin form *****/
Frm_BeginFormId (ActSeeNewNtf,"form_ntf"); Frm_BeginFormId (ActSeeNewNtf,"form_ntf");
@ -2150,8 +2150,9 @@ void Ntf_WriteNumberOfNewNtfs (void)
/***** Number of unseen notifications *****/ /***** Number of unseen notifications *****/
HTM_SPAN_Begin ("id=\"notif_all\""); HTM_SPAN_Begin ("id=\"notif_all\"");
HTM_TxtF ("%u&nbsp;%s",NumUnseenNtfs,NumUnseenNtfs == 1 ? Txt_notification : HTM_TxtF ("%u&nbsp;%s",NumUnseenNtfs,
Txt_notifications); NumUnseenNtfs == 1 ? Txt_notification :
Txt_notifications);
HTM_SPAN_End (); HTM_SPAN_End ();
/***** Icon and number of new notifications *****/ /***** Icon and number of new notifications *****/
@ -2162,8 +2163,8 @@ void Ntf_WriteNumberOfNewNtfs (void)
"class=\"ICO16x16\""); "class=\"ICO16x16\"");
HTM_TxtF ("&nbsp;%u",NumNewNtfs); HTM_TxtF ("&nbsp;%u",NumNewNtfs);
HTM_SPAN_Begin ("id=\"notif_new\""); HTM_SPAN_Begin ("id=\"notif_new\"");
HTM_TxtF ("&nbsp;%s",NumNewNtfs == 1 ? Txt_NOTIF_new_SINGULAR : HTM_TxtF ("&nbsp;%s",NumNewNtfs == 1 ? Txt_NOTIF_new_SINGULAR :
Txt_NOTIF_new_PLURAL); Txt_NOTIF_new_PLURAL);
HTM_SPAN_End (); HTM_SPAN_End ();
} }
@ -2176,7 +2177,7 @@ void Ntf_WriteNumberOfNewNtfs (void)
/************* Get the number of (all) my unseen notifications ***************/ /************* Get the number of (all) my unseen notifications ***************/
/*****************************************************************************/ /*****************************************************************************/
static unsigned Ntf_GetNumberOfAllMyUnseenNtfs (void) static unsigned Ntf_DB_GetNumberOfAllMyUnseenNtfs (void)
{ {
/***** Get number of places with a name from database *****/ /***** Get number of places with a name from database *****/
return (unsigned) return (unsigned)
@ -2193,7 +2194,7 @@ static unsigned Ntf_GetNumberOfAllMyUnseenNtfs (void)
/************** Get the number of my new unseen notifications ****************/ /************** Get the number of my new unseen notifications ****************/
/*****************************************************************************/ /*****************************************************************************/
static unsigned Ntf_GetNumberOfMyNewUnseenNtfs (void) static unsigned Ntf_DB_GetNumberOfMyNewUnseenNtfs (void)
{ {
/***** Get number of places with a name from database *****/ /***** Get number of places with a name from database *****/
return (unsigned) return (unsigned)
@ -2212,9 +2213,8 @@ static unsigned Ntf_GetNumberOfMyNewUnseenNtfs (void)
/**************** Remove all notifications made to a user ********************/ /**************** Remove all notifications made to a user ********************/
/*****************************************************************************/ /*****************************************************************************/
void Ntf_RemoveUsrNtfs (long ToUsrCod) void Ntf_DB_RemoveUsrNtfs (long ToUsrCod)
{ {
/***** Delete notifications of a user ******/
DB_QueryDELETE ("can not remove notifications of a user", DB_QueryDELETE ("can not remove notifications of a user",
"DELETE LOW_PRIORITY FROM ntf_notifications" "DELETE LOW_PRIORITY FROM ntf_notifications"
" WHERE ToUsrCod=%ld", " WHERE ToUsrCod=%ld",

View File

@ -140,6 +140,6 @@ void Ntf_PutFormChangeNotifSentByEMail (void);
void Ntf_ChangeNotifyEvents (void); void Ntf_ChangeNotifyEvents (void);
void Ntf_WriteNumberOfNewNtfs (void); void Ntf_WriteNumberOfNewNtfs (void);
void Ntf_RemoveUsrNtfs (long ToUsrCod); void Ntf_DB_RemoveUsrNtfs (long ToUsrCod);
#endif #endif

View File

@ -214,7 +214,8 @@ static void Pwd_CheckAndUpdateNewPwd (struct UsrData *UsrDat)
Par_GetParToText ("Paswd2",NewPlainPassword[1],Pwd_MAX_BYTES_PLAIN_PASSWORD); Par_GetParToText ("Paswd2",NewPlainPassword[1],Pwd_MAX_BYTES_PLAIN_PASSWORD);
/***** Check if I have written twice the same password *****/ /***** Check if I have written twice the same password *****/
if (strcmp (NewPlainPassword[0],NewPlainPassword[1])) if (strcmp (NewPlainPassword[0],
NewPlainPassword[1]))
// Passwords don't match // Passwords don't match
Ale_CreateAlert (Ale_WARNING,Pwd_PASSWORD_SECTION_ID, Ale_CreateAlert (Ale_WARNING,Pwd_PASSWORD_SECTION_ID,
Txt_You_have_not_written_twice_the_same_new_password); Txt_You_have_not_written_twice_the_same_new_password);
@ -505,8 +506,8 @@ void Pwd_SetMyPendingPassword (char PlainPassword[Pwd_MAX_BYTES_PLAIN_PASSWORD +
/************************ Check if a password is good ************************/ /************************ Check if a password is good ************************/
/*****************************************************************************/ /*****************************************************************************/
bool Pwd_SlowCheckIfPasswordIsGood (const char *PlainPassword, bool Pwd_SlowCheckIfPasswordIsGood (const char PlainPassword[Pwd_MAX_BYTES_PLAIN_PASSWORD + 1],
const char *EncryptedPassword, const char EncryptedPassword[Pwd_BYTES_ENCRYPTED_PASSWORD + 1],
long UsrCod) long UsrCod)
{ {
extern const char *Txt_The_password_is_too_trivial_; extern const char *Txt_The_password_is_too_trivial_;

View File

@ -58,8 +58,8 @@ void Pwd_ChkIdLoginAndSendNewPwd (void);
int Pwd_SendNewPasswordByEmail (char NewRandomPlainPassword[Pwd_MAX_BYTES_PLAIN_PASSWORD + 1]); int Pwd_SendNewPasswordByEmail (char NewRandomPlainPassword[Pwd_MAX_BYTES_PLAIN_PASSWORD + 1]);
void Pwd_SetMyPendingPassword (char PlainPassword[Pwd_MAX_BYTES_PLAIN_PASSWORD + 1]); void Pwd_SetMyPendingPassword (char PlainPassword[Pwd_MAX_BYTES_PLAIN_PASSWORD + 1]);
bool Pwd_SlowCheckIfPasswordIsGood (const char *PlainPassword, bool Pwd_SlowCheckIfPasswordIsGood (const char PlainPassword[Pwd_MAX_BYTES_PLAIN_PASSWORD + 1],
const char *EncryptedPassword, const char EncryptedPassword[Pwd_BYTES_ENCRYPTED_PASSWORD + 1],
long UsrCod); long UsrCod);
bool Pwd_FastCheckIfPasswordSeemsGood (const char *PlainPassword); bool Pwd_FastCheckIfPasswordSeemsGood (const char *PlainPassword);

View File

@ -879,7 +879,7 @@ static void Pho_UpdatePhoto1 (struct UsrData *UsrDat)
Pho_UpdatePhotoName (UsrDat); Pho_UpdatePhotoName (UsrDat);
/* Remove the user from the list of users without photo */ /* Remove the user from the list of users without photo */
Pho_RemoveUsrFromTableClicksWithoutPhoto (UsrDat->UsrCod); Pho_DB_RemoveUsrFromTableClicksWithoutPhoto (UsrDat->UsrCod);
Ale_CreateAlert (Ale_SUCCESS,NULL, Ale_CreateAlert (Ale_SUCCESS,NULL,
Txt_Photo_has_been_updated); Txt_Photo_has_been_updated);
@ -981,7 +981,7 @@ unsigned Pho_UpdateMyClicksWithoutPhoto (void)
/******** Remove user from table with number of clicks without photo *********/ /******** Remove user from table with number of clicks without photo *********/
/*****************************************************************************/ /*****************************************************************************/
void Pho_RemoveUsrFromTableClicksWithoutPhoto (long UsrCod) void Pho_DB_RemoveUsrFromTableClicksWithoutPhoto (long UsrCod)
{ {
DB_QueryDELETE ("can not remove a user from the list of users without photo", DB_QueryDELETE ("can not remove a user from the list of users without photo",
"DELETE FROM usr_clicks_without_photo" "DELETE FROM usr_clicks_without_photo"

View File

@ -114,7 +114,7 @@ void Pho_UpdateUsrPhoto1 (void);
void Pho_UpdateUsrPhoto2 (void); void Pho_UpdateUsrPhoto2 (void);
unsigned Pho_UpdateMyClicksWithoutPhoto (void); unsigned Pho_UpdateMyClicksWithoutPhoto (void);
void Pho_RemoveUsrFromTableClicksWithoutPhoto (long UsrCod); void Pho_DB_RemoveUsrFromTableClicksWithoutPhoto (long UsrCod);
void Pho_ShowUsrPhotoIfAllowed (struct UsrData *UsrDat, void Pho_ShowUsrPhotoIfAllowed (struct UsrData *UsrDat,
const char *ClassPhoto,Pho_Zoom_t Zoom, const char *ClassPhoto,Pho_Zoom_t Zoom,

View File

@ -436,7 +436,7 @@ void Prf_ShowDetailsUserProfile (const struct UsrData *UsrDat)
/***** Right list *****/ /***** Right list *****/
HTM_DIV_Begin ("class=\"PRF_FIG_RIGHT_CONT\""); HTM_DIV_Begin ("class=\"PRF_FIG_RIGHT_CONT\"");
UsrIsBannedFromRanking = Usr_CheckIfUsrBanned (UsrDat->UsrCod); UsrIsBannedFromRanking = Usr_DB_CheckIfUsrBanned (UsrDat->UsrCod);
if (!UsrIsBannedFromRanking) if (!UsrIsBannedFromRanking)
{ {
/* Start right list */ /* Start right list */
@ -1322,9 +1322,8 @@ static void Prf_CreateUsrFigures (long UsrCod,const struct UsrFigures *UsrFigure
/**************************** Remove user's figures **************************/ /**************************** Remove user's figures **************************/
/*****************************************************************************/ /*****************************************************************************/
void Prf_RemoveUsrFigures (long UsrCod) void Prf_DB_RemoveUsrFigures (long UsrCod)
{ {
/***** Remove user's figures *****/
DB_QueryDELETE ("can not delete user's figures", DB_QueryDELETE ("can not delete user's figures",
"DELETE FROM usr_figures" "DELETE FROM usr_figures"
" WHERE UsrCod=%ld", " WHERE UsrCod=%ld",

View File

@ -69,7 +69,7 @@ void Prf_CalculateFigures (void);
bool Prf_GetAndStoreAllUsrFigures (long UsrCod,struct UsrFigures *UsrFigures); bool Prf_GetAndStoreAllUsrFigures (long UsrCod,struct UsrFigures *UsrFigures);
void Prf_CreateNewUsrFigures (long UsrCod,bool CreatingMyOwnAccount); void Prf_CreateNewUsrFigures (long UsrCod,bool CreatingMyOwnAccount);
void Prf_RemoveUsrFigures (long UsrCod); void Prf_DB_RemoveUsrFigures (long UsrCod);
void Prf_IncrementNumClicksUsr (long UsrCod); void Prf_IncrementNumClicksUsr (long UsrCod);
void Prf_IncrementNumPubsUsr (long UsrCod); void Prf_IncrementNumPubsUsr (long UsrCod);
void Prf_IncrementNumFileViewsUsr (long UsrCod); void Prf_IncrementNumFileViewsUsr (long UsrCod);

View File

@ -1809,7 +1809,8 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
HTM_TD_End (); HTM_TD_End ();
/* Get the text of the field */ /* Get the text of the field */
if (Rec_GetFieldFromCrsRecord (UsrDat->UsrCod,Gbl.Crs.Records.LstFields.Lst[NumField].FieldCod,&mysql_res)) if (Rec_DB_GetFieldFromCrsRecord (&mysql_res,UsrDat->UsrCod,
Gbl.Crs.Records.LstFields.Lst[NumField].FieldCod))
{ {
ThisFieldHasText = true; ThisFieldHasText = true;
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
@ -1868,9 +1869,8 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
/************** Get the text of a field of a record of course ****************/ /************** Get the text of a field of a record of course ****************/
/*****************************************************************************/ /*****************************************************************************/
unsigned Rec_GetFieldFromCrsRecord (long UsrCod,long FieldCod,MYSQL_RES **mysql_res) unsigned Rec_DB_GetFieldFromCrsRecord (MYSQL_RES **mysql_res,long UsrCod,long FieldCod)
{ {
/***** Get the text of a field of a record from database *****/
return DB_QuerySELECT (mysql_res,"can not get the text" return DB_QuerySELECT (mysql_res,"can not get the text"
" of a field of a record", " of a field of a record",
"SELECT Txt" // row[0] "SELECT Txt" // row[0]
@ -1918,7 +1918,8 @@ void Rec_UpdateCrsRecord (long UsrCod)
if (Rec_CheckIfICanEditField (Gbl.Crs.Records.LstFields.Lst[NumField].Visibility)) if (Rec_CheckIfICanEditField (Gbl.Crs.Records.LstFields.Lst[NumField].Visibility))
{ {
/***** Check if already exists this field for this user in database *****/ /***** Check if already exists this field for this user in database *****/
FieldAlreadyExists = (Rec_GetFieldFromCrsRecord (UsrCod,Gbl.Crs.Records.LstFields.Lst[NumField].FieldCod,&mysql_res) != 0); FieldAlreadyExists = (Rec_DB_GetFieldFromCrsRecord (&mysql_res,UsrCod,
Gbl.Crs.Records.LstFields.Lst[NumField].FieldCod) != 0);
DB_FreeMySQLResult (&mysql_res); DB_FreeMySQLResult (&mysql_res);
if (FieldAlreadyExists) if (FieldAlreadyExists)
{ {
@ -1958,9 +1959,8 @@ void Rec_UpdateCrsRecord (long UsrCod)
/************ Remove fields of record of a user in current course ************/ /************ Remove fields of record of a user in current course ************/
/*****************************************************************************/ /*****************************************************************************/
void Rec_RemoveFieldsCrsRecordInCrs (long UsrCod,struct Crs_Course *Crs) void Rec_DB_RemoveFieldsCrsRecordInCrs (long UsrCod,struct Crs_Course *Crs)
{ {
/***** Remove text of the field of record course *****/
DB_QueryDELETE ("can not remove user's record in a course", DB_QueryDELETE ("can not remove user's record in a course",
"DELETE FROM crs_records" "DELETE FROM crs_records"
" WHERE UsrCod=%ld" " WHERE UsrCod=%ld"
@ -1975,9 +1975,8 @@ void Rec_RemoveFieldsCrsRecordInCrs (long UsrCod,struct Crs_Course *Crs)
/************* Remove fields of record of a user in all courses **************/ /************* Remove fields of record of a user in all courses **************/
/*****************************************************************************/ /*****************************************************************************/
void Rec_RemoveFieldsCrsRecordAll (long UsrCod) void Rec_DB_RemoveFieldsCrsRecordAll (long UsrCod)
{ {
/***** Remove text of the field of record course *****/
DB_QueryDELETE ("can not remove user's records in all courses", DB_QueryDELETE ("can not remove user's records in all courses",
"DELETE FROM crs_records" "DELETE FROM crs_records"
" WHERE UsrCod=%ld", " WHERE UsrCod=%ld",

View File

@ -150,11 +150,11 @@ void Rec_ListRecordsTchsPrint (void);
void Rec_UpdateAndShowMyCrsRecord (void); void Rec_UpdateAndShowMyCrsRecord (void);
void Rec_UpdateAndShowOtherCrsRecord (void); void Rec_UpdateAndShowOtherCrsRecord (void);
unsigned Rec_GetFieldFromCrsRecord (long UsrCod,long FieldCod,MYSQL_RES **mysql_res); unsigned Rec_DB_GetFieldFromCrsRecord (MYSQL_RES **mysql_res,long UsrCod,long FieldCod);
void Rec_GetFieldsCrsRecordFromForm (void); void Rec_GetFieldsCrsRecordFromForm (void);
void Rec_UpdateCrsRecord (long UsrCod); void Rec_UpdateCrsRecord (long UsrCod);
void Rec_RemoveFieldsCrsRecordInCrs (long UsrCod,struct Crs_Course *Crs); void Rec_DB_RemoveFieldsCrsRecordInCrs (long UsrCod,struct Crs_Course *Crs);
void Rec_RemoveFieldsCrsRecordAll (long UsrCod); void Rec_DB_RemoveFieldsCrsRecordAll (long UsrCod);
void Rec_AllocMemFieldsRecordsCrs (void); void Rec_AllocMemFieldsRecordsCrs (void);
void Rec_FreeMemFieldsRecordsCrs (void); void Rec_FreeMemFieldsRecordsCrs (void);

View File

@ -143,7 +143,7 @@ static void Rep_DrawBarNumHits (unsigned long HitsNum,unsigned long HitsMax,
static void Rep_WriteDouble (double Num); static void Rep_WriteDouble (double Num);
static void Rep_RemoveUsrReportsFiles (long UsrCod); static void Rep_RemoveUsrReportsFiles (long UsrCod);
static void Rep_RemoveUsrReportsFromDB (long UsrCod); static void Rep_DB_RemoveUsrReports (long UsrCod);
/*****************************************************************************/ /*****************************************************************************/
/******* Request my usage report (report on my use of the platform) **********/ /******* Request my usage report (report on my use of the platform) **********/
@ -1414,7 +1414,7 @@ void Rep_RemoveUsrUsageReports (long UsrCod)
Rep_RemoveUsrReportsFiles (UsrCod); Rep_RemoveUsrReportsFiles (UsrCod);
/***** Remove all user's usage reports of a user from database *****/ /***** Remove all user's usage reports of a user from database *****/
Rep_RemoveUsrReportsFromDB (UsrCod); Rep_DB_RemoveUsrReports (UsrCod);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -1460,9 +1460,8 @@ static void Rep_RemoveUsrReportsFiles (long UsrCod)
/********** Remove all user's usage reports of a user from database **********/ /********** Remove all user's usage reports of a user from database **********/
/*****************************************************************************/ /*****************************************************************************/
static void Rep_RemoveUsrReportsFromDB (long UsrCod) static void Rep_DB_RemoveUsrReports (long UsrCod)
{ {
/***** Insert a new user's usage report into database *****/
DB_QueryDELETE ("can not remove user's usage reports", DB_QueryDELETE ("can not remove user's usage reports",
"DELETE FROM usr_reports" "DELETE FROM usr_reports"
" WHERE UsrCod=%ld", " WHERE UsrCod=%ld",

View File

@ -131,7 +131,7 @@ void Ses_CloseSession (void)
Gbl.Session.Id[0] = '\0'; Gbl.Session.Id[0] = '\0';
/***** If there are no more sessions for current user ==> remove user from connected list *****/ /***** If there are no more sessions for current user ==> remove user from connected list *****/
Con_RemoveOldConnected (); Con_DB_RemoveOldConnected ();
/***** Remove unused data associated to expired sessions *****/ /***** Remove unused data associated to expired sessions *****/
Ses_RemoveParamsFromExpiredSessions (); Ses_RemoveParamsFromExpiredSessions ();
@ -266,6 +266,18 @@ void Ses_RemoveExpiredSessions (void)
Cfg_TIME_TO_CLOSE_SESSION_FROM_LAST_REFRESH); Cfg_TIME_TO_CLOSE_SESSION_FROM_LAST_REFRESH);
} }
/*****************************************************************************/
/******************* Remove all sessions of a given user *********************/
/*****************************************************************************/
void Ses_DB_RemoveUsrSessions (long UsrCod)
{
DB_QueryDELETE ("can not remove sessions of a user",
"DELETE FROM ses_sessions"
" WHERE UsrCod=%ld",
UsrCod);
}
/*****************************************************************************/ /*****************************************************************************/
/******* Get the data (user code and password) of an initiated session *******/ /******* Get the data (user code and password) of an initiated session *******/
/*****************************************************************************/ /*****************************************************************************/

View File

@ -45,6 +45,7 @@ void Ses_InsertSessionInDB (void);
void Ses_UpdateSessionDataInDB (void); void Ses_UpdateSessionDataInDB (void);
void Ses_UpdateSessionLastRefreshInDB (void); void Ses_UpdateSessionLastRefreshInDB (void);
void Ses_RemoveExpiredSessions (void); void Ses_RemoveExpiredSessions (void);
void Ses_DB_RemoveUsrSessions (long UsrCod);
bool Ses_GetSessionData (void); bool Ses_GetSessionData (void);
void Ses_InsertParamInDB (const char *ParamName,const char *ParamValue); void Ses_InsertParamInDB (const char *ParamName,const char *ParamValue);

View File

@ -371,3 +371,15 @@ void Set_EndOneSettingSelector (void)
{ {
HTM_DIV_End (); HTM_DIV_End ();
} }
/*****************************************************************************/
/************************ Remove a user from a course ************************/
/*****************************************************************************/
void Set_DB_RemCrsUsrSettings (long UsrCod)
{
DB_QueryDELETE ("can not remove a user from all courses",
"DELETE FROM crs_user_settings"
" WHERE UsrCod=%ld",
UsrCod);
}

View File

@ -53,4 +53,6 @@ void Set_EndSettingsHead (void);
void Set_BeginOneSettingSelector (void); void Set_BeginOneSettingSelector (void);
void Set_EndOneSettingSelector (void); void Set_EndOneSettingSelector (void);
void Set_DB_RemCrsUsrSettings (long UsrCod);
#endif #endif

View File

@ -3622,6 +3622,31 @@ static void Usr_InsertMyLastData (void)
(long) (time_t) 0); // The user never accessed to notifications (long) (time_t) 0); // The user never accessed to notifications
} }
/*****************************************************************************/
/*************************** Remove user's last data *************************/
/*****************************************************************************/
void Usr_DB_RemoveUsrLastData (long UsrCod)
{
DB_QueryDELETE ("can not remove user's last data",
"DELETE FROM usr_last"
" WHERE UsrCod=%ld",
UsrCod);
}
/*****************************************************************************/
/****************************** Remove user's data ***************************/
/*****************************************************************************/
void Usr_DB_RemoveUsrData (long UsrCod)
{
/***** Remove user's data *****/
DB_QueryDELETE ("can not remove user's data",
"DELETE FROM usr_data"
" WHERE UsrCod=%ld",
UsrCod);
}
/*****************************************************************************/ /*****************************************************************************/
/*********** Write a row of a table with the main data of a user *************/ /*********** Write a row of a table with the main data of a user *************/
/*****************************************************************************/ /*****************************************************************************/
@ -3871,7 +3896,8 @@ static void Usr_WriteRowStdAllData (struct UsrData *UsrDat,char *GroupNames)
NumField++) NumField++)
{ {
/* Get the text of the field */ /* Get the text of the field */
if (Rec_GetFieldFromCrsRecord (UsrDat->UsrCod,Gbl.Crs.Records.LstFields.Lst[NumField].FieldCod,&mysql_res)) if (Rec_DB_GetFieldFromCrsRecord (&mysql_res,UsrDat->UsrCod,
Gbl.Crs.Records.LstFields.Lst[NumField].FieldCod))
{ {
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
Str_Copy (Text,row[0],sizeof (Text) - 1); Str_Copy (Text,row[0],sizeof (Text) - 1);
@ -10097,7 +10123,7 @@ double Usr_GetCachedNumUsrsPerCrs (Hie_Lvl_Level_t Scope,long Cod,Rol_Role_t Rol
/****************** Check if a user is banned in ranking *********************/ /****************** Check if a user is banned in ranking *********************/
/*****************************************************************************/ /*****************************************************************************/
bool Usr_CheckIfUsrBanned (long UsrCod) bool Usr_DB_CheckIfUsrBanned (long UsrCod)
{ {
return (DB_QueryCOUNT ("can not check if user is banned", return (DB_QueryCOUNT ("can not check if user is banned",
"SELECT COUNT(*)" "SELECT COUNT(*)"
@ -10110,7 +10136,7 @@ bool Usr_CheckIfUsrBanned (long UsrCod)
/**************** Remove user from banned users in ranking *******************/ /**************** Remove user from banned users in ranking *******************/
/*****************************************************************************/ /*****************************************************************************/
void Usr_RemoveUsrFromUsrBanned (long UsrCod) void Usr_DB_RemoveUsrFromBanned (long UsrCod)
{ {
DB_QueryDELETE ("can not remove user from users banned", DB_QueryDELETE ("can not remove user from users banned",
"DELETE FROM usr_banned" "DELETE FROM usr_banned"

View File

@ -408,6 +408,9 @@ bool Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (struct UsrData *UsrDat,
void Usr_UpdateMyLastData (void); void Usr_UpdateMyLastData (void);
void Usr_InsertMyLastCrsTabAndTime (void); void Usr_InsertMyLastCrsTabAndTime (void);
void Usr_DB_RemoveUsrLastData (long UsrCod);
void Usr_DB_RemoveUsrData (long UsrCod);
void Usr_WriteRowUsrMainData (unsigned NumUsr,struct UsrData *UsrDat, void Usr_WriteRowUsrMainData (unsigned NumUsr,struct UsrData *UsrDat,
bool PutCheckBoxToSelectUsr,Rol_Role_t Role, bool PutCheckBoxToSelectUsr,Rol_Role_t Role,
struct SelectedUsrs *SelectedUsrs); struct SelectedUsrs *SelectedUsrs);
@ -535,8 +538,8 @@ unsigned Usr_GetCachedNumUsrsNotBelongingToAnyCrs (void);
double Usr_GetCachedNumCrssPerUsr (Hie_Lvl_Level_t Scope,long Cod,Rol_Role_t Role); double Usr_GetCachedNumCrssPerUsr (Hie_Lvl_Level_t Scope,long Cod,Rol_Role_t Role);
double Usr_GetCachedNumUsrsPerCrs (Hie_Lvl_Level_t Scope,long Cod,Rol_Role_t Role); double Usr_GetCachedNumUsrsPerCrs (Hie_Lvl_Level_t Scope,long Cod,Rol_Role_t Role);
bool Usr_CheckIfUsrBanned (long UsrCod); bool Usr_DB_CheckIfUsrBanned (long UsrCod);
void Usr_RemoveUsrFromUsrBanned (long UsrCod); void Usr_DB_RemoveUsrFromBanned (long UsrCod);
void Usr_PrintUsrQRCode (void); void Usr_PrintUsrQRCode (void);