mirror of https://github.com/acanas/swad-core.git
Version 21.57.5: Nov 18, 2021 Code refactoring related to check if user logged is me.
This commit is contained in:
parent
71c8bf59e9
commit
e3a4494721
|
@ -3199,7 +3199,6 @@ int swad__sendMessage (struct soap *soap,
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumUsrs;
|
unsigned NumUsrs;
|
||||||
unsigned NumUsr;
|
unsigned NumUsr;
|
||||||
bool ItsMe;
|
|
||||||
bool NotifyByEmail;
|
bool NotifyByEmail;
|
||||||
|
|
||||||
/***** Initializations *****/
|
/***** Initializations *****/
|
||||||
|
@ -3268,8 +3267,7 @@ int swad__sendMessage (struct soap *soap,
|
||||||
Usr_DONT_GET_ROLE_IN_CURRENT_CRS))
|
Usr_DONT_GET_ROLE_IN_CURRENT_CRS))
|
||||||
{
|
{
|
||||||
/* This received message must be notified by email? */
|
/* This received message must be notified by email? */
|
||||||
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
|
NotifyByEmail = (!Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod) &&
|
||||||
NotifyByEmail = (!ItsMe &&
|
|
||||||
(Gbl.Usrs.Other.UsrDat.NtfEvents.SendEmail & (1 << Ntf_EVENT_MESSAGE)));
|
(Gbl.Usrs.Other.UsrDat.NtfEvents.SendEmail & (1 << Ntf_EVENT_MESSAGE)));
|
||||||
|
|
||||||
/* Send message to this user */
|
/* Send message to this user */
|
||||||
|
|
22
swad_ID.c
22
swad_ID.c
|
@ -341,9 +341,7 @@ void ID_WriteUsrIDs (struct UsrData *UsrDat,const char *Anchor)
|
||||||
|
|
||||||
bool ID_ICanSeeOtherUsrIDs (const struct UsrData *UsrDat)
|
bool ID_ICanSeeOtherUsrIDs (const struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
if (Usr_ItsMe (UsrDat->UsrCod))
|
||||||
|
|
||||||
if (ItsMe)
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/***** Check if I have permission to see another user's IDs *****/
|
/***** Check if I have permission to see another user's IDs *****/
|
||||||
|
@ -677,16 +675,14 @@ void ID_RemoveMyUsrID (void)
|
||||||
|
|
||||||
void ID_RemoveOtherUsrID (void)
|
void ID_RemoveOtherUsrID (void)
|
||||||
{
|
{
|
||||||
bool ItsMe;
|
|
||||||
|
|
||||||
/***** Get other user's code from form and get user's data *****/
|
/***** Get other user's code from form and get user's data *****/
|
||||||
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
||||||
{
|
{
|
||||||
if (Usr_ICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat))
|
if (Usr_ICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat))
|
||||||
{
|
{
|
||||||
/***** Remove user's ID *****/
|
/***** Remove user's ID *****/
|
||||||
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
|
ID_RemoveUsrID (&Gbl.Usrs.Other.UsrDat,
|
||||||
ID_RemoveUsrID (&Gbl.Usrs.Other.UsrDat,ItsMe);
|
Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod));
|
||||||
|
|
||||||
/***** Update list of IDs *****/
|
/***** Update list of IDs *****/
|
||||||
ID_GetListIDsFromUsrCod (&Gbl.Usrs.Other.UsrDat);
|
ID_GetListIDsFromUsrCod (&Gbl.Usrs.Other.UsrDat);
|
||||||
|
@ -769,16 +765,14 @@ void ID_NewMyUsrID (void)
|
||||||
|
|
||||||
void ID_NewOtherUsrID (void)
|
void ID_NewOtherUsrID (void)
|
||||||
{
|
{
|
||||||
bool ItsMe;
|
|
||||||
|
|
||||||
/***** Get other user's code from form and get user's data *****/
|
/***** Get other user's code from form and get user's data *****/
|
||||||
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
||||||
{
|
{
|
||||||
if (Usr_ICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat))
|
if (Usr_ICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat))
|
||||||
{
|
{
|
||||||
/***** New user's ID *****/
|
/***** New user's ID *****/
|
||||||
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
|
ID_NewUsrID (&Gbl.Usrs.Other.UsrDat,
|
||||||
ID_NewUsrID (&Gbl.Usrs.Other.UsrDat,ItsMe);
|
Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod));
|
||||||
|
|
||||||
/***** Update list of IDs *****/
|
/***** Update list of IDs *****/
|
||||||
ID_GetListIDsFromUsrCod (&Gbl.Usrs.Other.UsrDat);
|
ID_GetListIDsFromUsrCod (&Gbl.Usrs.Other.UsrDat);
|
||||||
|
@ -881,7 +875,6 @@ void ID_ConfirmOtherUsrID (void)
|
||||||
long OriginalActCod;
|
long OriginalActCod;
|
||||||
char UsrID[ID_MAX_BYTES_USR_ID + 1];
|
char UsrID[ID_MAX_BYTES_USR_ID + 1];
|
||||||
bool ICanConfirm;
|
bool ICanConfirm;
|
||||||
bool ItsMe;
|
|
||||||
bool Found;
|
bool Found;
|
||||||
unsigned NumID;
|
unsigned NumID;
|
||||||
unsigned NumIDFound = 0; // Initialized to avoid warning
|
unsigned NumIDFound = 0; // Initialized to avoid warning
|
||||||
|
@ -893,9 +886,7 @@ void ID_ConfirmOtherUsrID (void)
|
||||||
/***** Get other user's code from form and get user's data *****/
|
/***** Get other user's code from form and get user's data *****/
|
||||||
ICanConfirm = false;
|
ICanConfirm = false;
|
||||||
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
||||||
{
|
if (!Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod)) // Not me
|
||||||
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
|
|
||||||
if (!ItsMe) // Not me
|
|
||||||
{
|
{
|
||||||
/* If user is a student in current course,
|
/* If user is a student in current course,
|
||||||
check if he/she has accepted */
|
check if he/she has accepted */
|
||||||
|
@ -906,7 +897,6 @@ void ID_ConfirmOtherUsrID (void)
|
||||||
if (ID_ICanSeeOtherUsrIDs (&Gbl.Usrs.Other.UsrDat))
|
if (ID_ICanSeeOtherUsrIDs (&Gbl.Usrs.Other.UsrDat))
|
||||||
ICanConfirm = true;
|
ICanConfirm = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (ICanConfirm)
|
if (ICanConfirm)
|
||||||
{
|
{
|
||||||
|
|
|
@ -372,7 +372,6 @@ void Agd_ShowUsrAgenda (void)
|
||||||
extern const char *Hlp_PROFILE_Agenda_public_agenda;
|
extern const char *Hlp_PROFILE_Agenda_public_agenda;
|
||||||
extern const char *Txt_Public_agenda_USER;
|
extern const char *Txt_Public_agenda_USER;
|
||||||
struct Agd_Agenda Agenda;
|
struct Agd_Agenda Agenda;
|
||||||
bool ItsMe;
|
|
||||||
bool Error = true;
|
bool Error = true;
|
||||||
|
|
||||||
/***** Get user *****/
|
/***** Get user *****/
|
||||||
|
@ -385,8 +384,7 @@ void Agd_ShowUsrAgenda (void)
|
||||||
Agd_ResetAgenda (&Agenda);
|
Agd_ResetAgenda (&Agenda);
|
||||||
|
|
||||||
/***** Begin box *****/
|
/***** Begin box *****/
|
||||||
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
|
if (Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod))
|
||||||
if (ItsMe)
|
|
||||||
Box_BoxBegin ("100%",Str_BuildStringStr (Txt_Public_agenda_USER,
|
Box_BoxBegin ("100%",Str_BuildStringStr (Txt_Public_agenda_USER,
|
||||||
Gbl.Usrs.Me.UsrDat.FullName),
|
Gbl.Usrs.Me.UsrDat.FullName),
|
||||||
Agd_PutIconsMyPublicAgenda,Gbl.Usrs.Me.UsrDat.EnUsrCod,
|
Agd_PutIconsMyPublicAgenda,Gbl.Usrs.Me.UsrDat.EnUsrCod,
|
||||||
|
@ -423,7 +421,6 @@ void Agd_ShowOtherAgendaAfterLogIn (void)
|
||||||
extern const char *Txt_Public_agenda_USER;
|
extern const char *Txt_Public_agenda_USER;
|
||||||
extern const char *Txt_Switching_to_LANGUAGE[1 + Lan_NUM_LANGUAGES];
|
extern const char *Txt_Switching_to_LANGUAGE[1 + Lan_NUM_LANGUAGES];
|
||||||
struct Agd_Agenda Agenda;
|
struct Agd_Agenda Agenda;
|
||||||
bool ItsMe;
|
|
||||||
|
|
||||||
if (Gbl.Usrs.Me.Logged)
|
if (Gbl.Usrs.Me.Logged)
|
||||||
{
|
{
|
||||||
|
@ -439,8 +436,7 @@ void Agd_ShowOtherAgendaAfterLogIn (void)
|
||||||
Agd_ResetAgenda (&Agenda);
|
Agd_ResetAgenda (&Agenda);
|
||||||
|
|
||||||
/***** Begin box *****/
|
/***** Begin box *****/
|
||||||
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
|
if (Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod))
|
||||||
if (ItsMe)
|
|
||||||
Box_BoxBegin ("100%",Str_BuildStringStr (Txt_Public_agenda_USER,
|
Box_BoxBegin ("100%",Str_BuildStringStr (Txt_Public_agenda_USER,
|
||||||
Gbl.Usrs.Me.UsrDat.FullName),
|
Gbl.Usrs.Me.UsrDat.FullName),
|
||||||
Agd_PutIconToViewEditMyFullAgenda,Gbl.Usrs.Me.UsrDat.EnUsrCod,
|
Agd_PutIconToViewEditMyFullAgenda,Gbl.Usrs.Me.UsrDat.EnUsrCod,
|
||||||
|
|
|
@ -602,13 +602,14 @@ TODO: FIX BUG, URGENT! En las fechas como par
|
||||||
|
|
||||||
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
|
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 21.57.4 (2021-11-18)"
|
#define Log_PLATFORM_VERSION "SWAD 21.57.5 (2021-11-18)"
|
||||||
#define CSS_FILE "swad21.57.css"
|
#define CSS_FILE "swad21.57.css"
|
||||||
#define JS_FILE "swad21.57.js"
|
#define JS_FILE "swad21.57.js"
|
||||||
/*
|
/*
|
||||||
TODO: Rename CENTRE to CENTER in help wiki.
|
TODO: Rename CENTRE to CENTER in help wiki.
|
||||||
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
||||||
|
|
||||||
|
Version 21.57.5: Nov 18, 2021 Code refactoring related to check if user logged is me. (319174 lines)
|
||||||
Version 21.57.4: Nov 17, 2021 Code refactoring in timeline. (319235 lines)
|
Version 21.57.4: Nov 17, 2021 Code refactoring in timeline. (319235 lines)
|
||||||
Version 21.57.3: Nov 17, 2021 Code refactoring in timeline. (319225 lines)
|
Version 21.57.3: Nov 17, 2021 Code refactoring in timeline. (319225 lines)
|
||||||
Version 21.57.2: Nov 14, 2021 Code refactoring in timeline. (319257 lines)
|
Version 21.57.2: Nov 14, 2021 Code refactoring in timeline. (319257 lines)
|
||||||
|
|
|
@ -297,7 +297,6 @@ static void Enr_NotifyAfterEnrolment (const struct UsrData *UsrDat,
|
||||||
};
|
};
|
||||||
bool CreateNotif;
|
bool CreateNotif;
|
||||||
bool NotifyByEmail;
|
bool NotifyByEmail;
|
||||||
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
|
||||||
|
|
||||||
/***** Check if user's role is allowed *****/
|
/***** Check if user's role is allowed *****/
|
||||||
if (!NotifyEvent[NewRole])
|
if (!NotifyEvent[NewRole])
|
||||||
|
@ -313,7 +312,7 @@ static void Enr_NotifyAfterEnrolment (const struct UsrData *UsrDat,
|
||||||
|
|
||||||
/***** Create new notification ******/
|
/***** Create new notification ******/
|
||||||
CreateNotif = (UsrDat->NtfEvents.CreateNotif & (1 << NotifyEvent[NewRole]));
|
CreateNotif = (UsrDat->NtfEvents.CreateNotif & (1 << NotifyEvent[NewRole]));
|
||||||
NotifyByEmail = CreateNotif && !ItsMe &&
|
NotifyByEmail = CreateNotif && !Usr_ItsMe (UsrDat->UsrCod) &&
|
||||||
(UsrDat->NtfEvents.SendEmail & (1 << NotifyEvent[NewRole]));
|
(UsrDat->NtfEvents.SendEmail & (1 << NotifyEvent[NewRole]));
|
||||||
if (CreateNotif)
|
if (CreateNotif)
|
||||||
Ntf_DB_StoreNotifyEventToUsr (NotifyEvent[NewRole],UsrDat->UsrCod,-1L,
|
Ntf_DB_StoreNotifyEventToUsr (NotifyEvent[NewRole],UsrDat->UsrCod,-1L,
|
||||||
|
@ -2676,25 +2675,22 @@ void Enr_RemUsrFromCrs2 (void)
|
||||||
|
|
||||||
static bool Enr_CheckIfICanRemUsrFromCrs (void)
|
static bool Enr_CheckIfICanRemUsrFromCrs (void)
|
||||||
{
|
{
|
||||||
bool ItsMe;
|
|
||||||
|
|
||||||
/* Check if I can remove another user from current course */
|
|
||||||
switch (Gbl.Usrs.Me.Role.Logged)
|
switch (Gbl.Usrs.Me.Role.Logged)
|
||||||
{
|
{
|
||||||
case Rol_STD:
|
case Rol_STD:
|
||||||
case Rol_NET:
|
case Rol_NET:
|
||||||
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
|
// A student or non-editing teacher can remove herself/himself
|
||||||
return ItsMe; // A student or non-editing teacher can remove herself/himself
|
return Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
|
||||||
case Rol_TCH:
|
case Rol_TCH:
|
||||||
case Rol_DEG_ADM:
|
case Rol_DEG_ADM:
|
||||||
case Rol_CTR_ADM:
|
case Rol_CTR_ADM:
|
||||||
case Rol_INS_ADM:
|
case Rol_INS_ADM:
|
||||||
case Rol_SYS_ADM:
|
case Rol_SYS_ADM:
|
||||||
return true; // A teacher or administrator can remove anyone
|
// A teacher or administrator can remove anyone
|
||||||
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -3086,7 +3082,6 @@ static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat,
|
||||||
Cns_QuietOrVerbose_t QuietOrVerbose)
|
Cns_QuietOrVerbose_t QuietOrVerbose)
|
||||||
{
|
{
|
||||||
extern const char *Txt_THE_USER_X_has_been_removed_from_the_course_Y;
|
extern const char *Txt_THE_USER_X_has_been_removed_from_the_course_Y;
|
||||||
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
|
||||||
|
|
||||||
if (Enr_CheckIfUsrBelongsToCurrentCrs (UsrDat))
|
if (Enr_CheckIfUsrBelongsToCurrentCrs (UsrDat))
|
||||||
{
|
{
|
||||||
|
@ -3130,7 +3125,7 @@ static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat,
|
||||||
Usr_FlushCachesUsr ();
|
Usr_FlushCachesUsr ();
|
||||||
|
|
||||||
/***** If it's me, change my roles *****/
|
/***** If it's me, change my roles *****/
|
||||||
if (ItsMe)
|
if (Usr_ItsMe (UsrDat->UsrCod))
|
||||||
{
|
{
|
||||||
/* Now I don't belong to current course */
|
/* Now I don't belong to current course */
|
||||||
Gbl.Usrs.Me.IBelongToCurrentCrs =
|
Gbl.Usrs.Me.IBelongToCurrentCrs =
|
||||||
|
@ -3383,8 +3378,6 @@ void Enr_FlushCacheUsrSharesAnyOfMyCrs (void)
|
||||||
|
|
||||||
bool Enr_CheckIfUsrSharesAnyOfMyCrs (struct UsrData *UsrDat)
|
bool Enr_CheckIfUsrSharesAnyOfMyCrs (struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
bool ItsMe;
|
|
||||||
|
|
||||||
/***** 1. Fast check: Am I logged? *****/
|
/***** 1. Fast check: Am I logged? *****/
|
||||||
if (!Gbl.Usrs.Me.Logged)
|
if (!Gbl.Usrs.Me.Logged)
|
||||||
return false;
|
return false;
|
||||||
|
@ -3394,8 +3387,7 @@ bool Enr_CheckIfUsrSharesAnyOfMyCrs (struct UsrData *UsrDat)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/***** 3. Fast check: It's me? *****/
|
/***** 3. Fast check: It's me? *****/
|
||||||
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
if (Usr_ItsMe (UsrDat->UsrCod))
|
||||||
if (ItsMe)
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/***** 4. Fast check: Is already calculated if user shares any course with me? *****/
|
/***** 4. Fast check: Is already calculated if user shares any course with me? *****/
|
||||||
|
|
|
@ -1369,15 +1369,12 @@ static void ExaRes_CheckIfICanViewResult (const struct Exa_Exam *Exam,
|
||||||
long UsrCod,
|
long UsrCod,
|
||||||
struct ExaRes_ICanView *ICanView)
|
struct ExaRes_ICanView *ICanView)
|
||||||
{
|
{
|
||||||
bool ItsMe;
|
|
||||||
|
|
||||||
/***** Check if I can view print result and score *****/
|
/***** Check if I can view print result and score *****/
|
||||||
switch (Gbl.Usrs.Me.Role.Logged)
|
switch (Gbl.Usrs.Me.Role.Logged)
|
||||||
{
|
{
|
||||||
case Rol_STD:
|
case Rol_STD:
|
||||||
// Depends on visibility of exam, session and result (eye icons)
|
// Depends on visibility of exam, session and result (eye icons)
|
||||||
ItsMe = Usr_ItsMe (UsrCod);
|
ICanView->Result = (Usr_ItsMe (UsrCod) && // The result is mine
|
||||||
ICanView->Result = (ItsMe && // The result is mine
|
|
||||||
!Exam->Hidden && // The exam is visible
|
!Exam->Hidden && // The exam is visible
|
||||||
!Session->Hidden && // The session is visible
|
!Session->Hidden && // The session is visible
|
||||||
Session->ShowUsrResults); // The results of the session are visible to users
|
Session->ShowUsrResults); // The results of the session are visible to users
|
||||||
|
|
|
@ -319,7 +319,6 @@ void Fol_ShowFollowingAndFollowers (const struct UsrData *UsrDat,
|
||||||
extern const char *Txt_Followers;
|
extern const char *Txt_Followers;
|
||||||
extern const char *Txt_Following_unfollow;
|
extern const char *Txt_Following_unfollow;
|
||||||
extern const char *Txt_Follow;
|
extern const char *Txt_Follow;
|
||||||
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
|
||||||
|
|
||||||
/***** Begin section *****/
|
/***** Begin section *****/
|
||||||
HTM_SECTION_Begin (Fol_FOLLOW_SECTION_ID);
|
HTM_SECTION_Begin (Fol_FOLLOW_SECTION_ID);
|
||||||
|
@ -355,7 +354,7 @@ void Fol_ShowFollowingAndFollowers (const struct UsrData *UsrDat,
|
||||||
/* I follow user? */
|
/* I follow user? */
|
||||||
HTM_DIV_Begin ("id=\"follow_usr\"");
|
HTM_DIV_Begin ("id=\"follow_usr\"");
|
||||||
if (Gbl.Usrs.Me.Logged && // Logged
|
if (Gbl.Usrs.Me.Logged && // Logged
|
||||||
!ItsMe) // Not me!
|
!Usr_ItsMe (UsrDat->UsrCod)) // Not me!
|
||||||
{
|
{
|
||||||
Frm_BeginForm (IFollowUsr ? ActUnfUsr :
|
Frm_BeginForm (IFollowUsr ? ActUnfUsr :
|
||||||
ActFolUsr);
|
ActFolUsr);
|
||||||
|
@ -614,7 +613,6 @@ static void Fol_ShowFollowedOrFollower (struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Another_user_s_profile;
|
extern const char *Txt_Another_user_s_profile;
|
||||||
bool Visible = Pri_ShowingIsAllowed (UsrDat->BaPrfVisibility,UsrDat);
|
bool Visible = Pri_ShowingIsAllowed (UsrDat->BaPrfVisibility,UsrDat);
|
||||||
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
|
||||||
|
|
||||||
/***** Show user's photo *****/
|
/***** Show user's photo *****/
|
||||||
HTM_TD_Begin ("class=\"FOLLOW_PHOTO\"");
|
HTM_TD_Begin ("class=\"FOLLOW_PHOTO\"");
|
||||||
|
@ -638,9 +636,8 @@ static void Fol_ShowFollowedOrFollower (struct UsrData *UsrDat)
|
||||||
Frm_EndForm ();
|
Frm_EndForm ();
|
||||||
}
|
}
|
||||||
|
|
||||||
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
|
||||||
if (!Gbl.Usrs.Me.Logged || // Not logged
|
if (!Gbl.Usrs.Me.Logged || // Not logged
|
||||||
ItsMe) // It's me
|
Usr_ItsMe (UsrDat->UsrCod)) // It's me
|
||||||
/* Inactive icon to follow/unfollow */
|
/* Inactive icon to follow/unfollow */
|
||||||
Fol_PutInactiveIconToFollowUnfollow ();
|
Fol_PutInactiveIconToFollowUnfollow ();
|
||||||
else // It's not me
|
else // It's not me
|
||||||
|
@ -666,7 +663,6 @@ static void Fol_WriteRowUsrToFollowOnRightColumn (struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Another_user_s_profile;
|
extern const char *Txt_Another_user_s_profile;
|
||||||
bool Visible = Pri_ShowingIsAllowed (UsrDat->BaPrfVisibility,UsrDat);
|
bool Visible = Pri_ShowingIsAllowed (UsrDat->BaPrfVisibility,UsrDat);
|
||||||
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
|
||||||
|
|
||||||
/***** Show user's photo *****/
|
/***** Show user's photo *****/
|
||||||
HTM_TR_Begin (NULL);
|
HTM_TR_Begin (NULL);
|
||||||
|
@ -696,7 +692,7 @@ static void Fol_WriteRowUsrToFollowOnRightColumn (struct UsrData *UsrDat)
|
||||||
/***** Icon to follow *****/
|
/***** Icon to follow *****/
|
||||||
HTM_TD_Begin ("class=\"CON_ICON_FOLLOW RM COLOR%u\"",Gbl.RowEvenOdd);
|
HTM_TD_Begin ("class=\"CON_ICON_FOLLOW RM COLOR%u\"",Gbl.RowEvenOdd);
|
||||||
if (!Gbl.Usrs.Me.Logged || // Not logged
|
if (!Gbl.Usrs.Me.Logged || // Not logged
|
||||||
ItsMe) // It's me
|
Usr_ItsMe (UsrDat->UsrCod)) // It's me
|
||||||
/* Inactive icon to follow/unfollow */
|
/* Inactive icon to follow/unfollow */
|
||||||
Fol_PutInactiveIconToFollowUnfollow ();
|
Fol_PutInactiveIconToFollowUnfollow ();
|
||||||
else // It's not me
|
else // It's not me
|
||||||
|
|
|
@ -2866,7 +2866,6 @@ void For_RemovePost (void)
|
||||||
char Subject[Cns_MAX_BYTES_SUBJECT + 1];
|
char Subject[Cns_MAX_BYTES_SUBJECT + 1];
|
||||||
char OriginalContent[Cns_MAX_BYTES_LONG_TEXT + 1];
|
char OriginalContent[Cns_MAX_BYTES_LONG_TEXT + 1];
|
||||||
struct Med_Media Media;
|
struct Med_Media Media;
|
||||||
bool ItsMe;
|
|
||||||
bool ThreadDeleted = false;
|
bool ThreadDeleted = false;
|
||||||
|
|
||||||
/***** Reset forum *****/
|
/***** Reset forum *****/
|
||||||
|
@ -2888,8 +2887,7 @@ void For_RemovePost (void)
|
||||||
Err_WrongPostExit ();
|
Err_WrongPostExit ();
|
||||||
|
|
||||||
/* Check if I am the author of the message */
|
/* Check if I am the author of the message */
|
||||||
ItsMe = Usr_ItsMe (UsrDat.UsrCod);
|
if (!Usr_ItsMe (UsrDat.UsrCod))
|
||||||
if (!ItsMe)
|
|
||||||
Err_NoPermissionExit ();
|
Err_NoPermissionExit ();
|
||||||
|
|
||||||
/* Check if the message is the last message in the thread */
|
/* Check if the message is the last message in the thread */
|
||||||
|
@ -2927,6 +2925,7 @@ void For_RemovePost (void)
|
||||||
{
|
{
|
||||||
/***** Show threads again *****/
|
/***** Show threads again *****/
|
||||||
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_SUCCESS,NULL);
|
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_SUCCESS,NULL);
|
||||||
|
|
||||||
/***** Show the remaining posts *****/
|
/***** Show the remaining posts *****/
|
||||||
For_ShowPostsOfAThread (&Forums,Ale_SUCCESS,Txt_FORUM_Post_removed);
|
For_ShowPostsOfAThread (&Forums,Ale_SUCCESS,Txt_FORUM_Post_removed);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1211,14 +1211,12 @@ void Grp_RemUsrFromAllGrps (long UsrCod)
|
||||||
|
|
||||||
static void Grp_RemoveUsrFromGroup (long UsrCod,long GrpCod)
|
static void Grp_RemoveUsrFromGroup (long UsrCod,long GrpCod)
|
||||||
{
|
{
|
||||||
bool ItsMe = Usr_ItsMe (UsrCod);
|
|
||||||
|
|
||||||
/***** Remove user from group *****/
|
/***** Remove user from group *****/
|
||||||
Grp_DB_RemoveUsrFromGrp (UsrCod,GrpCod);
|
Grp_DB_RemoveUsrFromGrp (UsrCod,GrpCod);
|
||||||
|
|
||||||
/***** Flush caches *****/
|
/***** Flush caches *****/
|
||||||
Grp_FlushCacheUsrSharesAnyOfMyGrpsInCurrentCrs ();
|
Grp_FlushCacheUsrSharesAnyOfMyGrpsInCurrentCrs ();
|
||||||
if (ItsMe)
|
if (Usr_ItsMe (UsrCod))
|
||||||
Grp_FlushCacheIBelongToGrp ();
|
Grp_FlushCacheIBelongToGrp ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3022,8 +3020,6 @@ void Grp_FlushCacheUsrSharesAnyOfMyGrpsInCurrentCrs (void)
|
||||||
|
|
||||||
bool Grp_CheckIfUsrSharesAnyOfMyGrpsInCurrentCrs (const struct UsrData *UsrDat)
|
bool Grp_CheckIfUsrSharesAnyOfMyGrpsInCurrentCrs (const struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
bool ItsMe;
|
|
||||||
|
|
||||||
/***** 1. Fast check: Am I logged? *****/
|
/***** 1. Fast check: Am I logged? *****/
|
||||||
if (!Gbl.Usrs.Me.Logged)
|
if (!Gbl.Usrs.Me.Logged)
|
||||||
return false;
|
return false;
|
||||||
|
@ -3041,8 +3037,7 @@ bool Grp_CheckIfUsrSharesAnyOfMyGrpsInCurrentCrs (const struct UsrData *UsrDat)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/***** 5. Fast check: It's me? *****/
|
/***** 5. Fast check: It's me? *****/
|
||||||
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
if (Usr_ItsMe (UsrDat->UsrCod))
|
||||||
if (ItsMe)
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/***** 6. Fast check: Is already calculated if user shares
|
/***** 6. Fast check: Is already calculated if user shares
|
||||||
|
|
11
swad_mail.c
11
swad_mail.c
|
@ -1308,16 +1308,14 @@ void May_NewMyUsrEmail (void)
|
||||||
|
|
||||||
void Mai_NewOtherUsrEmail (void)
|
void Mai_NewOtherUsrEmail (void)
|
||||||
{
|
{
|
||||||
bool ItsMe;
|
|
||||||
|
|
||||||
/***** Get other user's code from form and get user's data *****/
|
/***** Get other user's code from form and get user's data *****/
|
||||||
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
||||||
{
|
{
|
||||||
if (Usr_ICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat))
|
if (Usr_ICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat))
|
||||||
{
|
{
|
||||||
/***** New user's ID *****/
|
/***** New user's ID *****/
|
||||||
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
|
Mai_NewUsrEmail (&Gbl.Usrs.Other.UsrDat,
|
||||||
Mai_NewUsrEmail (&Gbl.Usrs.Other.UsrDat,ItsMe);
|
Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod));
|
||||||
|
|
||||||
/***** Show form again *****/
|
/***** Show form again *****/
|
||||||
Acc_ShowFormChgOtherUsrAccount ();
|
Acc_ShowFormChgOtherUsrAccount ();
|
||||||
|
@ -1625,9 +1623,8 @@ void Mai_WriteFootNoteEMail (FILE *FileMail,Lan_Language_t Language)
|
||||||
|
|
||||||
bool Mai_ICanSeeOtherUsrEmail (const struct UsrData *UsrDat)
|
bool Mai_ICanSeeOtherUsrEmail (const struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
/***** I can see my email *****/
|
||||||
|
if (Usr_ItsMe (UsrDat->UsrCod))
|
||||||
if (ItsMe)
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/***** Check if I have permission to see another user's email *****/
|
/***** Check if I have permission to see another user's email *****/
|
||||||
|
|
|
@ -1260,17 +1260,14 @@ static void MchRes_CheckIfICanSeeMatchResult (const struct Gam_Game *Game,
|
||||||
long UsrCod,
|
long UsrCod,
|
||||||
struct MchRes_ICanView *ICanView)
|
struct MchRes_ICanView *ICanView)
|
||||||
{
|
{
|
||||||
bool ItsMe;
|
|
||||||
|
|
||||||
/***** Check if I can view print result and score *****/
|
/***** Check if I can view print result and score *****/
|
||||||
switch (Gbl.Usrs.Me.Role.Logged)
|
switch (Gbl.Usrs.Me.Role.Logged)
|
||||||
{
|
{
|
||||||
case Rol_STD:
|
case Rol_STD:
|
||||||
// Depends on visibility of game and result (eye icons)
|
// Depends on visibility of game and result (eye icons)
|
||||||
ItsMe = Usr_ItsMe (UsrCod);
|
ICanView->Result = (!Game->Hidden && // The game is visible
|
||||||
ICanView->Result = (ItsMe && // The result is mine
|
Match->Status.ShowUsrResults && // The results of the match are visible to users
|
||||||
!Game->Hidden && // The game is visible
|
Usr_ItsMe (UsrCod)); // The result is mine
|
||||||
Match->Status.ShowUsrResults); // The results of the match are visible to users
|
|
||||||
// Whether I belong or not to groups of match is not checked here...
|
// Whether I belong or not to groups of match is not checked here...
|
||||||
// ...because I should be able to see old matches made in old groups to which I belonged
|
// ...because I should be able to see old matches made in old groups to which I belonged
|
||||||
|
|
||||||
|
|
13
swad_photo.c
13
swad_photo.c
|
@ -139,12 +139,11 @@ static void Pho_ComputePhotoSize (const struct Pho_DegPhotos *DegPhotos,
|
||||||
|
|
||||||
bool Pho_ICanChangeOtherUsrPhoto (struct UsrData *UsrDat)
|
bool Pho_ICanChangeOtherUsrPhoto (struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
/***** I can change my photo *****/
|
||||||
|
if (Usr_ItsMe (UsrDat->UsrCod))
|
||||||
if (ItsMe)
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/* Check if I have permission to change user's photo */
|
/***** Check if I have permission to change user's photo *****/
|
||||||
switch (Gbl.Usrs.Me.Role.Logged)
|
switch (Gbl.Usrs.Me.Role.Logged)
|
||||||
{
|
{
|
||||||
case Rol_TCH:
|
case Rol_TCH:
|
||||||
|
@ -154,8 +153,7 @@ bool Pho_ICanChangeOtherUsrPhoto (struct UsrData *UsrDat)
|
||||||
|
|
||||||
/* It's a student in this course,
|
/* It's a student in this course,
|
||||||
check if he/she has accepted registration */
|
check if he/she has accepted registration */
|
||||||
UsrDat->Accepted = Enr_CheckIfUsrHasAcceptedInCurrentCrs (UsrDat);
|
return (UsrDat->Accepted = Enr_CheckIfUsrHasAcceptedInCurrentCrs (UsrDat));
|
||||||
return UsrDat->Accepted;
|
|
||||||
case Rol_DEG_ADM:
|
case Rol_DEG_ADM:
|
||||||
case Rol_CTR_ADM:
|
case Rol_CTR_ADM:
|
||||||
case Rol_INS_ADM:
|
case Rol_INS_ADM:
|
||||||
|
@ -190,10 +188,9 @@ void Pho_PutIconToChangeUsrPhoto (void)
|
||||||
[Rol_INS_ADM] = ActReqOthPho,
|
[Rol_INS_ADM] = ActReqOthPho,
|
||||||
[Rol_SYS_ADM] = ActReqOthPho,
|
[Rol_SYS_ADM] = ActReqOthPho,
|
||||||
};
|
};
|
||||||
bool ItsMe = Usr_ItsMe (Gbl.Record.UsrDat->UsrCod);
|
|
||||||
|
|
||||||
/***** Link for changing / uploading the photo *****/
|
/***** Link for changing / uploading the photo *****/
|
||||||
if (ItsMe)
|
if (Usr_ItsMe (Gbl.Record.UsrDat->UsrCod))
|
||||||
{
|
{
|
||||||
TitleText = Gbl.Usrs.Me.MyPhotoExists ? Txt_Change_photo :
|
TitleText = Gbl.Usrs.Me.MyPhotoExists ? Txt_Change_photo :
|
||||||
Txt_Upload_photo;
|
Txt_Upload_photo;
|
||||||
|
|
|
@ -241,10 +241,8 @@ Pri_Visibility_t Pri_GetParamVisibility (const char *ParamName,
|
||||||
|
|
||||||
bool Pri_ShowingIsAllowed (Pri_Visibility_t Visibility,struct UsrData *UsrDat)
|
bool Pri_ShowingIsAllowed (Pri_Visibility_t Visibility,struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
|
||||||
|
|
||||||
/***** I always can see my things *****/
|
/***** I always can see my things *****/
|
||||||
if (ItsMe)
|
if (Usr_ItsMe (UsrDat->UsrCod))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/***** System admins always can see others' profiles *****/
|
/***** System admins always can see others' profiles *****/
|
||||||
|
|
|
@ -1190,7 +1190,7 @@ void Prf_ShowRankingFigure (MYSQL_RES **mysql_res,unsigned NumUsrs)
|
||||||
Usr_GetAllUsrDataFromUsrCod (&UsrDat,
|
Usr_GetAllUsrDataFromUsrCod (&UsrDat,
|
||||||
Usr_DONT_GET_PREFS,
|
Usr_DONT_GET_PREFS,
|
||||||
Usr_DONT_GET_ROLE_IN_CURRENT_CRS);
|
Usr_DONT_GET_ROLE_IN_CURRENT_CRS);
|
||||||
ItsMe = (UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
|
ItsMe = Usr_ItsMe (UsrDat.UsrCod);
|
||||||
|
|
||||||
/* Get figure (row[1]) */
|
/* Get figure (row[1]) */
|
||||||
if (sscanf (row[1],"%ld",&Figure) != 1)
|
if (sscanf (row[1],"%ld",&Figure) != 1)
|
||||||
|
@ -1260,7 +1260,7 @@ void Prf_GetAndShowRankingClicksPerDay (void)
|
||||||
Usr_GetAllUsrDataFromUsrCod (&UsrDat,
|
Usr_GetAllUsrDataFromUsrCod (&UsrDat,
|
||||||
Usr_DONT_GET_PREFS,
|
Usr_DONT_GET_PREFS,
|
||||||
Usr_DONT_GET_ROLE_IN_CURRENT_CRS);
|
Usr_DONT_GET_ROLE_IN_CURRENT_CRS);
|
||||||
ItsMe = (UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
|
ItsMe = Usr_ItsMe (UsrDat.UsrCod);
|
||||||
|
|
||||||
/* Get average number of clicks per day (row[1]) */
|
/* Get average number of clicks per day (row[1]) */
|
||||||
NumClicksPerDay = Str_GetDoubleFromStr (row[1]);
|
NumClicksPerDay = Str_GetDoubleFromStr (row[1]);
|
||||||
|
|
|
@ -2530,7 +2530,6 @@ static void Prj_ReqRemUsrFromPrj (struct Prj_Projects *Projects,
|
||||||
[Prj_ROLE_EVL] = ActRemEvlPrj, // Evaluator
|
[Prj_ROLE_EVL] = ActRemEvlPrj, // Evaluator
|
||||||
};
|
};
|
||||||
struct Prj_Project Prj;
|
struct Prj_Project Prj;
|
||||||
bool ItsMe;
|
|
||||||
|
|
||||||
/***** Allocate memory for the project *****/
|
/***** Allocate memory for the project *****/
|
||||||
Prj_AllocMemProject (&Prj);
|
Prj_AllocMemProject (&Prj);
|
||||||
|
@ -2548,12 +2547,10 @@ static void Prj_ReqRemUsrFromPrj (struct Prj_Projects *Projects,
|
||||||
{
|
{
|
||||||
if (Prj_CheckIfICanEditProject (&Prj))
|
if (Prj_CheckIfICanEditProject (&Prj))
|
||||||
{
|
{
|
||||||
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
|
|
||||||
|
|
||||||
/***** Show question and button to remove user as a role from project *****/
|
/***** Show question and button to remove user as a role from project *****/
|
||||||
/* Begin alert */
|
/* Begin alert */
|
||||||
Ale_ShowAlertAndButton1 (Ale_QUESTION,ItsMe ? Txt_Do_you_really_want_to_be_removed_as_a_X_from_the_project_Y :
|
Ale_ShowAlertAndButton1 (Ale_QUESTION,Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod) ? Txt_Do_you_really_want_to_be_removed_as_a_X_from_the_project_Y :
|
||||||
Txt_Do_you_really_want_to_remove_the_following_user_as_a_X_from_the_project_Y,
|
Txt_Do_you_really_want_to_remove_the_following_user_as_a_X_from_the_project_Y,
|
||||||
Txt_PROJECT_ROLES_SINGUL_abc[RoleInPrj][Gbl.Usrs.Other.UsrDat.Sex],
|
Txt_PROJECT_ROLES_SINGUL_abc[RoleInPrj][Gbl.Usrs.Other.UsrDat.Sex],
|
||||||
Prj.Title);
|
Prj.Title);
|
||||||
|
|
||||||
|
|
|
@ -968,8 +968,6 @@ void Rec_GetUsrAndShowRecOneStdCrs (void)
|
||||||
|
|
||||||
static void Rec_ShowRecordOneStdCrs (void)
|
static void Rec_ShowRecordOneStdCrs (void)
|
||||||
{
|
{
|
||||||
bool ItsMe;
|
|
||||||
|
|
||||||
/***** Get if student has accepted enrolment in current course *****/
|
/***** Get if student has accepted enrolment in current course *****/
|
||||||
Gbl.Usrs.Other.UsrDat.Accepted = Enr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat);
|
Gbl.Usrs.Other.UsrDat.Accepted = Enr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat);
|
||||||
|
|
||||||
|
@ -1013,8 +1011,7 @@ static void Rec_ShowRecordOneStdCrs (void)
|
||||||
switch (Gbl.Usrs.Me.Role.Logged)
|
switch (Gbl.Usrs.Me.Role.Logged)
|
||||||
{
|
{
|
||||||
case Rol_STD:
|
case Rol_STD:
|
||||||
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
|
if (Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod))
|
||||||
if (ItsMe)
|
|
||||||
{
|
{
|
||||||
HTM_DIV_Begin ("class=\"REC_RIGHT\"");
|
HTM_DIV_Begin ("class=\"REC_RIGHT\"");
|
||||||
Rec_ShowCrsRecord (Rec_CRS_MY_RECORD_AS_STUDENT_FORM,&Gbl.Usrs.Other.UsrDat,NULL);
|
Rec_ShowCrsRecord (Rec_CRS_MY_RECORD_AS_STUDENT_FORM,&Gbl.Usrs.Other.UsrDat,NULL);
|
||||||
|
@ -1065,7 +1062,6 @@ static void Rec_ListRecordsStds (Rec_SharedRecordViewType_t ShaTypeOfView,
|
||||||
unsigned NumUsr = 0;
|
unsigned NumUsr = 0;
|
||||||
const char *Ptr;
|
const char *Ptr;
|
||||||
struct UsrData UsrDat;
|
struct UsrData UsrDat;
|
||||||
bool ItsMe;
|
|
||||||
char RecordSectionId[32];
|
char RecordSectionId[32];
|
||||||
|
|
||||||
/***** Get list of selected users if not already got *****/
|
/***** Get list of selected users if not already got *****/
|
||||||
|
@ -1140,19 +1136,16 @@ static void Rec_ListRecordsStds (Rec_SharedRecordViewType_t ShaTypeOfView,
|
||||||
|
|
||||||
/* Record of the student in the course */
|
/* Record of the student in the course */
|
||||||
if (Gbl.Crs.Records.LstFields.Num) // There are fields in the record
|
if (Gbl.Crs.Records.LstFields.Num) // There are fields in the record
|
||||||
{
|
|
||||||
ItsMe = Usr_ItsMe (UsrDat.UsrCod);
|
|
||||||
if ( Gbl.Usrs.Me.Role.Logged == Rol_NET ||
|
if ( Gbl.Usrs.Me.Role.Logged == Rol_NET ||
|
||||||
Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
|
Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
|
||||||
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
||||||
(Gbl.Usrs.Me.Role.Logged == Rol_STD && // I am student in this course...
|
(Gbl.Usrs.Me.Role.Logged == Rol_STD && // I am student in this course...
|
||||||
ItsMe)) // ...and it's me
|
Usr_ItsMe (UsrDat.UsrCod))) // ...and it's me
|
||||||
{
|
{
|
||||||
HTM_DIV_Begin ("class=\"REC_RIGHT\"");
|
HTM_DIV_Begin ("class=\"REC_RIGHT\"");
|
||||||
Rec_ShowCrsRecord (CrsTypeOfView,&UsrDat,RecordSectionId);
|
Rec_ShowCrsRecord (CrsTypeOfView,&UsrDat,RecordSectionId);
|
||||||
HTM_DIV_End ();
|
HTM_DIV_End ();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* End container for this user */
|
/* End container for this user */
|
||||||
HTM_DIV_End ();
|
HTM_DIV_End ();
|
||||||
|
@ -1585,7 +1578,6 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
|
||||||
[Rec_CRS_PRINT_SEVERAL_RECORDS ] = NULL,
|
[Rec_CRS_PRINT_SEVERAL_RECORDS ] = NULL,
|
||||||
};
|
};
|
||||||
char StrRecordWidth[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
|
char StrRecordWidth[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
|
||||||
bool ItsMe;
|
|
||||||
bool ICanEdit = false;
|
bool ICanEdit = false;
|
||||||
unsigned NumField;
|
unsigned NumField;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
|
@ -1598,8 +1590,7 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
|
||||||
switch (Gbl.Usrs.Me.Role.Logged)
|
switch (Gbl.Usrs.Me.Role.Logged)
|
||||||
{
|
{
|
||||||
case Rol_STD: // I am a student
|
case Rol_STD: // I am a student
|
||||||
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
if (Usr_ItsMe (UsrDat->UsrCod))
|
||||||
if (ItsMe)
|
|
||||||
{
|
{
|
||||||
switch (TypeOfView)
|
switch (TypeOfView)
|
||||||
{
|
{
|
||||||
|
|
|
@ -692,7 +692,6 @@ void Str_AnalyzeTxtAndStoreNotifyEventToMentionedUsrs (long PubCod,const char *T
|
||||||
size_t Length; // Length of the nickname
|
size_t Length; // Length of the nickname
|
||||||
} Nickname;
|
} Nickname;
|
||||||
struct UsrData UsrDat;
|
struct UsrData UsrDat;
|
||||||
bool ItsMe;
|
|
||||||
bool CreateNotif;
|
bool CreateNotif;
|
||||||
bool NotifyByEmail;
|
bool NotifyByEmail;
|
||||||
|
|
||||||
|
@ -735,9 +734,7 @@ void Str_AnalyzeTxtAndStoreNotifyEventToMentionedUsrs (long PubCod,const char *T
|
||||||
UsrDat.Nickname[Nickname.Length] = '\0';
|
UsrDat.Nickname[Nickname.Length] = '\0';
|
||||||
|
|
||||||
if ((UsrDat.UsrCod = Nck_GetUsrCodFromNickname (UsrDat.Nickname)) > 0)
|
if ((UsrDat.UsrCod = Nck_GetUsrCodFromNickname (UsrDat.Nickname)) > 0)
|
||||||
{
|
if (!Usr_ItsMe (UsrDat.UsrCod)) // Not me
|
||||||
ItsMe = Usr_ItsMe (UsrDat.UsrCod);
|
|
||||||
if (!ItsMe) // Not me
|
|
||||||
{
|
{
|
||||||
/* Get user's data */
|
/* Get user's data */
|
||||||
Usr_GetAllUsrDataFromUsrCod (&UsrDat,
|
Usr_GetAllUsrDataFromUsrCod (&UsrDat,
|
||||||
|
@ -758,7 +755,6 @@ void Str_AnalyzeTxtAndStoreNotifyEventToMentionedUsrs (long PubCod,const char *T
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
Gbl.Hierarchy.Crs.CrsCod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* The next char is not the start of a nickname */
|
/* The next char is not the start of a nickname */
|
||||||
|
|
|
@ -1840,7 +1840,6 @@ static void TstPrn_ShowUsrPrints (struct UsrData *UsrDat)
|
||||||
struct TstPrn_NumQuestions NumTotalQsts;
|
struct TstPrn_NumQuestions NumTotalQsts;
|
||||||
double TotalScore;
|
double TotalScore;
|
||||||
unsigned NumPrintsVisibleByTchs = 0;
|
unsigned NumPrintsVisibleByTchs = 0;
|
||||||
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
|
||||||
struct TstRes_ICanView ICanView;
|
struct TstRes_ICanView ICanView;
|
||||||
char *ClassDat;
|
char *ClassDat;
|
||||||
|
|
||||||
|
@ -1990,7 +1989,7 @@ static void TstPrn_ShowUsrPrints (struct UsrData *UsrDat)
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Write totals for this user *****/
|
/***** Write totals for this user *****/
|
||||||
TstPrn_ShowPrintsSummaryRow (ItsMe,NumPrintsVisibleByTchs,
|
TstPrn_ShowPrintsSummaryRow (Usr_ItsMe (UsrDat->UsrCod),NumPrintsVisibleByTchs,
|
||||||
&NumTotalQsts,TotalScore);
|
&NumTotalQsts,TotalScore);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
38
swad_user.c
38
swad_user.c
|
@ -800,9 +800,8 @@ bool Usr_CheckIfUsrIsSuperuser (long UsrCod)
|
||||||
|
|
||||||
bool Usr_ICanChangeOtherUsrData (const struct UsrData *UsrDat)
|
bool Usr_ICanChangeOtherUsrData (const struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
/***** I can change my data *****/
|
||||||
|
if (Usr_ItsMe (UsrDat->UsrCod))
|
||||||
if (ItsMe)
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/***** Check if I have permission to see another user's IDs *****/
|
/***** Check if I have permission to see another user's IDs *****/
|
||||||
|
@ -834,9 +833,8 @@ bool Usr_ICanChangeOtherUsrData (const struct UsrData *UsrDat)
|
||||||
|
|
||||||
bool Usr_ICanEditOtherUsr (const struct UsrData *UsrDat)
|
bool Usr_ICanEditOtherUsr (const struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
/***** I can edit me *****/
|
||||||
|
if (Usr_ItsMe (UsrDat->UsrCod))
|
||||||
if (ItsMe)
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
switch (Gbl.Usrs.Me.Role.Logged)
|
switch (Gbl.Usrs.Me.Role.Logged)
|
||||||
|
@ -878,8 +876,6 @@ bool Usr_ICanEditOtherUsr (const struct UsrData *UsrDat)
|
||||||
|
|
||||||
bool Usr_CheckIfICanViewRecordStd (const struct UsrData *UsrDat)
|
bool Usr_CheckIfICanViewRecordStd (const struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
bool ItsMe;
|
|
||||||
|
|
||||||
/***** 1. Fast check: Am I logged? *****/
|
/***** 1. Fast check: Am I logged? *****/
|
||||||
if (!Gbl.Usrs.Me.Logged)
|
if (!Gbl.Usrs.Me.Logged)
|
||||||
return false;
|
return false;
|
||||||
|
@ -905,8 +901,7 @@ bool Usr_CheckIfICanViewRecordStd (const struct UsrData *UsrDat)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/***** 7. Fast check: It's me? *****/
|
/***** 7. Fast check: It's me? *****/
|
||||||
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
if (Usr_ItsMe (UsrDat->UsrCod))
|
||||||
if (ItsMe)
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/***** 8. Fast / slow check: Does he/she belong to the current course? *****/
|
/***** 8. Fast / slow check: Does he/she belong to the current course? *****/
|
||||||
|
@ -958,8 +953,6 @@ bool Usr_CheckIfICanViewRecordTch (struct UsrData *UsrDat)
|
||||||
|
|
||||||
bool Usr_CheckIfICanViewTstExaMchResult (const struct UsrData *UsrDat)
|
bool Usr_CheckIfICanViewTstExaMchResult (const struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
bool ItsMe;
|
|
||||||
|
|
||||||
/***** 1. Fast check: Am I logged? *****/
|
/***** 1. Fast check: Am I logged? *****/
|
||||||
if (!Gbl.Usrs.Me.Logged)
|
if (!Gbl.Usrs.Me.Logged)
|
||||||
return false;
|
return false;
|
||||||
|
@ -981,8 +974,7 @@ bool Usr_CheckIfICanViewTstExaMchResult (const struct UsrData *UsrDat)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/***** 6. Fast check: It's me? *****/
|
/***** 6. Fast check: It's me? *****/
|
||||||
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
if (Usr_ItsMe (UsrDat->UsrCod))
|
||||||
if (ItsMe)
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/***** 7. Fast check: Does he/she belong to the current course? *****/
|
/***** 7. Fast check: Does he/she belong to the current course? *****/
|
||||||
|
@ -1007,8 +999,6 @@ bool Usr_CheckIfICanViewTstExaMchResult (const struct UsrData *UsrDat)
|
||||||
|
|
||||||
bool Usr_CheckIfICanViewAsgWrk (const struct UsrData *UsrDat)
|
bool Usr_CheckIfICanViewAsgWrk (const struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
bool ItsMe;
|
|
||||||
|
|
||||||
/***** 1. Fast check: Am I logged? *****/
|
/***** 1. Fast check: Am I logged? *****/
|
||||||
if (!Gbl.Usrs.Me.Logged)
|
if (!Gbl.Usrs.Me.Logged)
|
||||||
return false;
|
return false;
|
||||||
|
@ -1035,8 +1025,7 @@ bool Usr_CheckIfICanViewAsgWrk (const struct UsrData *UsrDat)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/***** 7. Fast check: It's me? *****/
|
/***** 7. Fast check: It's me? *****/
|
||||||
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
if (Usr_ItsMe (UsrDat->UsrCod))
|
||||||
if (ItsMe)
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/***** 8. Fast / slow check depending on roles *****/
|
/***** 8. Fast / slow check depending on roles *****/
|
||||||
|
@ -1057,8 +1046,6 @@ bool Usr_CheckIfICanViewAsgWrk (const struct UsrData *UsrDat)
|
||||||
|
|
||||||
bool Usr_CheckIfICanViewAtt (const struct UsrData *UsrDat)
|
bool Usr_CheckIfICanViewAtt (const struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
bool ItsMe;
|
|
||||||
|
|
||||||
/***** 1. Fast check: Am I logged? *****/
|
/***** 1. Fast check: Am I logged? *****/
|
||||||
if (!Gbl.Usrs.Me.Logged)
|
if (!Gbl.Usrs.Me.Logged)
|
||||||
return false;
|
return false;
|
||||||
|
@ -1080,8 +1067,7 @@ bool Usr_CheckIfICanViewAtt (const struct UsrData *UsrDat)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/***** 6. Fast check: It's me? *****/
|
/***** 6. Fast check: It's me? *****/
|
||||||
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
if (Usr_ItsMe (UsrDat->UsrCod))
|
||||||
if (ItsMe)
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/***** 7. Fast / slow check depending on roles *****/
|
/***** 7. Fast / slow check depending on roles *****/
|
||||||
|
@ -1102,15 +1088,12 @@ bool Usr_CheckIfICanViewAtt (const struct UsrData *UsrDat)
|
||||||
|
|
||||||
bool Usr_CheckIfICanViewUsrAgenda (struct UsrData *UsrDat)
|
bool Usr_CheckIfICanViewUsrAgenda (struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
bool ItsMe;
|
|
||||||
|
|
||||||
/***** 1. Fast check: Am I logged? *****/
|
/***** 1. Fast check: Am I logged? *****/
|
||||||
if (!Gbl.Usrs.Me.Logged)
|
if (!Gbl.Usrs.Me.Logged)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/***** 2. Fast check: It's me? *****/
|
/***** 2. Fast check: It's me? *****/
|
||||||
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
if (Usr_ItsMe (UsrDat->UsrCod))
|
||||||
if (ItsMe)
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/***** 3. Fast check: Am I logged as system admin? *****/
|
/***** 3. Fast check: Am I logged as system admin? *****/
|
||||||
|
@ -2460,8 +2443,7 @@ static void Usr_WriteRowTchAllData (struct UsrData *UsrDat)
|
||||||
struct Ins_Instit Ins;
|
struct Ins_Instit Ins;
|
||||||
struct Ctr_Center Ctr;
|
struct Ctr_Center Ctr;
|
||||||
struct Dpt_Department Dpt;
|
struct Dpt_Department Dpt;
|
||||||
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
bool ShowData = (Usr_ItsMe (UsrDat->UsrCod) || UsrDat->Accepted ||
|
||||||
bool ShowData = (ItsMe || UsrDat->Accepted ||
|
|
||||||
Gbl.Usrs.Me.Role.Logged == Rol_DEG_ADM ||
|
Gbl.Usrs.Me.Role.Logged == Rol_DEG_ADM ||
|
||||||
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM);
|
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue