mirror of
https://github.com/acanas/swad-core.git
synced 2024-05-31 05:45:24 +02:00
Version 16.237
This commit is contained in:
parent
91bdda94d0
commit
024de153de
|
@ -3223,12 +3223,11 @@ static void Att_ListStdsAttendanceTable (Att_TypeOfView_t TypeOfView,
|
||||||
{
|
{
|
||||||
UsrDat.UsrCod = LstSelectedUsrCods[NumStd];
|
UsrDat.UsrCod = LstSelectedUsrCods[NumStd];
|
||||||
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // Get from the database the data of the student
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // Get from the database the data of the student
|
||||||
{
|
if (Usr_CheckIfICanViewWrkTstAtt (&UsrDat))
|
||||||
UsrDat.Accepted = Usr_CheckIfUsrBelongsToCrs (UsrDat.UsrCod,
|
{
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&UsrDat);
|
||||||
true);
|
Att_WriteRowStdSeveralAttEvents (NumStd,&UsrDat);
|
||||||
Att_WriteRowStdSeveralAttEvents (NumStd,&UsrDat);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Last row with the total of students present in each event *****/
|
/***** Last row with the total of students present in each event *****/
|
||||||
|
@ -3437,12 +3436,11 @@ static void Att_ListStdsWithAttEventsDetails (Att_TypeOfView_t TypeOfView,
|
||||||
{
|
{
|
||||||
UsrDat.UsrCod = LstSelectedUsrCods[NumStd];
|
UsrDat.UsrCod = LstSelectedUsrCods[NumStd];
|
||||||
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // Get from the database the data of the student
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // Get from the database the data of the student
|
||||||
{
|
if (Usr_CheckIfICanViewWrkTstAtt (&UsrDat))
|
||||||
UsrDat.Accepted = Usr_CheckIfUsrBelongsToCrs (UsrDat.UsrCod,
|
{
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&UsrDat);
|
||||||
true);
|
Att_ListAttEventsForAStd (NumStd,&UsrDat);
|
||||||
Att_ListAttEventsForAStd (NumStd,&UsrDat);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** End frame *****/
|
/***** End frame *****/
|
||||||
|
|
|
@ -242,13 +242,15 @@
|
||||||
/****************************** Public constants *****************************/
|
/****************************** Public constants *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 16.236 (2017-06-08)"
|
#define Log_PLATFORM_VERSION "SWAD 16.237 (2017-06-09)"
|
||||||
#define CSS_FILE "swad16.235.1.css"
|
#define CSS_FILE "swad16.235.1.css"
|
||||||
#define JS_FILE "swad16.206.3.js"
|
#define JS_FILE "swad16.206.3.js"
|
||||||
|
|
||||||
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
// 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 sql/swad*.sql | tail -1
|
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1
|
||||||
/*
|
/*
|
||||||
|
Version 16.237: Jun 09, 2017 Code refactoring related to users belonging to a course.
|
||||||
|
Changes in permissions to access students by non-editing teachers. (221303 lines)
|
||||||
Version 16.236: Jun 08, 2017 Changes in permissions related to record card contextual commands.
|
Version 16.236: Jun 08, 2017 Changes in permissions related to record card contextual commands.
|
||||||
Code refactoring related to roles. (221306 lines)
|
Code refactoring related to roles. (221306 lines)
|
||||||
Version 16.235.3: Jun 04, 2017 Non-editing teachers can not select/unselect groups to which they don't belong. (221107 lines)
|
Version 16.235.3: Jun 04, 2017 Non-editing teachers can not select/unselect groups to which they don't belong. (221107 lines)
|
||||||
|
|
|
@ -963,9 +963,7 @@ bool Enr_PutActionsRegRemOneUsr (bool ItsMe)
|
||||||
|
|
||||||
/***** Check if the other user belongs to the current course *****/
|
/***** Check if the other user belongs to the current course *****/
|
||||||
if (Gbl.CurrentCrs.Crs.CrsCod > 0)
|
if (Gbl.CurrentCrs.Crs.CrsCod > 0)
|
||||||
UsrBelongsToCrs = Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod,
|
UsrBelongsToCrs = Usr_CheckIfUsrBelongsToCurrentCrs (&Gbl.Usrs.Other.UsrDat);
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
|
||||||
false);
|
|
||||||
|
|
||||||
if (Gbl.CurrentIns.Ins.InsCod > 0)
|
if (Gbl.CurrentIns.Ins.InsCod > 0)
|
||||||
{
|
{
|
||||||
|
@ -1806,15 +1804,13 @@ static void Enr_RegisterUsr (struct UsrData *UsrDat,Rol_Role_t RegRemRole,
|
||||||
/***** Register user in current course in database *****/
|
/***** Register user in current course in database *****/
|
||||||
if (Gbl.CurrentCrs.Crs.CrsCod > 0) // Course selected
|
if (Gbl.CurrentCrs.Crs.CrsCod > 0) // Course selected
|
||||||
{
|
{
|
||||||
if (Usr_CheckIfUsrBelongsToCrs (UsrDat->UsrCod,
|
if (Usr_CheckIfUsrBelongsToCurrentCrs (UsrDat))
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
|
||||||
false)) // User does belong to current course
|
|
||||||
{
|
{
|
||||||
if (RegRemRole != UsrDat->Roles.InCurrentCrs.Role) // The role must be updated
|
if (RegRemRole != UsrDat->Roles.InCurrentCrs.Role) // The role must be updated
|
||||||
/* Modify role */
|
/* Modify role */
|
||||||
Enr_ModifyRoleInCurrentCrs (UsrDat,RegRemRole);
|
Enr_ModifyRoleInCurrentCrs (UsrDat,RegRemRole);
|
||||||
}
|
}
|
||||||
else
|
else // User does not belong to this course
|
||||||
/* Register user */
|
/* Register user */
|
||||||
Enr_RegisterUsrInCurrentCrs (UsrDat,RegRemRole,
|
Enr_RegisterUsrInCurrentCrs (UsrDat,RegRemRole,
|
||||||
Enr_SET_ACCEPTED_TO_FALSE);
|
Enr_SET_ACCEPTED_TO_FALSE);
|
||||||
|
@ -2130,9 +2126,7 @@ void Enr_AskIfRejectSignUp (void)
|
||||||
|
|
||||||
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) // If user's data exist...
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) // If user's data exist...
|
||||||
{
|
{
|
||||||
if (Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod,
|
if (Usr_CheckIfUsrBelongsToCurrentCrs (&Gbl.Usrs.Other.UsrDat))
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
|
||||||
false))
|
|
||||||
{
|
{
|
||||||
/* User already belongs to this course */
|
/* User already belongs to this course */
|
||||||
sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_is_already_enroled_in_the_course_Y,
|
sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_is_already_enroled_in_the_course_Y,
|
||||||
|
@ -2189,9 +2183,7 @@ void Enr_RejectSignUp (void)
|
||||||
|
|
||||||
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) // If user's data exist...
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) // If user's data exist...
|
||||||
{
|
{
|
||||||
if (Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod,
|
if (Usr_CheckIfUsrBelongsToCurrentCrs (&Gbl.Usrs.Other.UsrDat))
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
|
||||||
false))
|
|
||||||
{
|
{
|
||||||
/* User already belongs to this course */
|
/* User already belongs to this course */
|
||||||
sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_is_already_enroled_in_the_course_Y,
|
sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_is_already_enroled_in_the_course_Y,
|
||||||
|
@ -3251,13 +3243,9 @@ static void Enr_AskIfRegRemUsr (struct ListUsrCods *ListUsrCods,Rol_Role_t Role)
|
||||||
if (Gbl.CurrentCrs.Crs.CrsCod > 0) // Course selected
|
if (Gbl.CurrentCrs.Crs.CrsCod > 0) // Course selected
|
||||||
{
|
{
|
||||||
/* Check if this user belongs to the current course */
|
/* Check if this user belongs to the current course */
|
||||||
if (Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod,
|
if (Usr_CheckIfUsrBelongsToCurrentCrs (&Gbl.Usrs.Other.UsrDat))
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
|
||||||
false))
|
|
||||||
{
|
{
|
||||||
Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod,
|
Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat);
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
|
||||||
true);
|
|
||||||
if (Gbl.Usrs.Other.UsrDat.Accepted)
|
if (Gbl.Usrs.Other.UsrDat.Accepted)
|
||||||
sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_is_already_enroled_in_the_course_Y,
|
sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_is_already_enroled_in_the_course_Y,
|
||||||
Gbl.Usrs.Other.UsrDat.FullName,Gbl.CurrentCrs.Crs.FullName);
|
Gbl.Usrs.Other.UsrDat.FullName,Gbl.CurrentCrs.Crs.FullName);
|
||||||
|
@ -3768,9 +3756,7 @@ void Enr_CreateNewUsr1 (void)
|
||||||
/***** Register user in current course in database *****/
|
/***** Register user in current course in database *****/
|
||||||
if (Gbl.CurrentCrs.Crs.CrsCod > 0) // Course selected
|
if (Gbl.CurrentCrs.Crs.CrsCod > 0) // Course selected
|
||||||
{
|
{
|
||||||
if (Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod,
|
if (Usr_CheckIfUsrBelongsToCurrentCrs (&Gbl.Usrs.Other.UsrDat))
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
|
||||||
false)) // User does belong to current course
|
|
||||||
{
|
{
|
||||||
OldRole = Gbl.Usrs.Other.UsrDat.Roles.InCurrentCrs.Role; // Remember old role before changing it
|
OldRole = Gbl.Usrs.Other.UsrDat.Roles.InCurrentCrs.Role; // Remember old role before changing it
|
||||||
if (NewRole != OldRole) // The role must be updated
|
if (NewRole != OldRole) // The role must be updated
|
||||||
|
@ -3786,7 +3772,7 @@ void Enr_CreateNewUsr1 (void)
|
||||||
Txt_ROLES_SINGUL_abc[NewRole][Gbl.Usrs.Other.UsrDat.Sex]);
|
Txt_ROLES_SINGUL_abc[NewRole][Gbl.Usrs.Other.UsrDat.Sex]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else // User does not belong to current course
|
||||||
{
|
{
|
||||||
/* Register user */
|
/* Register user */
|
||||||
Enr_RegisterUsrInCurrentCrs (&Gbl.Usrs.Other.UsrDat,NewRole,
|
Enr_RegisterUsrInCurrentCrs (&Gbl.Usrs.Other.UsrDat,NewRole,
|
||||||
|
@ -3893,9 +3879,7 @@ void Enr_ModifyUsr1 (void)
|
||||||
NewRole = Rec_GetRoleFromRecordForm ();
|
NewRole = Rec_GetRoleFromRecordForm ();
|
||||||
|
|
||||||
/***** Register user in current course in database *****/
|
/***** Register user in current course in database *****/
|
||||||
if (Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod,
|
if (Usr_CheckIfUsrBelongsToCurrentCrs (&Gbl.Usrs.Other.UsrDat))
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
|
||||||
false)) // User does belong to current course
|
|
||||||
{
|
{
|
||||||
OldRole = Gbl.Usrs.Other.UsrDat.Roles.InCurrentCrs.Role; // Remember old role before changing it
|
OldRole = Gbl.Usrs.Other.UsrDat.Roles.InCurrentCrs.Role; // Remember old role before changing it
|
||||||
if (NewRole != OldRole) // The role must be updated
|
if (NewRole != OldRole) // The role must be updated
|
||||||
|
@ -3911,7 +3895,7 @@ void Enr_ModifyUsr1 (void)
|
||||||
Txt_ROLES_SINGUL_abc[NewRole][Gbl.Usrs.Other.UsrDat.Sex]);
|
Txt_ROLES_SINGUL_abc[NewRole][Gbl.Usrs.Other.UsrDat.Sex]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else // User does not belong to current course
|
||||||
{
|
{
|
||||||
/* Register user */
|
/* Register user */
|
||||||
Enr_RegisterUsrInCurrentCrs (&Gbl.Usrs.Other.UsrDat,NewRole,
|
Enr_RegisterUsrInCurrentCrs (&Gbl.Usrs.Other.UsrDat,NewRole,
|
||||||
|
@ -4092,9 +4076,7 @@ static void Enr_AskIfRemoveUsrFromCrs (struct UsrData *UsrDat)
|
||||||
bool ItsMe;
|
bool ItsMe;
|
||||||
Act_Action_t NextAction;
|
Act_Action_t NextAction;
|
||||||
|
|
||||||
if (Usr_CheckIfUsrBelongsToCrs (UsrDat->UsrCod,
|
if (Usr_CheckIfUsrBelongsToCurrentCrs (UsrDat))
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
|
||||||
false))
|
|
||||||
{
|
{
|
||||||
ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod);
|
ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod);
|
||||||
|
|
||||||
|
@ -4136,7 +4118,7 @@ static void Enr_AskIfRemoveUsrFromCrs (struct UsrData *UsrDat)
|
||||||
/* End alert */
|
/* End alert */
|
||||||
Ale_ShowAlertAndButton2 (ActUnk,NULL,NULL,NULL,Lay_NO_BUTTON,NULL);
|
Ale_ShowAlertAndButton2 (ActUnk,NULL,NULL,NULL,Lay_NO_BUTTON,NULL);
|
||||||
}
|
}
|
||||||
else
|
else // User does not belong to current course
|
||||||
Ale_ShowAlert (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
|
Ale_ShowAlert (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4152,9 +4134,7 @@ static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat,struct Course *
|
||||||
char Query[1024];
|
char Query[1024];
|
||||||
bool ItsMe;
|
bool ItsMe;
|
||||||
|
|
||||||
if (Usr_CheckIfUsrBelongsToCrs (UsrDat->UsrCod,
|
if (Usr_CheckIfUsrBelongsToCurrentCrs (UsrDat))
|
||||||
Crs->CrsCod,
|
|
||||||
false)) // User belongs to the course
|
|
||||||
{
|
{
|
||||||
/***** Remove user from all the attendance events in course *****/
|
/***** Remove user from all the attendance events in course *****/
|
||||||
Att_RemoveUsrFromCrsAttEvents (UsrDat->UsrCod,Crs->CrsCod);
|
Att_RemoveUsrFromCrsAttEvents (UsrDat->UsrCod,Crs->CrsCod);
|
||||||
|
|
|
@ -3225,9 +3225,7 @@ static void Brw_ShowFileBrowsersAsgWrkCrs (void)
|
||||||
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
||||||
Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat);
|
Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat);
|
||||||
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) // Get of the database the data of the user
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) // Get of the database the data of the user
|
||||||
if (Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod,
|
if (Usr_CheckIfICanViewWrkTstAtt (&Gbl.Usrs.Other.UsrDat))
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
|
||||||
false))
|
|
||||||
{
|
{
|
||||||
/***** Show a row with the data of the owner of the works *****/
|
/***** Show a row with the data of the owner of the works *****/
|
||||||
fprintf (Gbl.F.Out,"<tr>");
|
fprintf (Gbl.F.Out,"<tr>");
|
||||||
|
@ -3246,7 +3244,7 @@ static void Brw_ShowFileBrowsersAsgWrkCrs (void)
|
||||||
Brw_ShowFileBrowser ();
|
Brw_ShowFileBrowser ();
|
||||||
|
|
||||||
fprintf (Gbl.F.Out,"</td>"
|
fprintf (Gbl.F.Out,"</td>"
|
||||||
"</tr>");
|
"</tr>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4688,7 +4688,7 @@ void Grp_GetParamWhichGrps (void)
|
||||||
|
|
||||||
bool Grp_CheckIfUsrSharesAnyOfMyGrpsInCurrentCrs (const struct UsrData *UsrDat)
|
bool Grp_CheckIfUsrSharesAnyOfMyGrpsInCurrentCrs (const struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
char Query[256];
|
char Query[512];
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
long UsrCod;
|
long UsrCod;
|
||||||
|
@ -4731,6 +4731,7 @@ bool Grp_CheckIfUsrSharesAnyOfMyGrpsInCurrentCrs (const struct UsrData *UsrDat)
|
||||||
|
|
||||||
/***** 8. Slow check: Get if user shares any group in this course with me from database *****/
|
/***** 8. Slow check: Get if user shares any group in this course with me from database *****/
|
||||||
/* Check if user shares any group with me */
|
/* Check if user shares any group with me */
|
||||||
|
Cached.UsrCod = UsrDat->UsrCod;
|
||||||
sprintf (Query,"SELECT COUNT(*) FROM crs_grp_usr"
|
sprintf (Query,"SELECT COUNT(*) FROM crs_grp_usr"
|
||||||
" WHERE UsrCod=%ld"
|
" WHERE UsrCod=%ld"
|
||||||
" AND GrpCod IN"
|
" AND GrpCod IN"
|
||||||
|
@ -4746,6 +4747,5 @@ bool Grp_CheckIfUsrSharesAnyOfMyGrpsInCurrentCrs (const struct UsrData *UsrDat)
|
||||||
Cached.UsrSharesAnyOfMyGrpsInCurrentCrs = DB_QueryCOUNT (Query,"can not check"
|
Cached.UsrSharesAnyOfMyGrpsInCurrentCrs = DB_QueryCOUNT (Query,"can not check"
|
||||||
" if a user shares any group"
|
" if a user shares any group"
|
||||||
" in the current course with you") != 0;
|
" in the current course with you") != 0;
|
||||||
Cached.UsrCod = UsrDat->UsrCod;
|
|
||||||
return Cached.UsrSharesAnyOfMyGrpsInCurrentCrs;
|
return Cached.UsrSharesAnyOfMyGrpsInCurrentCrs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -390,9 +390,7 @@ void Pho_SendPhotoUsr (void)
|
||||||
{
|
{
|
||||||
if (Pho_ICanChangeOtherUsrPhoto (&Gbl.Usrs.Other.UsrDat)) // If I have permission to change user's photo...
|
if (Pho_ICanChangeOtherUsrPhoto (&Gbl.Usrs.Other.UsrDat)) // If I have permission to change user's photo...
|
||||||
{
|
{
|
||||||
Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod,
|
Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat);
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
|
||||||
true);
|
|
||||||
if (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // It's me
|
if (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // It's me
|
||||||
/***** Form to send my photo *****/
|
/***** Form to send my photo *****/
|
||||||
Pho_ReqMyPhotoWithContextLinks ();
|
Pho_ReqMyPhotoWithContextLinks ();
|
||||||
|
|
|
@ -287,9 +287,7 @@ bool Prf_ShowUserProfile (struct UsrData *UsrDat)
|
||||||
UsrDat->Roles.InCurrentCrs.UsrCod = UsrDat->UsrCod;
|
UsrDat->Roles.InCurrentCrs.UsrCod = UsrDat->UsrCod;
|
||||||
|
|
||||||
/* Get if user has accepted enrolment in current course */
|
/* Get if user has accepted enrolment in current course */
|
||||||
UsrDat->Accepted = Usr_CheckIfUsrBelongsToCrs (UsrDat->UsrCod,
|
UsrDat->Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (UsrDat);
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
|
||||||
true);
|
|
||||||
}
|
}
|
||||||
Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_PUBLIC,UsrDat,NULL);
|
Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_PUBLIC,UsrDat,NULL);
|
||||||
|
|
||||||
|
|
|
@ -1098,9 +1098,7 @@ void Rec_GetUsrAndShowRecordOneStdCrs (void)
|
||||||
static void Rec_ShowRecordOneStdCrs (void)
|
static void Rec_ShowRecordOneStdCrs (void)
|
||||||
{
|
{
|
||||||
/***** Get if student has accepted enrolment in current course *****/
|
/***** Get if student has accepted enrolment in current course *****/
|
||||||
Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod,
|
Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat);
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
|
||||||
true);
|
|
||||||
|
|
||||||
/***** Assign users listing type depending on current action *****/
|
/***** Assign users listing type depending on current action *****/
|
||||||
Gbl.Usrs.Listing.RecsUsrs = Rec_RECORD_USERS_STUDENTS;
|
Gbl.Usrs.Listing.RecsUsrs = Rec_RECORD_USERS_STUDENTS;
|
||||||
|
@ -1236,15 +1234,11 @@ static void Rec_ListRecordsStds (Rec_SharedRecordViewType_t ShaTypeOfView,
|
||||||
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
||||||
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
|
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
|
||||||
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // Get from the database the data of the student
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // Get from the database the data of the student
|
||||||
if (Usr_CheckIfUsrBelongsToCrs (UsrDat.UsrCod,
|
if (Usr_CheckIfUsrBelongsToCurrentCrs (&UsrDat))
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
|
||||||
false))
|
|
||||||
{
|
{
|
||||||
/* Check if this user has accepted
|
/* Check if this user has accepted
|
||||||
his/her inscription in the current course */
|
his/her inscription in the current course */
|
||||||
UsrDat.Accepted = Usr_CheckIfUsrBelongsToCrs (UsrDat.UsrCod,
|
UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&UsrDat);
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
|
||||||
true);
|
|
||||||
|
|
||||||
/* Start container for this user */
|
/* Start container for this user */
|
||||||
sprintf (RecordSectionId,"record_%u",NumUsr);
|
sprintf (RecordSectionId,"record_%u",NumUsr);
|
||||||
|
@ -1326,9 +1320,7 @@ static void Rec_ShowRecordOneTchCrs (void)
|
||||||
sprintf (Width,"%upx",Rec_RECORD_WIDTH);
|
sprintf (Width,"%upx",Rec_RECORD_WIDTH);
|
||||||
|
|
||||||
/***** Get if teacher has accepted enrolment in current course *****/
|
/***** Get if teacher has accepted enrolment in current course *****/
|
||||||
Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod,
|
Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat);
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
|
||||||
true);
|
|
||||||
|
|
||||||
/***** Assign users listing type depending on current action *****/
|
/***** Assign users listing type depending on current action *****/
|
||||||
Gbl.Usrs.Listing.RecsUsrs = Rec_RECORD_USERS_TEACHERS;
|
Gbl.Usrs.Listing.RecsUsrs = Rec_RECORD_USERS_TEACHERS;
|
||||||
|
@ -1459,15 +1451,11 @@ static void Rec_ListRecordsTchs (Rec_SharedRecordViewType_t TypeOfView)
|
||||||
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
||||||
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
|
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
|
||||||
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // Get from the database the data of the student
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // Get from the database the data of the student
|
||||||
if (Usr_CheckIfUsrBelongsToCrs (UsrDat.UsrCod,
|
if (Usr_CheckIfUsrBelongsToCurrentCrs (&UsrDat))
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
|
||||||
false))
|
|
||||||
{
|
{
|
||||||
/* Check if this user has accepted
|
/* Check if this user has accepted
|
||||||
his/her inscription in the current course */
|
his/her inscription in the current course */
|
||||||
UsrDat.Accepted = Usr_CheckIfUsrBelongsToCrs (UsrDat.UsrCod,
|
UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&UsrDat);
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
|
||||||
true);
|
|
||||||
|
|
||||||
/* Start container for this user */
|
/* Start container for this user */
|
||||||
sprintf (RecordSectionId,"record_%u",NumUsr);
|
sprintf (RecordSectionId,"record_%u",NumUsr);
|
||||||
|
@ -2168,9 +2156,7 @@ void Rec_ShowSharedRecordUnmodifiable (struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
/***** Get password, user type and user's data from database *****/
|
/***** Get password, user type and user's data from database *****/
|
||||||
Usr_GetAllUsrDataFromUsrCod (UsrDat);
|
Usr_GetAllUsrDataFromUsrCod (UsrDat);
|
||||||
UsrDat->Accepted = Usr_CheckIfUsrBelongsToCrs (UsrDat->UsrCod,
|
UsrDat->Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (UsrDat);
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
|
||||||
true);
|
|
||||||
|
|
||||||
/***** Show user's record *****/
|
/***** Show user's record *****/
|
||||||
fprintf (Gbl.F.Out,"<div class=\"CENTER_MIDDLE\">");
|
fprintf (Gbl.F.Out,"<div class=\"CENTER_MIDDLE\">");
|
||||||
|
@ -2332,7 +2318,7 @@ void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView,
|
||||||
Rec_ShowPhoto (UsrDat);
|
Rec_ShowPhoto (UsrDat);
|
||||||
fprintf (Gbl.F.Out,"</tr>");
|
fprintf (Gbl.F.Out,"</tr>");
|
||||||
|
|
||||||
/***** Commands and full name *****/
|
/***** Full name *****/
|
||||||
fprintf (Gbl.F.Out,"<tr>");
|
fprintf (Gbl.F.Out,"<tr>");
|
||||||
Rec_ShowFullName (UsrDat);
|
Rec_ShowFullName (UsrDat);
|
||||||
fprintf (Gbl.F.Out,"</tr>");
|
fprintf (Gbl.F.Out,"</tr>");
|
||||||
|
|
|
@ -108,9 +108,7 @@ void Rol_SetMyRoles (void)
|
||||||
{
|
{
|
||||||
Gbl.Usrs.Me.IBelongToCurrentCrs = Usr_CheckIfUsrBelongsToCurrentCrs (&Gbl.Usrs.Me.UsrDat);
|
Gbl.Usrs.Me.IBelongToCurrentCrs = Usr_CheckIfUsrBelongsToCurrentCrs (&Gbl.Usrs.Me.UsrDat);
|
||||||
if (Gbl.Usrs.Me.IBelongToCurrentCrs)
|
if (Gbl.Usrs.Me.IBelongToCurrentCrs)
|
||||||
Gbl.Usrs.Me.UsrDat.Accepted = Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Me.UsrDat);
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
|
||||||
true);
|
|
||||||
else
|
else
|
||||||
Gbl.Usrs.Me.UsrDat.Accepted = false;
|
Gbl.Usrs.Me.UsrDat.Accepted = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7146,9 +7146,7 @@ void Tst_ShowUsrsTestResults (void)
|
||||||
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
||||||
Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat);
|
Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat);
|
||||||
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) // Get of the database the data of the user
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) // Get of the database the data of the user
|
||||||
if (Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod,
|
if (Usr_CheckIfICanViewWrkTstAtt (&Gbl.Usrs.Other.UsrDat))
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
|
||||||
false))
|
|
||||||
/***** Show test results *****/
|
/***** Show test results *****/
|
||||||
Tst_ShowTestResults (&Gbl.Usrs.Other.UsrDat);
|
Tst_ShowTestResults (&Gbl.Usrs.Other.UsrDat);
|
||||||
}
|
}
|
||||||
|
@ -7709,6 +7707,8 @@ void Tst_ShowOneTestResult (void)
|
||||||
/* Get data of the user who made the test */
|
/* Get data of the user who made the test */
|
||||||
if (!Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat))
|
if (!Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat))
|
||||||
Lay_ShowErrorAndExit ("User does not exists.");
|
Lay_ShowErrorAndExit ("User does not exists.");
|
||||||
|
if (!Usr_CheckIfICanViewWrkTstAtt (&Gbl.Usrs.Other.UsrDat))
|
||||||
|
Lay_ShowErrorAndExit ("You can not view this test result.");
|
||||||
|
|
||||||
/* User */
|
/* User */
|
||||||
fprintf (Gbl.F.Out,"<tr>"
|
fprintf (Gbl.F.Out,"<tr>"
|
||||||
|
|
61
swad_user.c
61
swad_user.c
|
@ -1131,7 +1131,7 @@ bool Usr_CheckIfICanViewWrkTstAtt (const struct UsrData *UsrDat)
|
||||||
switch (Gbl.Usrs.Me.Role.Logged)
|
switch (Gbl.Usrs.Me.Role.Logged)
|
||||||
{
|
{
|
||||||
case Rol_NET:
|
case Rol_NET:
|
||||||
return Grp_CheckIfUsrSharesAnyOfMyGrpsInCurrentCrs (Gbl.Record.UsrDat);
|
return Grp_CheckIfUsrSharesAnyOfMyGrpsInCurrentCrs (UsrDat);
|
||||||
case Rol_TCH:
|
case Rol_TCH:
|
||||||
case Rol_SYS_ADM:
|
case Rol_SYS_ADM:
|
||||||
return true;
|
return true;
|
||||||
|
@ -1765,7 +1765,8 @@ bool Usr_CheckIfUsrBelongsToDeg (long UsrCod,long DegCod)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*************** Check if user belongs to the current course *****************/
|
/***** Check if user belongs (no matter if he/she has accepted or not) *******/
|
||||||
|
/***** to the current course *******/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
bool Usr_CheckIfUsrBelongsToCurrentCrs (const struct UsrData *UsrDat)
|
bool Usr_CheckIfUsrBelongsToCurrentCrs (const struct UsrData *UsrDat)
|
||||||
|
@ -1795,13 +1796,59 @@ bool Usr_CheckIfUsrBelongsToCurrentCrs (const struct UsrData *UsrDat)
|
||||||
|
|
||||||
/***** 3. Fast check: If we know role of user in the current course *****/
|
/***** 3. Fast check: If we know role of user in the current course *****/
|
||||||
if (UsrDat->Roles.InCurrentCrs.UsrCod == UsrDat->UsrCod)
|
if (UsrDat->Roles.InCurrentCrs.UsrCod == UsrDat->UsrCod)
|
||||||
return UsrDat->Roles.InCurrentCrs.Role == Rol_STD ||
|
{
|
||||||
UsrDat->Roles.InCurrentCrs.Role == Rol_NET ||
|
Cached.UsrCod = UsrDat->UsrCod;
|
||||||
UsrDat->Roles.InCurrentCrs.Role == Rol_TCH;
|
Cached.Belongs = UsrDat->Roles.InCurrentCrs.Role == Rol_STD ||
|
||||||
|
UsrDat->Roles.InCurrentCrs.Role == Rol_NET ||
|
||||||
|
UsrDat->Roles.InCurrentCrs.Role == Rol_TCH;
|
||||||
|
return Cached.Belongs;
|
||||||
|
}
|
||||||
|
|
||||||
/***** 4. Fast / slow check: Get if user belongs to current course *****/
|
/***** 4. Fast / slow check: Get if user belongs to current course *****/
|
||||||
return Usr_CheckIfUsrBelongsToCrs (UsrDat->UsrCod,Gbl.CurrentCrs.Crs.CrsCod,
|
Cached.UsrCod = UsrDat->UsrCod;
|
||||||
false);
|
Cached.Belongs = Usr_CheckIfUsrBelongsToCrs (UsrDat->UsrCod,
|
||||||
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
|
false);
|
||||||
|
return Cached.Belongs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/***** Check if user belongs (no matter if he/she has accepted or not) *******/
|
||||||
|
/***** to the current course *******/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
bool Usr_CheckIfUsrHasAcceptedInCurrentCrs (const struct UsrData *UsrDat)
|
||||||
|
{
|
||||||
|
static struct
|
||||||
|
{
|
||||||
|
long UsrCod;
|
||||||
|
bool Accepted;
|
||||||
|
} Cached =
|
||||||
|
{
|
||||||
|
-1L,
|
||||||
|
false
|
||||||
|
};
|
||||||
|
|
||||||
|
/***** 1. Fast check: trivial cases *****/
|
||||||
|
if (UsrDat->UsrCod <= 0 ||
|
||||||
|
Gbl.CurrentCrs.Crs.CrsCod <= 0)
|
||||||
|
{
|
||||||
|
Cached.UsrCod = -1L;
|
||||||
|
Cached.Accepted = false;
|
||||||
|
return Cached.Accepted;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** 2. Fast check: If cached... *****/
|
||||||
|
if (UsrDat->UsrCod == Cached.UsrCod)
|
||||||
|
return Cached.Accepted;
|
||||||
|
|
||||||
|
/***** 3. Fast / slow check: Get if user belongs to current course
|
||||||
|
and has accepted *****/
|
||||||
|
Cached.UsrCod = UsrDat->UsrCod;
|
||||||
|
Cached.Accepted = Usr_CheckIfUsrBelongsToCrs (UsrDat->UsrCod,
|
||||||
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
|
true);
|
||||||
|
return Cached.Accepted;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -258,6 +258,7 @@ unsigned Usr_GetNumUsrsInCrssOfAUsr (long UsrCod,Rol_Role_t UsrRole,
|
||||||
Rol_Role_t OthersRole);
|
Rol_Role_t OthersRole);
|
||||||
|
|
||||||
bool Usr_CheckIfUsrBelongsToCurrentCrs (const struct UsrData *UsrDat);
|
bool Usr_CheckIfUsrBelongsToCurrentCrs (const struct UsrData *UsrDat);
|
||||||
|
bool Usr_CheckIfUsrHasAcceptedInCurrentCrs (const struct UsrData *UsrDat);
|
||||||
bool Usr_CheckIfICanViewRecordStd (const struct UsrData *UsrDat);
|
bool Usr_CheckIfICanViewRecordStd (const struct UsrData *UsrDat);
|
||||||
bool Usr_CheckIfICanViewRecordTch (struct UsrData *UsrDat);
|
bool Usr_CheckIfICanViewRecordTch (struct UsrData *UsrDat);
|
||||||
bool Usr_CheckIfICanViewWrkTstAtt (const struct UsrData *UsrDat);
|
bool Usr_CheckIfICanViewWrkTstAtt (const struct UsrData *UsrDat);
|
||||||
|
|
|
@ -2768,9 +2768,7 @@ int swad__sendAttendanceUsers (struct soap *soap,
|
||||||
if (Usr_ChkIfUsrCodExists (UsrDat.UsrCod))
|
if (Usr_ChkIfUsrCodExists (UsrDat.UsrCod))
|
||||||
// The user must belong to course,
|
// The user must belong to course,
|
||||||
// but it's not necessary he/she belongs to groups associated to the event
|
// but it's not necessary he/she belongs to groups associated to the event
|
||||||
if (Usr_CheckIfUsrBelongsToCrs (UsrDat.UsrCod,
|
if (Usr_CheckIfUsrBelongsToCurrentCrs (&UsrDat))
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
|
||||||
false))
|
|
||||||
{
|
{
|
||||||
/* Mark user as present */
|
/* Mark user as present */
|
||||||
Att_RegUsrInAttEventNotChangingComments (Att.AttCod,UsrDat.UsrCod);
|
Att_RegUsrInAttEventNotChangingComments (Att.AttCod,UsrDat.UsrCod);
|
||||||
|
|
|
@ -184,9 +184,7 @@ void ZIP_CreateZIPAsgWrk (void)
|
||||||
|
|
||||||
|
|
||||||
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // Get user's data from database
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // Get user's data from database
|
||||||
if (Usr_CheckIfUsrBelongsToCrs (UsrDat.UsrCod,
|
if (Usr_CheckIfUsrBelongsToCurrentCrs (&UsrDat))
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
|
||||||
false))
|
|
||||||
ZIP_CreateDirCompressionUsr (&UsrDat);
|
ZIP_CreateDirCompressionUsr (&UsrDat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user