mirror of https://github.com/acanas/swad-core.git
Version 14.37
This commit is contained in:
parent
e2ce32ab4a
commit
5fc35cc942
2
Makefile
2
Makefile
|
@ -26,7 +26,7 @@
|
|||
# #
|
||||
###############################################################################
|
||||
|
||||
OBJS = swad_action.o swad_announcement.o swad_assignment.o swad_attendance.o \
|
||||
OBJS = swad_account.o swad_action.o swad_announcement.o swad_assignment.o swad_attendance.o \
|
||||
swad_banner.o \
|
||||
swad_centre.o swad_chat.o swad_config.o swad_connected.o swad_country.o swad_course.o swad_cryptography.o \
|
||||
swad_database.o swad_date.o swad_degree.o swad_department.o \
|
||||
|
|
|
@ -29,9 +29,9 @@
|
|||
#include <stdlib.h> // For exit, system, malloc, free, rand, etc.
|
||||
#include <string.h> // For string functions
|
||||
|
||||
#include "swad_account.h"
|
||||
#include "swad_bool.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_enrollment.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_ID.h"
|
||||
#include "swad_parameter.h"
|
||||
|
@ -558,7 +558,7 @@ void ID_RemoveMyUsrID (void)
|
|||
ID_GetListIDsFromUsrCod (&Gbl.Usrs.Me.UsrDat);
|
||||
|
||||
/***** Show my account again *****/
|
||||
Enr_ShowFormChangeMyAccount ();
|
||||
Acc_ShowFormChangeMyAccount ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -673,7 +673,7 @@ void ID_NewMyUsrID (void)
|
|||
ID_GetListIDsFromUsrCod (&Gbl.Usrs.Me.UsrDat);
|
||||
|
||||
/***** Show my account again *****/
|
||||
Enr_ShowFormChangeMyAccount ();
|
||||
Acc_ShowFormChangeMyAccount ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -0,0 +1,823 @@
|
|||
// 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.
|
||||
Copyright (C) 1999-2014 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_announcement.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_enrollment.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_ID.h"
|
||||
#include "swad_notification.h"
|
||||
#include "swad_parameter.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Private constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Internal types *******************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Acc_REQUEST_REMOVE_USR,
|
||||
Acc_REMOVE_USR,
|
||||
} Acc_ReqDelOrDelUsr_t;
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** External global variables from others modules ****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
extern struct Globals Gbl;
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************* Internal global variables *************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Private prototypes ****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
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);
|
||||
static void Acc_PrintAccountSeparator (void);
|
||||
|
||||
static void Acc_ReqDelOrDelUsrGbl (Acc_ReqDelOrDelUsr_t ReqDelOrDelUsr);
|
||||
|
||||
static void Acc_RemoveUsrBriefcase (struct UsrData *UsrDat);
|
||||
static void Acc_RemoveUsr (struct UsrData *UsrDat);
|
||||
|
||||
/*****************************************************************************/
|
||||
/******** Show form to change my account or to create a new account **********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Acc_ShowFormAccount (void)
|
||||
{
|
||||
if (Gbl.Usrs.Me.Logged)
|
||||
Acc_ShowFormChangeMyAccount ();
|
||||
else
|
||||
Acc_ShowFormRequestNewAccountWithParams ("","");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************* Show form to create a new account *********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Acc_ShowFormRequestNewAccountWithParams (const char *NewNicknameWithoutArroba,
|
||||
const char *NewEmail)
|
||||
{
|
||||
extern const char *The_ClassFormul[The_NUM_THEMES];
|
||||
extern const char *Txt_Log_in;
|
||||
extern const char *Txt_Nickname;
|
||||
extern const char *Txt_Email;
|
||||
extern const char *Txt_New_on_PLATFORM_Sign_up;
|
||||
extern const char *Txt_Create_account;
|
||||
|
||||
/***** Link to log in *****/
|
||||
fprintf (Gbl.F.Out,"<div align=\"center\" style=\"margin-bottom:20px;\">");
|
||||
Act_FormStart (ActFrmLogIn);
|
||||
Act_LinkFormSubmit (Txt_Log_in,The_ClassFormul[Gbl.Prefs.Theme]);
|
||||
Lay_PutSendIcon ("login",Txt_Log_in,Txt_Log_in);
|
||||
fprintf (Gbl.F.Out,"</form>"
|
||||
"</div>");
|
||||
|
||||
/***** Form to enter the ID of the new user *****/
|
||||
fprintf (Gbl.F.Out,"<div align=\"center\">");
|
||||
Act_FormStart (ActCreUsrAcc);
|
||||
sprintf (Gbl.Title,Txt_New_on_PLATFORM_Sign_up,Cfg_PLATFORM_SHORT_NAME);
|
||||
Lay_StartRoundFrameTable10 (NULL,2,Gbl.Title);
|
||||
|
||||
/***** Nickname *****/
|
||||
fprintf (Gbl.F.Out,"<tr>"
|
||||
"<td align=\"right\" class=\"%s\">"
|
||||
"%s: "
|
||||
"</td>"
|
||||
"<td align=\"left\">"
|
||||
"<input type=\"text\" name=\"NewNick\""
|
||||
" size=\"16\" maxlength=\"%u\" value=\"@%s\" />"
|
||||
"</td>"
|
||||
"</tr>",
|
||||
The_ClassFormul[Gbl.Prefs.Theme],
|
||||
Txt_Nickname,
|
||||
1+Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA,
|
||||
NewNicknameWithoutArroba);
|
||||
|
||||
/***** E-mail *****/
|
||||
fprintf (Gbl.F.Out,"<tr>"
|
||||
"<td align=\"right\" class=\"%s\">"
|
||||
"%s: "
|
||||
"</td>"
|
||||
"<td align=\"left\">"
|
||||
"<input type=\"text\" name=\"NewEmail\""
|
||||
" size=\"16\" maxlength=\"%u\" value=\"%s\" />"
|
||||
"</td>"
|
||||
"</tr>",
|
||||
The_ClassFormul[Gbl.Prefs.Theme],
|
||||
Txt_Email,
|
||||
Cns_MAX_BYTES_STRING,
|
||||
NewEmail);
|
||||
|
||||
/***** Password *****/
|
||||
Pwd_PutFormToGetNewPasswordTwice ();
|
||||
|
||||
/***** Send button and form end *****/
|
||||
fprintf (Gbl.F.Out,"<tr>"
|
||||
"<td colspan=\"2\" align=\"center\">"
|
||||
"<input type=\"submit\" value=\"%s\" />"
|
||||
"</td>"
|
||||
"</tr>",
|
||||
Txt_Create_account);
|
||||
Lay_EndRoundFrameTable10 ();
|
||||
fprintf (Gbl.F.Out,"</form>"
|
||||
"</div>");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********************** 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;
|
||||
extern const char *Txt_Before_going_to_any_other_option_you_must_fill_your_email_address;
|
||||
extern const char *Txt_Before_going_to_any_other_option_you_must_fill_your_ID;
|
||||
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);
|
||||
Mai_GetEmailFromUsrCod (Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.Usrs.Me.UsrDat.Email,&(Gbl.Usrs.Me.UsrDat.EmailConfirmed));
|
||||
|
||||
/***** 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])
|
||||
Lay_ShowAlert (Lay_WARNING,Txt_Before_going_to_any_other_option_you_must_fill_your_email_address);
|
||||
else if (!Gbl.Usrs.Me.UsrDat.IDs.Num)
|
||||
Lay_ShowAlert (Lay_WARNING,Txt_Before_going_to_any_other_option_you_must_fill_your_ID);
|
||||
|
||||
/***** Put links to change my password and to remove my account*****/
|
||||
fprintf (Gbl.F.Out,"<div align=\"center\">");
|
||||
Pwd_PutLinkToChangeUsrPassword (&Gbl.Usrs.Me.UsrDat);
|
||||
if (Acc_CheckIfICanEliminateAccount (true)) // ItsMe = true
|
||||
Acc_PutLinkToRemoveMyAccount ();
|
||||
fprintf (Gbl.F.Out,"</div>");
|
||||
|
||||
/***** Start table *****/
|
||||
Lay_StartRoundFrameTable10 ("80%",2,Txt_User_account);
|
||||
|
||||
/***** Nickname *****/
|
||||
Nck_ShowFormChangeUsrNickname ();
|
||||
|
||||
/***** Separator *****/
|
||||
Acc_PrintAccountSeparator ();
|
||||
|
||||
/***** E-mail *****/
|
||||
Mai_ShowFormChangeUsrEmail ();
|
||||
|
||||
/***** Separator *****/
|
||||
Acc_PrintAccountSeparator ();
|
||||
|
||||
/***** User's ID *****/
|
||||
ID_ShowFormChangeUsrID (&Gbl.Usrs.Me.UsrDat,true);
|
||||
|
||||
/***** End of table *****/
|
||||
Lay_EndRoundFrameTable10 ();
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/******** Put a link to the action used to request user's password ***********/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Acc_PutLinkToRemoveMyAccount (void)
|
||||
{
|
||||
extern const char *The_ClassFormul[The_NUM_THEMES];
|
||||
extern const char *Txt_Remove_account;
|
||||
|
||||
Act_FormStart (ActUpdOthUsrDat);
|
||||
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Me.UsrDat.EncryptedUsrCod);
|
||||
Par_PutHiddenParamUnsigned ("RegRemAction",(unsigned) Enr_ELIMINATE_ONE_USR_FROM_PLATFORM);
|
||||
Act_LinkFormSubmit (Txt_Remove_account,The_ClassFormul[Gbl.Prefs.Theme]);
|
||||
Lay_PutSendIcon ("delon",Txt_Remove_account,Txt_Remove_account);
|
||||
fprintf (Gbl.F.Out,"</form>");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******* 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>"
|
||||
"<td colspan=\"2\" align=\"center\" valign=\"middle\">"
|
||||
"<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];
|
||||
char NewEmail[Cns_MAX_BYTES_STRING+1];
|
||||
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;
|
||||
extern const char *Txt_You_have_not_written_twice_the_same_new_password;
|
||||
char Query[1024];
|
||||
char NewNicknameWithArroba[Nck_MAX_BYTES_NICKNAME_WITH_ARROBA+1];
|
||||
char NewPlainPassword[2][Pwd_MAX_LENGTH_PLAIN_PASSWORD+1];
|
||||
bool Error = false;
|
||||
|
||||
/***** Step 1/3: Get new nickname from form *****/
|
||||
Par_GetParToText ("NewNick",NewNicknameWithArroba,Nck_MAX_BYTES_NICKNAME_WITH_ARROBA);
|
||||
|
||||
if (Nck_CheckIfNickWithArrobaIsValid (NewNicknameWithArroba)) // If new nickname is valid
|
||||
{
|
||||
/***** Remove arrobas at the beginning *****/
|
||||
strncpy (NewNicknameWithoutArroba,NewNicknameWithArroba,Nck_MAX_BYTES_NICKNAME_WITH_ARROBA);
|
||||
NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_WITH_ARROBA] = '\0';
|
||||
Str_RemoveLeadingArrobas (NewNicknameWithoutArroba);
|
||||
|
||||
/***** Check if the new nickname matches any of the nicknames of other users *****/
|
||||
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 *****/
|
||||
Par_GetParToText ("NewEmail",NewEmail,Cns_MAX_BYTES_STRING);
|
||||
|
||||
if (Mai_CheckIfEmailIsValid (NewEmail)) // New e-mail is valid
|
||||
{
|
||||
/***** Check if the new e-mail matches any of the confirmed e-mails of other users *****/
|
||||
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);
|
||||
}
|
||||
|
||||
/***** Step 3/3: Get new user's ID from form *****/
|
||||
Par_GetParToText ("Paswd1",NewPlainPassword[0],Pwd_MAX_LENGTH_PLAIN_PASSWORD);
|
||||
Par_GetParToText ("Paswd2",NewPlainPassword[1],Pwd_MAX_LENGTH_PLAIN_PASSWORD);
|
||||
if (strcmp (NewPlainPassword[0],NewPlainPassword[1]))
|
||||
{
|
||||
// Passwords don't match
|
||||
Error = true;
|
||||
Lay_ShowAlert (Lay_WARNING,Txt_You_have_not_written_twice_the_same_new_password);
|
||||
}
|
||||
else
|
||||
{
|
||||
Str_ChangeFormat (Str_FROM_FORM,Str_TO_TEXT,
|
||||
NewPlainPassword[0],Pwd_MAX_LENGTH_PLAIN_PASSWORD,true);
|
||||
Cry_EncryptSHA512Base64 (NewPlainPassword[0],NewEncryptedPassword);
|
||||
if (!Pwd_SlowCheckIfPasswordIsGood (NewPlainPassword[0],NewEncryptedPassword,-1L)) // New password is good?
|
||||
{
|
||||
Error = true;
|
||||
Lay_ShowAlert (Lay_WARNING,Gbl.Message); // Error message is set in Usr_SlowCheckIfPasswordIsGood
|
||||
}
|
||||
}
|
||||
|
||||
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 *Ico_IconSetId[Ico_NUM_ICON_SETS];
|
||||
extern const char *The_ThemeId[The_NUM_THEMES];
|
||||
extern const char *Txt_STR_LANG_ID[Txt_NUM_LANGUAGES];
|
||||
extern const char *Usr_StringsSexDB[Usr_NUM_SEXS];
|
||||
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 */
|
||||
sprintf (Query,"INSERT INTO usr_data (EncryptedUsrCod,Password,Surname1,Surname2,FirstName,Sex,"
|
||||
"Layout,Theme,IconSet,Language,PublicPhoto,"
|
||||
"CtyCod,"
|
||||
"LocalAddress,LocalPhone,FamilyAddress,FamilyPhone,OriginPlace,Birthday,Comments,"
|
||||
"SideCols,NotifNtfEvents,EmailNtfEvents)"
|
||||
" VALUES ('%s','%s','%s','%s','%s','%s',"
|
||||
"'%u','%s','%s','%s','%c',"
|
||||
"'%ld',"
|
||||
"'%s','%s','%s','%s','%s','%04u-%02u-%02u','%s',"
|
||||
"'3','-1','0')",
|
||||
UsrDat->EncryptedUsrCod,
|
||||
UsrDat->Password,
|
||||
UsrDat->Surname1,UsrDat->Surname2,UsrDat->FirstName,
|
||||
Usr_StringsSexDB[UsrDat->Sex],
|
||||
(unsigned) UsrDat->Prefs.Layout,
|
||||
The_ThemeId[UsrDat->Prefs.Theme],
|
||||
Ico_IconSetId[UsrDat->Prefs.IconSet],
|
||||
Txt_STR_LANG_ID[UsrDat->Prefs.Language],
|
||||
UsrDat->PublicPhoto ? 'Y' :
|
||||
'N',
|
||||
UsrDat->CtyCod,
|
||||
UsrDat->LocalAddress ,UsrDat->LocalPhone,
|
||||
UsrDat->FamilyAddress,UsrDat->FamilyPhone,
|
||||
UsrDat->OriginPlace,
|
||||
UsrDat->Birthday.Year,UsrDat->Birthday.Month,UsrDat->Birthday.Day,
|
||||
UsrDat->Comments ? UsrDat->Comments :
|
||||
"");
|
||||
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);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** 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)
|
||||
{
|
||||
extern const char *Txt_New_account_created;
|
||||
|
||||
if (Gbl.Usrs.Me.Logged) // If account has been created without problem, I am logged
|
||||
{
|
||||
/***** Show message of success *****/
|
||||
Lay_ShowAlert (Lay_SUCCESS,Txt_New_account_created);
|
||||
|
||||
/***** Show form with account data *****/
|
||||
Acc_ShowFormChangeMyAccount ();
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********* Request definite removing of a user from the platform *************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Acc_ReqRemUsrGbl (void)
|
||||
{
|
||||
Acc_ReqDelOrDelUsrGbl (Acc_REQUEST_REMOVE_USR);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** Definite removing of a user from the platform ****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Acc_RemUsrGbl (void)
|
||||
{
|
||||
Acc_ReqDelOrDelUsrGbl (Acc_REMOVE_USR);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************************** Removing of a user *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Acc_ReqDelOrDelUsrGbl (Acc_ReqDelOrDelUsr_t ReqDelOrDelUsr)
|
||||
{
|
||||
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
|
||||
bool ItsMe;
|
||||
|
||||
/***** Get user to be removed *****/
|
||||
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
||||
{
|
||||
ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod);
|
||||
if (Acc_CheckIfICanEliminateAccount (ItsMe))
|
||||
switch (ReqDelOrDelUsr)
|
||||
{
|
||||
case Acc_REQUEST_REMOVE_USR: // Ask if eliminate completely the user from the platform
|
||||
Acc_AskIfCompletelyEliminateAccount (ItsMe);
|
||||
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;
|
||||
}
|
||||
else
|
||||
Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
|
||||
}
|
||||
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 *********/
|
||||
/*****************************************************************************/
|
||||
|
||||
bool Acc_CheckIfICanEliminateAccount (bool ItsMe)
|
||||
{
|
||||
// A user logged as superuser can eliminate any user except her/him
|
||||
// Other users only can eliminate themselves
|
||||
return (( ItsMe && // It's me
|
||||
(Gbl.Usrs.Me.AvailableRoles & (1 << Rol_ROLE_SUPERUSER)) == 0) // I can not be superuser
|
||||
||
|
||||
(!ItsMe && // It's not me
|
||||
Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SUPERUSER)); // I am logged as superuser
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Ask if really wanted to eliminate completely a user *************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Acc_AskIfCompletelyEliminateAccount (bool ItsMe)
|
||||
{
|
||||
extern const char *Txt_Do_you_really_want_to_completely_eliminate_your_user_account;
|
||||
extern const char *Txt_Do_you_really_want_to_completely_eliminate_the_following_user;
|
||||
extern const char *Txt_Completely_eliminate_me;
|
||||
extern const char *Txt_Completely_eliminate_user;
|
||||
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
|
||||
|
||||
if (Usr_ChkIfUsrCodExists (Gbl.Usrs.Other.UsrDat.UsrCod))
|
||||
{
|
||||
Lay_ShowAlert (Lay_WARNING,ItsMe ? Txt_Do_you_really_want_to_completely_eliminate_your_user_account :
|
||||
Txt_Do_you_really_want_to_completely_eliminate_the_following_user);
|
||||
|
||||
Rec_ShowCommonRecordUnmodifiable (&Gbl.Usrs.Other.UsrDat);
|
||||
|
||||
Act_FormStart (ActRemUsrGbl);
|
||||
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
|
||||
|
||||
/* Ask for consent on dangerous actions */
|
||||
Pwd_AskForConfirmationOnDangerousAction ();
|
||||
|
||||
fprintf (Gbl.F.Out,"<div align=\"center\">"
|
||||
"<input type=\"submit\" value=\"%s\" />"
|
||||
"</div>"
|
||||
"</form>",
|
||||
ItsMe ? Txt_Completely_eliminate_me :
|
||||
Txt_Completely_eliminate_user);
|
||||
}
|
||||
else
|
||||
Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Remove completely a user from the whole platform **************/
|
||||
/*****************************************************************************/
|
||||
|
||||
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");
|
||||
|
||||
/***** 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 *****/
|
||||
sprintf (Query,"DELETE FROM deg_admin"
|
||||
" 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);
|
||||
}
|
||||
|
||||
/***** Remove user's clipboards *****/
|
||||
Brw_RemoveUsrClipboard (UsrDat->UsrCod);
|
||||
For_RemoveUsrFromThrClipboard (UsrDat->UsrCod);
|
||||
|
||||
/***** Remove user's expanded folders *****/
|
||||
Brw_RemoveUsrExpandedFolders (UsrDat->UsrCod);
|
||||
|
||||
/***** 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);
|
||||
}
|
||||
|
||||
/***** Remove user from table of banned users *****/
|
||||
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");
|
||||
|
||||
/***** Remove the user from the list of users without photo *****/
|
||||
Pho_RemoveUsrFromTableClicksWithoutPhoto (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);
|
||||
}
|
||||
|
||||
/***** 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];
|
||||
|
||||
/***** Remove the briefcase of the user *****/
|
||||
Usr_ConstructPathUsr (UsrDat->UsrCod,PathRelUsr);
|
||||
Brw_RemoveTree (PathRelUsr);
|
||||
|
||||
/***** Remove files in the course from database *****/
|
||||
Brw_RemoveFilesFromDB (-1L,-1L,UsrDat->UsrCod);
|
||||
|
||||
/***** Remove size of the briefcase of the user from database *****/
|
||||
Brw_RemoveSizeOfFileTreeFromDB (-1L,-1L,UsrDat->UsrCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************ 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");
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
// swad_account.h: user's account
|
||||
|
||||
#ifndef _SWAD_ACC
|
||||
#define _SWAD_ACC
|
||||
/*
|
||||
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-2014 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 "swad_bool.h"
|
||||
#include "swad_constant.h"
|
||||
#include "swad_user.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************************** Public types *******************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Public prototypes ****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Acc_ShowFormAccount (void);
|
||||
void Acc_ShowFormChangeMyAccount (void);
|
||||
bool Acc_CreateNewAccountAndLogIn (void);
|
||||
void Acc_CreateNewUsr (struct UsrData *UsrDat);
|
||||
void Acc_AfterCreationNewAccount (void);
|
||||
|
||||
void Acc_ReqRemUsrGbl (void);
|
||||
void Acc_RemUsrGbl (void);
|
||||
|
||||
bool Acc_CheckIfICanEliminateAccount (bool ItsMe);
|
||||
void Acc_AskIfCompletelyEliminateAccount (bool ItsMe);
|
||||
void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat,
|
||||
Cns_QuietOrVerbose_t QuietOrVerbose);
|
||||
|
||||
#endif
|
|
@ -31,6 +31,7 @@
|
|||
#include <stdlib.h> // For malloc and free
|
||||
#include <string.h> // For string functions
|
||||
|
||||
#include "swad_account.h"
|
||||
#include "swad_action.h"
|
||||
#include "swad_announcement.h"
|
||||
#include "swad_banner.h"
|
||||
|
@ -1951,7 +1952,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
|
|||
/* ActChgPwdOthUsr */{ 82,-1,TabUsr,ActReqMdfOneUsr ,0x1E0,0x1E0,0x1E0,Act_CONTENT_NORM,Act_MAIN_WINDOW,Pwd_UpdateOtherPwd1 ,Pwd_UpdateOtherPwd2 ,NULL},
|
||||
|
||||
/* ActRemUsrCrs */{ 58,-1,TabUsr,ActReqMdfOneUsr ,0x1F8,0x1E0,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_RemUsrFromCrs ,NULL},
|
||||
/* ActRemUsrGbl */{ 62,-1,TabUsr,ActReqMdfOneUsr ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_RemUsrGbl ,NULL},
|
||||
/* ActRemUsrGbl */{ 62,-1,TabUsr,ActReqMdfOneUsr ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Acc_RemUsrGbl ,NULL},
|
||||
|
||||
/* ActReqRemAllStdCrs*/{ 88,-1,TabUsr,ActReqMdfSevUsr ,0x110,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_AskRemAllStdsThisCrs ,NULL},
|
||||
/* ActRemAllStdCrs */{ 87,-1,TabUsr,ActReqMdfSevUsr ,0x110,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_RemAllStdsThisCrs ,NULL},
|
||||
|
@ -2186,7 +2187,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
|
|||
// TabPrf ******************************************************************
|
||||
// Actions in menu:
|
||||
/* ActFrmLogIn */{ 843, 0,TabPrf,ActFrmLogIn ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Usr_WriteFormLoginLogout ,"keyuser" },
|
||||
/* ActFrmUsrAcc */{ 36, 1,TabPrf,ActFrmUsrAcc ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_ShowFormAccount ,"arroba" },
|
||||
/* ActFrmUsrAcc */{ 36, 1,TabPrf,ActFrmUsrAcc ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Acc_ShowFormAccount ,"arroba" },
|
||||
/* ActReqSndNewPwd */{ 665, 2,TabPrf,ActReqSndNewPwd ,0x000,0x001,0x001,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Pwd_ShowFormSendNewPwd ,"key" },
|
||||
/* ActFrmChgMyPwd */{ 34, 3,TabPrf,ActFrmChgMyPwd ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Pwd_ShowFormChgPwd ,"key" },
|
||||
/* ActReqEdiRecCom */{ 285, 4,TabPrf,ActReqEdiRecCom ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Rec_ShowFormMyCommRecord ,"card" },
|
||||
|
@ -2208,7 +2209,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
|
|||
|
||||
/* ActChgMyRol */{ 589,-1,TabPrf,ActFrmLogIn ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,Rol_ChangeMyRole ,Usr_ShowFormsRoleAndLogout ,NULL},
|
||||
|
||||
/* ActCreUsrAcc */{1163,-1,TabPrf,ActFrmUsrAcc ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_AfterCreationNewAccount ,NULL},
|
||||
/* ActCreUsrAcc */{1163,-1,TabPrf,ActFrmUsrAcc ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Acc_AfterCreationNewAccount ,NULL},
|
||||
|
||||
/* ActRemIDMe */{1147,-1,TabPrf,ActFrmUsrAcc ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,ID_RemoveMyUsrID ,NULL},
|
||||
/* ActNewIDMe */{1148,-1,TabPrf,ActFrmUsrAcc ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,ID_NewMyUsrID ,NULL},
|
||||
|
@ -3889,7 +3890,7 @@ void Act_AdjustCurrentAction (void)
|
|||
if (!Gbl.Usrs.Me.MyPhotoExists)
|
||||
if (!(Act_Actions[Gbl.CurrentAct].PermisIfIBelongToCrs & (1 << Rol_ROLE_UNKNOWN)) && // If current action is not available for unknown users...
|
||||
Gbl.CurrentAct != ActReqMyPho) // ...and current action is not ActReqMyPho...
|
||||
if ((Gbl.Usrs.Me.NumAccWithoutPhoto = Usr_UpdateMyClicksWithoutPhoto ()) > Usr_MAX_CLICKS_WITHOUT_PHOTO)
|
||||
if ((Gbl.Usrs.Me.NumAccWithoutPhoto = Pho_UpdateMyClicksWithoutPhoto ()) > Pho_MAX_CLICKS_WITHOUT_PHOTO)
|
||||
{
|
||||
/* If limit of clicks has been reached,
|
||||
the only action possible is show a form to send my photo */
|
||||
|
|
|
@ -35,12 +35,16 @@
|
|||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 14.36 (2014/12/12)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 14.37 (2014/12/12)"
|
||||
|
||||
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
||||
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h | tail -1
|
||||
|
||||
/*
|
||||
Version 14.37 :Dic 12, 2014 New module swad_account for user's account. (170863 lines)
|
||||
1 change necessary in Makefile:
|
||||
Add swad_account.o to list of object files
|
||||
|
||||
Version 14.36 :Dic 12, 2014 New module swad_role for user's roles. (170764 lines)
|
||||
1 change necessary in Makefile:
|
||||
Add swad_role.o to list of object files
|
||||
|
|
1165
swad_enrollment.c
1165
swad_enrollment.c
File diff suppressed because it is too large
Load Diff
|
@ -43,18 +43,22 @@ typedef enum
|
|||
Enr_INSERT_NEW_DATA,
|
||||
} Enr_ReplaceInsert_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Enr_REQUEST_REMOVE_USR,
|
||||
Enr_REMOVE_USR,
|
||||
} Enr_ReqDelOrDelUsr_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Enr_SET_ACCEPTED_TO_FALSE,
|
||||
Enr_SET_ACCEPTED_TO_TRUE,
|
||||
} Enr_KeepOrSetAccepted_t;
|
||||
|
||||
#define Enr_NUM_ACTIONS_REG_REM_ONE_USR 5
|
||||
typedef enum
|
||||
{
|
||||
Enr_REGISTER_MODIFY_ONE_USR_IN_CRS = 0,
|
||||
Enr_REGISTER_ONE_DEGREE_ADMIN = 1,
|
||||
Enr_REMOVE_ONE_USR_FROM_CRS = 2,
|
||||
Enr_REMOVE_ONE_DEGREE_ADMIN = 3,
|
||||
Enr_ELIMINATE_ONE_USR_FROM_PLATFORM = 4,
|
||||
} Enr_RegRemOneUsrAction_t;
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Public prototypes ****************************/
|
||||
/*****************************************************************************/
|
||||
|
@ -66,30 +70,20 @@ void Enr_RegisterUsrInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole,
|
|||
Cns_QuietOrVerbose_t QuietOrVerbose,
|
||||
Enr_KeepOrSetAccepted_t KeepOrSetAccepted);
|
||||
|
||||
void Enr_RemoveUsrFromTableClicksWithoutPhoto (long UsrCod);
|
||||
|
||||
void Enr_WriteFormToReqAnotherUsrID (Act_Action_t NextAction);
|
||||
|
||||
void Enr_AfterCreationNewAccount (void);
|
||||
void Enr_ShowFormAccount (void);
|
||||
void Enr_ShowFormChangeMyAccount (void);
|
||||
void Enr_ReqAcceptRegisterInCrs (void);
|
||||
void Enr_GetNotifEnrollment (char *SummaryStr,
|
||||
long CrsCod,long UsrCod,
|
||||
unsigned MaxChars);
|
||||
void Enr_UpdateUsrData (struct UsrData *UsrDat);
|
||||
void Enr_FilterUsrDat (struct UsrData *UsrDat);
|
||||
void Enr_UpdateInstitutionCentreDepartment (void);
|
||||
void Enr_ShowFormRegRemSeveralUsrs (void);
|
||||
|
||||
void Enr_AskRemoveOldUsrs (void);
|
||||
void Enr_RemoveOldUsrs (void);
|
||||
|
||||
void Enr_ReqAcceptRegisterInCrs (void);
|
||||
|
||||
void Enr_GetNotifEnrollment (char *SummaryStr,
|
||||
long CrsCod,long UsrCod,
|
||||
unsigned MaxChars);
|
||||
void Enr_CreateNewUsr (struct UsrData *UsrDat);
|
||||
void Enr_UpdateUsrData (struct UsrData *UsrDat);
|
||||
void Enr_UpdateInstitutionCentreDepartment (void);
|
||||
|
||||
bool Enr_CreateNewAccountAndLogIn (void);
|
||||
|
||||
void Enr_RemoveUsrBriefcase (struct UsrData *UsrDat);
|
||||
void Enr_ShowFormRegRemSeveralUsrs (void);
|
||||
void Enr_ReceiveFormUsrsCrs (void);
|
||||
void Enr_AskRemAllStdsThisCrs (void);
|
||||
void Enr_RemAllStdsThisCrs (void);
|
||||
|
@ -101,7 +95,7 @@ void Enr_GetNotifEnrollmentRequest (char *SummaryStr,char **ContentStr,
|
|||
void Enr_AskIfRejectSignUp (void);
|
||||
void Enr_RejectSignUp (void);
|
||||
void Enr_ShowEnrollmentRequests (void);
|
||||
Rol_Role_t Enr_GetRequestedRole (long UsrCod);
|
||||
|
||||
void Enr_ReqRegRemUsr (void);
|
||||
void Enr_AskIfRegRemAnotherUsr (void);
|
||||
void Enr_AddAdmToDeg (void);
|
||||
|
@ -109,12 +103,7 @@ void Enr_AddAdmToDeg (void);
|
|||
void Enr_ReqRemMeFromCrs (void);
|
||||
void Enr_ReqRemUsrFromCrs (void);
|
||||
void Enr_RemUsrFromCrs (void);
|
||||
void Enr_ReqRemOrRemUsrFromCrs (Enr_ReqDelOrDelUsr_t ReqDelOrDelUsr);
|
||||
void Enr_ReqRemUsrGbl (void);
|
||||
void Enr_RemAdm (void);
|
||||
void Enr_RemUsrGbl (void);
|
||||
void Enr_ReqDelOrDelUsrGbl (Enr_ReqDelOrDelUsr_t ReqDelOrDelUsr);
|
||||
void Enr_AskIfRemAdmFromDeg (bool ItsMe);
|
||||
|
||||
void Enr_AcceptRegisterMeInCrs (void);
|
||||
void Enr_CreatAndShowNewUsrRecordAndRegInCrs (void);
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <sys/wait.h> // For the macro WEXITSTATUS
|
||||
#include <unistd.h> // For unlink
|
||||
|
||||
#include "swad_account.h"
|
||||
#include "swad_config.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_enrollment.h"
|
||||
|
@ -246,7 +247,7 @@ void Imp_ImportStdsFromAnImpGrp (long ImpGrpCod,struct ListCodGrps *LstGrps,unsi
|
|||
|
||||
/* Create user */
|
||||
UsrDat.IDs.List[0].Confirmed = true; // If he/she is a new user ==> his/her ID will be stored as confirmed in database
|
||||
Enr_CreateNewUsr (&UsrDat);
|
||||
Acc_CreateNewUsr (&UsrDat);
|
||||
|
||||
/* Update e-mail */
|
||||
if (!Mai_UpdateEmailInDB (&UsrDat,UsrDat.Email)) // Email was already registered and confirmed by another user
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
#include <sys/wait.h> // For the macro WEXITSTATUS
|
||||
#include <unistd.h> // For access, lstat, getpid, chdir, symlink, unlink
|
||||
|
||||
#include "swad_account.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_enrollment.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_mail.h"
|
||||
#include "swad_parameter.h"
|
||||
|
@ -1109,7 +1109,7 @@ void Mai_RemoveEmail (void)
|
|||
Lay_ShowAlert (Lay_WARNING,Txt_You_can_not_delete_your_current_email);
|
||||
|
||||
/***** Show my account again *****/
|
||||
Enr_ShowFormChangeMyAccount ();
|
||||
Acc_ShowFormChangeMyAccount ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1189,7 +1189,7 @@ void Mai_UpdateEmail (void)
|
|||
}
|
||||
|
||||
/***** Show my account again *****/
|
||||
Enr_ShowFormChangeMyAccount ();
|
||||
Acc_ShowFormChangeMyAccount ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
|
||||
#include <string.h> // For string functions
|
||||
|
||||
#include "swad_account.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_enrollment.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_parameter.h"
|
||||
#include "swad_QR.h"
|
||||
|
@ -311,7 +311,7 @@ void Nck_RemoveNick (void)
|
|||
Lay_ShowAlert (Lay_WARNING,Txt_You_can_not_delete_your_current_nickname);
|
||||
|
||||
/***** Show my account again *****/
|
||||
Enr_ShowFormChangeMyAccount ();
|
||||
Acc_ShowFormChangeMyAccount ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -406,7 +406,7 @@ void Nck_UpdateNick (void)
|
|||
Gbl.Message);
|
||||
|
||||
/***** Show my account again *****/
|
||||
Enr_ShowFormChangeMyAccount ();
|
||||
Acc_ShowFormChangeMyAccount ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
63
swad_photo.c
63
swad_photo.c
|
@ -661,7 +661,7 @@ static void Pho_UpdatePhoto1 (struct UsrData *UsrDat)
|
|||
Pho_UpdatePhotoName (UsrDat);
|
||||
|
||||
/* Remove the user from the list of users without photo */
|
||||
Enr_RemoveUsrFromTableClicksWithoutPhoto (UsrDat->UsrCod);
|
||||
Pho_RemoveUsrFromTableClicksWithoutPhoto (UsrDat->UsrCod);
|
||||
|
||||
Gbl.Error = false;
|
||||
}
|
||||
|
@ -697,6 +697,67 @@ static void Pho_UpdatePhoto2 (void)
|
|||
Lay_ShowAlert (Lay_SUCCESS,Txt_Photo_has_been_updated);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* Update number of clicks without photo *******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Pho_UpdateMyClicksWithoutPhoto (void)
|
||||
{
|
||||
char Query[512];
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumRows;
|
||||
unsigned NumClicks;
|
||||
|
||||
/***** Get number of clicks without photo from database *****/
|
||||
sprintf (Query,"SELECT NumClicks FROM clicks_without_photo"
|
||||
" WHERE UsrCod='%ld'",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get number of clicks without photo");
|
||||
|
||||
/***** Update the list of clicks without photo *****/
|
||||
if (NumRows) // The user exists ==> update number of clicks without photo
|
||||
{
|
||||
/* Get current number of clicks */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
sscanf (row[0],"%u",&NumClicks);
|
||||
|
||||
/* Update number of clicks */
|
||||
if (NumClicks <= Pho_MAX_CLICKS_WITHOUT_PHOTO)
|
||||
{
|
||||
sprintf (Query,"UPDATE clicks_without_photo SET NumClicks=NumClicks+1 WHERE UsrCod='%ld'",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
DB_QueryUPDATE (Query,"can not update number of clicks without photo");
|
||||
NumClicks++;
|
||||
}
|
||||
}
|
||||
else // The user does not exist ==> add him/her
|
||||
{
|
||||
/* Add the user, with one access */
|
||||
sprintf (Query,"INSERT INTO clicks_without_photo (UsrCod,NumClicks) VALUES ('%ld',1)",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
DB_QueryINSERT (Query,"can not create number of clicks without photo");
|
||||
NumClicks = 1;
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
||||
/***** Return the number of rows of the result *****/
|
||||
return NumClicks;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******** Remove user from table with number of clicks without photo *********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Pho_RemoveUsrFromTableClicksWithoutPhoto (long UsrCod)
|
||||
{
|
||||
char Query[512];
|
||||
|
||||
sprintf (Query,"DELETE FROM clicks_without_photo WHERE UsrCod='%ld'",UsrCod);
|
||||
DB_QueryDELETE (Query,"can not remove a user from the list of users without photo");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************* Check if user's photo can be shown ********************/
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
/********************************* Headers ***********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************* Public types and constants ************************/
|
||||
/*****************************************************************************/
|
||||
|
@ -68,6 +67,8 @@ typedef enum
|
|||
Pho_DEGREE_NAME = 3,
|
||||
} Pho_HowOrderDegrees_t;
|
||||
|
||||
#define Pho_MAX_CLICKS_WITHOUT_PHOTO 50
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Public prototypes *****************************/
|
||||
/*****************************************************************************/
|
||||
|
@ -89,6 +90,9 @@ void Pho_UpdateMyPhoto2 (void);
|
|||
void Pho_UpdateUsrPhoto1 (void);
|
||||
void Pho_UpdateUsrPhoto2 (void);
|
||||
|
||||
unsigned Pho_UpdateMyClicksWithoutPhoto (void);
|
||||
void Pho_RemoveUsrFromTableClicksWithoutPhoto (long UsrCod);
|
||||
|
||||
bool Pho_ShowUsrPhotoIsAllowed (struct UsrData *UsrDat,char *PhotoURL);
|
||||
bool Pho_BuildLinkToPhoto (const struct UsrData *UsrDat,char *PhotoURL,bool HTTPS);
|
||||
bool Pho_CheckIfPrivPhotoExists (long UsrCod,char *PathPrivRelPhoto);
|
||||
|
|
|
@ -2339,7 +2339,7 @@ void Rec_ShowCommonRecord (Rec_RecordViewType_t TypeOfView,
|
|||
if (UsrDat->RoleInCurrentCrsDB < Rol_ROLE_STUDENT) // The other user does not belong to current course
|
||||
{
|
||||
/* If there is a request of this user, default role is the requested role */
|
||||
if ((DefaultRoleInCurrentCrs = Enr_GetRequestedRole (UsrDat->UsrCod)) == Rol_ROLE_UNKNOWN)
|
||||
if ((DefaultRoleInCurrentCrs = Rol_GetRequestedRole (UsrDat->UsrCod)) == Rol_ROLE_UNKNOWN)
|
||||
DefaultRoleInCurrentCrs = (UsrDat->Roles & (1 << Rol_ROLE_TEACHER)) ? Rol_ROLE_TEACHER :
|
||||
Rol_ROLE_STUDENT;
|
||||
}
|
||||
|
|
28
swad_role.c
28
swad_role.c
|
@ -433,3 +433,31 @@ static void Rol_PutOneRoleRegRemUsrsCrs (Rol_Role_t Role,bool Checked)
|
|||
fprintf (Gbl.F.Out," />%s</li>",
|
||||
Txt_ROLES_SINGULAR_Abc[Role][Usr_SEX_UNKNOWN]);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************ Get requested role of a user in current course *****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
Rol_Role_t Rol_GetRequestedRole (long UsrCod)
|
||||
{
|
||||
char Query[256];
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
Rol_Role_t Role = Rol_ROLE_UNKNOWN;
|
||||
|
||||
/***** Get requested role from database *****/
|
||||
sprintf (Query,"SELECT Role FROM crs_usr_requests"
|
||||
" WHERE CrsCod='%ld' AND UsrCod='%ld'",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,UsrCod);
|
||||
if (DB_QuerySELECT (Query,&mysql_res,"can not get requested role"))
|
||||
{
|
||||
/***** Get role *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
Role = Rol_ConvertUnsignedStrToRole (row[0]);
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
||||
return Role;
|
||||
}
|
||||
|
|
|
@ -83,4 +83,6 @@ void Rol_GetSelectedRoles (unsigned *Roles);
|
|||
|
||||
void Rol_PutAllRolesRegRemUsrsCrs (void);
|
||||
|
||||
Rol_Role_t Rol_GetRequestedRole (long UsrCod);
|
||||
|
||||
#endif
|
||||
|
|
57
swad_user.c
57
swad_user.c
|
@ -34,6 +34,7 @@
|
|||
#include <sys/wait.h> // For the macro WEXITSTATUS
|
||||
#include <unistd.h> // For access, lstat, getpid, chdir, symlink, unlink
|
||||
|
||||
#include "swad_account.h"
|
||||
#include "swad_announcement.h"
|
||||
#include "swad_config.h"
|
||||
#include "swad_connected.h"
|
||||
|
@ -185,12 +186,12 @@ void Usr_InformAboutNumClicksBeforePhoto (void)
|
|||
|
||||
if (Gbl.Usrs.Me.NumAccWithoutPhoto)
|
||||
{
|
||||
if (Gbl.Usrs.Me.NumAccWithoutPhoto >= Usr_MAX_CLICKS_WITHOUT_PHOTO)
|
||||
if (Gbl.Usrs.Me.NumAccWithoutPhoto >= Pho_MAX_CLICKS_WITHOUT_PHOTO)
|
||||
Lay_ShowAlert (Lay_WARNING,Txt_You_must_send_your_photo_because_);
|
||||
else if (Act_Actions[Gbl.CurrentAct].BrowserWindow == Act_MAIN_WINDOW)
|
||||
{
|
||||
sprintf (Message,Txt_You_can_only_perform_X_further_actions_,
|
||||
Usr_MAX_CLICKS_WITHOUT_PHOTO-Gbl.Usrs.Me.NumAccWithoutPhoto);
|
||||
Pho_MAX_CLICKS_WITHOUT_PHOTO-Gbl.Usrs.Me.NumAccWithoutPhoto);
|
||||
Lay_ShowAlert (Lay_WARNING,Message);
|
||||
|
||||
fprintf (Gbl.F.Out,"<div align=\"center\">");
|
||||
|
@ -1666,7 +1667,7 @@ void Usr_ChkUsrAndGetUsrData (void)
|
|||
if (Gbl.CurrentAct == ActCreUsrAcc)
|
||||
{
|
||||
/***** Create new account and login *****/
|
||||
if (Enr_CreateNewAccountAndLogIn ()) // User logged in
|
||||
if (Acc_CreateNewAccountAndLogIn ()) // User logged in
|
||||
{
|
||||
Gbl.Usrs.Me.Logged = true;
|
||||
Usr_SetUsrRoleAndPrefs ();
|
||||
|
@ -2319,56 +2320,6 @@ void Usr_ShowFormsRoleAndLogout (void)
|
|||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* Update number of clicks without photo *******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Usr_UpdateMyClicksWithoutPhoto (void)
|
||||
{
|
||||
char Query[512];
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumRows;
|
||||
unsigned NumClicks;
|
||||
|
||||
/***** Get number of clicks without photo from database *****/
|
||||
sprintf (Query,"SELECT NumClicks FROM clicks_without_photo"
|
||||
" WHERE UsrCod='%ld'",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get number of clicks without photo");
|
||||
|
||||
/***** Update the list of clicks without photo *****/
|
||||
if (NumRows) // The user exists ==> update number of clicks without photo
|
||||
{
|
||||
/* Get current number of clicks */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
sscanf (row[0],"%u",&NumClicks);
|
||||
|
||||
/* Update number of clicks */
|
||||
if (NumClicks <= Usr_MAX_CLICKS_WITHOUT_PHOTO)
|
||||
{
|
||||
sprintf (Query,"UPDATE clicks_without_photo SET NumClicks=NumClicks+1 WHERE UsrCod='%ld'",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
DB_QueryUPDATE (Query,"can not update number of clicks without photo");
|
||||
NumClicks++;
|
||||
}
|
||||
}
|
||||
else // The user does not exist ==> add him/her
|
||||
{
|
||||
/* Add the user, with one access */
|
||||
sprintf (Query,"INSERT INTO clicks_without_photo (UsrCod,NumClicks) VALUES ('%ld',1)",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
DB_QueryINSERT (Query,"can not create number of clicks without photo");
|
||||
NumClicks = 1;
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
||||
/***** Return the number of rows of the result *****/
|
||||
return NumClicks;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******* Check a user's code and get all user's data from user's code ********/
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -47,8 +47,6 @@
|
|||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Usr_MAX_CLICKS_WITHOUT_PHOTO 50
|
||||
|
||||
#define Usr_MIN_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_USRS 6
|
||||
#define Usr_DEF_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_USRS 12
|
||||
#define Usr_MAX_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_USRS 60
|
||||
|
@ -245,8 +243,6 @@ void Usr_ChkUsrAndGetUsrData (void);
|
|||
void Usr_WarningWhenDegreeTypeDoesntAllowDirectLogin (void);
|
||||
void Usr_ShowFormsRoleAndLogout (void);
|
||||
|
||||
unsigned Usr_UpdateMyClicksWithoutPhoto (void);
|
||||
|
||||
bool Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (struct UsrData *UsrDat);
|
||||
bool Usr_GetIfUserHasAcceptedEnrollmentInCurrentCrs (long UsrCod);
|
||||
void Usr_UpdateMyLastData (void);
|
||||
|
|
Loading…
Reference in New Issue