swad-core/swad_account.c

1027 lines
38 KiB
C
Raw Normal View History

2014-12-12 22:39:55 +01:00
// swad_account.c: user's account
/*
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.
2016-01-01 20:19:43 +01:00
Copyright (C) 1999-2016 Antonio Ca<EFBFBD>as Vargas
2014-12-12 22:39:55 +01:00
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_announcement.h"
2015-11-21 20:23:28 +01:00
#include "swad_calendar.h"
2014-12-12 22:39:55 +01:00
#include "swad_database.h"
2016-06-16 19:30:29 +02:00
#include "swad_duplicate.h"
2014-12-12 22:39:55 +01:00
#include "swad_enrollment.h"
2015-12-12 02:01:20 +01:00
#include "swad_follow.h"
2014-12-12 22:39:55 +01:00
#include "swad_global.h"
#include "swad_ID.h"
#include "swad_notification.h"
#include "swad_parameter.h"
2016-02-29 16:22:11 +01:00
#include "swad_preference.h"
2015-03-14 17:39:04 +01:00
#include "swad_profile.h"
2016-01-08 10:13:28 +01:00
#include "swad_social.h"
2014-12-12 22:39:55 +01:00
/*****************************************************************************/
/****************************** Public constants *****************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private constants *****************************/
/*****************************************************************************/
/*****************************************************************************/
/****************************** Internal types *******************************/
/*****************************************************************************/
/*****************************************************************************/
/************** External global variables from others modules ****************/
/*****************************************************************************/
extern struct Globals Gbl;
/*****************************************************************************/
/************************* Internal global variables *************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private prototypes ****************************/
/*****************************************************************************/
2016-09-22 13:33:42 +02:00
static void Acc_ShowFormCheckIfIHaveAccount (void);
2014-12-12 22:39:55 +01:00
static void Acc_ShowFormRequestNewAccountWithParams (const char *NewNicknameWithoutArroba,
const char *NewEmail);
static bool Acc_GetParamsNewAccount (char *NewNicknameWithoutArroba,
char *NewEmail,
char *NewEncryptedPassword);
static void Acc_CreateNewEncryptedUsrCod (struct UsrData *UsrDat);
static void Acc_PutLinkToRemoveMyAccount (void);
2015-04-02 18:39:49 +02:00
static void Acc_PutLinkToRemoveMyAccountParams (void);
2014-12-12 22:39:55 +01:00
static void Acc_PrintAccountSeparator (void);
2015-09-16 00:15:20 +02:00
static void Acc_AskIfRemoveUsrAccount (bool ItsMe);
static void Acc_AskIfRemoveOtherUsrAccount (void);
2014-12-12 22:39:55 +01:00
static void Acc_RemoveUsrBriefcase (struct UsrData *UsrDat);
static void Acc_RemoveUsr (struct UsrData *UsrDat);
2016-03-01 03:16:29 +01:00
/*****************************************************************************/
/******************** Put link to create a new account ***********************/
/*****************************************************************************/
void Acc_PutLinkToCreateAccount (void)
{
extern const char *Txt_Create_account;
Lay_PutContextualLink (ActFrmUsrAcc,NULL,
"arroba64x64.gif",
2016-07-01 16:32:42 +02:00
Txt_Create_account,Txt_Create_account,
NULL);
2016-03-01 03:16:29 +01:00
}
2014-12-12 22:39:55 +01:00
/*****************************************************************************/
/******** Show form to change my account or to create a new account **********/
/*****************************************************************************/
void Acc_ShowFormAccount (void)
{
if (Gbl.Usrs.Me.Logged)
Acc_ShowFormChangeMyAccount ();
else
2015-06-15 12:30:09 +02:00
{
2016-02-29 16:22:11 +01:00
/* Links to log in and to change language */
fprintf (Gbl.F.Out,"<div class=\"CONTEXT_MENU\">");
Usr_PutLinkToLogin ();
Pre_PutLinkToChangeLanguage ();
fprintf (Gbl.F.Out,"</div>");
2015-06-15 12:30:09 +02:00
2016-09-22 13:33:42 +02:00
/**** Show form to check if I have an account *****/
Acc_ShowFormCheckIfIHaveAccount ();
/**** Show form to create a new account *****/
2016-03-21 19:52:40 +01:00
Acc_ShowFormRequestNewAccountWithParams ("","");
2015-06-15 12:30:09 +02:00
}
2014-12-12 22:39:55 +01:00
}
2016-09-22 13:33:42 +02:00
/*****************************************************************************/
/***************** Show form to check if I have an account *******************/
/*****************************************************************************/
static void Acc_ShowFormCheckIfIHaveAccount (void)
{
extern const char *The_ClassForm[The_NUM_THEMES];
extern const char *Txt_ID;
/***** Start frame *****/
Lay_StartRoundFrame (NULL,"Compruebe si ya existe una cuenta para usted",NULL); // TODO: Need translation!!!
/***** Info message *****/
Lay_ShowAlert (Lay_INFO,"Es posible que un profesor o administrador"
2016-09-22 18:04:25 +02:00
" ya haya creado una cuenta para usted."
2016-09-22 13:33:42 +02:00
" Escriba su ID (DNI/c&eacute;dula)"
" para comprobarlo."); // TODO: Need translation!!!!
/***** Form to request user's ID for possible account already created *****/
Act_FormStart (ActChkUsrAcc);
fprintf (Gbl.F.Out,"<label class=\"%s\">"
"%s:&nbsp;"
"</label>"
"<input type=\"text\" name=\"ID\""
" size=\"20\" maxlength=\"%u\" value=\"\" />",
The_ClassForm[Gbl.Prefs.Theme],Txt_ID,
ID_MAX_LENGTH_USR_ID);
Lay_PutConfirmButton ("Comprobar"); // TODO: Need translation!!!!
Act_FormEnd ();
/***** End frame *****/
Lay_EndRoundFrame ();
}
/*****************************************************************************/
/* Check if already exists a new account without password associated to a ID */
/*****************************************************************************/
void Acc_CheckIfEmptyAccountExists (void)
{
2016-09-22 18:04:25 +02:00
char NewID[ID_MAX_LENGTH_USR_ID+1];
unsigned NumUsrs;
2016-09-22 13:33:42 +02:00
unsigned NumUsr;
2016-09-22 18:04:25 +02:00
struct UsrData UsrDat;
char Query[512];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
2016-09-22 13:33:42 +02:00
/***** Get new user's ID from form *****/
2016-09-22 18:04:25 +02:00
Par_GetParToText ("ID",NewID,ID_MAX_LENGTH_USR_ID);
2016-09-22 13:33:42 +02:00
// Users' IDs are always stored internally in capitals and without leading zeros
2016-09-22 18:04:25 +02:00
Str_RemoveLeadingZeros (NewID);
Str_ConvertToUpperText (NewID);
2016-09-22 13:33:42 +02:00
/***** Check if there are users with this user's ID *****/
2016-09-22 18:04:25 +02:00
if (ID_CheckIfUsrIDIsValid (NewID))
{
sprintf (Query,"SELECT DISTINCT(usr_IDs.UsrCod) FROM usr_IDs,usr_data"
" WHERE usr_IDs.UsrID='%s'"
" AND usr_IDs.UsrCod=usr_data.UsrCod"
" AND usr_data.Password=''",
NewID);
NumUsrs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get user's codes");
if (NumUsrs)
2016-09-22 13:33:42 +02:00
{
2016-09-22 18:04:25 +02:00
/***** Start frame and write message with number of users found *****/
if (NumUsrs == 1)
{
Lay_StartRoundFrame (NULL,"Cuenta encontrada",NULL); // TODO: Need translation!!!
Lay_ShowAlert (Lay_SUCCESS,"Existe una cuenta de usuario vac&iacute;a asociada a su ID."); // TODO: Need translation!!!
}
else
{
sprintf (Gbl.Title,"%u cuentas encontradas",
NumUsrs);
Lay_StartRoundFrame (NULL,Gbl.Title,NULL); // TODO: Need translation!!!
sprintf (Gbl.Message,"Existen %u cuentas vac&iacute;as asociadas a su ID:", // TODO: Need translation!!!
NumUsrs);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
}
/***** List users found *****/
2016-09-22 13:33:42 +02:00
for (NumUsr = 0;
2016-09-22 18:04:25 +02:00
NumUsr < NumUsrs;
2016-09-22 13:33:42 +02:00
NumUsr++)
2016-09-22 18:04:25 +02:00
{
/* Get user's code */
row = mysql_fetch_row (mysql_res);
UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
2016-09-22 13:33:42 +02:00
2016-09-22 20:52:08 +02:00
2016-09-22 18:04:25 +02:00
fprintf (Gbl.F.Out,"UsrCod = %ld", // TODO: Change this check!!!!!!!!
UsrDat.UsrCod);
/* Button to login with this account */
Lay_PutCreateButton ("Usar cuenta"); // TODO: Need translation!!!
}
/***** End frame *****/
Lay_EndRoundFrame ();
2016-09-22 13:33:42 +02:00
}
2016-09-22 18:04:25 +02:00
else
{
sprintf (Gbl.Message,"No hay ninguna cuenta vac&iacute;a asociada a su ID %s.", // TODO: Need translation!!!
NewID);
Lay_ShowAlert (Lay_INFO,Gbl.Message);
/**** Show form to check if I have an account *****/
Acc_ShowFormCheckIfIHaveAccount ();
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
/**** Show form to create a new account *****/
Acc_ShowFormRequestNewAccountWithParams ("","");
2016-09-22 13:33:42 +02:00
}
2016-02-29 16:22:11 +01:00
/*****************************************************************************/
/************ Show form to create a new account using parameters *************/
/*****************************************************************************/
2014-12-12 22:39:55 +01:00
static void Acc_ShowFormRequestNewAccountWithParams (const char *NewNicknameWithoutArroba,
const char *NewEmail)
{
2015-07-27 21:25:45 +02:00
extern const char *The_ClassForm[The_NUM_THEMES];
2014-12-12 22:39:55 +01:00
extern const char *Txt_Nickname;
2015-03-27 20:52:14 +01:00
extern const char *Txt_HELP_nickname;
extern const char *Txt_HELP_email;
2014-12-12 22:39:55 +01:00
extern const char *Txt_Email;
extern const char *Txt_New_on_PLATFORM_Sign_up;
extern const char *Txt_Create_account;
2015-03-27 20:52:14 +01:00
char NewNicknameWithArroba[Nck_MAX_BYTES_NICKNAME_WITH_ARROBA+1];
2014-12-12 22:39:55 +01:00
2014-12-26 17:55:42 +01:00
/***** Form to enter some data of the new user *****/
2014-12-12 22:39:55 +01:00
Act_FormStart (ActCreUsrAcc);
sprintf (Gbl.Title,Txt_New_on_PLATFORM_Sign_up,Cfg_PLATFORM_SHORT_NAME);
2015-04-12 18:01:06 +02:00
Lay_StartRoundFrameTable (NULL,2,Gbl.Title);
2014-12-12 22:39:55 +01:00
/***** Nickname *****/
2015-03-27 20:52:14 +01:00
if (NewNicknameWithoutArroba[0])
sprintf (NewNicknameWithArroba,"@%s",NewNicknameWithoutArroba);
else
NewNicknameWithArroba[0] = '\0';
2014-12-12 22:39:55 +01:00
fprintf (Gbl.F.Out,"<tr>"
2015-07-27 21:25:45 +02:00
"<td class=\"%s RIGHT_MIDDLE\">"
"%s:"
"</td>"
2015-07-28 00:51:32 +02:00
"<td class=\"LEFT_MIDDLE\">"
2014-12-12 22:39:55 +01:00
"<input type=\"text\" name=\"NewNick\""
2015-03-27 20:52:14 +01:00
" size=\"25\" maxlength=\"%u\""
" placeholder=\"%s\" value=\"%s\" />"
2014-12-12 22:39:55 +01:00
"</td>"
"</tr>",
2015-07-27 21:25:45 +02:00
The_ClassForm[Gbl.Prefs.Theme],
2014-12-12 22:39:55 +01:00
Txt_Nickname,
1+Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA,
2015-03-27 20:52:14 +01:00
Txt_HELP_nickname,
NewNicknameWithArroba);
2014-12-12 22:39:55 +01:00
/***** E-mail *****/
fprintf (Gbl.F.Out,"<tr>"
2015-07-27 21:25:45 +02:00
"<td class=\"%s RIGHT_MIDDLE\">"
"%s:"
"</td>"
2015-07-28 00:51:32 +02:00
"<td class=\"LEFT_MIDDLE\">"
2014-12-12 22:39:55 +01:00
"<input type=\"text\" name=\"NewEmail\""
2015-03-27 20:52:14 +01:00
" size=\"25\" maxlength=\"%u\""
" placeholder=\"%s\" value=\"%s\" />"
2014-12-12 22:39:55 +01:00
"</td>"
"</tr>",
2015-07-27 21:25:45 +02:00
The_ClassForm[Gbl.Prefs.Theme],
2014-12-12 22:39:55 +01:00
Txt_Email,
2015-04-14 19:38:00 +02:00
Usr_MAX_BYTES_USR_EMAIL,
2015-03-27 20:52:14 +01:00
Txt_HELP_email,
2014-12-12 22:39:55 +01:00
NewEmail);
/***** Password *****/
2015-11-20 21:11:33 +01:00
Pwd_PutFormToGetNewPasswordOnce ();
2014-12-12 22:39:55 +01:00
/***** Send button and form end *****/
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTableWithButton (Lay_CREATE_BUTTON,Txt_Create_account);
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
2014-12-12 22:39:55 +01:00
}
2016-03-21 19:52:40 +01:00
/*****************************************************************************/
/********* Show form to go to request the creation of a new account **********/
/*****************************************************************************/
void Acc_ShowFormGoToRequestNewAccount (void)
{
extern const char *Txt_New_on_PLATFORM_Sign_up;
extern const char *Txt_Create_new_account;
/***** Start frame *****/
sprintf (Gbl.Title,Txt_New_on_PLATFORM_Sign_up,Cfg_PLATFORM_SHORT_NAME);
Lay_StartRoundFrame (NULL,Gbl.Title,NULL);
/***** Button to go to request the creation of a new account *****/
Act_FormStart (ActFrmUsrAcc);
Lay_PutCreateButton (Txt_Create_new_account);
Act_FormEnd ();
/***** End frame *****/
Lay_EndRoundFrame ();
}
2014-12-12 22:39:55 +01:00
/*****************************************************************************/
/*********************** Show form to change my account **********************/
/*****************************************************************************/
void Acc_ShowFormChangeMyAccount (void)
{
extern const char *Txt_Before_going_to_any_other_option_you_must_fill_your_nickname;
2015-03-28 18:34:08 +01:00
extern const char *Txt_Please_fill_in_your_email_address;
extern const char *Txt_Please_fill_in_your_ID;
2014-12-12 22:39:55 +01:00
extern const char *Txt_User_account;
/***** Get current user's nickname and e-mail address
It's necessary because current nickname or e-mail could be just updated *****/
Nck_GetNicknameFromUsrCod (Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.Usrs.Me.UsrDat.Nickname);
2015-11-16 14:54:12 +01:00
Mai_GetEmailFromUsrCod (&Gbl.Usrs.Me.UsrDat);
2014-12-12 22:39:55 +01:00
/***** Check nickname and e-mail *****/
if (!Gbl.Usrs.Me.UsrDat.Nickname[0])
Lay_ShowAlert (Lay_WARNING,Txt_Before_going_to_any_other_option_you_must_fill_your_nickname);
else if (!Gbl.Usrs.Me.UsrDat.Email[0])
2015-03-28 18:34:08 +01:00
Lay_ShowAlert (Lay_WARNING,Txt_Please_fill_in_your_email_address);
2014-12-12 22:39:55 +01:00
else if (!Gbl.Usrs.Me.UsrDat.IDs.Num)
2015-03-28 18:34:08 +01:00
Lay_ShowAlert (Lay_WARNING,Txt_Please_fill_in_your_ID);
2014-12-12 22:39:55 +01:00
/***** Put links to change my password and to remove my account*****/
2015-04-02 14:22:21 +02:00
fprintf (Gbl.F.Out,"<div class=\"CONTEXT_MENU\">");
2015-04-02 18:39:49 +02:00
Pwd_PutLinkToChangeMyPassword ();
2016-06-17 23:38:32 +02:00
if (Acc_CheckIfICanEliminateAccount (Gbl.Usrs.Me.UsrDat.UsrCod))
2014-12-12 22:39:55 +01:00
Acc_PutLinkToRemoveMyAccount ();
fprintf (Gbl.F.Out,"</div>");
/***** Start table *****/
2015-04-12 18:01:06 +02:00
Lay_StartRoundFrameTable (NULL,2,Txt_User_account);
2014-12-12 22:39:55 +01:00
/***** Nickname *****/
Nck_ShowFormChangeUsrNickname ();
/***** Separator *****/
Acc_PrintAccountSeparator ();
/***** E-mail *****/
2015-11-16 14:54:12 +01:00
Mai_ShowFormChangeUsrEmail (&Gbl.Usrs.Me.UsrDat,true);
2014-12-12 22:39:55 +01:00
/***** Separator *****/
Acc_PrintAccountSeparator ();
/***** User's ID *****/
ID_ShowFormChangeUsrID (&Gbl.Usrs.Me.UsrDat,true);
/***** End of table *****/
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ();
2014-12-12 22:39:55 +01:00
}
/*****************************************************************************/
/******** Put a link to the action used to request user's password ***********/
/*****************************************************************************/
static void Acc_PutLinkToRemoveMyAccount (void)
{
extern const char *Txt_Remove_account;
2015-12-13 18:32:37 +01:00
Lay_PutContextualLink (ActReqRemMyAcc,Acc_PutLinkToRemoveMyAccountParams,
2015-12-13 19:02:06 +01:00
"remove-on64x64.png",
2016-07-01 16:32:42 +02:00
Txt_Remove_account,Txt_Remove_account,
NULL);
2015-04-02 18:39:49 +02:00
}
static void Acc_PutLinkToRemoveMyAccountParams (void)
{
Usr_PutParamUsrCodEncrypted (Gbl.Usrs.Me.UsrDat.EncryptedUsrCod);
2014-12-12 22:39:55 +01:00
Par_PutHiddenParamUnsigned ("RegRemAction",(unsigned) Enr_ELIMINATE_ONE_USR_FROM_PLATFORM);
}
/*****************************************************************************/
/******* Draw a separator between different parts of new account form ********/
/*****************************************************************************/
static void Acc_PrintAccountSeparator (void)
{
extern const char *The_ClassSeparator[The_NUM_THEMES];
/***** Separator *****/
fprintf (Gbl.F.Out,"<tr>"
2015-09-18 02:15:35 +02:00
"<td colspan=\"2\" class=\"CENTER_MIDDLE\">"
2014-12-12 22:39:55 +01:00
"<hr class=\"%s\" />"
"</td>"
"</tr>",
The_ClassSeparator[Gbl.Prefs.Theme]);
}
/*****************************************************************************/
/*************** Create new user account with an ID and login ****************/
/*****************************************************************************/
// Return true if no error and user can be logged in
// Return false on error
bool Acc_CreateNewAccountAndLogIn (void)
{
char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_WITH_ARROBA+1];
2015-04-14 19:38:00 +02:00
char NewEmail[Usr_MAX_BYTES_USR_EMAIL+1];
2014-12-12 22:39:55 +01:00
char NewEncryptedPassword[Cry_LENGTH_ENCRYPTED_STR_SHA512_BASE64+1];
if (Acc_GetParamsNewAccount (NewNicknameWithoutArroba,NewEmail,NewEncryptedPassword))
{
/***** User's has no ID *****/
Gbl.Usrs.Me.UsrDat.IDs.Num = 0;
Gbl.Usrs.Me.UsrDat.IDs.List = NULL;
/***** Set password to the password typed by the user *****/
strcpy (Gbl.Usrs.Me.UsrDat.Password,NewEncryptedPassword);
/***** User does not exist in the platform, so create him/her! *****/
Acc_CreateNewUsr (&Gbl.Usrs.Me.UsrDat);
/***** Save nickname *****/
Nck_UpdateMyNick (NewNicknameWithoutArroba);
strcpy (Gbl.Usrs.Me.UsrDat.Nickname,NewNicknameWithoutArroba);
/***** Save e-mail *****/
if (Mai_UpdateEmailInDB (&Gbl.Usrs.Me.UsrDat,NewEmail))
{
/* E-mail updated sucessfully */
strcpy (Gbl.Usrs.Me.UsrDat.Email,NewEmail);
Gbl.Usrs.Me.UsrDat.EmailConfirmed = false;
}
return true;
}
else
{
/***** Show form again ******/
Acc_ShowFormRequestNewAccountWithParams (NewNicknameWithoutArroba,NewEmail);
return false;
}
}
/*****************************************************************************/
/************* Get parameters for the creation of a new account **************/
/*****************************************************************************/
// Return false on error
static bool Acc_GetParamsNewAccount (char *NewNicknameWithoutArroba,
char *NewEmail,
char *NewEncryptedPassword)
{
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_email_address_X_had_been_registered_by_another_user;
extern const char *Txt_The_email_address_entered_X_is_not_valid;
char Query[1024];
char NewNicknameWithArroba[Nck_MAX_BYTES_NICKNAME_WITH_ARROBA+1];
2015-11-20 21:11:33 +01:00
char NewPlainPassword[Pwd_MAX_LENGTH_PLAIN_PASSWORD+1];
2014-12-12 22:39:55 +01:00
bool Error = false;
/***** Step 1/3: Get new nickname from form *****/
Par_GetParToText ("NewNick",NewNicknameWithArroba,Nck_MAX_BYTES_NICKNAME_WITH_ARROBA);
2016-03-21 19:52:40 +01:00
/* Remove arrobas at the beginning */
2015-03-24 17:47:26 +01:00
strncpy (NewNicknameWithoutArroba,NewNicknameWithArroba,Nck_MAX_BYTES_NICKNAME_WITH_ARROBA);
NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_WITH_ARROBA] = '\0';
2016-03-21 19:52:40 +01:00
Str_RemoveLeadingArrobas (NewNicknameWithoutArroba);
/* Create a new version of the nickname with arroba */
sprintf (NewNicknameWithArroba,"@%s",NewNicknameWithoutArroba);
2014-12-12 22:39:55 +01:00
if (Nck_CheckIfNickWithArrobaIsValid (NewNicknameWithArroba)) // If new nickname is valid
{
2016-03-21 19:52:40 +01:00
/* Check if the new nickname
matches any of the nicknames of other users */
2014-12-12 22:39:55 +01:00
sprintf (Query,"SELECT COUNT(*) FROM usr_nicknames"
" WHERE Nickname='%s' AND UsrCod<>'%ld'",
NewNicknameWithoutArroba,Gbl.Usrs.Me.UsrDat.UsrCod);
if (DB_QueryCOUNT (Query,"can not check if nickname already existed")) // A nickname of another user is the same that this nickname
{
Error = true;
sprintf (Gbl.Message,Txt_The_nickname_X_had_been_registered_by_another_user,
NewNicknameWithoutArroba);
Lay_ShowAlert (Lay_WARNING,Gbl.Message);
}
}
else // New nickname is not valid
{
Error = true;
sprintf (Gbl.Message,Txt_The_nickname_entered_X_is_not_valid_,
NewNicknameWithArroba,
Nck_MIN_LENGTH_NICKNAME_WITHOUT_ARROBA,
Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA);
Lay_ShowAlert (Lay_WARNING,Gbl.Message);
}
/***** Step 2/3: Get new e-mail from form *****/
2015-04-14 19:38:00 +02:00
Par_GetParToText ("NewEmail",NewEmail,Usr_MAX_BYTES_USR_EMAIL);
2014-12-12 22:39:55 +01:00
if (Mai_CheckIfEmailIsValid (NewEmail)) // New e-mail is valid
{
2016-03-21 19:52:40 +01:00
/* Check if the new e-mail matches
any of the confirmed e-mails of other users */
2014-12-12 22:39:55 +01:00
sprintf (Query,"SELECT COUNT(*) FROM usr_emails"
" WHERE E_mail='%s' AND Confirmed='Y'",
NewEmail);
if (DB_QueryCOUNT (Query,"can not check if e-mail already existed")) // An e-mail of another user is the same that my e-mail
{
Error = true;
sprintf (Gbl.Message,Txt_The_email_address_X_had_been_registered_by_another_user,
NewEmail);
Lay_ShowAlert (Lay_WARNING,Gbl.Message);
}
}
else // New e-mail is not valid
{
Error = true;
sprintf (Gbl.Message,Txt_The_email_address_entered_X_is_not_valid,
NewEmail);
Lay_ShowAlert (Lay_WARNING,Gbl.Message);
}
2015-07-13 12:34:26 +02:00
/***** Step 3/3: Get new password from form *****/
2015-11-20 21:11:33 +01:00
Par_GetParToText ("Paswd",NewPlainPassword,Pwd_MAX_LENGTH_PLAIN_PASSWORD);
Str_ChangeFormat (Str_FROM_FORM,Str_TO_TEXT,
NewPlainPassword,Pwd_MAX_LENGTH_PLAIN_PASSWORD,true);
Cry_EncryptSHA512Base64 (NewPlainPassword,NewEncryptedPassword);
if (!Pwd_SlowCheckIfPasswordIsGood (NewPlainPassword,NewEncryptedPassword,-1L)) // New password is good?
2014-12-12 22:39:55 +01:00
{
Error = true;
2015-11-20 21:11:33 +01:00
Lay_ShowAlert (Lay_WARNING,Gbl.Message); // Error message is set in Usr_SlowCheckIfPasswordIsGood
2014-12-12 22:39:55 +01:00
}
return !Error;
}
/*****************************************************************************/
/****************************** Create new user ******************************/
/*****************************************************************************/
// UsrDat->UsrCod must be <= 0
// UsrDat->UsrDat.IDs must contain a list of IDs for the new user
void Acc_CreateNewUsr (struct UsrData *UsrDat)
{
extern const char *The_ThemeId[The_NUM_THEMES];
2015-03-06 14:11:11 +01:00
extern const char *Ico_IconSetId[Ico_NUM_ICON_SETS];
2015-03-06 22:36:29 +01:00
extern const char *Pri_VisibilityDB[Pri_NUM_OPTIONS_PRIVACY];
2015-12-07 23:13:08 +01:00
extern const char *Txt_STR_LANG_ID[1+Txt_NUM_LANGUAGES];
2014-12-12 22:39:55 +01:00
extern const char *Usr_StringsSexDB[Usr_NUM_SEXS];
2016-05-01 01:52:35 +02:00
char BirthdayStrDB[Usr_BIRTHDAY_STR_DB_LENGTH+1];
2014-12-12 22:39:55 +01:00
char Query[2048];
char PathRelUsr[PATH_MAX+1];
unsigned NumID;
/***** Check if user's code is initialized *****/
if (UsrDat->UsrCod > 0)
Lay_ShowErrorAndExit ("Can not create new user.");
/***** Create encrypted user's code *****/
Acc_CreateNewEncryptedUsrCod (UsrDat);
/***** Filter some user's data before inserting */
Enr_FilterUsrDat (UsrDat);
/***** Insert new user in database *****/
/* Insert user's data */
2016-05-01 01:52:35 +02:00
Usr_CreateBirthdayStrDB (UsrDat,BirthdayStrDB);
2014-12-12 22:39:55 +01:00
sprintf (Query,"INSERT INTO usr_data (EncryptedUsrCod,Password,Surname1,Surname2,FirstName,Sex,"
2015-11-27 12:57:56 +01:00
"Theme,IconSet,Language,FirstDayOfWeek,PhotoVisibility,ProfileVisibility,"
2014-12-12 22:39:55 +01:00
"CtyCod,"
"LocalAddress,LocalPhone,FamilyAddress,FamilyPhone,OriginPlace,Birthday,Comments,"
2015-01-02 01:19:27 +01:00
"Menu,SideCols,NotifNtfEvents,EmailNtfEvents)"
2014-12-12 22:39:55 +01:00
" VALUES ('%s','%s','%s','%s','%s','%s',"
2015-11-27 12:57:56 +01:00
"'%s','%s','%s','%u','%s','%s',"
2014-12-12 22:39:55 +01:00
"'%ld',"
2016-05-01 01:52:35 +02:00
"'%s','%s','%s','%s','%s',%s,'%s',"
2015-01-02 01:19:27 +01:00
"'%u','%u','-1','0')",
2014-12-12 22:39:55 +01:00
UsrDat->EncryptedUsrCod,
UsrDat->Password,
UsrDat->Surname1,UsrDat->Surname2,UsrDat->FirstName,
Usr_StringsSexDB[UsrDat->Sex],
The_ThemeId[UsrDat->Prefs.Theme],
Ico_IconSetId[UsrDat->Prefs.IconSet],
Txt_STR_LANG_ID[UsrDat->Prefs.Language],
2015-11-21 20:23:28 +01:00
Cal_FIRST_DAY_OF_WEEK_DEFAULT,
2015-03-06 22:36:29 +01:00
Pri_VisibilityDB[UsrDat->PhotoVisibility],
2015-03-06 23:20:33 +01:00
Pri_VisibilityDB[UsrDat->ProfileVisibility],
2014-12-12 22:39:55 +01:00
UsrDat->CtyCod,
UsrDat->LocalAddress ,UsrDat->LocalPhone,
UsrDat->FamilyAddress,UsrDat->FamilyPhone,
UsrDat->OriginPlace,
2016-05-01 01:52:35 +02:00
BirthdayStrDB,
2014-12-12 22:39:55 +01:00
UsrDat->Comments ? UsrDat->Comments :
2014-12-27 13:09:29 +01:00
"",
2015-01-02 01:19:27 +01:00
Mnu_MENU_DEFAULT,
2014-12-27 13:49:17 +01:00
Cfg_DEFAULT_COLUMNS);
2014-12-12 22:39:55 +01:00
UsrDat->UsrCod = DB_QueryINSERTandReturnCode (Query,"can not create user");
/* Insert user's IDs as confirmed */
for (NumID = 0;
NumID < UsrDat->IDs.Num;
NumID++)
{
Str_ConvertToUpperText (UsrDat->IDs.List[NumID].ID);
sprintf (Query,"INSERT INTO usr_IDs (UsrCod,UsrID,CreatTime,Confirmed)"
" VALUES ('%ld','%s',NOW(),'%c')",
UsrDat->UsrCod,
UsrDat->IDs.List[NumID].ID,
UsrDat->IDs.List[NumID].Confirmed ? 'Y' :
'N');
DB_QueryINSERT (Query,"can not store user's ID when creating user");
}
/***** Create directory for the user, if not exists *****/
Usr_ConstructPathUsr (UsrDat->UsrCod,PathRelUsr);
Fil_CreateDirIfNotExists (PathRelUsr);
2015-03-28 18:34:08 +01:00
/***** Create user's figures *****/
Prf_CreateNewUsrFigures (UsrDat->UsrCod);
2014-12-12 22:39:55 +01:00
}
/*****************************************************************************/
/******************** Create a new encrypted user's code *********************/
/*****************************************************************************/
#define LENGTH_RANDOM_STR 32
#define MAX_TRY 10
static void Acc_CreateNewEncryptedUsrCod (struct UsrData *UsrDat)
{
char RandomStr[LENGTH_RANDOM_STR+1];
unsigned NumTry;
for (NumTry = 0;
NumTry < MAX_TRY;
NumTry++)
{
Str_CreateRandomAlphanumStr (RandomStr,LENGTH_RANDOM_STR);
Cry_EncryptSHA256Base64 (RandomStr,UsrDat->EncryptedUsrCod);
if (!Usr_ChkIfEncryptedUsrCodExists (UsrDat->EncryptedUsrCod))
break;
}
if (NumTry == MAX_TRY)
Lay_ShowErrorAndExit ("Can not create a new encrypted user's code.");
}
/*****************************************************************************/
/***************** Message after creation of a new account *******************/
/*****************************************************************************/
void Acc_AfterCreationNewAccount (void)
{
2015-04-15 19:48:33 +02:00
extern const char *Txt_Congratulations_You_have_created_your_account_X_Now_Y_will_request_you_;
2014-12-12 22:39:55 +01:00
if (Gbl.Usrs.Me.Logged) // If account has been created without problem, I am logged
{
/***** Show message of success *****/
2015-04-15 19:48:33 +02:00
sprintf (Gbl.Message,Txt_Congratulations_You_have_created_your_account_X_Now_Y_will_request_you_,
Gbl.Usrs.Me.UsrDat.Nickname,
Cfg_PLATFORM_SHORT_NAME);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
2014-12-12 22:39:55 +01:00
/***** Show form with account data *****/
Acc_ShowFormChangeMyAccount ();
}
}
/*****************************************************************************/
/************** Definite removing of a user from the platform ****************/
/*****************************************************************************/
2016-06-17 23:38:32 +02:00
void Acc_GetUsrCodAndRemUsrGbl (void)
2014-12-12 22:39:55 +01:00
{
2016-06-17 23:38:32 +02:00
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
Acc_ReqRemAccountOrRemAccount (Acc_REMOVE_USR);
else
Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
2014-12-12 22:39:55 +01:00
}
/*****************************************************************************/
/**************************** Removing of a user *****************************/
/*****************************************************************************/
2016-06-17 23:38:32 +02:00
void Acc_ReqRemAccountOrRemAccount (Acc_ReqOrRemUsr_t RequestOrRemove)
2014-12-12 22:39:55 +01:00
{
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
2016-06-17 23:38:32 +02:00
if (Acc_CheckIfICanEliminateAccount (Gbl.Usrs.Other.UsrDat.UsrCod))
switch (RequestOrRemove)
{
case Acc_REQUEST_REMOVE_USR: // Ask if eliminate completely the user from the platform
Acc_AskIfRemoveUsrAccount (Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod);
break;
case Acc_REMOVE_USR: // Eliminate completely the user from the platform
if (Pwd_GetConfirmationOnDangerousAction ())
{
Acc_CompletelyEliminateAccount (&Gbl.Usrs.Other.UsrDat,Cns_VERBOSE);
/***** Move unused contents of messages to table of deleted contents of messages *****/
Msg_MoveUnusedMsgsContentToDeleted ();
}
break;
}
2014-12-12 22:39:55 +01:00
else
Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
}
/*****************************************************************************/
/******** Check if I can eliminate completely another user's account *********/
/*****************************************************************************/
2016-06-17 23:38:32 +02:00
bool Acc_CheckIfICanEliminateAccount (long UsrCod)
2014-12-12 22:39:55 +01:00
{
2016-06-17 23:38:32 +02:00
bool ItsMe = (Gbl.Usrs.Me.Logged &&
UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
2014-12-12 22:39:55 +01:00
// A user logged as superuser can eliminate any user except her/him
// Other users only can eliminate themselves
2016-06-17 23:38:32 +02:00
return (( ItsMe && // It's me
(Gbl.Usrs.Me.AvailableRoles & (1 << Rol_SYS_ADM)) == 0) // I can not be system admin
2014-12-12 22:39:55 +01:00
||
2016-06-17 23:38:32 +02:00
(!ItsMe && // It's not me
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)); // I am logged as system admin
2014-12-12 22:39:55 +01:00
}
/*****************************************************************************/
/*********** Ask if really wanted to eliminate completely a user *************/
/*****************************************************************************/
2015-09-16 00:15:20 +02:00
static void Acc_AskIfRemoveUsrAccount (bool ItsMe)
{
if (ItsMe)
Acc_AskIfRemoveMyAccount ();
else
Acc_AskIfRemoveOtherUsrAccount ();
}
void Acc_AskIfRemoveMyAccount (void)
2014-12-12 22:39:55 +01:00
{
extern const char *Txt_Do_you_really_want_to_completely_eliminate_your_user_account;
2015-03-28 18:34:08 +01:00
extern const char *Txt_Eliminate_my_user_account;
2015-09-16 00:15:20 +02:00
Lay_ShowAlert (Lay_WARNING,Txt_Do_you_really_want_to_completely_eliminate_your_user_account);
Rec_ShowCommonRecordUnmodifiable (&Gbl.Usrs.Me.UsrDat);
Act_FormStart (ActRemMyAcc);
/* Ask for consent on dangerous actions */
Pwd_AskForConfirmationOnDangerousAction ();
Lay_PutRemoveButton (Txt_Eliminate_my_user_account);
Act_FormEnd ();
}
static void Acc_AskIfRemoveOtherUsrAccount (void)
{
extern const char *Txt_Do_you_really_want_to_completely_eliminate_the_following_user;
2015-03-28 18:34:08 +01:00
extern const char *Txt_Eliminate_user_account;
2014-12-12 22:39:55 +01:00
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
if (Usr_ChkIfUsrCodExists (Gbl.Usrs.Other.UsrDat.UsrCod))
{
2015-09-16 00:15:20 +02:00
Lay_ShowAlert (Lay_WARNING,Txt_Do_you_really_want_to_completely_eliminate_the_following_user);
2014-12-12 22:39:55 +01:00
Rec_ShowCommonRecordUnmodifiable (&Gbl.Usrs.Other.UsrDat);
Act_FormStart (ActRemUsrGbl);
2015-04-02 18:39:49 +02:00
Usr_PutParamOtherUsrCodEncrypted ();
2014-12-12 22:39:55 +01:00
/* Ask for consent on dangerous actions */
Pwd_AskForConfirmationOnDangerousAction ();
2015-09-16 00:15:20 +02:00
Lay_PutRemoveButton (Txt_Eliminate_user_account);
2015-03-24 17:47:26 +01:00
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
2014-12-12 22:39:55 +01:00
}
else
Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
}
/*****************************************************************************/
/************* Remove completely a user from the whole platform **************/
/*****************************************************************************/
2015-09-16 00:15:20 +02:00
void Acc_RemoveMyAccount (void)
{
if (Pwd_GetConfirmationOnDangerousAction ())
{
Acc_CompletelyEliminateAccount (&Gbl.Usrs.Me.UsrDat,Cns_VERBOSE);
/***** Move unused contents of messages to table of deleted contents of messages *****/
Msg_MoveUnusedMsgsContentToDeleted ();
}
}
2014-12-12 22:39:55 +01:00
void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat,
Cns_QuietOrVerbose_t QuietOrVerbose)
{
extern const char *Txt_THE_USER_X_has_been_removed_from_all_his_her_courses;
extern const char *Txt_THE_USER_X_has_been_removed_as_administrator;
extern const char *Txt_Messages_of_THE_USER_X_have_been_deleted;
extern const char *Txt_Virtual_pendrive_of_THE_USER_X_has_been_removed;
extern const char *Txt_Photo_of_THE_USER_X_has_been_removed;
extern const char *Txt_Record_card_of_THE_USER_X_has_been_removed;
char Query[1024];
bool PhotoRemoved = false;
/***** Remove the works zones of the user in all courses *****/
Brw_RemoveUsrWorksInAllCrss (UsrDat,QuietOrVerbose); // Make this before of removing the user from the courses
/***** Remove the fields of course record in all courses *****/
Rec_RemoveFieldsCrsRecordAll (UsrDat->UsrCod,QuietOrVerbose);
/***** Remove user from all the attendance events *****/
Att_RemoveUsrFromAllAttEvents (UsrDat->UsrCod);
/***** Remove user from all the groups of all courses *****/
Grp_RemUsrFromAllGrps (UsrDat,QuietOrVerbose);
/***** Remove user's requests for inscription *****/
sprintf (Query,"DELETE FROM crs_usr_requests"
" WHERE UsrCod='%ld'",
UsrDat->UsrCod);
DB_QueryDELETE (Query,"can not remove user's requests for inscription");
2016-06-15 14:52:43 +02:00
/***** Remove user from possible duplicate users *****/
2016-06-16 14:34:17 +02:00
Dup_RemoveUsrFromDuplicated (UsrDat->UsrCod);
2016-06-15 14:52:43 +02:00
2014-12-12 22:39:55 +01:00
/***** Remove user from the table of courses and users *****/
sprintf (Query,"DELETE FROM crs_usr"
" WHERE UsrCod='%ld'",
UsrDat->UsrCod);
DB_QueryDELETE (Query,"can not remove a user from all courses");
if (QuietOrVerbose == Cns_VERBOSE)
{
sprintf (Gbl.Message,Txt_THE_USER_X_has_been_removed_from_all_his_her_courses,
UsrDat->FullName);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
}
/***** Remove user as administrator of any degree *****/
2015-01-29 01:03:31 +01:00
sprintf (Query,"DELETE FROM admin"
2014-12-12 22:39:55 +01:00
" WHERE UsrCod='%ld'",
UsrDat->UsrCod);
DB_QueryDELETE (Query,"can not remove a user as administrator");
if (QuietOrVerbose == Cns_VERBOSE)
{
sprintf (Gbl.Message,Txt_THE_USER_X_has_been_removed_as_administrator,
UsrDat->FullName);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
}
2015-01-25 18:50:43 +01:00
/***** Remove user's clipboard in forums *****/
2014-12-12 22:39:55 +01:00
For_RemoveUsrFromThrClipboard (UsrDat->UsrCod);
2015-01-25 18:50:43 +01:00
/***** Remove some files of the user's from database *****/
Brw_RemoveUsrFilesFromDB (UsrDat->UsrCod);
/***** Remove the file tree of a user *****/
Acc_RemoveUsrBriefcase (UsrDat);
if (QuietOrVerbose == Cns_VERBOSE)
{
sprintf (Gbl.Message,Txt_Virtual_pendrive_of_THE_USER_X_has_been_removed,
UsrDat->FullName);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
}
2014-12-12 22:39:55 +01:00
/***** Remove exams made by user in all courses *****/
Tst_RemoveExamsMadeByUsrInAllCrss (UsrDat->UsrCod);
/***** Remove user's notifications *****/
Ntf_RemoveUsrNtfs (UsrDat->UsrCod);
/***** Delete user's messages sent and received *****/
Gbl.Msg.FilterContent[0] = '\0';
Msg_DelAllRecAndSntMsgsUsr (UsrDat->UsrCod);
if (QuietOrVerbose == Cns_VERBOSE)
{
sprintf (Gbl.Message,Txt_Messages_of_THE_USER_X_have_been_deleted,
UsrDat->FullName);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
}
2015-03-29 01:06:00 +01:00
/***** Remove user from tables of banned users *****/
Usr_RemoveUsrFromUsrBanned (UsrDat->UsrCod);
2014-12-12 22:39:55 +01:00
Msg_RemoveUsrFromBanned (UsrDat->UsrCod);
/***** Delete thread read status for this user *****/
For_RemoveUsrFromReadThrs (UsrDat->UsrCod);
/***** Remove user from table of seen announcements *****/
Ann_RemoveUsrFromSeenAnnouncements (UsrDat->UsrCod);
/***** Remove user from table of connected users *****/
sprintf (Query,"DELETE FROM connected WHERE UsrCod='%ld'",
UsrDat->UsrCod);
DB_QueryDELETE (Query,"can not remove a user from table of connected users");
/***** Remove all sessions of this user *****/
sprintf (Query,"DELETE FROM sessions WHERE UsrCod='%ld'",
UsrDat->UsrCod);
DB_QueryDELETE (Query,"can not remove sessions of a user");
2016-01-08 10:13:28 +01:00
/***** Remove social content associated to the user *****/
Soc_RemoveUsrSocialContent (UsrDat->UsrCod);
2015-03-11 12:48:41 +01:00
/***** Remove user's figures *****/
2015-03-14 17:39:04 +01:00
Prf_RemoveUsrFigures (UsrDat->UsrCod);
2015-03-11 12:48:41 +01:00
2015-12-12 02:01:20 +01:00
/***** Remove user from table of followers *****/
Fol_RemoveUsrFromUsrFollow (UsrDat->UsrCod);
2014-12-12 22:39:55 +01:00
/***** Remove the user from the list of users without photo *****/
Pho_RemoveUsrFromTableClicksWithoutPhoto (UsrDat->UsrCod);
/***** Remove user's photo *****/
PhotoRemoved = Pho_RemovePhoto (UsrDat);
if (PhotoRemoved && QuietOrVerbose == Cns_VERBOSE)
{
sprintf (Gbl.Message,Txt_Photo_of_THE_USER_X_has_been_removed,
UsrDat->FullName);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
}
/***** Remove user *****/
Acc_RemoveUsr (UsrDat);
if (QuietOrVerbose == Cns_VERBOSE)
{
sprintf (Gbl.Message,Txt_Record_card_of_THE_USER_X_has_been_removed,
UsrDat->FullName);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
}
}
/*****************************************************************************/
/********************** Remove the briefcase of a user ***********************/
/*****************************************************************************/
static void Acc_RemoveUsrBriefcase (struct UsrData *UsrDat)
{
char PathRelUsr[PATH_MAX+1];
2015-01-25 18:50:43 +01:00
/***** Remove files of the user's briefcase from disc *****/
2014-12-12 22:39:55 +01:00
Usr_ConstructPathUsr (UsrDat->UsrCod,PathRelUsr);
Brw_RemoveTree (PathRelUsr);
}
/*****************************************************************************/
/************************ Remove a user from database ************************/
/*****************************************************************************/
static void Acc_RemoveUsr (struct UsrData *UsrDat)
{
char Query[128];
/***** Remove user's webs / social networks *****/
sprintf (Query,"DELETE FROM usr_webs WHERE UsrCod='%ld'",
UsrDat->UsrCod);
DB_QueryDELETE (Query,"can not remove user's webs / social networks");
/***** Remove user's nicknames *****/
sprintf (Query,"DELETE FROM usr_nicknames WHERE UsrCod='%ld'",
UsrDat->UsrCod);
DB_QueryDELETE (Query,"can not remove user's nicknames");
/***** Remove user's e-mails *****/
sprintf (Query,"DELETE FROM pending_emails WHERE UsrCod='%ld'",
UsrDat->UsrCod);
DB_QueryDELETE (Query,"can not remove pending user's e-mails");
sprintf (Query,"DELETE FROM usr_emails WHERE UsrCod='%ld'",
UsrDat->UsrCod);
DB_QueryDELETE (Query,"can not remove user's e-mails");
/***** Remove user's IDs *****/
sprintf (Query,"DELETE FROM usr_IDs WHERE UsrCod='%ld'",
UsrDat->UsrCod);
DB_QueryDELETE (Query,"can not remove user's IDs");
/***** Remove user's last data *****/
sprintf (Query,"DELETE FROM usr_last WHERE UsrCod='%ld'",
UsrDat->UsrCod);
DB_QueryDELETE (Query,"can not remove user's last data");
/***** Remove user's data *****/
sprintf (Query,"DELETE FROM usr_data WHERE UsrCod='%ld'",
UsrDat->UsrCod);
DB_QueryDELETE (Query,"can not remove user's data");
}